| | |
| | | package com.consum.base.controller; |
| | | |
| | | 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.BaseController; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.pojo.FinSysTenantUserSearchParam; |
| | | import com.consum.base.pojo.FinSysTenantUserUpdParam; |
| | | 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.infrastructure.utils.PhoneNumberUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | 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; |
| | |
| | | * @Author wh |
| | | * @Date 2023/7/17 14:16 |
| | | */ |
| | | @Api(value = "机构用户信息", tags = "机构用户信息") |
| | | @RestController |
| | | @RequestMapping("/pc/fin/sys/tenant/user") |
| | | public class FinSysTenantUserController extends BaseController { |
| | |
| | | |
| | | private UserServiceImpl userService; |
| | | |
| | | private DeptServiceImpl deptService; |
| | | |
| | | private FinSysTenantServiceImpl finSysTenantService; |
| | | |
| | | private RoleServiceImpl roleService; |
| | | |
| | | @Autowired |
| | | private FinSysTenantDepartmentServiceImpl finSysTenantDepartmentService; |
| | | private FinSysTenantDepartmentService finSysTenantDepartmentService; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | this.userService = userService; |
| | | } |
| | | |
| | | private S_config sConfig; |
| | | |
| | | @Autowired |
| | | public FinSysTenantUserController(FinSysTenantServiceImpl finSysTenantService, FinSysTenantUserServiceImpl finSysTenantUserService, |
| | |
| | | |
| | | 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(); |
| | | } |
| | | return ResponseValue.success(pager); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "根据机构id查询用户", notes = "根据机构id查询用户") |
| | | @ApiImplicitParam(name = "tenantId", value = "机构id", required = true, dataType = "Long", paramType = "query") |
| | | @GetMapping("/query/user") |
| | | public ResponseValue queryUserByTenantId(Long tenantId) { |
| | | |
| | | FinSysTenantUser finSysTenantUser = new FinSysTenantUser(); |
| | | finSysTenantUser.setTenantId(String.valueOf(tenantId)); |
| | | List<FinSysTenantUser> result = finSysTenantUserService.select(finSysTenantUser); |
| | | return ResponseValue.success(result); |
| | | } |
| | | |
| | | |
| | |
| | | user.setSysUserId(NumberGenerator.getLongSequenceNumber()); |
| | | // 加密手机号 |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String pwdPhone = ""; |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | pwdPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | } |
| | | user.setUserPhone(pwdPhone); |
| | | user.setUserPhone(encPhone); |
| | | //怎么获取左侧机构树数据 |
| | | user.setSysDeptId(3L); //对应平台机构id 默认为平台管理 |
| | | this.finSysTenantUserService.insert(user); |
| | |
| | | userCore.setNick_name(user.getUserName()); |
| | | //用户类型 先默认设置为2 |
| | | userCore.setUser_type(2); |
| | | userCore.setPhonenumber(pwdPhone); |
| | | userCore.setPhonenumber(encPhone); |
| | | userCore.setSex(user.getSex().toString()); |
| | | //初始化密码 123456 |
| | | String pws = this.getArgumentVariable(ArgumentsConstants.KEY_SECURITY_PASSWORD_INIT).getStringValue(); |
| | |
| | | user.setRemark("批量导入"); |
| | | // 加密手机号 |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String pwdPhone = AESUtils.encryptStrAES(data.getUserPhone(), key); |
| | | user.setUserPhone(pwdPhone); |
| | | String encPhone = AESUtils.encryptStrAES(data.getUserPhone(), key); |
| | | user.setUserPhone(encPhone); |
| | | |
| | | user.setIsDelete(1); |
| | | //怎么获取左侧机构树数据 |
| | |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String pwdPhone = ""; |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | pwdPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | } |
| | | user.setUserPhone(pwdPhone); |
| | | user.setUserPhone(encPhone); |
| | | // 1.更新系统用户 FIN_SYS_TENANT_USER |
| | | finSysTenantUserService.update(user); |
| | | // 2.更新平台用户 S_USER_CORE |
| | |
| | | // 加密手机号 |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | String userPhone = user.getUserPhone(); |
| | | String pwdPhone = ""; |
| | | String encPhone = ""; |
| | | if (userPhone != null) { |
| | | pwdPhone = AESUtils.encryptStrAES(userPhone, key); |
| | | user.setUserPhone(pwdPhone); |
| | | encPhone = AESUtils.encryptStrAES(userPhone, key); |
| | | user.setUserPhone(encPhone); |
| | | } |
| | | |
| | | this.finSysTenantUserService.insert(user); |
| | |
| | | updUser.setEmail(user.getEmail()); |
| | | updUser.setUserName(user.getUserName()); |
| | | updUser.setSex(user.getSex()); |
| | | String pwdPhone = ""; |
| | | String encPhone = ""; |
| | | if (user.getUserPhone() != null) { |
| | | String key = PlatformRSAUtils.AES_KEY; |
| | | pwdPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | encPhone = AESUtils.encryptStrAES(user.getUserPhone(), key); |
| | | } |
| | | updUser.setUserPhone(pwdPhone); |
| | | updUser.setUserPhone(encPhone); |
| | | // 1.更新系统用户 FIN_SYS_TENANT_USER |
| | | finSysTenantUserService.update(updUser); |
| | | // 2.更新平台用户 S_USER_CORE |
| | |
| | | departmentVO.setId(id); |
| | | departmentVO.setName(department.getName()); |
| | | departmentVO.setType("department"); |
| | | FinSysTenantUser finSysTenantUser = new FinSysTenantUser(); |
| | | finSysTenantUser.setSysDeptId(id); |
| | | List<FinSysTenantUser> tenantUserList = finSysTenantUserService.select(finSysTenantUser); |
| | | |
| | | 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); |
| | | List<Map<String, Object>> select = finSysTenantUserService.select(sql, param, new MapperUtil()); |
| | | List<UserVO> userVOList = Lists.newArrayList(); |
| | | tenantUserList.forEach(user -> { |
| | | select.forEach(user -> { |
| | | UserVO userVO = new UserVO(); |
| | | userVO.setId(user.getId()); |
| | | userVO.setName(user.getUserName()); |
| | | userVO.setId((Long) user.get("sysUserId")); |
| | | userVO.setName(user.get("userName").toString()); |
| | | userVO.setType("user"); |
| | | userVOList.add(userVO); |
| | | }); |