| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD; |
| | |
| | | // throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | // } |
| | | boolean b = save(user) && submitUserDept(user); |
| | | String rtime = null; |
| | | if (null != user.getRtime()) { |
| | | rtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getRtime()); |
| | | } |
| | | user.setIsDeleted(0); |
| | | String s = "insert into blade_user(id,tenant_id,account,password,real_name,email,phone,sex,role_id,dept_id,cardid,nativePlace,nation," + |
| | | "politicaloutlook,healstats,height,address,registered,securitynumber,hold,status,dispatch) " + |
| | | "values(" + "'" + user.getId() + "'" + "," + "'" + user.getTenantId() + "'" + "," + "'" + user.getAccount() + "'" + "," + |
| | |
| | | public IPage<UserVO> selectUserPage(IPage<UserVO> page, User user, Long deptId, String tenantId) { |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | List<UserVO> users = baseMapper.selectUserPage(page, user, deptIdList, tenantId); |
| | | //遍历获取部门名称,角色名称 |
| | | users.forEach(userVO -> { |
| | | //查询当前部门名称及父级部门名称 |
| | | List<String> list = baseMapper.getDeptName(userVO.getDeptId()); |
| | | if (list.size()>1){ |
| | | if (null!=list.get(1) && list.get(1)!=""){ |
| | | userVO.setDeptName(list.get(1)+","+list.get(0)); |
| | | }else { |
| | | userVO.setDeptName(list.get(0)); |
| | | if(users.size()>0){ |
| | | //遍历获取部门名称,角色名称 |
| | | users.forEach(userVO -> { |
| | | //查询当前部门名称及父级部门名称 |
| | | if (null!=userVO.getDeptId()) { |
| | | List<String> list = baseMapper.getDeptName(userVO.getDeptId()); |
| | | if (list.size() > 1) { |
| | | if (null != list.get(1) && list.get(1) != "") { |
| | | userVO.setDeptName(list.get(1) + "," + list.get(0)); |
| | | } else { |
| | | userVO.setDeptName(list.get(0)); |
| | | } |
| | | } |
| | | if (list.size() == 1) { |
| | | userVO.setDeptName(list.get(0)); |
| | | } |
| | | } |
| | | } |
| | | if (list.size()==1){ |
| | | userVO.setDeptName(list.get(0)); |
| | | } |
| | | //查询角色名称 |
| | | List<String> asList = Arrays.asList(userVO.getRoleId().split(",")); |
| | | StringBuilder builder = new StringBuilder(); |
| | | asList.forEach(roleIs ->{ |
| | | Role role = roleService.getById(roleIs); |
| | | if (null!=role){ |
| | | builder.append(role.getRoleName()+","); |
| | | //查询角色名称 |
| | | if (null!=userVO.getRoleId()) { |
| | | List<String> asList = Arrays.asList(userVO.getRoleId().split(",")); |
| | | StringBuilder builder = new StringBuilder(); |
| | | asList.forEach(roleIs -> { |
| | | Role role = roleService.getById(roleIs); |
| | | if (null != role) { |
| | | builder.append(role.getRoleName() + ","); |
| | | } |
| | | }); |
| | | String substringRoleName = null; |
| | | if (builder.toString().length() > 0) { |
| | | substringRoleName = builder.toString().substring(0, builder.toString().length() - 1); |
| | | } |
| | | userVO.setRoleName(substringRoleName); |
| | | } |
| | | }); |
| | | String substringRoleName = builder.toString().substring(0, builder.toString().length() - 1); |
| | | userVO.setRoleName(substringRoleName); |
| | | }); |
| | | } |
| | | return page.setRecords(users); |
| | | } |
| | | |