重构Gaea服务, 升级版本
This commit is contained in:
@@ -21,8 +21,8 @@ allprojects {
|
||||
|
||||
subprojects {
|
||||
ext {
|
||||
version '0.1.6'
|
||||
gaea_version = '0.3.0'
|
||||
version '0.2.0'
|
||||
gaea_version = '0.4.0'
|
||||
spring_version = "2.3.0.RELEASE"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.synebula.zeus.app.controller
|
||||
|
||||
import com.synebula.gaea.app.IApplication
|
||||
import com.synebula.gaea.app.ISignInOut
|
||||
import com.synebula.gaea.app.component.HttpMessage
|
||||
import com.synebula.gaea.extension.toMd5
|
||||
import com.synebula.gaea.log.ILogger
|
||||
import com.synebula.zeus.query.contr.IUserQuery
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
@@ -12,18 +10,18 @@ import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sign")
|
||||
class SignInOutApp(var query: IUserQuery, override var logger: ILogger) : ISignInOut, IApplication {
|
||||
class SignInOutApp(var query: IUserQuery, override var logger: ILogger?) : IApplication {
|
||||
override var name: String = "用户登录管理"
|
||||
|
||||
@PostMapping("/in")
|
||||
override fun signIn(name: String, password: String): HttpMessage {
|
||||
fun signIn(name: String, password: String): HttpMessage {
|
||||
return this.safeExecute("用户登录出现异常") {
|
||||
it.load(this.query.signIn(name, password))
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/out")
|
||||
override fun signOut(user: String): HttpMessage {
|
||||
return HttpMessage()
|
||||
fun signOut(user: String): HttpMessage {
|
||||
return HttpMessage(user)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.UnionApp
|
||||
import com.synebula.gaea.app.Application
|
||||
import com.synebula.gaea.log.ILogger
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.domain.service.cmd.rbac.GroupCmd
|
||||
import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.IGroupService
|
||||
import com.synebula.zeus.domain.service.contr.rbac.IRoleService
|
||||
import com.synebula.zeus.query.view.GroupView
|
||||
import com.synebula.zeus.query.view.RoleView
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@@ -18,7 +15,7 @@ class GroupApp(
|
||||
service: IGroupService,
|
||||
query: IQuery,
|
||||
logger: ILogger
|
||||
) : UnionApp<GroupCmd, GroupView, String>(
|
||||
) : Application<GroupCmd, GroupView, String>(
|
||||
"分组信息", GroupView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.UnionApp
|
||||
import com.synebula.gaea.app.Application
|
||||
import com.synebula.gaea.log.ILogger
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd
|
||||
@@ -15,7 +15,7 @@ class RoleApp(
|
||||
service: IRoleService,
|
||||
query: IQuery,
|
||||
logger: ILogger
|
||||
) : UnionApp<RoleCmd, RoleView, String>(
|
||||
) : Application<RoleCmd, RoleView, String>(
|
||||
"用户信息", RoleView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.UnionApp
|
||||
import com.synebula.gaea.app.Application
|
||||
import com.synebula.gaea.app.component.HttpMessage
|
||||
import com.synebula.gaea.data.message.Status
|
||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||
@@ -18,7 +18,7 @@ class UserApp(
|
||||
service: IUserService,
|
||||
query: IQuery,
|
||||
logger: ILogger
|
||||
) : UnionApp<UserCmd, UserView, String>(
|
||||
) : Application<UserCmd, UserView, String>(
|
||||
"用户信息", UserView::class.java,
|
||||
service, query, logger
|
||||
) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.synebula.zeus.query.impl
|
||||
import com.synebula.gaea.data.message.Message
|
||||
import com.synebula.gaea.data.message.Status
|
||||
import com.synebula.gaea.extension.toMd5
|
||||
import com.synebula.gaea.mongo.query.MongoGenericQuery
|
||||
import com.synebula.gaea.mongo.whereId
|
||||
import com.synebula.zeus.query.contr.IUserQuery
|
||||
import com.synebula.zeus.query.view.GroupView
|
||||
@@ -15,29 +14,32 @@ import org.springframework.data.mongodb.core.query.Criteria
|
||||
import org.springframework.data.mongodb.core.query.Query
|
||||
import org.springframework.data.mongodb.core.query.isEqualTo
|
||||
|
||||
class UserQuery(template: MongoTemplate) :
|
||||
MongoGenericQuery<UserView>("user", UserView::class.java, template), IUserQuery {
|
||||
class UserQuery(var template: MongoTemplate) : IUserQuery {
|
||||
private val clazz = UserView::class.java
|
||||
|
||||
override fun signIn(name: String, password: String): Message<SignUserView> {
|
||||
this.check()
|
||||
val query = Query.query(
|
||||
Criteria.where("name").isEqualTo(name)
|
||||
.and("password").isEqualTo(password.toMd5())
|
||||
.and("alive").isEqualTo(true)
|
||||
Criteria.where("name").isEqualTo(name)
|
||||
.and("password").isEqualTo(password.toMd5())
|
||||
.and("alive").isEqualTo(true)
|
||||
)
|
||||
val user = this.template.findOne(query, this.clazz!!, "user")
|
||||
val user = this.template.findOne(query, this.clazz, "user")
|
||||
return if (user != null) {
|
||||
val role = this.template.findOne(whereId(user.role), RoleView::class.java, "role")
|
||||
val group = this.template.findOne(whereId(user.group), GroupView::class.java, "group")
|
||||
Message(SignUserView(user.id, user.name, user.realName ?: "",
|
||||
Message(
|
||||
SignUserView(
|
||||
user.id, user.name, user.realName ?: "",
|
||||
user.role ?: "", role?.name ?: "",
|
||||
user.group ?: "", group?.name ?: ""))
|
||||
user.group ?: "", group?.name ?: ""
|
||||
)
|
||||
)
|
||||
} else
|
||||
Message(Status.Failure, "用户名或密码错误")
|
||||
}
|
||||
|
||||
|
||||
override fun listUsers(idList: List<String>): List<UserView> {
|
||||
return this.template.find(Query.query(Criteria.where("_id").`in`(idList)), this.clazz!!, "user")
|
||||
return this.template.find(Query.query(Criteria.where("_id").`in`(idList)), this.clazz, "user")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user