Add role chang status (not finish)
This commit is contained in:
@@ -7,7 +7,6 @@ import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import top.fatweb.api.converter.permission.GroupConverter
|
||||
import top.fatweb.api.entity.common.ResponseCode
|
||||
import top.fatweb.api.entity.common.ResponseResult
|
||||
import top.fatweb.api.param.authentication.GroupGetParam
|
||||
import top.fatweb.api.service.permission.IGroupService
|
||||
@@ -31,8 +30,8 @@ class GroupController(
|
||||
@Operation(summary = "获取用户组列表")
|
||||
@GetMapping
|
||||
fun get(@Valid groupGetParam: GroupGetParam?): ResponseResult<PageVo<GroupVo>> {
|
||||
return ResponseResult.success(
|
||||
ResponseCode.DATABASE_SELECT_SUCCESS, data = GroupConverter.groupPageToGroupPageVo(
|
||||
return ResponseResult.databaseSuccess(
|
||||
data = GroupConverter.groupPageToGroupPageVo(
|
||||
groupService.getPage(groupGetParam)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import top.fatweb.api.converter.permission.PowerConverter
|
||||
import top.fatweb.api.entity.common.ResponseResult
|
||||
import top.fatweb.api.service.permission.IPowerService
|
||||
|
||||
/**
|
||||
@@ -19,5 +20,5 @@ class PowerController(
|
||||
) {
|
||||
@Operation(summary = "获取权限列表")
|
||||
@GetMapping
|
||||
fun get() = PowerConverter.powerSetToPowerSetVo(powerService.getAll())
|
||||
fun get() = ResponseResult.databaseSuccess(data = PowerConverter.powerSetToPowerSetVo(powerService.getAll()))
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import top.fatweb.api.converter.permission.RoleConverter
|
||||
import top.fatweb.api.entity.common.ResponseCode
|
||||
import top.fatweb.api.entity.common.ResponseResult
|
||||
import top.fatweb.api.param.authentication.RoleAddParam
|
||||
import top.fatweb.api.param.authentication.RoleChangeStatusParam
|
||||
import top.fatweb.api.param.authentication.RoleGetParam
|
||||
import top.fatweb.api.service.permission.IRoleService
|
||||
import top.fatweb.api.vo.PageVo
|
||||
@@ -29,8 +30,8 @@ class RoleController(
|
||||
@Operation(summary = "获取角色列表")
|
||||
@GetMapping
|
||||
fun get(roleGetParam: RoleGetParam?): ResponseResult<PageVo<RoleWithPowerVo>> {
|
||||
return ResponseResult.success(
|
||||
ResponseCode.DATABASE_SELECT_SUCCESS, data = RoleConverter.rolePageToRoleWithPowerPageVo(
|
||||
return ResponseResult.databaseSuccess(
|
||||
data = RoleConverter.rolePageToRoleWithPowerPageVo(
|
||||
roleService.getPage(roleGetParam)
|
||||
)
|
||||
)
|
||||
@@ -40,7 +41,22 @@ class RoleController(
|
||||
@PostMapping
|
||||
fun add(@Valid @RequestBody roleAddParam: RoleAddParam): ResponseResult<RoleVo> {
|
||||
return roleService.add(roleAddParam)
|
||||
?.let { ResponseResult.success(ResponseCode.DATABASE_INSERT_SUCCESS, data = RoleConverter.roleToRoleVo(it)) }
|
||||
?: let { ResponseResult.fail(ResponseCode.DATABASE_INSERT_FAILED) }
|
||||
?.let {
|
||||
ResponseResult.databaseSuccess(
|
||||
ResponseCode.DATABASE_INSERT_SUCCESS,
|
||||
data = RoleConverter.roleToRoleVo(it)
|
||||
)
|
||||
}
|
||||
?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_INSERT_FAILED) }
|
||||
}
|
||||
|
||||
@Operation(summary = "修改角色状态")
|
||||
@PatchMapping
|
||||
fun changStatus(@Valid @RequestBody roleChangeStatusParam: RoleChangeStatusParam): ResponseResult<Nothing> {
|
||||
return if (roleService.changeStatus(roleChangeStatusParam)) {
|
||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS)
|
||||
} else {
|
||||
ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user