From fb036b3ca33d483afbf83eede9fd806a2f77deaa Mon Sep 17 00:00:00 2001 From: futian.liu <liufutianyoo@163.com> Date: 星期三, 06 十二月 2023 13:06:41 +0800 Subject: [PATCH] 代码优化、漏洞修复 --- consum-base/src/main/java/com/consum/base/controller/FinSysTenantUserController.java | 423 +++++++++++++++++++++++++--------------------------- 1 files changed, 200 insertions(+), 223 deletions(-) diff --git a/consum-base/src/main/java/com/consum/base/controller/FinSysTenantUserController.java b/consum-base/src/main/java/com/consum/base/controller/FinSysTenantUserController.java index f03df71..868cd29 100644 --- a/consum-base/src/main/java/com/consum/base/controller/FinSysTenantUserController.java +++ b/consum-base/src/main/java/com/consum/base/controller/FinSysTenantUserController.java @@ -1,52 +1,70 @@ package com.consum.base.controller; -import cn.hutool.core.util.ReflectUtil; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +import org.apache.commons.compress.utils.Lists; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelDataConvertException; import com.consum.base.BaseController; +import com.consum.base.core.utils.CommonUtil; import com.consum.base.core.utils.MapperUtil; import com.consum.base.pojo.FinSysTenantUserSearchParam; import com.consum.base.pojo.FinSysTenantUserUpdParam; +import com.consum.base.pojo.ImportUserParam; import com.consum.base.pojo.response.DepartmentVO; import com.consum.base.pojo.response.FinSysTenantUserVO; import com.consum.base.pojo.response.FinSysTenantVO; import com.consum.base.pojo.response.UserVO; -import com.consum.base.service.FinSysTenantDepartmentServiceImpl; +import com.consum.base.service.FinSysTenantDepartmentService; import com.consum.base.service.FinSysTenantServiceImpl; import com.consum.base.service.FinSysTenantUserServiceImpl; import com.consum.model.po.FinSysTenant; import com.consum.model.po.FinSysTenantDepartment; import com.consum.model.po.FinSysTenantUser; import com.iplatform.base.ArgumentsConstants; -import com.iplatform.base.service.DeptServiceImpl; import com.iplatform.base.service.RoleServiceImpl; import com.iplatform.base.service.UserServiceImpl; import com.iplatform.base.util.PlatformRSAUtils; import com.iplatform.core.util.AESUtils; -import com.iplatform.model.po.S_config; import com.iplatform.model.po.S_dept; import com.iplatform.model.po.S_role; import com.iplatform.model.po.S_user_core; import com.walker.db.page.GenericPager; -import com.walker.infrastructure.utils.*; +import com.walker.infrastructure.utils.CollectionUtils; +import com.walker.infrastructure.utils.DateUtils; +import com.walker.infrastructure.utils.NumberGenerator; +import com.walker.infrastructure.utils.PhoneNumberUtils; +import com.walker.infrastructure.utils.StringUtils; import com.walker.web.ResponseValue; + +import cn.hutool.core.util.ReflectUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.apache.commons.compress.utils.Lists; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.*; /** * @Description 绯荤粺鐢ㄦ埛 @@ -64,26 +82,21 @@ private UserServiceImpl userService; - private DeptServiceImpl deptService; - private FinSysTenantServiceImpl finSysTenantService; private RoleServiceImpl roleService; @Autowired - private FinSysTenantDepartmentServiceImpl finSysTenantDepartmentService; - + private FinSysTenantDepartmentService finSysTenantDepartmentService; @Autowired public void setUserService(UserServiceImpl userService) { this.userService = userService; } - private S_config sConfig; - @Autowired - public FinSysTenantUserController(FinSysTenantServiceImpl finSysTenantService, FinSysTenantUserServiceImpl finSysTenantUserService, - RoleServiceImpl roleService) { + public FinSysTenantUserController(FinSysTenantServiceImpl finSysTenantService, + FinSysTenantUserServiceImpl finSysTenantUserService, RoleServiceImpl roleService) { this.finSysTenantUserService = finSysTenantUserService; this.finSysTenantService = finSysTenantService; this.roleService = roleService; @@ -95,7 +108,11 @@ * @Date 2023/7/11 13:59 */ @RequestMapping("/select/list") - public ResponseValue allocatedList(FinSysTenantUserSearchParam param) { + public ResponseValue allocatedList() { + FinSysTenantUserSearchParam param = CommonUtil.getObjFromReq(FinSysTenantUserSearchParam.class); + FinSysTenantUserSearchParam param2 = new FinSysTenantUserSearchParam(); + CommonUtil.copyProperties(param, param2); + param = param2; if (param.getTenantCode() == 0) { FinSysTenantUser user = new FinSysTenantUser(); Long id = this.getCurrentUser().getId(); @@ -141,7 +158,7 @@ finSysTenantUser.setRoleStr(roleStr); } - //寰幆鏌ヨ杩愮淮鍟唅d + // 寰幆鏌ヨ杩愮淮鍟唅d if (finSysTenantUser.getSupplierId() != null) { finSysTenantUser.setIsSupplier("鏄�"); } else { @@ -159,16 +176,15 @@ try { Field fieldDatas = GenericPager.class.getDeclaredField("datas"); -// fieldDatas.setAccessible(true); -// fieldDatas.set(pager, resultList); + // fieldDatas.setAccessible(true); + // fieldDatas.set(pager, resultList); ReflectUtil.setFieldValue(pager, fieldDatas, resultList); } catch (Exception e) { - e.printStackTrace(); + logger.error("鍒嗛〉鍒楄〃鏌ヨ澶辫触锛屽師鍥狅細" + e); } return ResponseValue.success(pager); } - @ApiOperation(value = "鏍规嵁鏈烘瀯id鏌ヨ鐢ㄦ埛", notes = "鏍规嵁鏈烘瀯id鏌ヨ鐢ㄦ埛") @ApiImplicitParam(name = "tenantId", value = "鏈烘瀯id", required = true, dataType = "Long", paramType = "query") @@ -181,7 +197,6 @@ return ResponseValue.success(result); } - /** * @Description 鏂板 * @Author wh @@ -189,12 +204,17 @@ */ @PostMapping("/add") @Transactional(rollbackFor = Exception.class) - public ResponseValue add(@RequestBody FinSysTenantUser user) { + public ResponseValue add() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser formInventoryParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, formInventoryParam); + user = formInventoryParam; if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } - //鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず - if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { + // 鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず + if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null + && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { return ResponseValue.error("鍛樺伐缂栧彿閲嶅"); } if (user.getTenantId() == null || "".equals(user.getTenantId()) || new Integer(user.getTenantId()) == 0) { @@ -203,13 +223,13 @@ if (user.getTenantCode() == null || "".equals(user.getTenantCode()) || new Integer(user.getTenantCode()) == 0) { return ResponseValue.error("娣诲姞鏃惰閫夋嫨鍖哄幙"); } - //鎻掑叆绯荤粺鐢ㄦ埛 + // 鎻掑叆绯荤粺鐢ㄦ埛 user.setId(NumberGenerator.getLongSequenceNumber()); user.setCreateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); user.setCreateBy(this.getCurrentUser().getUser_name()); user.setUpdateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); user.setUpdateBy(this.getCurrentUser().getUser_name()); - //user.setStatus(1);// 0绂佺敤 1鍚敤 + // user.setStatus(1);// 0绂佺敤 1鍚敤 user.setIsDelete(0); user.setSysUserId(NumberGenerator.getLongSequenceNumber()); // 鍔犲瘑鎵嬫満鍙� @@ -219,22 +239,22 @@ encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); } user.setUserPhone(encPhone); - //鎬庝箞鑾峰彇宸︿晶鏈烘瀯鏍戞暟鎹� - user.setSysDeptId(3L); //瀵瑰簲骞冲彴鏈烘瀯id 榛樿涓哄钩鍙扮鐞� + // 鎬庝箞鑾峰彇宸︿晶鏈烘瀯鏍戞暟鎹� + user.setSysDeptId(3L); // 瀵瑰簲骞冲彴鏈烘瀯id 榛樿涓哄钩鍙扮鐞� this.finSysTenantUserService.insert(user); // 鎻掑叆骞冲彴鐢ㄦ埛 S_user_core userCore = new S_user_core(); userCore.setId(user.getSysUserId()); - userCore.setDept_id(3L); //閮ㄩ棬id锛岀洰鍓嶅啓姝� - userCore.setOrg_id(user.getSysDeptId()); //鏈烘瀯id + userCore.setDept_id(3L); // 閮ㄩ棬id锛岀洰鍓嶅啓姝� + userCore.setOrg_id(user.getSysDeptId()); // 鏈烘瀯id userCore.setOrg_id(1L); - userCore.setUser_name(user.getUserCode()); //鐢ㄦ埛璐﹀彿 + userCore.setUser_name(user.getUserCode()); // 鐢ㄦ埛璐﹀彿 userCore.setNick_name(user.getUserName()); - //鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 + // 鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 userCore.setUser_type(2); userCore.setPhonenumber(encPhone); userCore.setSex(user.getSex().toString()); - //鍒濆鍖栧瘑鐮� 123456 + // 鍒濆鍖栧瘑鐮� 123456 String pws = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue(); userCore.setPassword(pws); // 骞冲彴鐢ㄦ埛琛ㄥ拰绯荤粺鐢ㄦ埛 琛ㄧ姸鎬佺浉鍙� @@ -262,95 +282,20 @@ userCore.setIs_logoff(0); userCore.setLogoff_time(0L); userCore.setIs_sms(0); - //绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� + // 绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� userCore.setType(1); - //鍟嗘埛id锛�0-骞冲彴 + // 鍟嗘埛id锛�0-骞冲彴 userCore.setMer_id(0L); this.userService.insert(userCore); // 鎻掑叆骞冲彴鏈烘瀯 - //灏戣鑹瞚d - List<Long> roleList = user.getRoleList(); //鏈烘瀯id 澶氫釜 + // 灏戣鑹瞚d + List<Long> roleList = user.getRoleList(); // 鏈烘瀯id 澶氫釜 if (!CollectionUtils.isEmpty(roleList)) { - Long sysUserId = user.getSysUserId(); //鐢ㄦ埛id + Long sysUserId = user.getSysUserId(); // 鐢ㄦ埛id this.finSysTenantUserService.execInsertRoleUserList(roleList, sysUserId); } -// this.getFinCustomerCache().remove(); + // this.getFinCustomerCache().remove(); return ResponseValue.success(1); - } - - - public static class ImportUserParam { - - @ExcelProperty("鐢ㄦ埛濮撳悕") - private String userName; - @ExcelProperty("鐢ㄦ埛缂栧彿") - private String userCode; - @ExcelProperty("鎵嬫満鍙�") - private String userPhone; - @ExcelProperty("鎬у埆(1鐢凤紝2濂�)") - private Integer sex; - @ExcelProperty("鐢靛瓙閭") - private String email; - @ExcelProperty("椤哄簭鍙�") - private Long seq; - @ExcelProperty("瑙掕壊鍚嶇О") - private String roleName; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getUserCode() { - return userCode; - } - - public void setUserCode(String userCode) { - this.userCode = userCode; - } - - public String getUserPhone() { - return userPhone; - } - - public void setUserPhone(String userPhone) { - this.userPhone = userPhone; - } - - public Integer getSex() { - return sex; - } - - public void setSex(Integer sex) { - this.sex = sex; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public Long getSeq() { - return seq; - } - - public void setSeq(Long seq) { - this.seq = seq; - } - - public String getRoleName() { - return roleName; - } - - public void setRoleName(String roleName) { - this.roleName = roleName; - } } /** @@ -359,7 +304,8 @@ * @Date 2023/10/12 15:56 */ @PostMapping("/import") - public ResponseValue importUser(@RequestParam String tenantId, @RequestParam String tenantCode, MultipartFile file) throws IOException { + public ResponseValue importUser(@RequestParam String tenantId, @RequestParam String tenantCode, MultipartFile file) + throws IOException { String originalFilename = file.getOriginalFilename(); if (!"xls".equals(originalFilename.substring(originalFilename.lastIndexOf(".") + 1))) { return ResponseValue.error("鏂囦欢鏍煎紡鏈夎!"); @@ -379,11 +325,13 @@ EasyExcel.read(file.getInputStream(), ImportUserParam.class, new AnalysisEventListener<ImportUserParam>() { @Override public void invoke(ImportUserParam data, AnalysisContext context) { - if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) || StringUtils.isEmpty(data.getUserPhone()) - || null == data.getSex() || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() || StringUtils.isEmpty(data.getRoleName())) { + if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) + || StringUtils.isEmpty(data.getUserPhone()) || null == data.getSex() + || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() + || StringUtils.isEmpty(data.getRoleName())) { throw new ImportUserParamVerifyException("鍗曞厓鏍间笉鑳戒负绌�!"); } - //鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず + // 鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず if (finSysTenantUserService.getByUserCode(data.getUserCode()) > 0) { throw new ImportUserParamVerifyException("鍛樺伐缂栧彿涓虹┖鎴栧凡瀛樺湪!"); } @@ -399,8 +347,9 @@ user.setSeq(data.getSeq()); user.setTenantId(tenantId); user.setTenantCode(tenantCode); - //璁剧疆瑙掕壊 - Optional<S_role> sRole = roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); + // 璁剧疆瑙掕壊 + Optional<S_role> sRole = + roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); user.setRoleList(Arrays.asList(sRole.orElse(new S_role()).getRole_id())); user.setId(NumberGenerator.getLongSequenceNumber()); @@ -418,8 +367,8 @@ user.setUserPhone(encPhone); user.setIsDelete(1); - //鎬庝箞鑾峰彇宸︿晶鏈烘瀯鏍戞暟鎹� - user.setSysDeptId(3L); //瀵瑰簲骞冲彴鏈烘瀯id 榛樿涓哄钩鍙扮鐞� + // 鎬庝箞鑾峰彇宸︿晶鏈烘瀯鏍戞暟鎹� + user.setSysDeptId(3L); // 瀵瑰簲骞冲彴鏈烘瀯id 榛樿涓哄钩鍙扮鐞� finSysTenantUsers.add(user); } @@ -433,15 +382,17 @@ if (exception != null) { // 濡傛灉鏄煇涓�涓崟鍏冩牸鐨勮浆鎹㈠紓甯� 鑳借幏鍙栧埌鍏蜂綋琛屽彿 灏佽鏃跺紓甯� if (exception instanceof ExcelDataConvertException) { - ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; - logger.error("绗瑊}琛岋紝绗瑊}鍒楄В鏋愬紓甯革紝鏁版嵁涓�:{}", excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex() + 1, + ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; + logger.error("绗瑊}琛岋紝绗瑊}鍒楄В鏋愬紓甯革紝鏁版嵁涓�:{}", excelDataConvertException.getRowIndex(), + excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData().getStringValue()); - throw new IllegalStateException( - "绗�" + (excelDataConvertException.getRowIndex() + 1) + "琛岋紝绗�" + (excelDataConvertException.getColumnIndex() + 1) + "鍒楄В鏋愬紓甯革紝寮傚父鏁版嵁涓�:[ " - + excelDataConvertException.getCellData().getStringValue() + " ]"); + throw new IllegalStateException("绗�" + (excelDataConvertException.getRowIndex() + 1) + "琛岋紝绗�" + + (excelDataConvertException.getColumnIndex() + 1) + "鍒楄В鏋愬紓甯革紝寮傚父鏁版嵁涓�:[ " + + excelDataConvertException.getCellData().getStringValue() + " ]"); } if (exception instanceof ImportUserParamVerifyException) { - throw new IllegalStateException("绗�" + context.readSheetHolder().getRowIndex() + "琛�, 瑙f瀽閿欒:[ " + exception.getMessage() + " ]"); + throw new IllegalStateException("绗�" + context.readSheetHolder().getRowIndex() + "琛�, 瑙f瀽閿欒:[ " + + exception.getMessage() + " ]"); } throw exception; } @@ -463,16 +414,16 @@ // 鎻掑叆骞冲彴鐢ㄦ埛 S_user_core userCore = new S_user_core(); userCore.setId(user.getSysUserId()); - userCore.setDept_id(3L); //閮ㄩ棬id锛岀洰鍓嶅啓姝� - userCore.setOrg_id(user.getSysDeptId()); //鏈烘瀯id + userCore.setDept_id(3L); // 閮ㄩ棬id锛岀洰鍓嶅啓姝� + userCore.setOrg_id(user.getSysDeptId()); // 鏈烘瀯id userCore.setOrg_id(1L); - userCore.setUser_name(user.getUserCode()); //鐢ㄦ埛璐﹀彿 + userCore.setUser_name(user.getUserCode()); // 鐢ㄦ埛璐﹀彿 userCore.setNick_name(user.getUserName()); - //鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 + // 鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 userCore.setUser_type(2); userCore.setPhonenumber(user.getUserPhone()); userCore.setSex(user.getSex().toString()); - //鍒濆鍖栧瘑鐮� 123456 + // 鍒濆鍖栧瘑鐮� 123456 String pws = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue(); userCore.setPassword(pws); // 骞冲彴鐢ㄦ埛琛ㄥ拰绯荤粺鐢ㄦ埛 琛ㄧ姸鎬佺浉鍙� @@ -500,17 +451,17 @@ userCore.setIs_logoff(0); userCore.setLogoff_time(0L); userCore.setIs_sms(0); - //绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� + // 绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� userCore.setType(1); - //鍟嗘埛id锛�0-骞冲彴 + // 鍟嗘埛id锛�0-骞冲彴 userCore.setMer_id(0L); sUserCores.add(userCore); } - //淇濆瓨鐢ㄦ埛淇℃伅 + // 淇濆瓨鐢ㄦ埛淇℃伅 this.finSysTenantUserService.insertBatch(finSysTenantUsers); - //淇濆瓨骞冲彴鐢ㄦ埛淇℃伅 + // 淇濆瓨骞冲彴鐢ㄦ埛淇℃伅 this.userService.insertBatch(sUserCores); - //淇濆瓨瑙掕壊鏉冮檺淇℃伅 + // 淇濆瓨瑙掕壊鏉冮檺淇℃伅 this.finSysTenantUserService.execInsertRoleUserList(finSysTenantUsers); } @@ -525,7 +476,6 @@ } } - /** * @Description 缂栬緫 * @Author wh @@ -533,7 +483,12 @@ */ @PostMapping("/update") @Transactional(rollbackFor = Exception.class) - public ResponseValue update(@RequestBody FinSysTenantUser user) { + public ResponseValue update() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser formInventoryParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, formInventoryParam); + user = formInventoryParam; + if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } @@ -543,9 +498,9 @@ encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); } user.setUserPhone(encPhone); - // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER + // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER finSysTenantUserService.update(user); - // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE + // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE S_user_core userCore = new S_user_core(); userCore.setId(user.getSysUserId()); userCore.setUpdate_by(this.getCurrentUser().getUser_name()); @@ -565,11 +520,11 @@ // 鍔犲瘑鎵嬫満鍙� userCore.setPhonenumber(user.getUserPhone()); this.userService.update(userCore); - // 3. 鏇存柊瑙掕壊閰嶇疆 S_ROLE_USER - // 1. 鏍规嵁 user.getSysUserId() 鏌ヨ - List<S_role> list = finSysTenantUserService.getByUserId(user.getSysUserId()); //宸叉湁鐨勬潈闄� - List<Long> roleList = user.getRoleList(); //閫夋嫨鐨勬潈闄� - //鍏堝垹闄ゅ啀娣诲姞 + // 3. 鏇存柊瑙掕壊閰嶇疆 S_ROLE_USER + // 1. 鏍规嵁 user.getSysUserId() 鏌ヨ + List<S_role> list = finSysTenantUserService.getByUserId(user.getSysUserId()); // 宸叉湁鐨勬潈闄� + List<Long> roleList = user.getRoleList(); // 閫夋嫨鐨勬潈闄� + // 鍏堝垹闄ゅ啀娣诲姞 if (list != null && list.size() > 0) { finSysTenantUserService.execDelRoleUserList(user.getSysUserId()); } @@ -587,11 +542,15 @@ */ @PostMapping("/updateStatus") @Transactional(rollbackFor = Exception.class) - public ResponseValue updateStatus(@RequestBody FinSysTenantUser user) { + public ResponseValue updateStatus() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser formInventoryParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, formInventoryParam); + user = formInventoryParam; if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } - // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER 搴旇鏄煡璇� 鐒跺悗鍙敼鐘舵�� + // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER 搴旇鏄煡璇� 鐒跺悗鍙敼鐘舵�� List<FinSysTenantUser> select = finSysTenantUserService.select(new FinSysTenantUser(user.getId())); if (select == null || select.size() == 0) { return ResponseValue.error("鐢ㄦ埛涓嶅瓨鍦�"); @@ -599,7 +558,7 @@ FinSysTenantUser finSysTenantUser = select.get(0); finSysTenantUser.setStatus(user.getStatus()); finSysTenantUserService.update(finSysTenantUser); - // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE + // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE S_user_core userCore = new S_user_core(); userCore.setId(user.getSysUserId()); userCore.setUpdate_by(this.getCurrentUser().getUser_name()); @@ -625,10 +584,10 @@ if (finSysTenantUser == null) { return ResponseValue.error("鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } - //鍒濆鍖栧瘑鐮� 123456 + // 鍒濆鍖栧瘑鐮� 123456 String stringValue = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue();// 瀵嗘枃 // 1. 淇敼鐢ㄦ埛琛� - //鐢ㄦ埛琛╥d + // 鐢ㄦ埛琛╥d Long sysUserId = finSysTenantUser.getSysUserId(); S_user_core userCore = new S_user_core(); userCore.setId(sysUserId); @@ -684,21 +643,23 @@ } // 鏌ヨ 鐢ㄦ埛瑙掕壊 TODO 涓存椂瑙e喅 灏嗘潵鏀鹃厤缃枃浠朵腑 - List<S_role> list = finSysTenantUserService.getByUserId(sysInfo.getSysUserId()); //宸叉湁鐨勬潈闄� + // 宸叉湁鐨勬潈闄� + List<S_role> list = finSysTenantUserService.getByUserId(sysInfo.getSysUserId()); for (S_role s_role : list) { if (s_role.getRole_id() != null && s_role.getRole_id().equals(1690961420053L)) { sysInfo.setKfStatus(1); } } - // 鏌ヨ鐖剁被鐨刼rgcode 闇�瑕佸皢鑷繁鐨刼rg鍏堟煡鍑烘潵 鍐嶆牴鎹畃arentid 鏌ョ埗绫� + // 鏌ヨ鐖剁被鐨刼rgcode 闇�瑕佸皢鑷繁鐨刼rg鍏堟煡鍑烘潵 鍐嶆牴鎹畃arentid 鏌ョ埗绫� String tenantId = sysInfo.getTenantId(); if (tenantId != null && !tenantId.equals("")) { List<FinSysTenant> select = finSysTenantService.select(new FinSysTenant(Long.valueOf(tenantId))); if (select != null && select.size() > 0) { FinSysTenant finSysTenant = select.get(0); if (finSysTenant != null && finSysTenant.getParentId() != null) { - List<FinSysTenant> parents = finSysTenantService.select(new FinSysTenant(finSysTenant.getParentId())); + List<FinSysTenant> parents = + finSysTenantService.select(new FinSysTenant(finSysTenant.getParentId())); if (parents != null && parents.size() > 0) { sysInfo.setParentCode(parents.get(0).getCode()); } @@ -710,22 +671,25 @@ return ResponseValue.success(sysInfo); } - /** * 鏇存柊瑙掕壊鏉冮檺 * - * @param user * @return */ @PostMapping("/updRole") - public ResponseValue updRole(@RequestBody FinSysTenantUser user) { + public ResponseValue updRole() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser finSysTenantParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, finSysTenantParam); + user = finSysTenantParam; + if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } - // 1. 鏍规嵁 user.getSysUserId() 鏌ヨ - List<S_role> list = finSysTenantUserService.getByUserId(user.getSysUserId()); //宸叉湁鐨勬潈闄� - List<Long> roleList = user.getRoleList(); //閫夋嫨鐨勬潈闄� - //鍏堝垹闄ゅ啀娣诲姞 + // 1. 鏍规嵁 user.getSysUserId() 鏌ヨ + List<S_role> list = finSysTenantUserService.getByUserId(user.getSysUserId()); // 宸叉湁鐨勬潈闄� + List<Long> roleList = user.getRoleList(); // 閫夋嫨鐨勬潈闄� + // 鍏堝垹闄ゅ啀娣诲姞 if (list != null && list.size() > 0) { finSysTenantUserService.execDelRoleUserList(user.getSysUserId()); } @@ -735,7 +699,6 @@ return ResponseValue.success(1); } - /** * @Description 鏂板 * @Author llb @@ -743,7 +706,11 @@ */ @PostMapping("/addSupplier") @Transactional(rollbackFor = Exception.class) - public ResponseValue addSupplier(@RequestBody FinSysTenantUser user) { + public ResponseValue addSupplier() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser finSysTenantParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, finSysTenantParam); + user = finSysTenantParam; if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } @@ -752,12 +719,13 @@ if (depts == null || depts.size() == 0) { return ResponseValue.error(roleName + "鐨勮鑹蹭笉瀛樺湪"); } - //鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず - if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { + // 鏍规嵁鍛樺伐缂栧彿鏌ヨ锛屽鏋滃瓨鍦ㄥ垯鎻愮ず + if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null + && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { return ResponseValue.error("鍛樺伐缂栧彿閲嶅"); } FinSysTenantUser sysInfo = this.getSysInfo(); - //鎻掑叆绯荤粺鐢ㄦ埛 + // 鎻掑叆绯荤粺鐢ㄦ埛 user.setId(NumberGenerator.getLongSequenceNumber()); user.setCreateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); user.setCreateBy(this.getCurrentUser().getUser_name()); @@ -769,7 +737,7 @@ user.setLv(sysInfo.getLv()); user.setTenantCode(sysInfo.getTenantCode()); user.setTenantId(sysInfo.getTenantId()); - user.setSysDeptId(2l); //杩愮淮绠$悊 + user.setSysDeptId(2l); // 杩愮淮绠$悊 // 鍔犲瘑鎵嬫満鍙� String key = PlatformRSAUtils.AES_KEY; String userPhone = user.getUserPhone(); @@ -783,16 +751,16 @@ // 鎻掑叆骞冲彴鐢ㄦ埛 S_user_core userCore = new S_user_core(); userCore.setId(user.getSysUserId()); - userCore.setDept_id(depts.get(0).getId()); //閮ㄩ棬 + userCore.setDept_id(depts.get(0).getId()); // 閮ㄩ棬 userCore.setOrg_id(1L); - //userCore.setUser_name(); //鐢ㄦ埛璐﹀彿 - userCore.setUser_name(user.getUserCode()); //鐢ㄦ埛璐﹀彿 + // userCore.setUser_name(); //鐢ㄦ埛璐﹀彿 + userCore.setUser_name(user.getUserCode()); // 鐢ㄦ埛璐﹀彿 userCore.setNick_name(user.getUserName()); - //鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 + // 鐢ㄦ埛绫诲瀷 鍏堥粯璁よ缃负2 userCore.setUser_type(2); userCore.setPhonenumber(userPhone); - //鍒濆鍖栧瘑鐮� 123456 + // 鍒濆鍖栧瘑鐮� 123456 String pws = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue(); userCore.setPassword(pws); if (user.getStatus() == 0) { @@ -818,41 +786,47 @@ userCore.setIs_logoff(0); userCore.setLogoff_time(0L); userCore.setIs_sms(0); - //绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� + // 绠$悊鍛樼被鍨嬶細1= 骞冲彴瓒呯, 2=鍟嗘埛瓒呯, 3=绯荤粺绠$悊鍛橈紝4=鍟嗘埛绠$悊鍛� userCore.setType(2); - //鍟嗘埛id锛�0-骞冲彴 + // 鍟嗘埛id锛�0-骞冲彴 userCore.setMer_id(0L); this.userService.insert(userCore); // 鎻掑叆骞冲彴鏈烘瀯 - //灏戣鑹瞚d - List<Long> roleList = user.getRoleList(); //鏈烘瀯id 澶氫釜 - Long sysUserId = user.getSysUserId(); //鐢ㄦ埛id + // 灏戣鑹瞚d + List<Long> roleList = user.getRoleList(); // 鏈烘瀯id 澶氫釜 + Long sysUserId = user.getSysUserId(); // 鐢ㄦ埛id this.finSysTenantUserService.execInsertRoleUserList(roleList, sysUserId); return ResponseValue.success(1); } - private Set<String> picFormatArr = new HashSet<String>() {{ - add(".pjp"); - add(".svgz"); - add(".jxl"); - add(".jpeg"); - add(".ico"); - add(".avif"); - add(".tif"); - add(".gif"); - add(".jfif"); - add(".jpg"); - add(".svg"); - add(".png"); - add(".xbm"); - add(".pjpeg"); - add(".bmp"); - add(".webp"); - }}; + private Set<String> picFormatArr = new HashSet<String>() { + { + add(".pjp"); + add(".svgz"); + add(".jxl"); + add(".jpeg"); + add(".ico"); + add(".avif"); + add(".tif"); + add(".gif"); + add(".jfif"); + add(".jpg"); + add(".svg"); + add(".png"); + add(".xbm"); + add(".pjpeg"); + add(".bmp"); + add(".webp"); + } + }; @PostMapping("/updatePerson") @Transactional(rollbackFor = Exception.class) - public ResponseValue updatePerson(@RequestBody FinSysTenantUser user) { + public ResponseValue updatePerson() { + FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); + FinSysTenantUser finSysTenantParam = new FinSysTenantUser(); + CommonUtil.copyProperties(user, finSysTenantParam); + user = finSysTenantParam; if (user == null) { return ResponseValue.error("鍙傛暟涓虹┖"); } @@ -876,9 +850,9 @@ encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); } updUser.setUserPhone(encPhone); - // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER + // 1.鏇存柊绯荤粺鐢ㄦ埛 FIN_SYS_TENANT_USER finSysTenantUserService.update(updUser); - // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE + // 2.鏇存柊骞冲彴鐢ㄦ埛 S_USER_CORE S_user_core userCore = new S_user_core(); userCore.setId(sysInfo.getSysUserId()); userCore.setUpdate_by(this.getCurrentUser().getUser_name()); @@ -897,11 +871,16 @@ * @Description 淇敼瀵嗙爜 */ @PostMapping("/updatePassword") - public ResponseValue updatePassword(@RequestBody FinSysTenantUserUpdParam param) { + public ResponseValue updatePassword() { + FinSysTenantUserUpdParam param = CommonUtil.getObjFromReqBody(FinSysTenantUserUpdParam.class); + FinSysTenantUserUpdParam finSysTenantParam = new FinSysTenantUserUpdParam(); + CommonUtil.copyProperties(param, finSysTenantParam); + param = finSysTenantParam; + String oldMixPd = param.getOldMixPd(); String newMixPd = param.getNewMixPd(); String btnMixPd = param.getBtnMixPd(); - //鏍¢獙鍙傛暟 + // 鏍¢獙鍙傛暟 if (StringUtils.isEmpty(oldMixPd) || StringUtils.isEmpty(newMixPd) || StringUtils.isEmpty(btnMixPd)) { return ResponseValue.error("淇℃伅涓嶈兘涓虹┖锛�"); } @@ -909,7 +888,7 @@ if (sysInfo == null) { return ResponseValue.error("鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } - //鏍¢獙淇╂杈撳叆鐨勫瘑鐮� + // 鏍¢獙淇╂杈撳叆鐨勫瘑鐮� btnMixPd = PlatformRSAUtils.getRsaDecryptValue(btnMixPd, PlatformRSAUtils.PRIK); newMixPd = PlatformRSAUtils.getRsaDecryptValue(newMixPd, PlatformRSAUtils.PRIK); if (!newMixPd.equals(btnMixPd)) { @@ -923,7 +902,7 @@ if (validatePasswordRule != null) { return ResponseValue.error(validatePasswordRule); } - //鐢ㄦ埛琛╥d + // 鐢ㄦ埛琛╥d Long sysUserId = sysInfo.getSysUserId(); S_user_core queryU = new S_user_core(); queryU.setId(sysUserId); @@ -932,14 +911,14 @@ return ResponseValue.error("鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } oldMixPd = PlatformRSAUtils.getRsaDecryptValue(oldMixPd, PlatformRSAUtils.PRIK); - //鏍¢獙鑰佸瘑鐮� + // 鏍¢獙鑰佸瘑鐮� if (!this.matchesPassword(oldMixPd, queryUserInfo.getPassword())) { return ResponseValue.error("鏃у瘑鐮佽緭鍏ユ湁璇紒"); } if (oldMixPd.equalsIgnoreCase(btnMixPd)) { return ResponseValue.error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚岋紒"); } - //鏇存柊鏁版嵁搴� + // 鏇存柊鏁版嵁搴� // 1. 淇敼鐢ㄦ埛琛� queryU.setPassword(this.encryptPassword(btnMixPd)); queryU.setModify_pwd(1); @@ -950,8 +929,7 @@ @ApiOperation(value = "鏍规嵁鏈烘瀯id鏌ヨ閮ㄩ棬涓殑鐢ㄦ埛", notes = "鏍规嵁鏈烘瀯id鏌ヨ閮ㄩ棬涓殑鐢ㄦ埛") @ApiImplicitParams({ - @ApiImplicitParam(name = "agencyId", value = "鏈烘瀯id", required = true, dataType = "Long", paramType = "query") - }) + @ApiImplicitParam(name = "agencyId", value = "鏈烘瀯id", required = true, dataType = "Long", paramType = "query")}) @GetMapping("/select/department") public ResponseValue selectDepartment(Long agencyId) { FinSysTenantVO finSysTenantVO = new FinSysTenantVO(); @@ -965,18 +943,18 @@ // 閮ㄩ棬 FinSysTenantDepartment finSysTenantDepartment = new FinSysTenantDepartment(); finSysTenantDepartment.setTenantId(agencyId); - List<FinSysTenantDepartment> tenantDepartmentList = finSysTenantDepartmentService.select(finSysTenantDepartment); + List<FinSysTenantDepartment> tenantDepartmentList = + finSysTenantDepartmentService.select(finSysTenantDepartment); List<DepartmentVO> departmentVOList = Lists.newArrayList(); tenantDepartmentList.forEach(department -> { DepartmentVO departmentVO = new DepartmentVO(); - //鐢ㄦ埛 + // 鐢ㄦ埛 Long id = department.getId(); departmentVO.setId(id); departmentVO.setName(department.getName()); departmentVO.setType("department"); - String sql = "SELECT SYS_USER_ID,USER_NAME FROM " - + "fin_sys_tenant_user " + String sql = "SELECT SYS_USER_ID,USER_NAME FROM " + "fin_sys_tenant_user " + "WHERE SYS_DEPT_ID =:deptId AND SYS_USER_ID NOT IN(SELECT MANAGER_ID FROM base_warehouse_manager)"; Map<String, Object> param = new HashMap<>(); param.put("deptId", id); @@ -984,7 +962,7 @@ List<UserVO> userVOList = Lists.newArrayList(); select.forEach(user -> { UserVO userVO = new UserVO(); - userVO.setId((Long) user.get("sysUserId")); + userVO.setId((Long)user.get("sysUserId")); userVO.setName(user.get("userName").toString()); userVO.setType("user"); userVOList.add(userVO); @@ -996,6 +974,5 @@ return ResponseValue.success(finSysTenantVO); } - } -- Gitblit v1.9.1