diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java index b82c6e4..c47ead3 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java @@ -182,5 +182,13 @@ public interface IApiConsts { * 获取所在部门用户列表(通过职位ID列表) */ String LIST_USER_DEPARTMENT_RESOURCE_BY_POSITION_IDS = "%s/resource/user/listuserdepartmentresourcebypositionids"; + /** + * 组织部门人员分页列表 + */ + String LIST_SELECT_DEPARTMENT_USER = "%s/resource/user/listselectdepartmentuser/%s"; + /** + * 通过id列表获取用户ID + */ + String LIST_PAGE_SELECT_DEPARTMENT_USER = "%s/resource/user/listpageselectdepartmentuser/%s"; } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/user/UserController.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/user/UserController.java index 0e21b82..177dc76 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/user/UserController.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/user/UserController.java @@ -11,13 +11,16 @@ import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.plugin.oauth.service.user.IUserService; import com.cm.common.plugin.pojo.bos.UserResourceBO; +import com.cm.common.pojo.ListPage; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -87,18 +90,6 @@ public class UserController extends AbstractController { return userService.listPositionUsers(params); } - @ApiOperation(value = "通过用户ID获取用户列表", notes = "通过用户ID获取用户列表接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "userIds", value = "用不ID列表", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listuserbyids/{userIds}") - public JSONArray listUserByIds(@PathVariable("userIds") String userIds) throws AccessTokenException, SearchException { - Map params = getParams(); - params.put("userIds", userIds); - return userService.listUserByIds(params); - } - @ApiOperation(value = "全部用户列表", notes = "全部用户列表接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listallusers") @@ -189,4 +180,47 @@ public class UserController extends AbstractController { return userService.listPageUserSimple(params); } + @ApiOperation(value = "组织部门人员列表", notes = "组织部门人员列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listselectdepartmentuser/{departmentId}") + public JSONArray listSelectDepartmentUser(@PathVariable("departmentId") String departmentId) throws SearchException { + return userService.listSelectDepartmentUser(departmentId); + } + + @ApiOperation(value = "组织部门人员分页列表", notes = "组织部门人员分页列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "path"), + @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("listpageselectdepartmentuser/{departmentId}") + public JSONObject listPageSelectDepartmentUser(@PathVariable("departmentId") String departmentId, ListPage page) throws SearchException { + Map params = requestParams(); + page.setParams(params); + return userService.listPageSelectDepartmentUserByDepartmentId(departmentId, page); + } + + @ApiOperation(value = "通过ID列表获取用户列表", notes = "通过ID列表获取用户列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userIds", value = "用户ID列表,用下划线分隔,如:1_2_3", paramType = "body") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("listuserbyids") + public JSONArray listUserByIds(@RequestBody Map params) throws SearchException, ParamsException { + if (params.get("selectedUserIds") == null || StringUtils.isBlank(params.get("selectedUserIds").toString())) { + throw new ParamsException("用户列表不能为空"); + } + params.put("userIds", params.get("selectedUserIds")); + params.remove("selectedUserIds"); + return userService.listUserByIds(params); + } + } \ No newline at end of file diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java index 46b446d..fb8488c 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/IUserService.java @@ -6,6 +6,7 @@ import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.SearchException; import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO; +import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import org.aspectj.lang.annotation.DeclareError; @@ -68,17 +69,6 @@ public interface IUserService { @Deprecated JSONArray listPositionUsers(Map params) throws AccessTokenException, SearchException; - /** - * 通过id列表获取用户ID - * - * @param params - * @return - * @throws AccessTokenException - * @throws SearchException - */ - @Deprecated - JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException; - /** * 全部用户 * @@ -331,4 +321,32 @@ public interface IUserService { */ List listUserDepartmentResourceByPositionIds(List positionIds) throws SearchException; + /** + * 获取选择的部门用户(插件用) + * + * @param params + * @return + * @throws SearchException + */ + JSONArray listSelectDepartmentUser(String departmentId) throws AccessTokenException, SearchException; + + /** + * 组织部门人员分页列表(插件用) + * + * @param departmentId + * @param page + * @return + * @throws SearchException + */ + JSONObject listPageSelectDepartmentUserByDepartmentId(String departmentId, ListPage page) throws AccessTokenException, SearchException; + + /** + * 通过id列表获取用户ID(插件用) + * + * @param params + * @return + * @throws AccessTokenException + * @throws SearchException + */ + JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException; } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java index 80af27c..ff149db 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/service/user/impl/UserServiceImpl.java @@ -13,6 +13,7 @@ import com.cm.common.plugin.oauth.token.ClientTokenManager; import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO; import com.cm.common.plugin.utils.RestTemplateUtil; +import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultList; import org.apache.commons.lang3.StringUtils; @@ -71,13 +72,6 @@ public class UserServiceImpl extends AbstractService implements IUserService { return JSONArray.parseArray(result); } - @Override - public JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException { - String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params); - searchResourceResult(result, "获取人员列表失败"); - return JSONArray.parseArray(result); - } - @Override public JSONArray listAllUsers(Map params) throws AccessTokenException, SearchException { String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_ALL_USER, apiPathProperties.getUserCenter()), params); @@ -380,4 +374,29 @@ public class UserServiceImpl extends AbstractService implements IUserService { searchResourceResult(result, "获取人员信息失败"); return JSONArray.parseArray(result, UserDepartmentResourceBO.class); } + + @Override + public JSONArray listSelectDepartmentUser(String departmentId) throws SearchException { + Map params = getHashMap(2); + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_SELECT_DEPARTMENT_USER, apiPathProperties.getUserCenter(), departmentId), params); + searchResourceResult(result, "获取组织部门人员列表失败"); + return JSONArray.parseArray(result); + } + + @Override + public JSONObject listPageSelectDepartmentUserByDepartmentId(String departmentId, ListPage page) throws SearchException { + page.getParams().put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_PAGE_SELECT_DEPARTMENT_USER, apiPathProperties.getUserCenter(), departmentId), page.getParams()); + searchResourceResult(result, "获取组织部门人员分页列表失败"); + return JSONObject.parseObject(result); + } + + @Override + public JSONArray listUserByIds(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doPostFormNormal(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取人员列表失败"); + return JSONArray.parseArray(result); + } } diff --git a/cloud-common-plugin-oauth/src/main/resources/templates/user/select-department-user.html b/cloud-common-plugin-oauth/src/main/resources/templates/user/select-department-user.html index eaedeee..9b77e11 100644 --- a/cloud-common-plugin-oauth/src/main/resources/templates/user/select-department-user.html +++ b/cloud-common-plugin-oauth/src/main/resources/templates/user/select-department-user.html @@ -1,193 +1,337 @@ - - - - - - - - - - - - - - -
-
-
-
-
-
-
    + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    -
    -
    -