diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/resource/teammember/TeamMemberResourceController.java b/src/main/java/cn/com/tenlion/usercenter/controller/resource/teammember/TeamMemberResourceController.java index d8fd3b1..be2ad10 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/resource/teammember/TeamMemberResourceController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/resource/teammember/TeamMemberResourceController.java @@ -3,11 +3,13 @@ package cn.com.tenlion.usercenter.controller.resource.teammember; import cn.com.tenlion.usercenter.pojo.dtos.teammember.TeamMemberDTO; import cn.com.tenlion.usercenter.service.teammember.ITeamMemberService; 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.SuccessResultData; 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.*; @@ -32,8 +34,8 @@ public class TeamMemberResourceController extends DefaultBaseController { @ApiOperation(value = "队伍人员详情", notes = "队伍人员详情接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "teamMemberId", value = "队伍人员ID", paramType = "path") + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @ApiImplicitParam(name = "teamMemberId", value = "队伍人员ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get/{teamMemberId}") @@ -43,7 +45,7 @@ public class TeamMemberResourceController extends DefaultBaseController { @ApiOperation(value = "队伍人员列表", notes = "队伍人员列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("list") @@ -54,12 +56,12 @@ public class TeamMemberResourceController extends DefaultBaseController { @ApiOperation(value = "队伍人员分页列表", notes = "队伍人员分页列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), - @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), + @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpage") @@ -196,4 +198,42 @@ public class TeamMemberResourceController extends DefaultBaseController { return teamMemberService.listPageSubByAreaCodeAndSort(areaCode, sort, page); } + @ApiOperation(value = "队伍人员列表(通过部门ID列表)", notes = "队伍人员列表(通过部门ID列表)接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("list/department-ids") + public List listByDepartmentIds(@RequestBody IdsVO idsVO) { + if (idsVO.getIds().isEmpty()) { + throw new ParamsException("id列表不能为空"); + } + return teamMemberService.listByDepartmentIds(idsVO.getIds()); + } + + @ApiOperation(value = "获取队伍人员分页列表(通过部门ID列表)", notes = "获取队伍人员分页列表(通过部门ID列表)接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), + @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("listpage/department-ids") + public SuccessResultList> listPageByDepartmentIds(ListPage page, @RequestBody IdsVO idsVO) { + if (idsVO.getIds().isEmpty()) { + throw new ParamsException("id列表不能为空"); + } + Map params = requestParams(); + page.setParams(params); + return teamMemberService.listPageByDepartmentIds(page, idsVO.getIds()); + } + + @ApiOperation(value = "队伍人员统计(通过部门ID列表)", notes = "队伍人员统计(通过部门ID列表)接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("count/department-ids") + public SuccessResultData countByDepartmentIds(@RequestBody IdsVO idsVO) { + if (idsVO.getIds().isEmpty()) { + throw new ParamsException("id列表不能为空"); + } + return teamMemberService.countByDepartmentIds(idsVO.getIds()); + } } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/service/teammember/ITeamMemberService.java b/src/main/java/cn/com/tenlion/usercenter/service/teammember/ITeamMemberService.java index 9155a9d..de57ebf 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/teammember/ITeamMemberService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/teammember/ITeamMemberService.java @@ -1,6 +1,7 @@ package cn.com.tenlion.usercenter.service.teammember; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import cn.com.tenlion.usercenter.pojo.dtos.teammember.TeamMemberDTO; import cn.com.tenlion.usercenter.pojo.vos.teammember.TeamMemberVO; @@ -303,4 +304,28 @@ public interface ITeamMemberService { */ SuccessResultList> listPageSubByAreaCodeAndSort(String areaCode, String sort, ListPage page); + /** + * 队伍人员列表(通过部门ID列表) + * + * @param departmentIds 部门ID列表 + * @return + */ + List listByDepartmentIds(List departmentIds); + + /** + * 获取队伍人员分页列表(通过部门ID列表) + * + * @param page + * @param departmentIds 部门ID列表 + * @return + */ + SuccessResultList> listPageByDepartmentIds(ListPage page, List departmentIds); + + /** + * 队伍人员统计(通过部门ID列表) + * + * @param departmentIds + * @return + */ + SuccessResultData countByDepartmentIds(List departmentIds); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/service/teammember/impl/TeamMemberServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/teammember/impl/TeamMemberServiceImpl.java index de639e8..d343d3c 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/teammember/impl/TeamMemberServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/teammember/impl/TeamMemberServiceImpl.java @@ -14,7 +14,9 @@ import ink.wgink.interfaces.role.IRoleUserBaseService; import ink.wgink.interfaces.user.IUserBaseService; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.department.service.IDepartmentUserService; import ink.wgink.util.UUIDUtil; import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.string.WStringUtil; @@ -40,6 +42,8 @@ public class TeamMemberServiceImpl extends DefaultBaseService implements ITeamMe private IUserBaseService userBaseService; @Autowired private IRoleUserBaseService roleUserBaseService; + @Autowired + private IDepartmentUserService departmentUserService; @Override public void save(TeamMemberVO teamMemberVO) { @@ -297,6 +301,38 @@ public class TeamMemberServiceImpl extends DefaultBaseService implements ITeamMe return listPage(page); } + @Override + public List listByDepartmentIds(List departmentIds) { + List userIds = departmentUserService.listUserId(departmentIds); + if (userIds.isEmpty()) { + return new ArrayList<>(); + } + Map params = getHashMap(2); + params.put("userIds", userIds); + return list(params); + } + + @Override + public SuccessResultList> listPageByDepartmentIds(ListPage page, List departmentIds) { + List userIds = departmentUserService.listUserId(departmentIds); + if (userIds.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), 1, 0L); + } + page.getParams().put("userIds", userIds); + return listPage(page); + } + + @Override + public SuccessResultData countByDepartmentIds(List departmentIds) { + List userIds = departmentUserService.listUserId(departmentIds); + if (userIds.isEmpty()) { + return new SuccessResultData<>(0); + } + Map params = getHashMap(2); + params.put("userIds", userIds); + return new SuccessResultData<>(count(params)); + } + /** * 设置用户 * diff --git a/src/main/resources/mybatis/mapper/teammember/team-member-mapper.xml b/src/main/resources/mybatis/mapper/teammember/team-member-mapper.xml index a9c3c18..e7302e3 100644 --- a/src/main/resources/mybatis/mapper/teammember/team-member-mapper.xml +++ b/src/main/resources/mybatis/mapper/teammember/team-member-mapper.xml @@ -370,9 +370,16 @@ FROM city_team_member t1 - + t1.area_code = #{areaCode} - + + + AND + t1.user_id IN + + #{userIds[${index}]} + +