|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.sun.javafx.logging.PulseLogger;
|
|
|
import com.szwl.annotation.Audit;
|
|
|
import com.szwl.constant.AuditEnum;
|
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
@@ -852,11 +853,50 @@ public class TAdminController {
|
|
|
if (admin.getApplyEndTime() != null) {
|
|
|
oldAdmin.setApplyEndTime(admin.getApplyEndTime());
|
|
|
}
|
|
|
+ if (StringUtils.isNotEmpty(admin.getRelationAdminId())) {
|
|
|
+ oldAdmin.setRelationAdminId(admin.getRelationAdminId());
|
|
|
+ }
|
|
|
oldAdmin.setModifyDate(new Date());
|
|
|
tAdminService.updateById(oldAdmin);
|
|
|
return R.ok(null, "修改成功");
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "设置关联上级")
|
|
|
+ @PostMapping("/setRelationAdminId")
|
|
|
+ public ResponseModel<?> setRelationAdminId(@RequestBody Map<String, String> params) {
|
|
|
+ String managerId = params.get("managerId");
|
|
|
+ String username = params.get("username");
|
|
|
+ String relationUsername = params.get("relationUsername");
|
|
|
+ if (StringUtils.isEmpty(managerId) || StringUtils.isEmpty(username)) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "参数不能为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<TAdmin> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(TAdmin::getUsername, username);
|
|
|
+ TAdmin admin = tAdminService.getOne(lqw);
|
|
|
+ if (Objects.isNull(admin)) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0206, "用户不存在");
|
|
|
+ }
|
|
|
+ String managerId1 = admin.getManagerId();
|
|
|
+
|
|
|
+ if (!managerId1.equals(managerId)) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "用户名或系统id不匹配");
|
|
|
+ }
|
|
|
+ if (username.equals(relationUsername)) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "同一账户不能构成上下级");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(relationUsername) || "".equals(relationUsername)) { // 无上级,或取消上级
|
|
|
+ admin.setRelationAdminId("");
|
|
|
+ } else {
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TAdmin::getUsername, relationUsername);
|
|
|
+ TAdmin relationAdmin = tAdminService.getOne(wrapper);
|
|
|
+ Long relationAdminId = relationAdmin.getId();
|
|
|
+ admin.setRelationAdminId(String.valueOf(relationAdminId));
|
|
|
+ }
|
|
|
+ tAdminService.saveOrUpdate(admin);
|
|
|
+ return R.ok("关联成功");
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "绑定上级账户")
|
|
|
@GetMapping("/setRelationAdmin")
|
|
|
@Transactional
|
|
@@ -934,6 +974,35 @@ public class TAdminController {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "通过 adminId 获取上级账号信息")
|
|
|
+ @GetMapping("/getRelation")
|
|
|
+ public ResponseModel<TAdmin> getRelation(String adminId) {
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TAdmin::getId, adminId);
|
|
|
+ TAdmin admin = tAdminService.getOne(wrapper);
|
|
|
+ if (Objects.nonNull(admin)) {
|
|
|
+ String relationAdminId = admin.getRelationAdminId();
|
|
|
+ if (StringUtils.isNotEmpty(relationAdminId) && !"".equals(relationAdminId)) {
|
|
|
+ TAdmin relationAdmin = tAdminService.getById(relationAdminId);
|
|
|
+ return R.ok(relationAdmin);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "通过 username 获取账号的 id")
|
|
|
+ @GetMapping("/getRelationAdminId")
|
|
|
+ public ResponseModel<String> getRelationAdminId(String relationUsername) {
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TAdmin::getUsername, relationUsername);
|
|
|
+ TAdmin admin = tAdminService.getOne(wrapper);
|
|
|
+ if (Objects.nonNull(admin)) {
|
|
|
+ Long adminId = admin.getId();
|
|
|
+ return R.ok(String.valueOf(adminId));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "获取上级账号名")
|
|
|
@GetMapping("/getRelationAdminUsername")
|
|
|
public String getRelationAdminUsername(String relationAdminId) {
|