增加用户注册,登录,激活逻辑
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.synebula.zeus.domain.service.cmd
|
||||
package com.synebula.zeus.domain.service.cmd.rbac
|
||||
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.synebula.zeus.domain.service.cmd
|
||||
package com.synebula.zeus.domain.service.cmd.rbac
|
||||
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
|
||||
@@ -2,4 +2,11 @@ package com.synebula.zeus.domain.service.contr.rbac
|
||||
|
||||
import com.synebula.gaea.domain.service.IService
|
||||
|
||||
interface IUserService : IService<String>
|
||||
interface IUserService : IService<String> {
|
||||
/**
|
||||
* 激活用户
|
||||
*
|
||||
* @param key 用户ID
|
||||
*/
|
||||
fun active(key: String)
|
||||
}
|
||||
@@ -1,13 +1,35 @@
|
||||
package com.synebula.zeus.domain.service.impl.rbac
|
||||
|
||||
import com.synebula.gaea.data.IObjectConverter
|
||||
import com.synebula.gaea.data.message.Message
|
||||
import com.synebula.gaea.domain.repository.IRepository
|
||||
import com.synebula.gaea.domain.service.ICommand
|
||||
import com.synebula.gaea.domain.service.Service
|
||||
import com.synebula.gaea.extension.toMd5
|
||||
import com.synebula.gaea.log.ILogger
|
||||
import com.synebula.zeus.domain.model.rbac.User
|
||||
import com.synebula.zeus.domain.service.contr.rbac.IUserService
|
||||
|
||||
class UserService(repository: IRepository<User, String>, converter: IObjectConverter, logger: ILogger) :
|
||||
Service<User, String>(User::class.java, repository, converter, logger), IUserService {
|
||||
Service<User, String>(User::class.java, repository, converter, logger), IUserService {
|
||||
override fun add(command: ICommand): Message<String> {
|
||||
val user = this.convert(command)
|
||||
user.password = user.password.toMd5()
|
||||
user.alive = false
|
||||
this.repository.add(user)
|
||||
return Message(user.id!!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活用户
|
||||
*
|
||||
* @param key 用户ID
|
||||
*/
|
||||
override fun active(key: String) {
|
||||
val user = this.repository.get(key)
|
||||
if (!user.alive) {
|
||||
user.alive = true
|
||||
this.repository.update(user)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user