From 88b84c4e4069f19b07f827d0347c323ca85221b8 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Wed, 12 Apr 2023 09:55:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/userexpand/UserExpandController.java | 2 ++ .../UserExpandResourceController.java | 18 ++++++++++++++++++ .../service/userexpand/IUserExpandService.java | 12 ++++++++++++ .../userexpand/impl/UserExpandServiceImpl.java | 18 ++++++++++++++++++ .../mapper/user-expand/user-expand-mapper.xml | 6 ++++++ 5 files changed, 56 insertions(+) diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/api/userexpand/UserExpandController.java b/src/main/java/cn/com/tenlion/usercenter/controller/api/userexpand/UserExpandController.java index c0fd3d2..4a27c1b 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/api/userexpand/UserExpandController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/api/userexpand/UserExpandController.java @@ -12,6 +12,8 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * @ClassName: UserExpandController * @Description: 用户拓展 diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java b/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java index 00587eb..78d1338 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java @@ -9,14 +9,17 @@ import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.exceptions.ParamsException; import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.ErrorResult; import ink.wgink.pojo.result.SuccessResult; +import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.vos.IdsVO; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Map; /** * @ClassName: UserExpandController @@ -87,4 +90,19 @@ public class UserExpandResourceController extends DefaultBaseController { return userExpandService.listWholeByRoleIdAndAreaCode(roleId, areaCode); } + @ApiOperation(value = "通过角色和区域编码获取拓展属性完整分页列表", notes = "通过角色和区域编码获取拓展属性完整分页列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", required = true), + @ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path", required = true) + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listpage/role-id/{roleId}/area-code/{areaCode}") + public SuccessResultList> listPageByRoleIdAndAreaCode(@PathVariable("roleId") String roleId, + @PathVariable("areaCode") String areaCode, + ListPage page) { + Map params = requestParams(); + page.setParams(params); + return userExpandService.listPageByRoleIdAndAreaCode(roleId, areaCode, page); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java index 64c8d21..5155b94 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java @@ -7,7 +7,9 @@ import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.GridUserAuthBindVO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import ink.wgink.interfaces.user.IUserExpandBaseService; +import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultList; import java.util.List; @@ -94,4 +96,14 @@ public interface IUserExpandService extends IUserExpandBaseService> listPageByRoleIdAndAreaCode(String roleId, String areaCode, ListPage page); } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java index fd313ca..5732489 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java @@ -12,6 +12,8 @@ import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.GridUserAuthBindVO; import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.exceptions.ParamsException; import ink.wgink.exceptions.SearchException; @@ -46,6 +48,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @ClassName: UserExpandServiceImpl @@ -408,6 +411,21 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx return gridUserAuthBindDTO; } + @Override + public SuccessResultList> listPageByRoleIdAndAreaCode(String roleId, String areaCode, ListPage page) { + page.getParams().put("roleId", roleId); + page.getParams().put("areaCode", areaCode); + PageHelper.startPage(page.getPage(), page.getRows()); + List userExpandDTOS = userExpandDao.list(page.getParams()); + if(userExpandDTOS.size() > 0) { + List userIds = userExpandDTOS.stream().map(UserExpandDTO::getUserId).collect(Collectors.toList()); + List userDTOs = userService.listByUserIds(userIds); + setUser(userDTOs, userExpandDTOS); + } + PageInfo pageInfo = new PageInfo<>(userExpandDTOS); + return new SuccessResultList<>(userExpandDTOS, pageInfo.getPageNum(), pageInfo.getTotal()); + } + /** * 设置用户 * diff --git a/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml b/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml index 8447011..05d5e22 100644 --- a/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml +++ b/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml @@ -307,6 +307,12 @@ #{userIds[${index}]} + + AND + EXISTS (SELECT 1 FROM sys_role_user st1 WHERE t1.user_id = st1.user_id AND st1.role_id = #{roleId}) + + AND + EXISTS (SELECT 1 FROM sys_user st1 WHERE t1.user_id = st1.user_id)