|
@@ -26,26 +26,28 @@ class DepartmentAction {
|
|
|
ApiImplicitParam(name = "remark", value = "备注", paramType = "query"),
|
|
|
ApiImplicitParam(name = "parentId", value = "上级部门Id", paramType = "query")
|
|
|
)
|
|
|
- fun add(name: String, @RequestParam(required = false) duty: String?,
|
|
|
- @RequestParam(required = false) remark: String?, parentId: Long): Reply<Any> {
|
|
|
+ fun add(
|
|
|
+ name: String, @RequestParam(required = false) duty: String?,
|
|
|
+ @RequestParam(required = false) remark: String?, parentId: Long
|
|
|
+ ): Reply<Any> {
|
|
|
val result = departmentService.add(name, duty, remark, parentId)
|
|
|
return if (result) Reply.ok() else Reply.fail("部门名称重复或未找到上级部门")
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取部门树")
|
|
|
@GetMapping("getTree")
|
|
|
- fun getTree(): Reply<Department> {
|
|
|
+ fun getTree(@RequestParam(defaultValue = "false") withUser: Boolean): Reply<Department> {
|
|
|
val root = departmentService.findRoot()
|
|
|
if (!root.isPresent) {
|
|
|
return Reply.fail("未找到部门列表")
|
|
|
}
|
|
|
- val tree = departmentService.getTree(root.get().id!!)
|
|
|
+ val tree = departmentService.getTree(root.get().id!!, withUser)
|
|
|
return Reply.ok(tree.orElse(null))
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取部门列表")
|
|
|
@GetMapping("list")
|
|
|
- fun list():Reply<List<Department>>{
|
|
|
+ fun list(): Reply<List<Department>> {
|
|
|
val result = departmentService.list()
|
|
|
return Reply.ok(result)
|
|
|
}
|
|
@@ -59,16 +61,18 @@ class DepartmentAction {
|
|
|
ApiImplicitParam(name = "remark", value = "备注", paramType = "query"),
|
|
|
ApiImplicitParam(name = "parentId", value = "上级部门Id", paramType = "query")
|
|
|
)
|
|
|
- fun update(id: Long, name: String, @RequestParam(required = false) duty: String?,
|
|
|
- @RequestParam(required = false) remark: String?,
|
|
|
- @RequestParam(required = false) parentId: Long?): Reply<Any> {
|
|
|
+ fun update(
|
|
|
+ id: Long, name: String, @RequestParam(required = false) duty: String?,
|
|
|
+ @RequestParam(required = false) remark: String?,
|
|
|
+ @RequestParam(required = false) parentId: Long?
|
|
|
+ ): Reply<Any> {
|
|
|
val result = departmentService.update(id, name, duty, remark, parentId)
|
|
|
return if (result) Reply.ok() else Reply.fail("更新失败")
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除部门及其子部门")
|
|
|
@PostMapping("delete")
|
|
|
- @ApiImplicitParam(name = "id",value = "部门id",paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "id", value = "部门id", paramType = "query")
|
|
|
fun delete(id: Long): Reply<Any> {
|
|
|
val result = departmentService.delete(id)
|
|
|
return if (result) Reply.ok() else Reply.fail("删除失败")
|