| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springblade.core.tool.utils.DigestUtil; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import org.sxkj.system.entity.User; |
| | | import org.sxkj.system.entity.UserInfo; |
| | | import org.sxkj.system.enums.DictEnum; |
| | | import org.sxkj.system.mapper.UserMapper; |
| | | import org.sxkj.system.param.DeptAddParam; |
| | | import org.sxkj.system.service.IDeptService; |
| | | import org.sxkj.system.service.IRoleService; |
| | |
| | | private final BladeLogger bladeLogger; |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * 新增或修改-对外 |
| | | */ |
| | | @PostMapping("/submitDeptExternal") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "机构新增或修改", notes = "传入dept") |
| | | @ApiLog("组织机构信息新增或修改") |
| | | public R submit(@Valid @RequestBody DeptAddParam dept) { |
| | | // 参数校验:确保关键字段不为空 |
| | | if (dept.getId() == null) { |
| | | return R.fail("参数缺失:id 不能为空"); |
| | | } |
| | | // 删除操作 |
| | | if (dept.getId() != null && dept.getIsDeleted() == 1) { |
| | | deptService.removeDept(String.valueOf(dept.getId())); |
| | | CacheUtil.clear(SYS_CACHE); // 清理缓存 |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId()) |
| | | .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory())); |
| | | return R.data(kv); |
| | | } |
| | | // 新增操作 |
| | | Dept deptEntity = Objects.requireNonNull(BeanUtil.copy(dept, Dept.class)); |
| | | String times = OrderNumUtils.initOrderNum2(WordOrderConstant.ORG_CODE); |
| | | String deptCode = WordOrderConstant.ORG_PREFIX + times; |
| | | deptEntity.setDeptCode(deptCode); |
| | | deptEntity.setAreaCode(HeaderUtils.processAreaCode(dept.getAreaCode())); |
| | | deptEntity.setCreateTime(new Date()); |
| | | deptEntity.setUpdateTime(new Date()); |
| | | if (deptService.submit(deptEntity)) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * 新增或修改-对外 |
| | | */ |
| | | @PostMapping("/submitRoleExternal") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "角色新增或修改", notes = "传入role") |
| | | @ApiLog("角色信息新增或修改") |
| | | public R submit(@Valid @RequestBody Role role) { |
| | | // 参数校验:确保关键字段不为空 |
| | | if (role.getId() == null) { |
| | | return R.fail("参数缺失:id 不能为空"); |
| | | } |
| | | CacheUtil.clear(SYS_CACHE); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | // 删除操作 |
| | | if (role.getIsDeleted() != null && role.getIsDeleted() == 1) { |
| | | roleService.removeRole(String.valueOf(role.getId())); |
| | | return R.status(true); |
| | | } |
| | | // 新增操作 |
| | | return R.status(roleService.submit(role)); |
| | | } |
| | | |
| | |
| | | * 用户信息新增或者修改-对外 |
| | | */ |
| | | @PostMapping("/submitUserExternal") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "新增或修改用户", notes = "传入User,新增或修改用户") |
| | | @ApiLog("用户信息新增或者修改-对外") |
| | | public R submitExternal(@Valid @RequestBody User user) { |
| | |
| | | user.setRoleId(userInfo.getUser().getRoleId()); |
| | | isRet = userService.updateUser(user); |
| | | } else { |
| | | Dept dept = deptService.getById(1123598813738675201L); |
| | | Dept dept = deptService.getById(user.getDeptId()); |
| | | user.setAreaCode(HeaderUtils.processAreaCode(dept.getAreaCode())); |
| | | user.setPassword("jadk@2026"); |
| | | user.setPassword(DigestUtil.encrypt("jadk@2026")); |
| | | user.setDeptId(user.getDeptId() == null ? String.valueOf(dept.getId()) : user.getDeptId()); |
| | | user.setRoleId(user.getRoleId() == null ? "2011678430358691842" : user.getRoleId()); |
| | | isRet = userService.save(user); |