|
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
@@ -1629,4 +1630,114 @@ public class SysUserController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户列表数据
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="用户管理(运营)", notes="用户管理(运营)")
|
|
|
+ @RequestMapping(value = "/listV2", method = RequestMethod.GET)
|
|
|
+ public Result<Object> queryPageListV2(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ String userId = user.getId();
|
|
|
+ String roleCode = roleService.getRoleCodeByUserId(userId);
|
|
|
+ if (Check.isNull(roleCode)){
|
|
|
+ return Result.errorMsg("请输入正确的用户id。");
|
|
|
+ }
|
|
|
+ //角色为 管理员并且projectId是空表示:全量查询
|
|
|
+
|
|
|
+ if (!"admin".equals(roleCode)) {
|
|
|
+ List<SysUser> list = sysUserService.queryPageList(user);
|
|
|
+ //1.根据搜索框过滤数据
|
|
|
+ if(!Check.isNull(user.getUsername())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getUsername().contains(user.getUsername())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getRealname())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getRealname().contains(user.getRealname())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getLeaderName())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getLeaderName().contains(user.getLeaderName())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getRoleName())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getRoleName().contains(user.getRoleName())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getDepartId())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ SysUser user2 = it.next();
|
|
|
+ if(Check.isNull(user2.getDepartId2()) || !user2.getDepartId2().equals(user.getDepartId())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getEmail())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getEmail().contains(user.getEmail())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(user.getStatus())){
|
|
|
+ Iterator<SysUser> it = list.iterator();
|
|
|
+ while(it.hasNext()){
|
|
|
+ if(!it.next().getStatus().equals(user.getStatus())) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2.根据分页页数和条数来筛选数据
|
|
|
+ int total = list.size();
|
|
|
+ int beginIndex = (pageNo - 1) * pageSize + 1;
|
|
|
+ int endIndex = beginIndex + pageSize;
|
|
|
+ if(list.size() > beginIndex){
|
|
|
+ list = list.subList(beginIndex-1,list.size() > endIndex ? endIndex : list.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ PageInfo<SysUser> pageInfo = new PageInfo<>(list);
|
|
|
+ pageInfo.setTotal(total);
|
|
|
+ return Result.ok(pageInfo);
|
|
|
+ }else{
|
|
|
+ user.setId(null);
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
+ List<SysUser> list = sysUserService.queryAdminPageList(user);
|
|
|
+ PageInfo<SysUser> pageInfo = new PageInfo<>(list);
|
|
|
+ return Result.ok(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取用户列表数据-分页列表查询异常", e);
|
|
|
+ }
|
|
|
+ return Result.error("查询失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|