refactor: 重构部门页面
This commit is contained in:
@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author valarchie
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
@RequestMapping("/system")
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "部门API", description = "部门相关的增删查改")
|
||||
@@ -47,7 +47,7 @@ public class SysDeptController extends BaseController {
|
||||
*/
|
||||
@Operation(summary = "部门列表")
|
||||
@PreAuthorize("@permission.has('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
@GetMapping("/depts")
|
||||
public ResponseDTO<List<DeptDTO>> list(DeptQuery query) {
|
||||
List<DeptDTO> deptList = deptApplicationService.getDeptList(query);
|
||||
return ResponseDTO.ok(deptList);
|
||||
@@ -58,7 +58,7 @@ public class SysDeptController extends BaseController {
|
||||
*/
|
||||
@Operation(summary = "部门详情")
|
||||
@PreAuthorize("@permission.has('system:dept:query')")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
@GetMapping(value = "/dept/{deptId}")
|
||||
public ResponseDTO<DeptDTO> getInfo(@PathVariable Long deptId) {
|
||||
DeptDTO dept = deptApplicationService.getDeptInfo(deptId);
|
||||
return ResponseDTO.ok(dept);
|
||||
@@ -68,7 +68,7 @@ public class SysDeptController extends BaseController {
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@Operation(summary = "获取部门树级结构")
|
||||
@GetMapping("/dropdownList")
|
||||
@GetMapping("/depts/dropdown")
|
||||
public ResponseDTO<List<Tree<Long>>> dropdownList() {
|
||||
List<Tree<Long>> deptTree = deptApplicationService.getDeptTree();
|
||||
return ResponseDTO.ok(deptTree);
|
||||
@@ -80,7 +80,7 @@ public class SysDeptController extends BaseController {
|
||||
@Operation(summary = "新增部门")
|
||||
@PreAuthorize("@permission.has('system:dept:add')")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.ADD)
|
||||
@PostMapping
|
||||
@PostMapping("/dept")
|
||||
public ResponseDTO<Void> add(@RequestBody AddDeptCommand addCommand) {
|
||||
deptApplicationService.addDept(addCommand);
|
||||
return ResponseDTO.ok();
|
||||
@@ -92,8 +92,9 @@ public class SysDeptController extends BaseController {
|
||||
@Operation(summary = "修改部门")
|
||||
@PreAuthorize("@permission.has('system:dept:edit') AND @dataScope.checkDeptId(#updateCommand.deptId)")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.MODIFY)
|
||||
@PutMapping
|
||||
public ResponseDTO<Void> edit(@RequestBody UpdateDeptCommand updateCommand) {
|
||||
@PutMapping("/dept/{deptId}")
|
||||
public ResponseDTO<Void> edit(@PathVariable("deptId")Long deptId, @RequestBody UpdateDeptCommand updateCommand) {
|
||||
updateCommand.setDeptId(deptId);
|
||||
deptApplicationService.updateDept(updateCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
@@ -104,7 +105,7 @@ public class SysDeptController extends BaseController {
|
||||
@Operation(summary = "删除部门")
|
||||
@PreAuthorize("@permission.has('system:dept:remove') AND @dataScope.checkDeptId(#deptId)")
|
||||
@AccessLog(title = "部门管理", businessType = BusinessTypeEnum.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
@DeleteMapping("/dept/{deptId}")
|
||||
public ResponseDTO<Void> remove(@PathVariable @NotNull Long deptId) {
|
||||
deptApplicationService.removeDept(deptId);
|
||||
return ResponseDTO.ok();
|
||||
|
||||
@@ -20,11 +20,6 @@ public class AddDeptCommand {
|
||||
@PositiveOrZero
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
private String ancestors;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@@ -57,4 +52,7 @@ public class AddDeptCommand {
|
||||
private String email;
|
||||
|
||||
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,4 @@ public class UpdateDeptCommand extends AddDeptCommand {
|
||||
@PositiveOrZero
|
||||
private Long deptId;
|
||||
|
||||
@PositiveOrZero
|
||||
private String status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DeptDTO {
|
||||
|
||||
public DeptDTO(SysDeptEntity entity) {
|
||||
if (entity != null) {
|
||||
this.deptId = entity.getDeptId();
|
||||
this.id = entity.getDeptId();
|
||||
this.parentId = entity.getParentId();
|
||||
this.deptName = entity.getDeptName();
|
||||
this.orderNum = entity.getOrderNum();
|
||||
@@ -28,7 +28,7 @@ public class DeptDTO {
|
||||
}
|
||||
|
||||
|
||||
private Long deptId;
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ public class DeptModel extends SysDeptEntity {
|
||||
|
||||
public void loadAddCommand(AddDeptCommand addCommand) {
|
||||
this.setParentId(addCommand.getParentId());
|
||||
this.setAncestors(addCommand.getAncestors());
|
||||
this.setDeptName(addCommand.getDeptName());
|
||||
this.setOrderNum(addCommand.getOrderNum());
|
||||
this.setLeaderName(addCommand.getLeaderName());
|
||||
this.setPhone(addCommand.getPhone());
|
||||
this.setEmail(addCommand.getEmail());
|
||||
this.setStatus(addCommand.getStatus());
|
||||
}
|
||||
|
||||
public void loadUpdateCommand(UpdateDeptCommand updateCommand) {
|
||||
|
||||
@@ -34,7 +34,6 @@ public class DeptModelFactory {
|
||||
|
||||
public DeptModel loadFromAddCommand(AddDeptCommand addCommand, DeptModel model) {
|
||||
model.setParentId(addCommand.getParentId());
|
||||
model.setAncestors(addCommand.getAncestors());
|
||||
model.setDeptName(addCommand.getDeptName());
|
||||
model.setOrderNum(addCommand.getOrderNum());
|
||||
model.setLeaderName(addCommand.getLeaderName());
|
||||
|
||||
@@ -18,18 +18,16 @@ public class DeptQuery extends AbstractQuery<SysDeptEntity> {
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String deptName;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<SysDeptEntity> addQueryCondition() {
|
||||
// TODO parentId 这个似乎没使用
|
||||
return new QueryWrapper<SysDeptEntity>()
|
||||
.eq(status != null, "status", status)
|
||||
.eq(parentId != null, "parent_id", parentId)
|
||||
.like(StrUtil.isNotEmpty(deptName), "dept_name", deptName);
|
||||
// .eq(status != null, "status", status)
|
||||
.eq(parentId != null, "parent_id", parentId);
|
||||
// .like(StrUtil.isNotEmpty(deptName), "dept_name", deptName);
|
||||
// .and(deptId != null && isExcludeCurrentDept, o ->
|
||||
// o.ne("dept_id", deptId)
|
||||
// .or()
|
||||
|
||||
Reference in New Issue
Block a user