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 77c5010..8f6b05d 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 @@ -138,4 +138,8 @@ public interface IApiConsts { * 获取用户ID列表(通过上级区域ID) */ String LIST_USER_ID_BY_AREA_ID = "%s/resource/user/listuseridbyareaid"; + /** + * 用户列表(简单格式) + */ + String LIST_PAGE_USER_SIMPLE = "%s/resource/user/listpageusersimple"; } 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 54c8c79..0e21b82 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 @@ -10,8 +10,10 @@ import com.cm.common.exception.ParamsException; 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.result.ErrorResult; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultList; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -174,4 +176,17 @@ public class UserController extends AbstractController { return userService.listDepartmentUserByUserDepartmentId(params); } + @ApiOperation(value = "用户列表(简单格式)", notes = "用户列表(简单格式)接口") + @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") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listpageusersimple") + public SuccessResultList> listPageUserSimple() { + Map params = requestParams(); + return userService.listPageUserSimple(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 1f4b91a..3cf26f6 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.result.SuccessResult; +import com.cm.common.result.SuccessResultList; import java.util.List; import java.util.Map; @@ -210,4 +211,13 @@ public interface IUserService { */ List listUserIdByAreaId(Map params) throws AccessTokenException, SearchException; + /** + * 用户列表(简单格式) + * + * @param params + * @return + * @throws AccessTokenException + * @throws SearchException + */ + SuccessResultList> listPageUserSimple(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 5dc26ed..c2b8abe 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.utils.RestTemplateUtil; import com.cm.common.result.SuccessResult; +import com.cm.common.result.SuccessResultList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -181,4 +182,17 @@ public class UserServiceImpl extends AbstractService implements IUserService { return JSONArray.parseArray(result, String.class); } + @Override + public SuccessResultList> listPageUserSimple(Map params) throws AccessTokenException, SearchException { + params.put(IApiConsts.ACCESS_TOKEN, ClientTokenManager.getInstance().getClientToken().getAccessToken()); + String result = restTemplateUtil.doGetFormNormal(String.format(IApiConsts.LIST_PAGE_USER_SIMPLE, apiPathProperties.getUserCenter()), params); + searchResourceResult(result, "获取用户列表(简单格式)失败"); + JSONObject resultObj = JSONObject.parseObject(result); + SuccessResultList> successResult = new SuccessResultList<>(); + successResult.setPage(resultObj.getInteger("page")); + successResult.setTotal(resultObj.getLong("total")); + successResult.setRows(resultObj.getJSONArray("rows").toJavaList(UserResourceBO.class)); + return successResult; + } + } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java index 00da273..6d60d8b 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/pojo/bos/UserResourceBO.java @@ -25,6 +25,10 @@ public class UserResourceBO implements Serializable { this.userId = userId; } + public String getUserId() { + return userId == null ? "" : userId.trim(); + } + public String getUserUsername() { return userUsername == null ? "" : userUsername.trim(); }