【7.1.6】【scanner】【user】优化user模块的接口描述,ApiResource注解去掉以往的responseClass属性

pull/25/MERGE
fengshuonan 2022-01-15 23:57:58 +08:00
parent e2eb5ced1c
commit 850ac50a9a
24 changed files with 187 additions and 204 deletions

View File

@ -90,16 +90,6 @@ public @interface ApiResource {
*/
boolean viewFlag() default false;
/**
* api
*/
Class<?> responseClass() default Void.class;
/**
* api
*/
Class<?> responseGenericClass() default Void.class;
/**
* (RequestMapping)
*/

View File

@ -85,16 +85,6 @@ public @interface GetResource {
*/
boolean viewFlag() default false;
/**
* api
*/
Class<?> responseClass() default Void.class;
/**
* api
*/
Class<?> responseGenericClass() default Void.class;
/**
* (RequestMapping)
*/

View File

@ -90,16 +90,6 @@ public @interface PostResource {
*/
boolean viewFlag() default false;
/**
* api
*/
Class<?> responseClass() default Void.class;
/**
* api
*/
Class<?> responseGenericClass() default Void.class;
/**
* (RequestMapping)
*/

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.scanner.api.context;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.scanner.api.enums.FieldTypeEnum;
import cn.stylefeng.roses.kernel.scanner.api.util.ClassTypeUtil;
@ -97,4 +98,17 @@ public class MetadataContext {
META_DATA_CLASS_COUNT_CONTEXT.clear();
}
/**
*
*
* @author fengshuonan
* @date 2022/1/15 10:49
*/
public static void cleanContext(String uuid) {
if (StrUtil.isEmpty(uuid)) {
return;
}
META_DATA_CLASS_COUNT_CONTEXT.remove(uuid);
}
}

View File

@ -152,7 +152,7 @@ public class ClassDetailMetadataFactory {
return fieldDetailMetadataSet;
} else {
log.info("带泛型的实体主题rawType非Class类型" + fieldType);
log.debug("带泛型的实体主题rawType非Class类型" + fieldType);
return null;
}
}

View File

@ -53,16 +53,16 @@ public class ClassMetadataFactory {
ParameterizedType parameterizedType = (ParameterizedType) type;
// 创建类型的基本信息
FieldMetadata baseMetadata = ClassDescriptionUtil.createParameterizedMetadata(parameterizedType, classFieldType);
fieldMetadata = ClassDescriptionUtil.createParameterizedMetadata(parameterizedType, classFieldType);
// 补充类型的子信息
Set<FieldMetadata> fieldDetailMetadataSet = ClassDetailMetadataFactory.createFieldDetailMetadataSet(type, uuid);
baseMetadata.setGenericFieldMetadata(fieldDetailMetadataSet);
fieldMetadata.setGenericFieldMetadata(fieldDetailMetadataSet);
}
// 其他情况
else {
log.info("未知类型的处理既不是class也不是ParameterizedType打印出类的信息如下{}", type.getTypeName());
log.debug("未知类型的处理既不是class也不是ParameterizedType打印出类的信息如下{}", type.getTypeName());
}
return fieldMetadata;

View File

@ -148,7 +148,7 @@ public class ResourceDefinition implements Serializable {
*
*/
@ChineseDescription("接口返回结果的字段描述")
private Set<FieldMetadata> responseFieldDescriptions;
private FieldMetadata responseFieldDescriptions;
/**
*

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ClassUtil;
import cn.stylefeng.roses.kernel.scanner.api.enums.FieldTypeEnum;
import lombok.extern.slf4j.Slf4j;
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
import sun.reflect.generics.reflectiveObjects.WildcardTypeImpl;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@ -87,7 +88,7 @@ public class ClassTypeUtil {
// 其他类型,暂不处理
else {
log.info("类型是Class但有处理不到的情况打印出类的信息如下{}", clazz.toGenericString());
log.debug("类型是Class但有处理不到的情况打印出类的信息如下{}", clazz.toGenericString());
return FieldTypeEnum.OTHER;
}
}
@ -120,12 +121,12 @@ public class ClassTypeUtil {
// 泛型的主体情况不确定,不处理
else {
log.info("泛型的主体情况不确定不处理打印出rawTypeClass{}", rawTypeClass.getName());
log.debug("泛型的主体情况不确定不处理打印出rawTypeClass{}", rawTypeClass.getName());
return FieldTypeEnum.OTHER;
}
} else {
// 泛型的主体是别的类型
log.info("rawType为非Class类型打印出rawType{}", rawType.getTypeName());
log.debug("rawType为非Class类型打印出rawType{}", rawType.getTypeName());
return FieldTypeEnum.OTHER;
}
}
@ -135,9 +136,14 @@ public class ClassTypeUtil {
return FieldTypeEnum.WITH_UNKNOWN_GENERIC;
}
// 带?的参数例如解析到ResponseData<?>中的data字段就是这种情况
else if (type instanceof WildcardTypeImpl) {
return FieldTypeEnum.OTHER;
}
// 其他情况既不是class也不是ParameterizedType
else {
log.info("未知类型的处理既不是class也不是ParameterizedType打印出类的信息如下{}", type.getTypeName());
log.debug("未知类型的处理既不是class也不是ParameterizedType打印出类的信息如下{}", type.getTypeName());
return FieldTypeEnum.OTHER;
}
}

View File

@ -31,6 +31,7 @@ import org.springframework.validation.annotation.Validated;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -105,7 +106,7 @@ public class MethodReflectUtil {
Method validateGroupMethod = annotation.annotationType().getMethod("value");
Object invoke = validateGroupMethod.invoke(annotation);
if (invoke != null) {
Class<?>[] result = (Class<?>[])invoke;
Class<?>[] result = (Class<?>[]) invoke;
if (result.length > 0) {
HashSet<String> groupClassNames = new HashSet<>();
for (Class<?> groupClass : result) {
@ -123,43 +124,33 @@ public class MethodReflectUtil {
}
/**
*
*
*
* @param method
* @return class
* @author fengshuonan
* @date 2020/12/8 18:16
*/
public static Class<?> getMethodFirstParamClass(Method method) {
public static Type[] getMethodGenericTypes(Method method) {
if (method == null) {
return null;
}
if (method.getParameterCount() <= 0) {
return null;
}
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length > 0) {
return parameterTypes[0];
} else {
return null;
}
return method.getGenericParameterTypes();
}
/**
* class
* typetypeclass
*
* @param method
* @return class
* @author fengshuonan
* @date 2020/12/8 18:20
*/
public static Class<?> getMethodReturnClass(Method method) {
public static Type getMethodReturnType(Method method) {
if (method == null) {
return null;
}
return method.getReturnType();
return method.getGenericReturnType();
}
}

View File

@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.scanner;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.rule.util.AopTargetUtils;
import cn.stylefeng.roses.kernel.scanner.api.ResourceCollectorApi;
@ -33,11 +34,13 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.scanner.api.constants.ScannerConstants;
import cn.stylefeng.roses.kernel.scanner.api.context.MetadataContext;
import cn.stylefeng.roses.kernel.scanner.api.exception.ScannerException;
import cn.stylefeng.roses.kernel.scanner.api.factory.ClassMetadataFactory;
import cn.stylefeng.roses.kernel.scanner.api.holder.IpAddrHolder;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.FieldMetadata;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
import cn.stylefeng.roses.kernel.scanner.api.pojo.scanner.ScannerProperties;
import cn.stylefeng.roses.kernel.scanner.api.util.ClassReflectUtil;
import cn.stylefeng.roses.kernel.scanner.api.util.MethodReflectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
@ -49,10 +52,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.lang.reflect.Type;
import java.util.*;
import static cn.stylefeng.roses.kernel.scanner.api.exception.enums.ScannerExceptionEnum.ERROR_CONTROLLER_NAME;
@ -209,6 +210,7 @@ public class ApiResourceScanner implements BeanPostProcessor {
// 填充模块编码模块编码就是控制器名称截取Controller关键字前边的字符串
String className = resourceDefinition.getClassName();
int controllerIndex = className.indexOf("Controller");
if (controllerIndex == -1) {
throw new ScannerException(ERROR_CONTROLLER_NAME, controllerClass.getName());
@ -294,18 +296,22 @@ public class ApiResourceScanner implements BeanPostProcessor {
}
// 填充方法返回结果字段的详细信息
// @ApiResource注解上标识了responseClass属性则用responseClass的值为准否则按真实方法的返回值class
Class<?> responseClass = invokeAnnotationMethod(apiResource, "responseClass", Class.class);
if (!Void.class.equals(responseClass)) {
resourceDefinition.setResponseFieldDescriptions(ClassReflectUtil.getClassFieldDescription(responseClass));
} else {
Class<?> methodReturnClass = MethodReflectUtil.getMethodReturnClass(method);
resourceDefinition.setResponseFieldDescriptions(ClassReflectUtil.getClassFieldDescription(methodReturnClass));
}
Type returnType = MethodReflectUtil.getMethodReturnType(method);
String processReturnTypeUuid = RandomUtil.randomString(32);
resourceDefinition.setResponseFieldDescriptions(ClassMetadataFactory.beginCreateFieldMetadata(returnType, processReturnTypeUuid));
MetadataContext.cleanContext(processReturnTypeUuid);
// 填充方法的请求参数字段的详细信息
Class<?> firstParamClass = MethodReflectUtil.getMethodFirstParamClass(method);
resourceDefinition.setParamFieldDescriptions(ClassReflectUtil.getClassFieldDescription(firstParamClass));
Type[] methodGenericTypes = MethodReflectUtil.getMethodGenericTypes(method);
if (methodGenericTypes.length > 0) {
LinkedHashSet<FieldMetadata> fieldMetadataLinkedHashSet = new LinkedHashSet<>();
for (Type methodGenericType : methodGenericTypes) {
String parameterContextUuid = RandomUtil.randomString(32);
fieldMetadataLinkedHashSet.add(ClassMetadataFactory.beginCreateFieldMetadata(methodGenericType, parameterContextUuid));
MetadataContext.cleanContext(parameterContextUuid);
}
resourceDefinition.setParamFieldDescriptions(fieldMetadataLinkedHashSet);
}
return resourceDefinition;
}

View File

@ -106,7 +106,7 @@ public class SysAppController {
* @author fengshuonan
* @date 2020/3/26 9:49
*/
@GetResource(name = "查看系统应用", path = "/sysApp/detail", responseClass = SysApp.class)
@GetResource(name = "查看系统应用", path = "/sysApp/detail")
public ResponseData detail(@Validated(SysAppRequest.detail.class) SysAppRequest sysAppParam) {
return new SuccessResponseData(sysAppService.detail(sysAppParam));
}
@ -117,7 +117,7 @@ public class SysAppController {
* @author fengshuonan
* @date 2020/4/19 14:55
*/
@GetResource(name = "系统应用列表", path = "/sysApp/list", responseClass = SysApp.class)
@GetResource(name = "系统应用列表", path = "/sysApp/list")
public ResponseData list(SysAppRequest sysAppParam) {
return new SuccessResponseData(sysAppService.findList(sysAppParam));
}

View File

@ -123,7 +123,7 @@ public class SysMenuButtonController {
* @author luojie
* @date 2021/1/9 11:53
*/
@GetResource(name = "获取菜单按钮详情", path = "/sysMenuButton/detail", responseClass = SysMenuButton.class)
@GetResource(name = "获取菜单按钮详情", path = "/sysMenuButton/detail")
public ResponseData detail(@Validated(SysMenuButtonRequest.detail.class) SysMenuButtonRequest sysMenuButtonRequest) {
SysMenuButton detail = sysMenuButtonService.detail(sysMenuButtonRequest);
return new SuccessResponseData(detail);
@ -136,7 +136,7 @@ public class SysMenuButtonController {
* @author luojie
* @date 2021/1/9 12:33
*/
@GetResource(name = "获取菜单按钮列表", path = "/sysMenuButton/pageList", responseClass = SysMenuButton.class)
@GetResource(name = "获取菜单按钮列表", path = "/sysMenuButton/pageList")
public ResponseData pageList(@Validated(SysMenuButtonRequest.list.class) SysMenuButtonRequest sysMenuButtonRequest) {
PageResult<SysMenuButton> pageResult = sysMenuButtonService.findPage(sysMenuButtonRequest);
return new SuccessResponseData(pageResult);

View File

@ -32,11 +32,9 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.menu.MenuAndButtonTreeResponse;
import cn.stylefeng.roses.kernel.system.api.pojo.menu.SysMenuRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.menu.antd.AntdMenuSelectTreeNode;
import cn.stylefeng.roses.kernel.system.api.pojo.menu.antd.AntdSysMenuDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.menu.layui.LayuiMenuAndButtonTreeResponse;
import cn.stylefeng.roses.kernel.system.api.pojo.role.request.SysRoleRequest;
import cn.stylefeng.roses.kernel.system.modular.menu.entity.SysMenu;
import cn.stylefeng.roses.kernel.system.modular.menu.service.SysMenuService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
@ -100,7 +98,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2020/3/27 9:01
*/
@GetResource(name = "查看系统菜单", path = "/sysMenu/detail", responseClass = SysMenu.class)
@GetResource(name = "查看系统菜单", path = "/sysMenu/detail")
public ResponseData detail(@Validated(SysMenuRequest.detail.class) SysMenuRequest sysMenuRequest) {
return new SuccessResponseData(sysMenuService.detail(sysMenuRequest));
}
@ -111,7 +109,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2021/1/6 17:09
*/
@GetResource(name = "获取菜单列表layui版本", path = "/sysMenu/layuiList", responseClass = SysMenu.class)
@GetResource(name = "获取菜单列表layui版本", path = "/sysMenu/layuiList")
public ResponseData layuiList(SysMenuRequest sysMenuRequest) {
return new SuccessResponseData(sysMenuService.findList(sysMenuRequest));
}
@ -122,7 +120,7 @@ public class SysMenuController {
* @author majianguo
* @date 2021/1/9 17:10
*/
@GetResource(name = "获取系统菜单和按钮的树用于角色分配菜单按钮layui版本使用", path = "/sysMenu/menuAndButtonTree", responseClass = LayuiMenuAndButtonTreeResponse.class)
@GetResource(name = "获取系统菜单和按钮的树用于角色分配菜单按钮layui版本使用", path = "/sysMenu/menuAndButtonTree")
public List<LayuiMenuAndButtonTreeResponse> menuAndButtonTree(SysRoleRequest sysRoleRequest) {
return sysMenuService.getMenuAndButtonTree(sysRoleRequest, true);
}
@ -133,7 +131,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2021/1/6 17:09
*/
@GetResource(name = "获取菜单的树形列表用于选择上级菜单layui版本", path = "/sysMenu/layuiSelectParentMenuTreeList", responseClass = ZTreeNode.class)
@GetResource(name = "获取菜单的树形列表用于选择上级菜单layui版本", path = "/sysMenu/layuiSelectParentMenuTreeList")
public List<ZTreeNode> layuiSelectParentMenuTreeList() {
return sysMenuService.layuiSelectParentMenuTreeList();
}
@ -144,7 +142,7 @@ public class SysMenuController {
* @author majianguo
* @date 2021/1/7 15:17
*/
@GetResource(name = "获取系统所有菜单适用于登录后获取左侧菜单适配antd vue版本", path = "/sysMenu/getLeftMenusAntdv", requiredPermission = false, responseClass = AntdSysMenuDTO.class)
@GetResource(name = "获取系统所有菜单适用于登录后获取左侧菜单适配antd vue版本", path = "/sysMenu/getLeftMenusAntdv", requiredPermission = false)
public ResponseData getLeftMenusAntdv(SysMenuRequest sysMenuRequest) {
List<AntdSysMenuDTO> sysMenuResponses = sysMenuService.getLeftMenusAntdv(sysMenuRequest);
return new SuccessResponseData(sysMenuResponses);
@ -156,7 +154,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2020/3/20 21:23
*/
@GetResource(name = "系统菜单列表(树)", path = "/sysMenu/list", responseClass = SysMenu.class)
@GetResource(name = "系统菜单列表(树)", path = "/sysMenu/list")
public ResponseData list(SysMenuRequest sysMenuRequest) {
return new SuccessResponseData(sysMenuService.findListWithTreeStructure(sysMenuRequest));
}
@ -167,7 +165,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2020/3/27 15:55
*/
@GetResource(name = "获取系统菜单树,用于新增,编辑时选择上级节点", path = "/sysMenu/tree", responseClass = AntdMenuSelectTreeNode.class)
@GetResource(name = "获取系统菜单树,用于新增,编辑时选择上级节点", path = "/sysMenu/tree")
public ResponseData tree(SysMenuRequest sysMenuRequest) {
return new SuccessResponseData(sysMenuService.tree(sysMenuRequest));
}
@ -178,7 +176,7 @@ public class SysMenuController {
* @author majianguo
* @date 2021/1/9 17:10
*/
@GetResource(name = "获取系统菜单和按钮的树用于角色分配菜单按钮antd vue版本使用", path = "/sysMenu/menuAndButtonTreeChildren", responseClass = LayuiMenuAndButtonTreeResponse.class)
@GetResource(name = "获取系统菜单和按钮的树用于角色分配菜单按钮antd vue版本使用", path = "/sysMenu/menuAndButtonTreeChildren")
public ResponseData menuAndButtonTreeChildren(SysRoleRequest sysRoleRequest) {
List<LayuiMenuAndButtonTreeResponse> treeResponseList = sysMenuService.getMenuAndButtonTree(sysRoleRequest, false);
return new SuccessResponseData(treeResponseList);
@ -190,7 +188,7 @@ public class SysMenuController {
* @author fengshuonan
* @date 2021/8/10 22:21
*/
@GetResource(name = "新版角色分配菜单和按钮界面使用的接口v2", path = "/sysMenu/menuAndButtonTreeChildrenV2", responseClass = LayuiMenuAndButtonTreeResponse.class)
@GetResource(name = "新版角色分配菜单和按钮界面使用的接口v2", path = "/sysMenu/menuAndButtonTreeChildrenV2")
public ResponseData menuAndButtonTreeChildrenV2(SysRoleRequest sysRoleRequest) {
List<MenuAndButtonTreeResponse> treeResponseList = sysMenuService.getRoleMenuAndButtons(sysRoleRequest);
return new SuccessResponseData(treeResponseList);

View File

@ -30,7 +30,6 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.notice.SysNoticeRequest;
import cn.stylefeng.roses.kernel.system.modular.notice.entity.SysNotice;
import cn.stylefeng.roses.kernel.system.modular.notice.service.SysNoticeService;
import cn.stylefeng.roses.kernel.system.modular.notice.wrapper.NoticeWrapper;
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
@ -95,7 +94,7 @@ public class SysNoticeController {
* @author liuhanqing
* @date 2021/1/9 9:49
*/
@GetResource(name = "查看通知管理", path = "/sysNotice/detail", responseClass = SysNotice.class)
@GetResource(name = "查看通知管理", path = "/sysNotice/detail")
public ResponseData detail(@Validated(SysNoticeRequest.detail.class) SysNoticeRequest sysNoticeParam) {
return new SuccessResponseData(sysNoticeService.detail(sysNoticeParam));
}
@ -106,7 +105,7 @@ public class SysNoticeController {
* @author liuhanqing
* @date 2021/1/9 21:23
*/
@GetResource(name = "查询通知管理", path = "/sysNotice/page", responseClass = SysNotice.class)
@GetResource(name = "查询通知管理", path = "/sysNotice/page")
@Wrapper(NoticeWrapper.class)
public ResponseData page(SysNoticeRequest sysNoticeParam) {
return new SuccessResponseData(sysNoticeService.findPage(sysNoticeParam));
@ -118,7 +117,7 @@ public class SysNoticeController {
* @author liuhanqing
* @date 2021/1/9 14:55
*/
@GetResource(name = "通知管理列表", path = "/sysNotice/list", responseClass = SysNotice.class)
@GetResource(name = "通知管理列表", path = "/sysNotice/list")
public ResponseData list(SysNoticeRequest sysNoticeParam) {
return new SuccessResponseData(sysNoticeService.findList(sysNoticeParam));
}

View File

@ -31,8 +31,6 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.OrganizationTreeNode;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrOrganization;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
@ -108,7 +106,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "查看详情系统组织机构", path = "/hrOrganization/detail", responseClass = HrOrganization.class)
@GetResource(name = "查看详情系统组织机构", path = "/hrOrganization/detail")
public ResponseData detail(@Validated(HrOrganizationRequest.detail.class) HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.detail(hrOrganizationRequest));
}
@ -119,7 +117,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "分页查询系统组织机构", path = "/hrOrganization/page", responseClass = HrOrganization.class)
@GetResource(name = "分页查询系统组织机构", path = "/hrOrganization/page")
public ResponseData page(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.findPage(hrOrganizationRequest));
}
@ -130,7 +128,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2020/11/04 11:05
*/
@GetResource(name = "获取全部系统组织机构", path = "/hrOrganization/list", responseClass = HrOrganization.class)
@GetResource(name = "获取全部系统组织机构", path = "/hrOrganization/list")
public ResponseData list(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.findList(hrOrganizationRequest));
}
@ -141,7 +139,7 @@ public class HrOrganizationController {
* @author chenjinlong
* @date 2021/01/05 15:55
*/
@GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/tree", responseClass = OrganizationTreeNode.class)
@GetResource(name = "获取全部系统组织机构树", path = "/hrOrganization/tree")
public ResponseData organizationTree(HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.organizationTree(hrOrganizationRequest));
}
@ -152,7 +150,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2021/3/19 22:20
*/
@GetResource(name = "获取组织机构树(用于用户绑定数据范围)", path = "/hrOrganization/userBindOrgScope", responseClass = OrganizationTreeNode.class)
@GetResource(name = "获取组织机构树(用于用户绑定数据范围)", path = "/hrOrganization/userBindOrgScope")
public ResponseData userBindOrgScope(@Validated(HrOrganizationRequest.userBindOrgScope.class) HrOrganizationRequest hrOrganizationRequest) {
return new SuccessResponseData(hrOrganizationService.organizationTree(hrOrganizationRequest));
}
@ -163,7 +161,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2021/1/9 18:37
*/
@GetResource(name = "Layui版本--获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)", path = "/hrOrganization/roleBindOrgScope", responseClass = ZTreeNode.class)
@GetResource(name = "Layui版本--获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)", path = "/hrOrganization/roleBindOrgScope")
public List<ZTreeNode> roleBindOrgScope(@Validated(HrOrganizationRequest.roleBindOrgScope.class) HrOrganizationRequest hrOrganizationRequest) {
return hrOrganizationService.orgZTree(hrOrganizationRequest, false);
}
@ -174,7 +172,7 @@ public class HrOrganizationController {
* @author fengshuonan
* @date 2021/1/9 18:37
*/
@GetResource(name = "AntdVue版本--获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)", path = "/hrOrganization/roleBindOrgScopeAntdv", responseClass = ZTreeNode.class)
@GetResource(name = "AntdVue版本--获取组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)", path = "/hrOrganization/roleBindOrgScopeAntdv")
public ResponseData roleBindOrgScopeAntdv(@Validated(HrOrganizationRequest.roleBindOrgScope.class) HrOrganizationRequest hrOrganizationRequest) {
List<ZTreeNode> zTreeNodes = hrOrganizationService.orgZTree(hrOrganizationRequest, true);
return new SuccessResponseData(zTreeNodes);

View File

@ -31,7 +31,6 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest;
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
import cn.stylefeng.roses.kernel.system.modular.organization.service.HrPositionService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
@ -118,7 +117,7 @@ public class HrPositionController {
* @author chenjinlong
* @date 2020/11/04 11:07
*/
@GetResource(name = "查看详情系统职位", path = "/hrPosition/detail", responseClass = HrPosition.class)
@GetResource(name = "查看详情系统职位", path = "/hrPosition/detail")
public ResponseData detail(@Validated(HrPositionRequest.detail.class) HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(hrPositionService.detail(hrPositionRequest));
}
@ -129,7 +128,7 @@ public class HrPositionController {
* @author chenjinlong
* @date 2020/11/04 11:07
*/
@GetResource(name = "分页查询系统职位", path = "/hrPosition/page", responseClass = HrPosition.class)
@GetResource(name = "分页查询系统职位", path = "/hrPosition/page")
public ResponseData page(HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(hrPositionService.findPage(hrPositionRequest));
}
@ -140,7 +139,7 @@ public class HrPositionController {
* @author chenjinlong
* @date 2020/11/04 11:07
*/
@GetResource(name = "获取全部系统职位", path = "/hrPosition/list", responseClass = HrPosition.class)
@GetResource(name = "获取全部系统职位", path = "/hrPosition/list")
public ResponseData list(HrPositionRequest hrPositionRequest) {
return new SuccessResponseData(hrPositionService.findList(hrPositionRequest));
}

View File

@ -58,7 +58,7 @@ public class ResourceController {
* @author fengshuonan
* @date 2020/11/24 19:47
*/
@GetResource(name = "获取资源列表", path = "/resource/pageList", responseClass = SysResource.class)
@GetResource(name = "获取资源列表", path = "/resource/pageList")
public ResponseData pageList(ResourceRequest resourceRequest) {
PageResult<SysResource> result = this.sysResourceService.findPage(resourceRequest);
return new SuccessResponseData(result);
@ -70,7 +70,7 @@ public class ResourceController {
* @author fengshuonan
* @date 2020/11/24 19:51
*/
@GetResource(name = "获取资源下拉列表", path = "/resource/getMenuResourceList", responseClass = SysResource.class)
@GetResource(name = "获取资源下拉列表", path = "/resource/getMenuResourceList")
public ResponseData getMenuResourceList(ResourceRequest resourceRequest) {
List<SysResource> menuResourceList = this.sysResourceService.findList(resourceRequest);
return new SuccessResponseData(menuResourceList);
@ -82,7 +82,7 @@ public class ResourceController {
* @author majianguo
* @date 2021/1/9 15:07
*/
@GetResource(name = "Layui版本--获取资源树列表,用于角色分配接口权限", path = "/resource/getRoleResourceTree", responseClass = ResourceTreeNode.class)
@GetResource(name = "Layui版本--获取资源树列表,用于角色分配接口权限", path = "/resource/getRoleResourceTree")
public List<ResourceTreeNode> getLateralTree(SysRoleRequest sysRoleRequest) {
return sysResourceService.getRoleResourceTree(sysRoleRequest.getRoleId(), false);
}
@ -93,7 +93,7 @@ public class ResourceController {
* @author majianguo
* @date 2021/1/9 15:07
*/
@GetResource(name = "AntdVue版本--获取资源树列表,用于角色分配接口权限", path = "/resource/getRoleResourceTreeAntdv", responseClass = ResourceTreeNode.class)
@GetResource(name = "AntdVue版本--获取资源树列表,用于角色分配接口权限", path = "/resource/getRoleResourceTreeAntdv")
public ResponseData getLateralTreeChildren(SysRoleRequest sysRoleRequest) {
List<ResourceTreeNode> resourceLateralTree = sysResourceService.getRoleResourceTree(sysRoleRequest.getRoleId(), true);
return new SuccessResponseData(resourceLateralTree);

View File

@ -130,7 +130,7 @@ public class ResourceFactory {
// 转化接口返回结果的字段描述
if (ObjectUtil.isNotEmpty(sysResource.getResponseFieldDescriptions())) {
resourceDefinition.setResponseFieldDescriptions(JSON.parseObject(sysResource.getResponseFieldDescriptions(), Set.class, Feature.SupportAutoType));
resourceDefinition.setResponseFieldDescriptions(JSON.parseObject(sysResource.getResponseFieldDescriptions(), FieldMetadata.class, Feature.SupportAutoType));
}
return resourceDefinition;
@ -149,10 +149,12 @@ public class ResourceFactory {
// 接口的请求参数信息
Set<FieldMetadata> paramFieldDescriptions = resourceDefinition.getParamFieldDescriptions();
fillDetailMessage(validateGroups, paramFieldDescriptions);
for (FieldMetadata fieldMetadata : paramFieldDescriptions) {
fillDetailMessage(validateGroups, fieldMetadata);
}
// 接口的响应参数信息
Set<FieldMetadata> responseFieldDescriptions = resourceDefinition.getResponseFieldDescriptions();
FieldMetadata responseFieldDescriptions = resourceDefinition.getResponseFieldDescriptions();
fillDetailMessage(validateGroups, responseFieldDescriptions);
return resourceDefinition;
@ -164,33 +166,32 @@ public class ResourceFactory {
* @author fengshuonan
* @date 2021/1/16 18:00
*/
public static Set<FieldMetadata> fillDetailMessage(Set<String> validateGroups, Set<FieldMetadata> fieldMetadataSet) {
public static void fillDetailMessage(Set<String> validateGroups, FieldMetadata fieldMetadata) {
if (validateGroups == null || validateGroups.isEmpty()) {
return fieldMetadataSet;
return;
}
if (fieldMetadataSet == null || fieldMetadataSet.isEmpty()) {
return fieldMetadataSet;
if (fieldMetadata == null) {
return;
}
for (FieldMetadata fieldMetadata : fieldMetadataSet) {
StringBuilder finalValidateMessages = new StringBuilder();
Map<String, Set<String>> groupAnnotations = fieldMetadata.getGroupValidationMessage();
if (groupAnnotations != null) {
for (String validateGroup : validateGroups) {
Set<String> validateMessage = groupAnnotations.get(validateGroup);
if (validateMessage != null && !validateMessage.isEmpty()) {
finalValidateMessages.append(StrUtil.join("", validateMessage));
}
StringBuilder finalValidateMessages = new StringBuilder();
Map<String, Set<String>> groupAnnotations = fieldMetadata.getGroupValidationMessage();
if (groupAnnotations != null) {
for (String validateGroup : validateGroups) {
Set<String> validateMessage = groupAnnotations.get(validateGroup);
if (validateMessage != null && !validateMessage.isEmpty()) {
finalValidateMessages.append(StrUtil.join("", validateMessage));
}
}
fieldMetadata.setValidationMessages(finalValidateMessages.toString());
}
fieldMetadata.setValidationMessages(finalValidateMessages.toString());
// 递归填充子类型的详细提示信息
if (fieldMetadata.getGenericFieldMetadata() != null && !fieldMetadata.getGenericFieldMetadata().isEmpty()) {
fillDetailMessage(validateGroups, fieldMetadata.getGenericFieldMetadata());
// 递归填充子类型的详细提示信息
if (fieldMetadata.getGenericFieldMetadata() != null && !fieldMetadata.getGenericFieldMetadata().isEmpty()) {
for (FieldMetadata metadata : fieldMetadata.getGenericFieldMetadata()) {
fillDetailMessage(validateGroups, metadata);
}
}
return fieldMetadataSet;
}
/**
@ -209,7 +210,7 @@ public class ResourceFactory {
for (ResourceDefinition sysResource : sysResourceList) {
String url = sysResource.getUrl();
result.put(url,sysResource);
result.put(url, sysResource);
}
return result;

View File

@ -25,15 +25,12 @@
package cn.stylefeng.roses.kernel.system.modular.role.controller;
import cn.hutool.core.collection.ListUtil;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.role.dto.SysRoleDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.role.request.SysRoleRequest;
import cn.stylefeng.roses.kernel.system.modular.role.entity.SysRole;
import cn.stylefeng.roses.kernel.system.modular.role.service.SysRoleResourceService;
import cn.stylefeng.roses.kernel.system.modular.role.service.SysRoleService;
import org.springframework.validation.annotation.Validated;
@ -100,7 +97,7 @@ public class SysRoleController {
* @author majianguo
* @date 2020/11/5 10:50
*/
@GetResource(name = "角色查看", path = "/sysRole/detail", responseClass = SysRoleDTO.class)
@GetResource(name = "角色查看", path = "/sysRole/detail")
public ResponseData detail(@Validated(SysRoleRequest.detail.class) SysRoleRequest sysRoleRequest) {
return new SuccessResponseData(sysRoleService.detail(sysRoleRequest));
}
@ -111,7 +108,7 @@ public class SysRoleController {
* @author majianguo
* @date 2020/11/5 10:19
*/
@GetResource(name = "查询角色", path = "/sysRole/page", responseClass = SysRole.class)
@GetResource(name = "查询角色", path = "/sysRole/page")
public ResponseData page(SysRoleRequest sysRoleRequest) {
return new SuccessResponseData(sysRoleService.findPage(sysRoleRequest));
}
@ -194,7 +191,7 @@ public class SysRoleController {
* @author majianguo
* @date 2020/11/6 13:49
*/
@GetResource(name = "角色下拉", path = "/sysRole/dropDown", responseClass = SimpleDict.class)
@GetResource(name = "角色下拉", path = "/sysRole/dropDown")
public ResponseData dropDown() {
return new SuccessResponseData(sysRoleService.dropDown());
}
@ -205,7 +202,7 @@ public class SysRoleController {
* @author majianguo
* @date 2020/11/5 10:58
*/
@GetResource(name = "角色拥有菜单", path = "/sysRole/getRoleMenus", responseClass = Long.class)
@GetResource(name = "角色拥有菜单", path = "/sysRole/getRoleMenus")
public ResponseData getRoleMenus(@Validated(SysRoleRequest.detail.class) SysRoleRequest sysRoleRequest) {
Long roleId = sysRoleRequest.getRoleId();
return new SuccessResponseData(sysRoleService.getMenuIdsByRoleIds(ListUtil.toList(roleId)));
@ -217,7 +214,7 @@ public class SysRoleController {
* @author majianguo
* @date 2020/11/5 10:59
*/
@GetResource(name = "角色拥有数据", path = "/sysRole/getRoleDataScope", responseClass = Long.class)
@GetResource(name = "角色拥有数据", path = "/sysRole/getRoleDataScope")
public ResponseData getRoleDataScope(@Validated(SysRoleRequest.detail.class) SysRoleRequest sysRoleRequest) {
return new SuccessResponseData(sysRoleService.getRoleDataScope(sysRoleRequest));
}

View File

@ -60,9 +60,9 @@ public class KaptchaController {
* @author fengshuonan
* @date 2021/7/5 12:00
*/
@GetResource(name = "获取图形验证码", path = "/captcha", requiredPermission = false, requiredLogin = false, responseClass = ImageCaptcha.class)
public ResponseData captcha() {
return new SuccessResponseData(captchaApi.captcha());
@GetResource(name = "获取图形验证码", path = "/captcha", requiredPermission = false, requiredLogin = false)
public ResponseData<ImageCaptcha> captcha() {
return new SuccessResponseData<>(captchaApi.captcha());
}
/**
@ -71,12 +71,12 @@ public class KaptchaController {
* @author fengshuonan
* @date 2021/7/5 12:00
*/
@GetResource(name = "获取图形验证码", path = "/dragCaptcha", requiredPermission = false, requiredLogin = false, responseClass = DragCaptchaImageDTO.class)
public ResponseData dragCaptcha() {
@GetResource(name = "获取图形验证码", path = "/dragCaptcha", requiredPermission = false, requiredLogin = false)
public ResponseData<DragCaptchaImageDTO> dragCaptcha() {
DragCaptchaImageDTO captcha = dragCaptchaApi.createCaptcha();
captcha.setSrcImage(BASE64_IMG_PREFIX + captcha.getSrcImage());
captcha.setCutImage(BASE64_IMG_PREFIX + captcha.getCutImage());
return new SuccessResponseData(captcha);
return new SuccessResponseData<>(captcha);
}
}

View File

@ -71,11 +71,11 @@ public class LoginController {
* @author fengshuonan
* @date 2021/3/17 17:23
*/
@PostResource(name = "登陆", path = "/login", requiredLogin = false, requiredPermission = false, responseClass = String.class)
public ResponseData login(@RequestBody @Validated LoginRequest loginRequest) {
@PostResource(name = "登陆", path = "/login", requiredLogin = false, requiredPermission = false)
public ResponseData<String> login(@RequestBody @Validated LoginRequest loginRequest) {
loginRequest.setCreateCookie(true);
LoginResponse loginResponse = authServiceApi.login(loginRequest);
return new SuccessResponseData(loginResponse.getToken());
return new SuccessResponseData<>(loginResponse.getToken());
}
/**
@ -84,11 +84,11 @@ public class LoginController {
* @author fengshuonan
* @date 2021/3/17 17:23
*/
@PostResource(name = "登陆(分离版)", path = "/loginApi", requiredLogin = false, requiredPermission = false, responseClass = LoginResponse.class)
public ResponseData loginApi(@RequestBody @Validated LoginRequest loginRequest) {
@PostResource(name = "登陆(分离版)", path = "/loginApi", requiredLogin = false, requiredPermission = false)
public ResponseData<LoginResponse> loginApi(@RequestBody @Validated LoginRequest loginRequest) {
loginRequest.setCreateCookie(false);
LoginResponse loginResponse = authServiceApi.login(loginRequest);
return new SuccessResponseData(loginResponse);
return new SuccessResponseData<>(loginResponse);
}
/**
@ -97,10 +97,10 @@ public class LoginController {
* @author fengshuonan
* @date 2021/5/25 22:36
*/
@PostResource(name = "适用于单点登录", path = "/loginWithToken", requiredLogin = false, requiredPermission = false, responseClass = String.class)
public ResponseData loginWithToken(@RequestBody @Validated LoginWithTokenRequest loginWithTokenRequest) {
@PostResource(name = "适用于单点登录", path = "/loginWithToken", requiredLogin = false, requiredPermission = false)
public ResponseData<String> loginWithToken(@RequestBody @Validated LoginWithTokenRequest loginWithTokenRequest) {
LoginResponse loginResponse = authServiceApi.LoginWithToken(loginWithTokenRequest);
return new SuccessResponseData(loginResponse.getToken());
return new SuccessResponseData<>(loginResponse.getToken());
}
/**
@ -110,9 +110,9 @@ public class LoginController {
* @date 2021/3/17 17:24
*/
@ApiResource(name = "登出", path = "/logoutAction", requiredPermission = false, method = {RequestMethod.GET, RequestMethod.POST})
public ResponseData logoutAction() {
public ResponseData<?> logoutAction() {
authServiceApi.logout();
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -121,14 +121,14 @@ public class LoginController {
* @author fengshuonan
* @date 2021/3/17 17:37
*/
@GetResource(name = "获取当前用户的用户信息", path = "/getCurrentLoginUserInfo", requiredPermission = false, responseClass = CurrentUserInfoResponse.class)
public ResponseData getCurrentLoginUserInfo() {
@GetResource(name = "获取当前用户的用户信息", path = "/getCurrentLoginUserInfo", requiredPermission = false)
public ResponseData<CurrentUserInfoResponse> getCurrentLoginUserInfo() {
LoginUser loginUser = LoginContext.me().getLoginUser();
// 转化返回结果
CurrentUserInfoResponse currentUserInfoResponse = UserLoginInfoFactory.parseUserInfo(loginUser);
return new SuccessResponseData(currentUserInfoResponse);
return new SuccessResponseData<>(currentUserInfoResponse);
}
/**
@ -138,9 +138,9 @@ public class LoginController {
* @date 2021/6/18 15:26
*/
@PostResource(name = "校验token是否正确", path = "/validateToken", requiredPermission = false, requiredLogin = false)
public ResponseData validateToken(@RequestBody @Valid ValidateTokenRequest validateTokenRequest) {
public ResponseData<Boolean> validateToken(@RequestBody @Valid ValidateTokenRequest validateTokenRequest) {
boolean haveSessionFlag = sessionManagerApi.haveSession(validateTokenRequest.getToken());
return new SuccessResponseData(haveSessionFlag);
return new SuccessResponseData<>(haveSessionFlag);
}
}

View File

@ -41,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
/**
* 线
@ -64,9 +65,9 @@ public class OnlineUserController {
* @author fengshuonan
* @date 2021/1/11 22:53
*/
@GetResource(name = "当前在线用户列表", path = "/sysUser/onlineUserList", responseClass = OnlineUserDTO.class)
public ResponseData onlineUserList(OnlineUserRequest onlineUserRequest) {
return new SuccessResponseData(sysUserService.onlineUserList(onlineUserRequest));
@GetResource(name = "当前在线用户列表", path = "/sysUser/onlineUserList")
public ResponseData<List<OnlineUserDTO>> onlineUserList(OnlineUserRequest onlineUserRequest) {
return new SuccessResponseData<>(sysUserService.onlineUserList(onlineUserRequest));
}
/**
@ -76,12 +77,12 @@ public class OnlineUserController {
* @date 2021/1/11 22:53
*/
@PostResource(name = "踢掉在线用户", path = "/sysUser/removeSession")
public ResponseData removeSession(@Valid @RequestBody OnlineUserRequest onlineUserRequest) {
public ResponseData<?> removeSession(@Valid @RequestBody OnlineUserRequest onlineUserRequest) {
if (DemoConfigExpander.getDemoEnvFlag()) {
throw new DemoException(DemoExceptionEnum.DEMO_OPERATE);
}
sessionManagerApi.removeSession(onlineUserRequest.getToken());
return new SuccessResponseData();
return new SuccessResponseData<>();
}
}

View File

@ -56,9 +56,9 @@ public class PersonalInfoController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "个人信息_更新个人信息", path = "/sysUser/updateInfo", requiredPermission = false)
public ResponseData updateInfo(@RequestBody @Validated(SysUserRequest.updateInfo.class) SysUserRequest sysUserRequest) {
public ResponseData<?> updateInfo(@RequestBody @Validated(SysUserRequest.updateInfo.class) SysUserRequest sysUserRequest) {
sysUserService.editInfo(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -68,9 +68,9 @@ public class PersonalInfoController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "个人信息_修改密码", path = "/sysUser/updatePassword", requiredPermission = false)
public ResponseData updatePwd(@RequestBody @Validated(SysUserRequest.updatePwd.class) SysUserRequest sysUserRequest) {
public ResponseData<?> updatePwd(@RequestBody @Validated(SysUserRequest.updatePwd.class) SysUserRequest sysUserRequest) {
sysUserService.editPassword(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -80,9 +80,9 @@ public class PersonalInfoController {
* @date 2020/11/6 13:48
*/
@PostResource(name = "个人信息_修改头像", path = "/sysUser/updateAvatar", requiredPermission = false)
public ResponseData updateAvatar(@RequestBody @Validated(SysUserRequest.updateAvatar.class) SysUserRequest sysUserRequest) {
public ResponseData<?> updateAvatar(@RequestBody @Validated(SysUserRequest.updateAvatar.class) SysUserRequest sysUserRequest) {
sysUserService.editAvatar(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
}

View File

@ -26,6 +26,8 @@ package cn.stylefeng.roses.kernel.system.modular.user.controller;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
@ -35,6 +37,7 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.UserSelectTreeNode;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.SysUserRequest;
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
import org.springframework.validation.annotation.Validated;
@ -68,9 +71,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_增加", path = "/sysUser/add")
public ResponseData add(@RequestBody @Validated(BaseRequest.add.class) SysUserRequest sysUserRequest) {
public ResponseData<?> add(@RequestBody @Validated(BaseRequest.add.class) SysUserRequest sysUserRequest) {
sysUserService.add(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -80,9 +83,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_删除", path = "/sysUser/delete")
public ResponseData delete(@RequestBody @Validated(SysUserRequest.delete.class) SysUserRequest sysUserRequest) {
public ResponseData<?> delete(@RequestBody @Validated(SysUserRequest.delete.class) SysUserRequest sysUserRequest) {
sysUserService.del(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -92,9 +95,9 @@ public class SysUserController {
* @date 2021/4/7 16:12
*/
@PostResource(name = "系统用户_批量删除系统用户", path = "/sysUser/batchDelete")
public ResponseData batchDelete(@RequestBody @Validated(SysUserRequest.batchDelete.class) SysUserRequest sysUserRequest) {
public ResponseData<?> batchDelete(@RequestBody @Validated(SysUserRequest.batchDelete.class) SysUserRequest sysUserRequest) {
sysUserService.batchDelete(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -104,9 +107,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_编辑", path = "/sysUser/edit")
public ResponseData edit(@RequestBody @Validated(SysUserRequest.edit.class) SysUserRequest sysUserRequest) {
public ResponseData<?> edit(@RequestBody @Validated(SysUserRequest.edit.class) SysUserRequest sysUserRequest) {
sysUserService.edit(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -116,9 +119,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_修改状态", path = "/sysUser/changeStatus")
public ResponseData changeStatus(@RequestBody @Validated(SysUserRequest.changeStatus.class) SysUserRequest sysUserRequest) {
public ResponseData<?> changeStatus(@RequestBody @Validated(SysUserRequest.changeStatus.class) SysUserRequest sysUserRequest) {
sysUserService.editStatus(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -128,9 +131,9 @@ public class SysUserController {
* @date 2020/11/6 13:48
*/
@PostResource(name = "系统用户_重置密码", path = "/sysUser/resetPwd")
public ResponseData resetPwd(@RequestBody @Validated(SysUserRequest.resetPwd.class) SysUserRequest sysUserRequest) {
public ResponseData<?> resetPwd(@RequestBody @Validated(SysUserRequest.resetPwd.class) SysUserRequest sysUserRequest) {
sysUserService.resetPassword(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -140,9 +143,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_授权角色", path = "/sysUser/grantRole")
public ResponseData grantRole(@RequestBody @Validated(SysUserRequest.grantRole.class) SysUserRequest sysUserRequest) {
public ResponseData<?> grantRole(@RequestBody @Validated(SysUserRequest.grantRole.class) SysUserRequest sysUserRequest) {
sysUserService.grantRole(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -152,9 +155,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@PostResource(name = "系统用户_授权数据", path = "/sysUser/grantData")
public ResponseData grantData(@RequestBody @Validated(SysUserRequest.grantData.class) SysUserRequest sysUserRequest) {
public ResponseData<?> grantData(@RequestBody @Validated(SysUserRequest.grantData.class) SysUserRequest sysUserRequest) {
sysUserService.grantData(sysUserRequest);
return new SuccessResponseData();
return new SuccessResponseData<>();
}
/**
@ -163,9 +166,9 @@ public class SysUserController {
* @author luojie
* @date 2020/11/6 13:50
*/
@GetResource(name = "系统用户_查看", path = "/sysUser/detail", responseClass = SysUserDTO.class)
public ResponseData detail(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
return new SuccessResponseData(sysUserService.detail(sysUserRequest));
@GetResource(name = "系统用户_查看", path = "/sysUser/detail")
public ResponseData<SysUserDTO> detail(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
return new SuccessResponseData<>(sysUserService.detail(sysUserRequest));
}
/**
@ -174,13 +177,13 @@ public class SysUserController {
* @author fengshuonan
* @date 2021/1/1 19:01
*/
@GetResource(name = "获取当前登录用户的信息", path = "/sysUser/currentUserInfo", requiredPermission = false,responseClass = SysUserDTO.class)
public ResponseData currentUserInfo() {
@GetResource(name = "获取当前登录用户的信息", path = "/sysUser/currentUserInfo", requiredPermission = false)
public ResponseData<SysUserDTO> currentUserInfo() {
LoginUser loginUser = LoginContext.me().getLoginUser();
SysUserRequest sysUserRequest = new SysUserRequest();
sysUserRequest.setUserId(loginUser.getUserId());
return new SuccessResponseData(sysUserService.detail(sysUserRequest));
return new SuccessResponseData<>(sysUserService.detail(sysUserRequest));
}
/**
@ -189,9 +192,9 @@ public class SysUserController {
* @author luojie
* @date 2020/11/6 13:49
*/
@GetResource(name = "系统用户_查询", path = "/sysUser/page",responseClass = SysUserDTO.class)
public ResponseData page(SysUserRequest sysUserRequest) {
return new SuccessResponseData(sysUserService.findPage(sysUserRequest));
@GetResource(name = "系统用户_查询", path = "/sysUser/page")
public ResponseData<PageResult<SysUserDTO>> page(SysUserRequest sysUserRequest) {
return new SuccessResponseData<>(sysUserService.findPage(sysUserRequest));
}
/**
@ -211,9 +214,9 @@ public class SysUserController {
* @author liuhanqing
* @date 2021/1/15 8:28
*/
@GetResource(name = "获取用户选择树数据(用在系统通知,选择发送人的时候)", path = "/sysUser/getUserSelectTree",responseClass = UserSelectTreeNode.class)
public ResponseData getUserTree() {
return new SuccessResponseData(this.sysUserService.userSelectTree(new SysUserRequest()));
@GetResource(name = "获取用户选择树数据(用在系统通知,选择发送人的时候)", path = "/sysUser/getUserSelectTree")
public ResponseData<List<UserSelectTreeNode>> getUserTree() {
return new SuccessResponseData<>(this.sysUserService.userSelectTree(new SysUserRequest()));
}
/**
@ -223,9 +226,9 @@ public class SysUserController {
* @date 2020/11/6 13:51
*/
@GetResource(name = "系统用户_获取用户数据范围列表", path = "/sysUser/getUserDataScope")
public ResponseData ownData(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
public ResponseData<List<Long>> ownData(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
List<Long> userBindDataScope = sysUserService.getUserBindDataScope(sysUserRequest.getUserId());
return new SuccessResponseData(userBindDataScope);
return new SuccessResponseData<>(userBindDataScope);
}
/**
@ -235,9 +238,9 @@ public class SysUserController {
* @date 2020/11/6 13:50
*/
@GetResource(name = "系统用户_获取用户的角色列表", path = "/sysUser/getUserRoles")
public ResponseData ownRole(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
public ResponseData<List<SysUserRole>> ownRole(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
Long userId = sysUserRequest.getUserId();
return new SuccessResponseData(sysUserRoleService.findListByUserId(userId));
return new SuccessResponseData<>(sysUserRoleService.findListByUserId(userId));
}
/**
@ -249,8 +252,8 @@ public class SysUserController {
* @date 2020/11/6 09:49
*/
@GetResource(name = "系统用户_选择器", path = "/sysUser/selector")
public ResponseData selector(SysUserRequest sysUserRequest) {
return new SuccessResponseData(sysUserService.selector(sysUserRequest));
public ResponseData<List<SimpleDict>> selector(SysUserRequest sysUserRequest) {
return new SuccessResponseData<>(sysUserService.selector(sysUserRequest));
}
}