12
src/main/java/com/cool/core/annotation/EpsField.java
Normal file
12
src/main/java/com/cool/core/annotation/EpsField.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.cool.core.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EpsField {
|
||||
String component() default "input";
|
||||
}
|
||||
105
src/main/java/com/cool/core/enums/AdminComponentsEnum.java
Normal file
105
src/main/java/com/cool/core/enums/AdminComponentsEnum.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.cool.core.enums;
|
||||
|
||||
public class AdminComponentsEnum {
|
||||
|
||||
|
||||
/**
|
||||
* 省市区选择器 - 用户选择省市区
|
||||
*/
|
||||
public static final String PCA = "pca";
|
||||
|
||||
/**
|
||||
* 文本输入 - 文本编辑框
|
||||
*/
|
||||
public static final String INPUT = "input";
|
||||
|
||||
/**
|
||||
* 文本域 - 多行文本编辑框
|
||||
*/
|
||||
public static final String TEXTAREA = "textarea";
|
||||
|
||||
/**
|
||||
* 富文本编辑器 - 用于文章,商品详情的编辑
|
||||
*/
|
||||
public static final String EDITOR_RICH = "editor-rich";
|
||||
|
||||
/**
|
||||
* 代码编辑器 - 用于开发人员编写代码,支持多种语言,支持代码高亮,支持代码格式化
|
||||
*/
|
||||
public static final String CODING = "coding";
|
||||
|
||||
/**
|
||||
* 数字输入 - 数字输入编辑框
|
||||
*/
|
||||
public static final String INPUT_NUMBER = "input-number";
|
||||
|
||||
/**
|
||||
* 日期选择器 - 用户选择 年-月-日
|
||||
*/
|
||||
public static final String DATE = "date";
|
||||
|
||||
/**
|
||||
* 日期范围选择器 - 用户选择起始 年-月-日
|
||||
*/
|
||||
public static final String DATERANGE = "daterange";
|
||||
|
||||
/**
|
||||
* 时间选择器 - 用户选择 时:分:秒
|
||||
*/
|
||||
public static final String DATETIME = "datetime";
|
||||
|
||||
/**
|
||||
* 时间范围选择器 - 用户选择起始 年-月-日 时:分:秒
|
||||
*/
|
||||
public static final String DATETIMERANGE = "datetimerange";
|
||||
|
||||
/**
|
||||
* 单图上传 - 用户上传单张图片,如:头像、logo、封面
|
||||
*/
|
||||
public static final String UPLOAD_IMG = "upload-img";
|
||||
|
||||
/**
|
||||
* 多图上传 - 用户上传多张图片, 如:照片、图片
|
||||
*/
|
||||
public static final String UPLOAD_IMG_MULTIPLE = "upload-img-multiple";
|
||||
|
||||
/**
|
||||
* 单个文件上传 - 用户上传单个文件
|
||||
*/
|
||||
public static final String UPLOAD_FILE = "upload-file";
|
||||
|
||||
/**
|
||||
* 多个文件上传 - 用户上传多个文件
|
||||
*/
|
||||
public static final String UPLOAD_FILE_MULTIPLE = "upload-file-multiple";
|
||||
|
||||
/**
|
||||
* 状态选择器 - 用户开启或者关闭操作,如:是否启用、是否推荐、是否默认、置顶、启用禁用等
|
||||
*/
|
||||
public static final String SWITCH = "switch";
|
||||
|
||||
/**
|
||||
* 评分选择器 - 用户评分
|
||||
*/
|
||||
public static final String RATE = "rate";
|
||||
|
||||
/**
|
||||
* 滑块选择器 - 在一个固定区间内进行选择, 如:进度
|
||||
*/
|
||||
public static final String PROGRESS = "progress";
|
||||
|
||||
/**
|
||||
* 单选框 - 在一组备选项中进行单选,如:审批状态
|
||||
*/
|
||||
public static final String RADIO = "radio";
|
||||
|
||||
/**
|
||||
* 多选框 - 适用于选项比较少的情况,在一组备选项中进行多选, 如:学历、爱好等
|
||||
*/
|
||||
public static final String CHECKBOX = "checkbox";
|
||||
|
||||
/**
|
||||
* 下拉框 - 适用于当选项过多时,使用下拉菜单展示并选择内容,如:分类、标签等
|
||||
*/
|
||||
public static final String SELECT = "select";
|
||||
}
|
||||
13
src/main/java/com/cool/core/enums/Apis.java
Normal file
13
src/main/java/com/cool/core/enums/Apis.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.cool.core.enums;
|
||||
|
||||
public class Apis {
|
||||
public static final String ADD = "add";
|
||||
public static final String DELETE = "delete";
|
||||
public static final String UPDATE = "update";
|
||||
public static final String PAGE = "page";
|
||||
public static final String LIST = "list";
|
||||
public static final String INFO = "info";
|
||||
|
||||
|
||||
public static final String[] ALL_API = new String[]{ ADD, DELETE, UPDATE, PAGE, LIST, INFO };
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cool.core.annotation.EpsField;
|
||||
import com.cool.core.config.CustomOpenApiResource;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
@@ -43,6 +44,8 @@ public class CoolEps {
|
||||
private int serverPort;
|
||||
|
||||
private Dict entityInfo;
|
||||
|
||||
private Dict menuInfo;
|
||||
|
||||
private JSONObject swaggerInfo;
|
||||
|
||||
@@ -62,6 +65,7 @@ public class CoolEps {
|
||||
return;
|
||||
}
|
||||
entityInfo = Dict.create();
|
||||
menuInfo = Dict.create();
|
||||
swaggerInfo = swaggerInfo();
|
||||
Runnable task = () -> {
|
||||
entity();
|
||||
@@ -131,6 +135,7 @@ public class CoolEps {
|
||||
item.set("api", new ArrayList<Dict>());
|
||||
item.set("prefix", prefix);
|
||||
item.set("columns", entityInfo.get(entityName));
|
||||
item.set("menu", menuInfo.get( entityName ) );
|
||||
item.set("api", apis(prefix, methodPath, item.getBean("api")));
|
||||
urls.add(item);
|
||||
}
|
||||
@@ -285,6 +290,13 @@ public class CoolEps {
|
||||
Field[] fields = getAllDeclaredFields(e);
|
||||
List<Dict> columns = columns(fields);
|
||||
entityInfo.set(e.getSimpleName(), columns);
|
||||
|
||||
|
||||
Table mergedAnnotation = AnnotatedElementUtils.findMergedAnnotation(e, Table.class);
|
||||
|
||||
menuInfo.set(e.getSimpleName(), mergedAnnotation.comment());
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -324,8 +336,13 @@ public class CoolEps {
|
||||
List<Dict> dictList = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
Dict dict = Dict.create();
|
||||
ColumnDefine columnInfo = AnnotatedElementUtils.findMergedAnnotation(field,
|
||||
ColumnDefine.class);
|
||||
|
||||
EpsField epsField = AnnotatedElementUtils.findMergedAnnotation(field, EpsField.class);
|
||||
if (epsField != null) {
|
||||
dict.set("component", epsField.component());
|
||||
}
|
||||
|
||||
ColumnDefine columnInfo = AnnotatedElementUtils.findMergedAnnotation(field, ColumnDefine.class);
|
||||
if (columnInfo == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.enums.Apis;
|
||||
import com.cool.core.util.ConvertUtil;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -43,7 +44,7 @@ public class AutoPrefixUrlMapping extends RequestMappingHandlerMapping {
|
||||
* @return 是否需要构建路由
|
||||
*/
|
||||
private boolean checkApis(CoolRestController[] annotations, RequestMappingInfo info) {
|
||||
String[] apis = new String[] { "add", "delete", "update", "page", "list", "info" };
|
||||
String[] apis = Apis.ALL_API;
|
||||
if (info.getPathPatternsCondition() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ import com.cool.core.base.TenantEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Ignore;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
import org.dromara.autotable.annotation.enums.IndexTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(value = "base_sys_user", comment = "系统用户表")
|
||||
@@ -58,4 +62,11 @@ public class BaseSysUserEntity extends TenantEntity<BaseSysUserEntity> {
|
||||
|
||||
@ColumnDefine(comment = "socketId")
|
||||
private String socketId;
|
||||
|
||||
|
||||
@Ignore
|
||||
@Schema( description = "角色列表" )
|
||||
private List<Long> roleIdList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.cool.modules.base.mapper.sys.BaseSysRoleMenuMapper;
|
||||
import com.cool.modules.base.service.sys.BaseSysPermsService;
|
||||
import com.cool.modules.base.service.sys.BaseSysRoleService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -46,7 +48,7 @@ public class BaseSysRoleServiceImpl extends BaseServiceImpl<BaseSysRoleMapper, B
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object info(Long id) {
|
||||
public BaseSysRoleEntity info(Long id) {
|
||||
BaseSysRoleEntity roleEntity = getById(id);
|
||||
Long[] menuIdList = new Long[0];
|
||||
Long[] departmentIdList = new Long[0];
|
||||
@@ -60,8 +62,14 @@ public class BaseSysRoleServiceImpl extends BaseServiceImpl<BaseSysRoleMapper, B
|
||||
|
||||
departmentIdList = departmentEntities.stream().map(BaseSysRoleDepartmentEntity::getDepartmentId)
|
||||
.toArray(Long[]::new);
|
||||
|
||||
|
||||
roleEntity.setMenuIdList(Arrays.asList( menuIdList ));
|
||||
roleEntity.setDepartmentIdList(Arrays.asList(departmentIdList ));
|
||||
|
||||
}
|
||||
return Dict.parse(roleEntity).set("menuIdList", menuIdList).set("departmentIdList", departmentIdList);
|
||||
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.autotable.core.constants.DatabaseDialect;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*/
|
||||
@@ -171,13 +173,17 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object info(Long id) {
|
||||
public BaseSysUserEntity info(Long id) {
|
||||
BaseSysUserEntity userEntity = getById(id);
|
||||
Long[] roleIdList = baseSysPermsService.getRoles(id);
|
||||
BaseSysDepartmentEntity departmentEntity = baseSysDepartmentMapper.selectOneById(
|
||||
userEntity.getDepartmentId());
|
||||
userEntity.setPassword(null);
|
||||
return Dict.parse(userEntity).set("roleIdList", roleIdList).set("departmentName",
|
||||
departmentEntity != null ? departmentEntity.getName() : null);
|
||||
|
||||
|
||||
userEntity.setRoleIdList(List.of(roleIdList));
|
||||
userEntity.setDepartmentName(departmentEntity != null ? departmentEntity.getName() : userEntity.getDepartmentName() );
|
||||
|
||||
return userEntity;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,11 @@ springdoc:
|
||||
api-docs:
|
||||
#是否开启文档功能 本地为了配合eps功能不可关闭
|
||||
enabled: true
|
||||
group-configs:
|
||||
- group: app
|
||||
paths-to-match: /app/**
|
||||
- group: admin
|
||||
paths-to-match: /admin/**
|
||||
|
||||
# 设置日志级别
|
||||
logging:
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cool.modules.[(${module})].controller.[(${type})][(${subModule}?'.'+
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.base.BaseController;
|
||||
import com.cool.core.enums.Apis;
|
||||
import com.cool.modules.[(${module})].entity[(${subModule}?'.'+${subModule}:'')].[(${entity})]Entity;
|
||||
import com.cool.modules.[(${module})].service[(${subModule}?'.'+${subModule}:'')].[(${entity})]Service;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -12,7 +13,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
* [(${name})]
|
||||
*/
|
||||
@Tag(name = "[(${name})]", description = "[(${name})]")
|
||||
@CoolRestController(api = {"add", "delete", "update", "page", "list", "info"})
|
||||
@CoolRestController(api = {Apis.ADD, Apis.DELETE, Apis.UPDATE, Apis.PAGE, Apis.LIST, Apis.INFO})
|
||||
public class [(${upperType})][(${entity})]Controller extends BaseController<[(${entity})]Service, [(${entity})]Entity> {
|
||||
@Override
|
||||
protected void init(HttpServletRequest request, JSONObject requestParams) {
|
||||
|
||||
Reference in New Issue
Block a user