diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java index 2c5ae51..2fbc3e5 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java @@ -1,12 +1,15 @@ package com.hxhq.system.controller; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; +import com.hxhq.business.enums.dept.DeptTypeEnum; +import com.hxhq.system.dto.UserExportDto; import com.hxhq.system.service.ISysConfigService; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -101,8 +104,26 @@ public class SysUserController extends BaseController public void export(HttpServletResponse response, SysUser user) { List list = userService.selectUserList(user); - ExcelUtil util = new ExcelUtil(SysUser.class); - util.exportExcel(response, list, "用户数据"); + List userList = new ArrayList<>(); + for(SysUser u : list){ + UserExportDto exportDto = new UserExportDto(); + exportDto.setUserName(u.getUserName()); + exportDto.setNickName(u.getNickName()); + exportDto.setPhonenumber(u.getPhonenumber()); + exportDto.setDeptName(u.getDept()==null?"":u.getDept().getDeptName()); + exportDto.setRoleName(getRoleName(u.getRoles())); + exportDto.setStatus(u.getStatus()); + userList.add(exportDto); + } + ExcelUtil util = new ExcelUtil(UserExportDto.class); + util.exportExcel(response, userList, "用户数据"); + } + + private String getRoleName(List roleList){ + if(roleList==null || roleList.size()==0){ + return ""; + } + return String.join(",",roleList.stream().map(o->o.getRoleName()).toArray(String[]::new)); } @Log(title = "用户管理", businessType = BusinessType.IMPORT) @@ -282,6 +303,10 @@ public class SysUserController extends BaseController { return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } + SysDept sysDept = deptService.selectDeptById(user.getDeptId()); + if(!sysDept.getType().equals(DeptTypeEnum.subject.getValue()) && !sysDept.getType().equals(DeptTypeEnum.team.getValue())){ + return error("新增用户'" + user.getUserName() + "'失败,部门必须选到学科或者小组"); + } user.setCreateBy(SecurityUtils.getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); return toAjax(userService.insertUser(user)); @@ -311,6 +336,10 @@ public class SysUserController extends BaseController { return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); } + SysDept sysDept = deptService.selectDeptById(user.getDeptId()); + if(!sysDept.getType().equals(DeptTypeEnum.subject.getValue()) && !sysDept.getType().equals(DeptTypeEnum.team.getValue())){ + return error("修改用户'" + user.getUserName() + "'失败,部门必须选到学科或者小组"); + } user.setUpdateBy(SecurityUtils.getUsername()); return toAjax(userService.updateUser(user)); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java new file mode 100644 index 0000000..1bc79ca --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java @@ -0,0 +1,87 @@ +package com.hxhq.system.dto; + +import com.hxhq.common.core.annotation.Excel; + +/** + * @author memory + */ +public class UserExportDto { + /** + * 账号 + */ + @Excel(name = "账号") + private String userName; + /** + * 姓名 + */ + @Excel(name = "姓名") + private String nickName; + /** + * 手机 + */ + @Excel(name = "手机") + private String phonenumber; + /** + * 所属部门/学科 + */ + @Excel(name = "所属部门/学科") + private String deptName; + /** + * 所属角色 + */ + @Excel(name = "所属角色") + private String roleName; + /** + * 状态 + */ + @Excel(name = "状态", readConverterExp = "0=启用,1=禁用") + private String status; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getPhonenumber() { + return phonenumber; + } + + public void setPhonenumber(String phonenumber) { + this.phonenumber = phonenumber; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java index 99a9fc2..241235a 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysDeptServiceImpl.java @@ -43,7 +43,7 @@ public class SysDeptServiceImpl implements ISysDeptService * @return 部门信息集合 */ @Override - @DataScope(deptAlias = "d") +// @DataScope(deptAlias = "d") public List selectDeptList(SysDept dept) { return deptMapper.selectDeptList(dept); @@ -58,7 +58,7 @@ public class SysDeptServiceImpl implements ISysDeptService @Override public List selectDeptTreeList(SysDept dept) { - List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + List depts = deptMapper.selectDeptList(dept); return buildDeptTreeSelect(depts); } @@ -195,7 +195,7 @@ public class SysDeptServiceImpl implements ISysDeptService { SysDept dept = new SysDept(); dept.setDeptId(deptId); - List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + List depts = deptMapper.selectDeptList(dept); if (StringUtils.isEmpty(depts)) { throw new ServiceException("没有权限访问部门数据!"); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java index cce1fd8..a8850b0 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java @@ -53,7 +53,7 @@ public class SysRoleServiceImpl implements ISysRoleService * @return 角色数据集合信息 */ @Override - @DataScope(deptAlias = "d") +// @DataScope(deptAlias = "d") public List selectRoleList(SysRole role) { return roleMapper.selectRoleList(role); @@ -113,7 +113,7 @@ public class SysRoleServiceImpl implements ISysRoleService @Override public List selectRoleAll() { - return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); + return roleMapper.selectRoleList(new SysRole()); } /** @@ -204,7 +204,7 @@ public class SysRoleServiceImpl implements ISysRoleService { SysRole role = new SysRole(); role.setRoleId(roleId); - List roles = SpringUtils.getAopProxy(this).selectRoleList(role); + List roles = roleMapper.selectRoleList(role); if (StringUtils.isEmpty(roles)) { throw new ServiceException("没有权限访问角色数据!"); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java index 10481ed..5539ca4 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java @@ -75,7 +75,7 @@ public class SysUserServiceImpl implements ISysUserService * @return 用户信息集合信息 */ @Override - @DataScope(deptAlias = "d", userAlias = "u") +// @DataScope(deptAlias = "d", userAlias = "u") public List selectUserList(SysUser user) { return userMapper.selectUserList(user); @@ -88,7 +88,7 @@ public class SysUserServiceImpl implements ISysUserService * @return 用户信息集合信息 */ @Override - @DataScope(deptAlias = "d", userAlias = "u") +// @DataScope(deptAlias = "d", userAlias = "u") public List selectAllocatedList(SysUser user) { return userMapper.selectAllocatedList(user); @@ -101,7 +101,7 @@ public class SysUserServiceImpl implements ISysUserService * @return 用户信息集合信息 */ @Override - @DataScope(deptAlias = "d", userAlias = "u") +// @DataScope(deptAlias = "d", userAlias = "u") public List selectUnallocatedList(SysUser user) { return userMapper.selectUnallocatedList(user); @@ -245,7 +245,7 @@ public class SysUserServiceImpl implements ISysUserService { SysUser user = new SysUser(); user.setUserId(userId); - List users = SpringUtils.getAopProxy(this).selectUserList(user); + List users = userMapper.selectUserList(user); if (StringUtils.isEmpty(users)) { throw new ServiceException("没有权限访问用户数据!"); diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml index b8529a1..e0cb99a 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND status = #{status} - ${params.dataScope} +-- ${params.dataScope} order by d.parent_id, d.order_num diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml index 839c008..adfbd20 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date_format(r.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') - ${params.dataScope} +-- ${params.dataScope} order by r.role_id desc diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml index a8b3c7c..03e0b2a 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -58,15 +58,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"