| | |
| | | package com.consum.base.controller; |
| | | |
| | | 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 cn.hutool.core.util.ReflectUtil; |
| | | 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.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.request.FinSysTenantUserParam; |
| | | import com.consum.base.pojo.response.DepartmentVO; |
| | | import com.consum.base.pojo.response.FinSysTenantUserVO; |
| | | import com.consum.base.pojo.response.FinSysTenantVO; |
| | |
| | | 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.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.infrastructure.utils.*; |
| | | 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 系统用户 |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue add() { |
| | | FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); |
| | | FinSysTenantUser formInventoryParam = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, formInventoryParam); |
| | | user = formInventoryParam; |
| | | if (user == null) { |
| | | FinSysTenantUser tenantUser = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, tenantUser); |
| | | |
| | | if (tenantUser == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | // 根据员工编号查询,如果存在则提示 |
| | | if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null |
| | | && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { |
| | | if (finSysTenantUserService.getByUserCode(tenantUser.getUserCode()) != null |
| | | && finSysTenantUserService.getByUserCode(tenantUser.getUserCode()) > 0) { |
| | | return ResponseValue.error("员工编号重复"); |
| | | } |
| | | if (user.getTenantId() == null || "".equals(user.getTenantId()) || new Integer(user.getTenantId()) == 0) { |
| | | |
| | | if (StringUtils.isEmpty(tenantUser.getTenantId()) || "0".equals(tenantUser.getTenantId())) { |
| | | return ResponseValue.error("添加时请选择区县"); |
| | | } |
| | | if (user.getTenantCode() == null || "".equals(user.getTenantCode()) || new Integer(user.getTenantCode()) == 0) { |
| | | |
| | | if (StringUtils.isEmpty(tenantUser.getTenantCode()) || "0".equals(tenantUser.getTenantCode())) { |
| | | 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()); |
| | | tenantUser.setId(NumberGenerator.getLongSequenceNumber()); |
| | | tenantUser.setCreateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | tenantUser.setCreateBy(this.getCurrentUser().getUser_name()); |
| | | tenantUser.setUpdateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | tenantUser.setUpdateBy(this.getCurrentUser().getUser_name()); |
| | | // user.setStatus(1);// 0禁用 1启用 |
| | | user.setIsDelete(0); |
| | | user.setSysUserId(NumberGenerator.getLongSequenceNumber()); |
| | | tenantUser.setIsDelete(0); |
| | | tenantUser.setSysUserId(NumberGenerator.getLongSequenceNumber()); |
| | | // 加密手机号 |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | if (tenantUser.getUserPhone() != null) { |
| | | encPhone = AESUtils.encryptStrAES(tenantUser.getUserPhone(), key); |
| | | } |
| | | user.setUserPhone(encPhone); |
| | | tenantUser.setUserPhone(encPhone); |
| | | // 怎么获取左侧机构树数据 |
| | | user.setSysDeptId(3L); // 对应平台机构id 默认为平台管理 |
| | | this.finSysTenantUserService.insert(user); |
| | | // tenantUser.setSysDeptId(3L); // 对应平台机构id 默认为平台管理 |
| | | this.finSysTenantUserService.insert(tenantUser); |
| | | |
| | | // 插入平台用户 |
| | | S_user_core userCore = new S_user_core(); |
| | | userCore.setId(user.getSysUserId()); |
| | | userCore.setId(tenantUser.getSysUserId()); |
| | | userCore.setDept_id(3L); // 部门id,目前写死 |
| | | userCore.setOrg_id(user.getSysDeptId()); // 机构id |
| | | userCore.setOrg_id(tenantUser.getSysDeptId()); // 机构id |
| | | userCore.setOrg_id(1L); |
| | | userCore.setUser_name(user.getUserCode()); // 用户账号 |
| | | userCore.setNick_name(user.getUserName()); |
| | | userCore.setUser_name(tenantUser.getUserCode()); // 用户账号 |
| | | userCore.setNick_name(tenantUser.getUserName()); |
| | | // 用户类型 先默认设置为2 |
| | | userCore.setUser_type(2); |
| | | userCore.setPhonenumber(encPhone); |
| | | userCore.setSex(user.getSex().toString()); |
| | | userCore.setSex(tenantUser.getSex().toString()); |
| | | // 初始化密码 123456 |
| | | String pws = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue(); |
| | | userCore.setPassword(pws); |
| | | // 平台用户表和系统用户 表状态相反 |
| | | if (user.getStatus() == 0) { |
| | | user.setStatus(1); |
| | | if (tenantUser.getStatus() == 0) { |
| | | tenantUser.setStatus(1); |
| | | } else { |
| | | user.setStatus(0); |
| | | tenantUser.setStatus(0); |
| | | } |
| | | userCore.setStatus(user.getStatus()); |
| | | userCore.setStatus(tenantUser.getStatus()); |
| | | userCore.setDel_flag(0); |
| | | userCore.setCreate_by(this.getCurrentUser().getUser_name()); |
| | | userCore.setCreate_time(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | userCore.setRemark(user.getRemark()); |
| | | userCore.setRemark(tenantUser.getRemark()); |
| | | userCore.setType(1); |
| | | userCore.setBind_client_id("0"); |
| | | userCore.setBind_wechat(0); |
| | |
| | | // 少角色id |
| | | List<Long> roleList = user.getRoleList(); // 机构id 多个 |
| | | if (!CollectionUtils.isEmpty(roleList)) { |
| | | Long sysUserId = user.getSysUserId(); // 用户id |
| | | Long sysUserId = tenantUser.getSysUserId(); // 用户id |
| | | this.finSysTenantUserService.execInsertRoleUserList(roleList, sysUserId); |
| | | } |
| | | // 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; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/update") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue update(@RequestBody FinSysTenantUser user) { |
| | | if (user == null) { |
| | | public ResponseValue update() { |
| | | FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); |
| | | FinSysTenantUser tenantUser = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, tenantUser); |
| | | |
| | | if (tenantUser == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | if (tenantUser.getUserPhone() != null) { |
| | | encPhone = AESUtils.encryptStrAES(tenantUser.getUserPhone(), key); |
| | | } |
| | | user.setUserPhone(encPhone); |
| | | tenantUser.setUserPhone(encPhone); |
| | | // 1.更新系统用户 FIN_SYS_TENANT_USER |
| | | finSysTenantUserService.update(user); |
| | | finSysTenantUserService.update(tenantUser); |
| | | // 2.更新平台用户 S_USER_CORE |
| | | S_user_core userCore = new S_user_core(); |
| | | userCore.setId(user.getSysUserId()); |
| | |
| | | */ |
| | | @PostMapping("/updateStatus") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue updateStatus(@RequestBody FinSysTenantUser user) { |
| | | if (user == null) { |
| | | public ResponseValue updateStatus() { |
| | | FinSysTenantUserParam user = CommonUtil.getObjFromReqBody(FinSysTenantUserParam.class); |
| | | FinSysTenantUser tenantUser = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, tenantUser); |
| | | if (tenantUser == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | // 1.更新系统用户 FIN_SYS_TENANT_USER 应该是查询 然后只改状态 |
| | | List<FinSysTenantUser> select = finSysTenantUserService.select(new FinSysTenantUser(user.getId())); |
| | | List<FinSysTenantUser> select = finSysTenantUserService.select(new FinSysTenantUser(tenantUser.getId())); |
| | | if (select == null || select.size() == 0) { |
| | | return ResponseValue.error("用户不存在"); |
| | | } |
| | |
| | | * @Date 2023/7/17 14:36 |
| | | */ |
| | | @PostMapping("/defaultPassword") |
| | | public ResponseValue defaultPassword(@RequestBody FinSysTenantUser finSysTenantUser) { |
| | | if (finSysTenantUser == null) { |
| | | public ResponseValue defaultPassword() { |
| | | FinSysTenantUserParam user = CommonUtil.getObjFromReqBody(FinSysTenantUserParam.class); |
| | | FinSysTenantUserParam tenantUser = new FinSysTenantUserParam(); |
| | | CommonUtil.copyProperties(user, tenantUser); |
| | | user = tenantUser; |
| | | |
| | | if (Objects.isNull(user)) { |
| | | return ResponseValue.error("用户信息不存在"); |
| | | } |
| | | // 初始化密码 123456 |
| | | String stringValue = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue();// 密文 |
| | | // 1. 修改用户表 |
| | | // 用户表id |
| | | Long sysUserId = finSysTenantUser.getSysUserId(); |
| | | Long sysUserId = user.getSysUserId(); |
| | | S_user_core userCore = new S_user_core(); |
| | | userCore.setId(sysUserId); |
| | | userCore.setPassword(stringValue); |
| | |
| | | /** |
| | | * 更新角色权限 |
| | | * |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @PostMapping("/updRole") |
| | | public ResponseValue updRole(@RequestBody FinSysTenantUser user) { |
| | | public ResponseValue updRole() { |
| | | FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); |
| | | FinSysTenantUser tenantUser = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, tenantUser); |
| | | user = tenantUser; |
| | | |
| | | if (user == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/addSupplier") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue addSupplier(@RequestBody FinSysTenantUser user) { |
| | | public ResponseValue addSupplier() { |
| | | FinSysTenantUserParam userParam = CommonUtil.getObjFromReqBody(FinSysTenantUserParam.class); |
| | | FinSysTenantUser user = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(userParam, user); |
| | | |
| | | if (user == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | |
| | | |
| | | @PostMapping("/updatePerson") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue updatePerson(@RequestBody FinSysTenantUser user) { |
| | | if (user == null) { |
| | | public ResponseValue updatePerson() { |
| | | FinSysTenantUserParam userParam = CommonUtil.getObjFromReqBody(FinSysTenantUserParam.class); |
| | | FinSysTenantUserParam tenantUser = new FinSysTenantUserParam(); |
| | | CommonUtil.copyProperties(userParam, tenantUser); |
| | | userParam = tenantUser; |
| | | if (userParam == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("用户信息不存在"); |
| | | } |
| | | String avatar = user.getAvatar(); |
| | | String avatar = userParam.getAvatar(); |
| | | if (!picFormatArr.contains(avatar.substring(avatar.lastIndexOf(".")))) { |
| | | return ResponseValue.error("头像格式不允许"); |
| | | } |
| | | FinSysTenantUser updUser = new FinSysTenantUser(); |
| | | updUser.setId(sysInfo.getId()); |
| | | updUser.setAvatar(user.getAvatar()); |
| | | updUser.setEmail(user.getEmail()); |
| | | updUser.setUserName(user.getUserName()); |
| | | updUser.setSex(user.getSex()); |
| | | updUser.setAvatar(userParam.getAvatar()); |
| | | updUser.setEmail(userParam.getEmail()); |
| | | updUser.setUserName(userParam.getUserName()); |
| | | updUser.setSex(userParam.getSex()); |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | if (userParam.getUserPhone() != null) { |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | encPhone = AESUtils.encryptStrAES(userParam.getUserPhone(), key); |
| | | } |
| | | updUser.setUserPhone(encPhone); |
| | | // 1.更新系统用户 FIN_SYS_TENANT_USER |
| | |
| | | * @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(); |