From 9fbf17c1b1d96ebb4ee9fffb3104d0c41af2559b Mon Sep 17 00:00:00 2001 From: admin <417727563@qq.com> Date: Wed, 17 Jul 2024 17:11:37 +0800 Subject: [PATCH] =?UTF-8?q?17-=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AnnualCompPointController.java | 2 +- .../impl/AnnualCompPointServiceImpl.java | 10 +++ .../controller/AnnualCompAwardController.java | 17 ++++- .../system/controller/SysUserController.java | 76 +++++++++++++++++++ .../system/service/ISysUserService.java | 7 ++ .../service/impl/SysUserServiceImpl.java | 25 ++++++ .../department/AnnualCompPoint.data.ts | 2 +- .../department/AnnualCompPointList.vue | 4 +- .../components/AnnualCompPointForm.vue | 4 +- .../annualcomp/school/AnnualComp.data.ts | 4 +- .../annualcomp/uncommitted/AnnualCompList.vue | 4 +- .../annualcompaward/AnnualCompAwardList.vue | 16 ++-- .../src/views/system/userZJ/user.data.ts | 14 +++- .../src/views/system/userdep/userYX.api.ts | 4 +- 14 files changed, 164 insertions(+), 25 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java index 3511d2f7..77afcbe8 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualCompPoint/controller/AnnualCompPointController.java @@ -856,7 +856,7 @@ public class AnnualCompPointController extends JeecgController roleList = iSysUserRoleService.getUserRoleByUserId(loginUser.getId()); - Map roleMap = Optional.ofNullable(roleList).orElse(new LinkedList<>()).stream().collect(Collectors.toMap(SysRole::getRoleCode, SysRole::getRoleCode)); + // Map roleMap = Optional.ofNullable(roleList).orElse(new LinkedList<>()).stream().collect(Collectors.toMap(SysRole::getRoleCode, SysRole::getRoleCode)); //角色编码 管理员&组委会&教务处 可以看到所有,其它用户可见到所属自己数据 Map efficientRoleMap = new LinkedHashMap<>(); efficientRoleMap.put("admin", "admin"); efficientRoleMap.put("committee", "committee"); efficientRoleMap.put("superAdmin", "superAdmin"); + boolean containsEfficientRole = roleList.stream() + .map(SysRole::getRoleCode) + .anyMatch(efficientRoleMap::containsKey); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); Page page = new Page(pageNo, pageSize); // 查询所属当前登录用户数据 - if (!efficientRoleMap.containsValue(roleMap.get("admin")) - && !efficientRoleMap.containsValue(roleMap.get("committee")) - && !efficientRoleMap.containsValue(roleMap.get("superAdmin"))) { + if (containsEfficientRole) + { + //根据比赛管理员查询 对应必比赛 List compList = iCompService.list(new LambdaQueryWrapper().eq(Comp::getCompAdmin, loginUser.getUsername())); if (ObjectUtils.isEmpty(compList)) { return Result.OK(page); } + //获取比赛ID Set compIds = compList.stream().map(c -> c.getId()).collect(Collectors.toSet()); + //根据比赛ID查询年度必死啊 List annualCompList = annualCompService.list(new LambdaQueryWrapper().in(AnnualComp::getCompid, compIds)); if (!ObjectUtils.isEmpty(annualCompList)) { + //得到年度比赛ID Set annualCompIds = annualCompList.stream().map(d -> d.getId()).collect(Collectors.toSet()); + //根据年度比赛ID查询年度比赛项目 List annualCompPointList = annualCompPointService.list(new LambdaQueryWrapper().in(AnnualCompPoint::getAnnualCompId, annualCompIds)); if (!ObjectUtils.isEmpty(annualCompPointList)) { + //根据年度比赛ID查询奖项ID Set annualCompPointIds = annualCompPointList.stream().map(e -> e.getId()).collect(Collectors.toSet()); queryWrapper.in(AnnualCompAward::getAnnucompid, annualCompPointIds); } diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java index c96550d9..f4019134 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java @@ -256,6 +256,41 @@ public class SysUserController { return result; } + @RequestMapping(value = "/adddep", method = RequestMethod.POST) + public Result adddep(@RequestBody JSONObject jsonObject) { + Result result = new Result(); + String selectedRoles = jsonObject.getString("selectedroles"); + String selectedDeparts = jsonObject.getString("selecteddeparts"); + try { + boolean rs=sysUserService.isDepCode(selectedDeparts); + if(!rs) + { + result.error500("不能添加非院系用户"); + return result; + } + SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); + user.setCreateTime(new Date());//设置创建时间 + String salt = oConvertUtils.randomGen(8); + user.setSalt(salt); + String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), salt); + user.setPassword(passwordEncode); + user.setStatus(1); + user.setDelFlag(CommonConstant.DEL_FLAG_0); + //用户表字段org_code不能在这里设置他的值 + user.setOrgCode(null); + // 保存用户走一个service 保证事务 + //获取租户ids + String relTenantIds = jsonObject.getString("relTenantIds"); + sysUserService.saveUser(user, selectedRoles, selectedDeparts, relTenantIds); + baseCommonService.addLog("添加用户,username: " +user.getUsername() ,CommonConstant.LOG_TYPE_2, 2); + result.success("添加成功!"); + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败"); + } + return result; + } + //@RequiresPermissions("system:user:edit") @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) public Result edit(@RequestBody JSONObject jsonObject) { @@ -291,6 +326,47 @@ public class SysUserController { return result; } + //@RequiresPermissions("system:user:edit") + @RequestMapping(value = "/editdep", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result editdep(@RequestBody JSONObject jsonObject) { + Result result = new Result(); + try { + SysUser sysUser = sysUserService.getById(jsonObject.getString("id")); + baseCommonService.addLog("编辑用户,username: " +sysUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2); + if(sysUser==null) { + result.error500("未找到对应实体"); + }else { + SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); + user.setUpdateTime(new Date()); + //String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt()); + user.setPassword(sysUser.getPassword()); + String roles = jsonObject.getString("selectedroles"); + String departs = jsonObject.getString("selecteddeparts"); + boolean rs=sysUserService.isDepCode(departs); + if(!rs) + { + result.error500("不能添加非院系用户"); + return result; + } + if(oConvertUtils.isEmpty(departs)){ + //vue3.0前端只传递了departIds + departs=user.getDepartIds(); + } + //用户表字段org_code不能在这里设置他的值 + user.setOrgCode(null); + // 修改用户走一个service 保证事务 + //获取租户ids + String relTenantIds = jsonObject.getString("relTenantIds"); + sysUserService.editUser(user, roles, departs, relTenantIds); + result.success("修改成功!"); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败"); + } + return result; + } + /** * 删除用户 */ diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java index e650716f..0fcfcfc8 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java @@ -413,5 +413,12 @@ public interface ISysUserService extends IService { */ Result> queryPageListYx(HttpServletRequest req, QueryWrapper queryWrapper, Integer pageSize, Integer pageNo); + /** + * 不能添加非院系用户! + * @param selectedDeparts + * @return + */ + boolean isDepCode(String selectedDeparts); + // void getById(); } diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index 38b7ed22..bdc40fa6 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -1351,6 +1351,31 @@ public class SysUserServiceImpl extends ServiceImpl impl return result; } + /** + * 不能添加非院系用户! + * @param selectedDeparts + * @return + */ + @Override + public boolean isDepCode(String selectedDeparts) { + boolean result=true; + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String code=loginUser.getOrgCode(); + //step.3 保存所属部门 + if(oConvertUtils.isNotEmpty(selectedDeparts)) { + String[] arr = selectedDeparts.split(","); + for (String deaprtId : arr) { + SysDepart item=sysDepartMapper.selectById(deaprtId); + if(!item.getOrgCode().startsWith(code)) + { + result=false; + break; + } + } + } + return result; + } + /** * 修改租户下的部门 * @param departs diff --git a/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPoint.data.ts b/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPoint.data.ts index 12cd3012..c1489cfd 100644 --- a/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPoint.data.ts +++ b/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPoint.data.ts @@ -127,7 +127,7 @@ export const formSchema: FormSchema[] = [ fieldConfig: [ {source: 'name', target: 'annualCompId'}, ], - multi: true + multi: false } }, diff --git a/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPointList.vue b/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPointList.vue index ff30db0d..d12aa024 100644 --- a/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPointList.vue +++ b/jeecgboot-vue3-master/src/views/annualCompPoint/department/AnnualCompPointList.vue @@ -16,9 +16,9 @@ 导出 - +