mirror of
https://github.com/cool-team-official/cool-admin-java.git
synced 2026-10-06 15:54:04 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14191d2720 | ||
|
|
1354b27010 | ||
|
|
f0f278c2e9 | ||
|
|
405472a9b2 | ||
|
|
91b26375ef | ||
|
|
24011ae9ae | ||
|
|
6c1f44a565 | ||
|
|
509e2f1f4d | ||
|
|
fc2a06d4b6 | ||
|
|
4c18020fd7 | ||
|
|
a39a4ea772 | ||
|
|
2d5bc7097d | ||
|
|
7fde7645d6 | ||
|
|
ee695de3de | ||
|
|
a990bba61d | ||
|
|
e21e5675f2 | ||
|
|
5d18f8bf0e | ||
|
|
2c2b9473a4 | ||
|
|
c86c52225a | ||
|
|
7e751ef07f | ||
|
|
7be1be932b | ||
|
|
c4f1df9774 | ||
|
|
94b2c45eb1 | ||
|
|
eab1b92be6 | ||
|
|
c0ff69011f | ||
|
|
bf8c6d711e | ||
|
|
f9767320d6 | ||
|
|
842a6e2383 | ||
|
|
98109e98d2 | ||
|
|
25a87cca86 | ||
|
|
77749e6c2e | ||
|
|
72e45dc2c7 |
+2
-2
@@ -5,10 +5,10 @@ FROM ghcr.io/graalvm/graalvm-ce:latest
|
||||
WORKDIR /app
|
||||
|
||||
# 将可执行的jar文件复制到容器内
|
||||
COPY target/cool-admin-7.1.0.jar /app/cool-admin-7.1.0.jar
|
||||
COPY target/cool-admin-8.0.0.jar /app/cool-admin-8.0.0.jar
|
||||
|
||||
# 暴露Spring Boot应用程序运行的端口
|
||||
EXPOSE 8001
|
||||
|
||||
# 运行Spring Boot应用程序的命令
|
||||
ENTRYPOINT ["java", "-jar", "/app/cool-admin-7.1.0.jar", "--spring.profiles.active=prod"]
|
||||
ENTRYPOINT ["java", "-jar", "/app/cool-admin-8.0.0.jar", "--spring.profiles.active=prod"]
|
||||
|
||||
@@ -19,12 +19,15 @@
|
||||
|
||||
Ai时代,很多老旧的框架已经无法满足现代化的开发需求,Cool-Admin开发了一系列的功能,让开发变得更简单、更快速、更高效。
|
||||
|
||||
- **Ai编码**:通过微调大模型学习框架特有写法,实现简单功能从Api接口到前端页面的一键生成
|
||||
- **流程编排**:通过拖拽编排方式,即可实现类似像智能客服这样的功能
|
||||
- **Ai编码**:通过微调大模型学习框架特有写法,实现简单功能从Api接口到前端页面的一键生成[详情](https://java.cool-admin.com/src/guide/ai.html)
|
||||
- **流程编排**:通过拖拽编排方式,即可实现类似像智能客服这样的功能[详情](https://cool-js.com/plugin/118)
|
||||
- **多租户**:支持多租户,采用全局动态注入查询条件[详情](https://java.cool-admin.com/src/guide/tenant.html)
|
||||
- **多语言**:基于大模型自动翻译,无需更改原有代码[详情](https://java.cool-admin.com/src/guide/i18n.html)
|
||||
- **模块化**:代码是模块化的,清晰明了,方便维护
|
||||
- **插件化**:插件化的设计,可以通过安装插件的方式扩展如:支付、短信、邮件等功能
|
||||
- **自动初始化**:数据自动化,无需再手动维护,启动时自动生成数据库表和表结构数据
|
||||
- **cool-admin-java-plus**: [cool-admin-java-plus](https://gitee.com/hlc4417/cool-admin-java-plus)
|
||||
- **cool-admin-java-plus**: [详情](https://gitee.com/hlc4417/cool-admin-java-plus)
|
||||
- ......
|
||||

|
||||
|
||||
## 地址
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
</parent>
|
||||
<groupId>com.cool</groupId>
|
||||
<artifactId>cool-admin</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<version>8.0.0</version>
|
||||
<name>cool-admin</name>
|
||||
<description>cool admin for java</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<lombok.version>1.18.34</lombok.version>
|
||||
<mybatis-flex.version>1.10.8</mybatis-flex.version>
|
||||
<mybatis-flex.ext.version>1.10.8.110</mybatis-flex.ext.version>
|
||||
<mybatis-flex.version>1.11.0</mybatis-flex.version>
|
||||
<mybatis-flex.ext.version>1.11.0.146</mybatis-flex.ext.version>
|
||||
<hutool.version>5.8.26</hutool.version>
|
||||
<ognl.version>3.3.2</ognl.version>
|
||||
<fastjson2.version>2.0.51</fastjson2.version>
|
||||
<springdoc-openapi.version>2.5.0</springdoc-openapi.version>
|
||||
<perf4j.version>0.9.16</perf4j.version>
|
||||
<weixin-java.version>4.6.3.B</weixin-java.version>
|
||||
<weixin-java.version>4.7.0</weixin-java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -84,7 +84,6 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.cool.core.annotation;
|
||||
|
||||
import org.dromara.autotable.annotation.ColumnComment;
|
||||
import org.dromara.autotable.annotation.ColumnDefault;
|
||||
import org.dromara.autotable.annotation.ColumnNotNull;
|
||||
import org.dromara.autotable.annotation.ColumnType;
|
||||
import org.dromara.autotable.annotation.enums.DefaultValueEnum;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
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)
|
||||
@Documented
|
||||
@ColumnType
|
||||
@ColumnNotNull
|
||||
@ColumnDefault
|
||||
@ColumnComment("")
|
||||
public @interface ColumnDefine {
|
||||
|
||||
/**
|
||||
* 字段类型:不填默认使用属性的数据类型进行转换,转换失败的字段不会添加
|
||||
*
|
||||
* @return 字段类型
|
||||
*/
|
||||
@AliasFor(annotation = ColumnType.class, attribute = "value")
|
||||
String type() default "";
|
||||
|
||||
/**
|
||||
* 字段长度,默认是-1,小于0相当于null
|
||||
*
|
||||
* @return 默认字段长度
|
||||
*/
|
||||
@AliasFor(annotation = ColumnType.class, attribute = "length")
|
||||
int length() default -1;
|
||||
|
||||
/**
|
||||
* 小数点长度,默认是-1,小于0相当于null
|
||||
*
|
||||
* @return 小数点长度
|
||||
*/
|
||||
@AliasFor(annotation = ColumnType.class, attribute = "decimalLength")
|
||||
int decimalLength() default -1;
|
||||
|
||||
/**
|
||||
* 是否为可以为null,true是可以,false是不可以,默认为true
|
||||
*
|
||||
* @return 是否为可以为null,true是不可以,false是可以,默认为false
|
||||
*/
|
||||
@AliasFor(annotation = ColumnNotNull.class, attribute = "value")
|
||||
boolean notNull() default false;
|
||||
|
||||
/**
|
||||
* 默认值,默认为null
|
||||
*
|
||||
* @return 默认值
|
||||
*/
|
||||
@AliasFor(annotation = ColumnDefault.class, attribute = "type")
|
||||
DefaultValueEnum defaultValueType() default DefaultValueEnum.UNDEFINED;
|
||||
|
||||
/**
|
||||
* 默认值,默认为null
|
||||
*
|
||||
* @return 默认值
|
||||
*/
|
||||
@AliasFor(annotation = ColumnDefault.class, attribute = "value")
|
||||
String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 数据表字段备注
|
||||
*
|
||||
* @return 默认值,默认为空
|
||||
*/
|
||||
@AliasFor(annotation = ColumnComment.class, attribute = "value")
|
||||
String comment() default "";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cool.core.annotation;
|
||||
|
||||
import com.cool.core.enums.AdminComponentsEnum;
|
||||
|
||||
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 AdminComponentsEnum.INPUT;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.cool.core.autotable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.dromara.autotable.annotation.ColumnType;
|
||||
import org.dromara.autotable.core.constants.DatabaseDialect;
|
||||
import org.dromara.autotable.core.converter.DatabaseTypeAndLength;
|
||||
import org.dromara.autotable.core.converter.JavaTypeToDatabaseTypeConverter;
|
||||
import org.dromara.autotable.core.strategy.pgsql.data.PgsqlDefaultTypeEnum;
|
||||
import org.dromara.autotable.core.utils.StringUtils;
|
||||
import org.dromara.autotable.core.utils.TableBeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CustomJavaTypeToDatabaseTypeConverter implements JavaTypeToDatabaseTypeConverter {
|
||||
|
||||
/**
|
||||
* 重新 java转数据库类型
|
||||
* 兼容 mybatisflex 不兼容 postgresql 的json类型问题
|
||||
*/
|
||||
@Override
|
||||
public DatabaseTypeAndLength convert(String databaseDialect, Class<?> clazz, Field field) {
|
||||
|
||||
ColumnType column = TableBeanUtils.getColumnType(field);
|
||||
// 设置了类型
|
||||
if (column != null) {
|
||||
String type = column.value();
|
||||
Integer length = column.length() > -1 ? column.length() : null;
|
||||
Integer decimalLength = column.decimalLength() > -1 ? column.decimalLength() : null;
|
||||
List<String> values = Arrays.asList(column.values());
|
||||
// 如果明确指定了类型名,直接替换
|
||||
if (StringUtils.hasText(type)) {
|
||||
if (DatabaseDialect.PostgreSQL.equals(databaseDialect) &&
|
||||
type.equalsIgnoreCase("json")) {
|
||||
// json 类型在 postgresql 处理成 text
|
||||
PgsqlDefaultTypeEnum typeEnum = PgsqlDefaultTypeEnum.TEXT;
|
||||
return new DatabaseTypeAndLength(typeEnum.getTypeName(), typeEnum.getDefaultLength(), typeEnum.getDefaultLength(), values);
|
||||
}
|
||||
return new DatabaseTypeAndLength(type, length, decimalLength, values);
|
||||
}
|
||||
// 如果没有指定明确的类型名,但是却指定了长度。那么使用默认类型+指定长度
|
||||
if (length != null || decimalLength != null) {
|
||||
DatabaseTypeAndLength typeAndLength = getDatabaseTypeAndLength(databaseDialect, clazz, field);
|
||||
typeAndLength.setLength(length);
|
||||
typeAndLength.setDecimalLength(decimalLength);
|
||||
return typeAndLength;
|
||||
}
|
||||
}
|
||||
// 其他情况,使用默认类型
|
||||
return getDatabaseTypeAndLength(databaseDialect, clazz, field);
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,11 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
|
||||
protected final String COOL_PAGE_OP = "COOL_PAGE_OP";
|
||||
protected final String COOL_LIST_OP = "COOL_LIST_OP";
|
||||
protected final String COOL_INFO_OP = "COOL_INFO_OP";
|
||||
|
||||
private final ThreadLocal<CrudOption<T>> pageOption = new ThreadLocal<>();
|
||||
private final ThreadLocal<CrudOption<T>> listOption = new ThreadLocal<>();
|
||||
private final ThreadLocal<CrudOption<T>> infoOption = new ThreadLocal<>();
|
||||
private final ThreadLocal<JSONObject> requestParams = new ThreadLocal<>();
|
||||
|
||||
@ModelAttribute
|
||||
@@ -61,16 +63,20 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
@RequestAttribute JSONObject requestParams) {
|
||||
String requestPath = ((ServletRequestAttributes) Objects.requireNonNull(
|
||||
RequestContextHolder.getRequestAttributes())).getRequest().getRequestURI();
|
||||
if (!requestPath.endsWith("/page") && !requestPath.endsWith("/list")) {
|
||||
if (!requestPath.endsWith("/page") && !requestPath.endsWith("/list")
|
||||
&& !requestPath.endsWith("/info")) {
|
||||
// 非page或list不执行
|
||||
return;
|
||||
}
|
||||
this.pageOption.set(new CrudOption<>(requestParams));
|
||||
this.listOption.set(new CrudOption<>(requestParams));
|
||||
this.infoOption.set(new CrudOption<>(requestParams));
|
||||
this.requestParams.set(requestParams);
|
||||
init(request, requestParams);
|
||||
request.setAttribute(COOL_PAGE_OP, this.pageOption.get());
|
||||
request.setAttribute(COOL_LIST_OP, this.listOption.get());
|
||||
request.setAttribute(COOL_INFO_OP, this.infoOption.get());
|
||||
|
||||
removeThreadLocal();
|
||||
}
|
||||
|
||||
@@ -87,6 +93,10 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
return new CrudOption<>(this.requestParams.get());
|
||||
}
|
||||
|
||||
public void setInfoOption(CrudOption<T> infoOption) {
|
||||
this.infoOption.set(infoOption);
|
||||
}
|
||||
|
||||
public void setListOption(CrudOption<T> listOption) {
|
||||
this.listOption.set(listOption);
|
||||
}
|
||||
@@ -109,7 +119,7 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
if (JSONUtil.isTypeJSONArray(body)) {
|
||||
JSONArray array = JSONUtil.parseArray(body);
|
||||
return R.ok(Dict.create()
|
||||
.set("ids", service.addBatch(requestParams, array.toList(currentEntityClass()))));
|
||||
.set("id", service.addBatch(requestParams, array.toList(currentEntityClass()))));
|
||||
} else {
|
||||
return R.ok(Dict.create().set("id",
|
||||
service.add(requestParams, requestParams.toBean(currentEntityClass()))));
|
||||
@@ -152,9 +162,13 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
*/
|
||||
@Operation(summary = "信息", description = "根据ID查询单个信息")
|
||||
@GetMapping("/info")
|
||||
protected R info(@RequestAttribute() JSONObject requestParams,
|
||||
@RequestParam() Long id) {
|
||||
return R.ok(service.info(requestParams, id));
|
||||
protected R<T> info(@RequestAttribute() JSONObject requestParams,
|
||||
@RequestParam() Long id,
|
||||
@RequestAttribute(COOL_INFO_OP) CrudOption<T> option) {
|
||||
invokerTransformParam(option, requestParams);
|
||||
T info = (T) service.info(requestParams, id);
|
||||
invokerTransformValue(option, info);
|
||||
return R.ok(info);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,15 +178,16 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
*/
|
||||
@Operation(summary = "查询", description = "查询多个信息")
|
||||
@PostMapping("/list")
|
||||
protected R list(@RequestAttribute() JSONObject requestParams,
|
||||
protected R<List<T>> list(@RequestAttribute() JSONObject requestParams,
|
||||
@RequestAttribute(COOL_LIST_OP) CrudOption<T> option) {
|
||||
invokerTransformParam(option, requestParams);
|
||||
QueryModeEnum queryModeEnum = option.getQueryModeEnum();
|
||||
List list = (List) switch (queryModeEnum) {
|
||||
case ENTITY_WITH_RELATIONS -> service.listWithRelations(requestParams, option.getQueryWrapper(currentEntityClass()));
|
||||
case CUSTOM -> transformList(service.list(requestParams, option.getQueryWrapper(currentEntityClass()), option.getAsType()), option.getAsType());
|
||||
default -> service.list(requestParams, option.getQueryWrapper(currentEntityClass()));
|
||||
};
|
||||
invokerTransform(option, list);
|
||||
invokerTransformValue(option, list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@@ -183,8 +198,9 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
*/
|
||||
@Operation(summary = "分页", description = "分页查询多个信息")
|
||||
@PostMapping("/page")
|
||||
protected R page(@RequestAttribute() JSONObject requestParams,
|
||||
protected R<PageResult<T>> page(@RequestAttribute() JSONObject requestParams,
|
||||
@RequestAttribute(COOL_PAGE_OP) CrudOption<T> option) {
|
||||
invokerTransformParam(option, requestParams);
|
||||
Integer page = requestParams.getInt("page", 1);
|
||||
Integer size = requestParams.getInt("size", 20);
|
||||
QueryModeEnum queryModeEnum = option.getQueryModeEnum();
|
||||
@@ -194,39 +210,41 @@ public abstract class BaseController<S extends BaseService<T>, T extends BaseEnt
|
||||
default -> service.page(requestParams, new Page<>(page, size), option.getQueryWrapper(currentEntityClass()));
|
||||
};
|
||||
Page pageResult = (Page) obj;
|
||||
invokerTransform(option, pageResult.getRecords());
|
||||
invokerTransformValue(option, pageResult.getRecords());
|
||||
return R.ok(pageResult(pageResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换参数,组装数据
|
||||
* 转换值,组装数据
|
||||
*/
|
||||
private void invokerTransform(CrudOption<T> option, Object obj) {
|
||||
if (ObjUtil.isNotEmpty(option.getTransform())) {
|
||||
private void invokerTransformValue(CrudOption<T> option, Object obj) {
|
||||
if (ObjUtil.isNotNull(option.getTransformValue())) {
|
||||
if (obj instanceof List) {
|
||||
((List)obj).forEach(o -> {
|
||||
option.getTransform().apply(o);
|
||||
option.getTransformValue().apply(o);
|
||||
});
|
||||
} else {
|
||||
option.getTransform().apply(obj);
|
||||
option.getTransformValue().apply(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换入参
|
||||
*/
|
||||
private void invokerTransformParam(CrudOption<T> option, JSONObject obj) {
|
||||
if (ObjUtil.isNotNull(option.getTransformParam())) {
|
||||
option.getTransformParam().apply(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页结果
|
||||
*
|
||||
* @param page 分页返回数据
|
||||
*/
|
||||
protected PageResult pageResult(Page page) {
|
||||
PageResult result = new PageResult();
|
||||
Map<String, Object> pagination = new HashMap<>();
|
||||
pagination.put("size", page.getPageSize());
|
||||
pagination.put("page", page.getPageNumber());
|
||||
pagination.put("total", page.getTotalRow());
|
||||
result.setList(page.getRecords());
|
||||
result.setPagination(pagination);
|
||||
return result;
|
||||
protected PageResult<T> pageResult(Page<T> page) {
|
||||
return PageResult.of(page);
|
||||
}
|
||||
|
||||
public Class<T> currentEntityClass() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.core.activerecord.Model;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.cool.core.base;
|
||||
|
||||
import com.mybatisflex.core.activerecord.Model;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
/** 租户ID实体类 */
|
||||
@Getter
|
||||
@Setter
|
||||
public class TenantEntity<T extends Model<T>> extends BaseEntity<T> {
|
||||
@Index
|
||||
@ColumnDefine(comment = "租户id")
|
||||
protected Long tenantId;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.cool.core.config;
|
||||
|
||||
import com.cool.core.tenant.CoolTenantFactory;
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.tenant.TenantFactory;
|
||||
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@@ -10,6 +14,14 @@ public class MyBatisFlexConfiguration implements MyBatisFlexCustomizer {
|
||||
@Override
|
||||
public void customize(FlexGlobalConfig globalConfig) {
|
||||
// 我们可以在这里进行一些列的初始化配置
|
||||
|
||||
// 指定多租户列的列名
|
||||
FlexGlobalConfig.getDefaultConfig().setTenantColumn("tenant_id");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "cool.multi-tenant.enable", havingValue = "true")
|
||||
public TenantFactory tenantFactory(){
|
||||
return new CoolTenantFactory();
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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,9 +10,11 @@ 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.annotation.TokenIgnore;
|
||||
import com.cool.core.config.CustomOpenApiResource;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -43,6 +45,8 @@ public class CoolEps {
|
||||
private int serverPort;
|
||||
|
||||
private Dict entityInfo;
|
||||
|
||||
private Dict menuInfo;
|
||||
|
||||
private JSONObject swaggerInfo;
|
||||
|
||||
@@ -62,6 +66,7 @@ public class CoolEps {
|
||||
return;
|
||||
}
|
||||
entityInfo = Dict.create();
|
||||
menuInfo = Dict.create();
|
||||
swaggerInfo = swaggerInfo();
|
||||
Runnable task = () -> {
|
||||
entity();
|
||||
@@ -86,25 +91,28 @@ public class CoolEps {
|
||||
private void urls() {
|
||||
Dict admin = Dict.create();
|
||||
Dict app = Dict.create();
|
||||
ArrayList<Object> emptyList = new ArrayList<>();
|
||||
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
|
||||
for (Map.Entry<RequestMappingInfo, HandlerMethod> methodEntry : map.entrySet()) {
|
||||
RequestMappingInfo info = methodEntry.getKey();
|
||||
HandlerMethod method = methodEntry.getValue();
|
||||
TokenIgnore tokenIgnore = method.getMethodAnnotation(TokenIgnore.class);
|
||||
String module = getModule(method);
|
||||
if (StrUtil.isNotEmpty(module)) {
|
||||
String entityName = getEntity(method.getBeanType());
|
||||
String methodPath = getMethodUrl(method);
|
||||
String escapedMethodPath = methodPath.replace("{", "\\{").replace("}", "\\}");
|
||||
String prefix = Objects.requireNonNull(getUrl(info))
|
||||
.replaceFirst("(?s)(.*)" + escapedMethodPath, "$1");
|
||||
Dict result = Dict.create();
|
||||
.replaceFirst("(?s)(.*)" + escapedMethodPath, "$1");
|
||||
Dict result;
|
||||
int type = 0;
|
||||
if (prefix.startsWith("/admin")) {
|
||||
result = admin;
|
||||
}
|
||||
if (prefix.startsWith("/app")) {
|
||||
} else if (prefix.startsWith("/app")) {
|
||||
result = app;
|
||||
type = 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (result.get(module) == null) {
|
||||
result.set(module, new ArrayList<Dict>());
|
||||
@@ -121,16 +129,24 @@ public class CoolEps {
|
||||
}
|
||||
});
|
||||
if (item != null) {
|
||||
item.set("api", apis(prefix, methodPath, item.getBean("api")));
|
||||
item.set("api", apis(prefix, methodPath, item.getBean("api"), tokenIgnore));
|
||||
} else {
|
||||
item = Dict.create();
|
||||
item.set("controller", method.getBeanType().getSimpleName());
|
||||
item.set("module", module);
|
||||
item.set("info", Dict.create().set("type",
|
||||
Dict.create()
|
||||
.set("name", getLastPathSegment(prefix))
|
||||
.set("description", "")
|
||||
));
|
||||
item.set("api", apis(prefix, methodPath, item.getBean("api"), tokenIgnore));
|
||||
item.set("name", entityName);
|
||||
item.set("api", new ArrayList<Dict>());
|
||||
item.set("prefix", prefix);
|
||||
item.set("columns", entityInfo.get(entityName));
|
||||
item.set("api", apis(prefix, methodPath, item.getBean("api")));
|
||||
item.set("pageQueryOp", Dict.create().set("keyWordLikeFields", emptyList)
|
||||
.set("fieldEq", emptyList)
|
||||
.set("fieldLike", emptyList));
|
||||
item.set("prefix", prefix);
|
||||
item.set("menu", menuInfo.get(entityName));
|
||||
urls.add(item);
|
||||
}
|
||||
if (type == 0) {
|
||||
@@ -146,6 +162,28 @@ public class CoolEps {
|
||||
this.app = app;
|
||||
|
||||
}
|
||||
/**
|
||||
* 提取URL路径中的最后一个路径段
|
||||
* 示例:输入 "/api/getData" 返回 "getData"
|
||||
*/
|
||||
private String getLastPathSegment(String url) {
|
||||
if (StrUtil.isBlank(url)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int queryIndex = url.indexOf('?');
|
||||
if (queryIndex != -1) {
|
||||
url = url.substring(0, queryIndex);
|
||||
}
|
||||
|
||||
int slashIndex = url.lastIndexOf('/');
|
||||
if (slashIndex != -1 && slashIndex < url.length() - 1) {
|
||||
return url.substring(slashIndex + 1);
|
||||
} else {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置所有的api
|
||||
@@ -155,13 +193,18 @@ public class CoolEps {
|
||||
* @param list api列表
|
||||
* @return api列表
|
||||
*/
|
||||
private List<Dict> apis(String prefix, String methodPath, List<Dict> list) {
|
||||
private List<Dict> apis(String prefix, String methodPath, List<Dict> list, TokenIgnore tokenIgnore) {
|
||||
if (ObjUtil.isNull(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
Dict item = Dict.create();
|
||||
item.set("method", "");
|
||||
item.set("path", methodPath);
|
||||
item.set("summary", "");
|
||||
item.set("tag", "");
|
||||
item.set("dts", new Object());
|
||||
item.set("dts", Dict.create());
|
||||
item.set("ignoreToken", false);
|
||||
if (tokenIgnore != null) {
|
||||
item.set("ignoreToken", true);
|
||||
}
|
||||
setSwaggerInfo(item, prefix + methodPath);
|
||||
list.add(item);
|
||||
return list;
|
||||
@@ -178,10 +221,8 @@ public class CoolEps {
|
||||
JSONObject urlInfo = paths.getJSONObject(url);
|
||||
String method = urlInfo.keySet().iterator().next();
|
||||
JSONObject methodInfo = urlInfo.getJSONObject(method);
|
||||
item.set("dts", methodInfo);
|
||||
item.set("method", method);
|
||||
item.set("summary", methodInfo.getStr("summary"));
|
||||
item.set("description", methodInfo.get("description"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,6 +325,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());
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -323,8 +371,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;
|
||||
}
|
||||
@@ -333,6 +386,7 @@ public class CoolEps {
|
||||
dict.set("propertyName", field.getName());
|
||||
dict.set("type", matchType(field.getType().getName()));
|
||||
dict.set("nullable", !columnInfo.notNull());
|
||||
dict.set("source", "a." + field.getName());
|
||||
dictList.add(dict);
|
||||
}
|
||||
return dictList;
|
||||
|
||||
@@ -21,10 +21,10 @@ public class CoolExceptionHandler {
|
||||
public R handleRRException(CoolException e) {
|
||||
R r = new R();
|
||||
if (ObjUtil.isNotEmpty(e.getData())) {
|
||||
r.put("data", e.getData());
|
||||
r.setData( e.getData() );
|
||||
} else {
|
||||
r.put("code", e.getCode());
|
||||
r.put("message", e.getMessage());
|
||||
r.setCode( e.getCode() );
|
||||
r.setMessage( e.getMessage() );
|
||||
}
|
||||
if (ObjUtil.isNotEmpty(e.getCause())) {
|
||||
log.error(e.getCause().getMessage(), e.getCause());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.cool.core.exception;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cool.core.request.R;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import lombok.Getter;
|
||||
@@ -57,6 +59,13 @@ public class CoolPreconditions {
|
||||
returnData(true, data);
|
||||
}
|
||||
|
||||
public static void returnNoData(Object object) {
|
||||
if (ObjectUtil.isEmpty(object)) {
|
||||
R r = R.ok();
|
||||
throw new CoolException(r.getMessage(), r.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象如果为空 就抛异常
|
||||
*/
|
||||
@@ -69,6 +78,7 @@ public class CoolPreconditions {
|
||||
}
|
||||
|
||||
private static String formatMessage(String messagePattern, Object... arguments) {
|
||||
messagePattern = I18nUtil.getI18nMsg(messagePattern);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int argumentIndex = 0;
|
||||
int placeholderIndex = messagePattern.indexOf("{}");
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.cool.core.i18n;
|
||||
|
||||
import static com.cool.core.util.I18nUtil.*;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cool.core.lock.CoolLock;
|
||||
import com.cool.core.util.CoolPluginInvokers;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.core.util.PathUtils;
|
||||
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
|
||||
import com.cool.modules.base.service.sys.BaseSysMenuService;
|
||||
import com.cool.modules.dict.entity.DictInfoEntity;
|
||||
import com.cool.modules.dict.entity.DictTypeEntity;
|
||||
import com.cool.modules.dict.service.DictInfoService;
|
||||
import com.cool.modules.dict.service.DictTypeService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class I18nGenerator {
|
||||
private final BaseSysMenuService baseSysMenuService;
|
||||
private final DictTypeService dictTypeService;
|
||||
private final DictInfoService dictInfoService;
|
||||
private final CoolLock coolLock;
|
||||
private final I18nUtil i18nUtil;
|
||||
|
||||
private List<String> languages;
|
||||
private static final Duration DURATION = Duration.ofSeconds(30);
|
||||
public void run(Map<String, Object> map) {
|
||||
log.info("国际化 翻译...");
|
||||
languages = (List<String>) map.getOrDefault("languages", List.of("zh-cn", "zh-tw", "en"));
|
||||
path = (String) map.getOrDefault("path", "assets/i18n");
|
||||
init();
|
||||
log.info("✅国际化 翻译 成功!!!");
|
||||
enable = true;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// 四个任务并发执行
|
||||
CompletableFuture<Void> futureMsg = CompletableFuture.runAsync(this::genBaseMsg);
|
||||
CompletableFuture<Void> futureMenu = CompletableFuture.runAsync(this::genBaseMenu);
|
||||
CompletableFuture<Void> futureDictInfo = CompletableFuture.runAsync(this::genBaseDictInfo);
|
||||
CompletableFuture<Void> futureDictType = CompletableFuture.runAsync(this::genBaseDictType);
|
||||
|
||||
// 等待全部执行完成
|
||||
CompletableFuture.allOf(futureMsg, futureMenu, futureDictInfo, futureDictType).join();
|
||||
}
|
||||
|
||||
private void genBaseMsg() {
|
||||
try {
|
||||
Map<String, String> msgMap = new HashMap<>();
|
||||
// 从idea本地启动时,从项目目录中读取
|
||||
Files.walk(Paths.get(System.getProperty("user.dir")))
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(path -> path.toString().endsWith(".java"))
|
||||
.filter(path -> !path.toString().contains("/target/") && !path.toString().contains("/.git/"))
|
||||
.forEach(path -> msgMap.putAll(processFile(path)));
|
||||
if (ObjUtil.isNotEmpty(msgMap)) {
|
||||
// 系统异常信息,输出到resources/i18n 文件夹下,只有本地运行会生成
|
||||
File msgfile = FileUtil.file(PathUtils.getUserDir(),
|
||||
"src", "main", "resources", "cool", "i18n", "msg", "template.json");
|
||||
// 确保父目录存在
|
||||
FileUtil.mkParentDirs(msgfile);
|
||||
// 写入内容
|
||||
FileUtil.writeUtf8String(JSONUtil.toJsonStr(msgMap), msgfile);
|
||||
} else {
|
||||
try {
|
||||
// jar启动时,从jar包中读取
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource resource = resolver.getResource("classpath:cool/i18n/msg/template.json");
|
||||
String content = FileUtil.readUtf8String(resource.getFile());
|
||||
msgMap.putAll(JSONUtil.toBean(content, Map.class));
|
||||
} catch (Exception e) {
|
||||
log.error("获取系统异常信息失败", e);
|
||||
}
|
||||
}
|
||||
extracted(MSG_PREFIX, msgMap);
|
||||
} catch (Exception e) {
|
||||
log.error("国际化系统异常信息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成菜单信息国际化
|
||||
*/
|
||||
@Async
|
||||
public void asyncGenBaseMenu() {
|
||||
if (coolLock.tryLock(MENU_PREFIX, DURATION)) {
|
||||
genBaseMenu();
|
||||
coolLock.unlock(MENU_PREFIX);
|
||||
}
|
||||
}
|
||||
private void genBaseMenu() {
|
||||
try {
|
||||
Map<String, String> menuMap = baseSysMenuService.list(QueryWrapper.create().select(BaseSysMenuEntity::getName))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
BaseSysMenuEntity::getName,
|
||||
BaseSysMenuEntity::getName,
|
||||
(oldValue, newValue) -> oldValue
|
||||
));
|
||||
extracted(MENU_PREFIX, menuMap);
|
||||
} catch (Exception e) {
|
||||
log.error("国际化菜单信息失败", e);
|
||||
}
|
||||
}
|
||||
@Async
|
||||
public void asyncGenBaseDictType() {
|
||||
if (coolLock.tryLock(DICT_TYPE_PREFIX, DURATION)) {
|
||||
genBaseDictType();
|
||||
coolLock.unlock(DICT_TYPE_PREFIX);
|
||||
}
|
||||
}
|
||||
private void genBaseDictType() {
|
||||
try {
|
||||
Map<String, String> dataMap = dictTypeService.list(QueryWrapper.create().select(DictTypeEntity::getName))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
DictTypeEntity::getName,
|
||||
DictTypeEntity::getName,
|
||||
(oldValue, newValue) -> oldValue
|
||||
));
|
||||
extracted(DICT_TYPE_PREFIX, dataMap);
|
||||
} catch (Exception e) {
|
||||
log.error("国际化字段类型信息失败", e);
|
||||
}
|
||||
}
|
||||
@Async
|
||||
public void asyncGenBaseDictInfo() {
|
||||
if (coolLock.tryLock(DICT_INFO_PREFIX, DURATION)) {
|
||||
genBaseDictInfo();
|
||||
coolLock.unlock(DICT_INFO_PREFIX);
|
||||
}
|
||||
}
|
||||
private void genBaseDictInfo() {
|
||||
try {
|
||||
Map<String, String> dataMap = dictInfoService.list(QueryWrapper.create().select(DictInfoEntity::getName))
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
DictInfoEntity::getName,
|
||||
DictInfoEntity::getName,
|
||||
(oldValue, newValue) -> oldValue
|
||||
));
|
||||
extracted(DICT_INFO_PREFIX, dataMap);
|
||||
} catch (Exception e) {
|
||||
log.error("国际化字段类型信息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void extracted(String prefix, Map<String, String> dataMap) {
|
||||
languages.forEach(language -> {
|
||||
String key = prefix + language;
|
||||
if (!i18nUtil.exist(key)) {
|
||||
JSONObject jsonObject = invokeTranslate(dataMap, language);
|
||||
if (ObjUtil.isNotNull(jsonObject)) {
|
||||
i18nUtil.update(key, jsonObject);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JSONObject invokeTranslate(Map<String, String> map, String language) {
|
||||
return (JSONObject) CoolPluginInvokers.invoke("i18n", "invokeTranslate", map, language);
|
||||
}
|
||||
|
||||
// 匹配 CoolPreconditions 抛异常语句中的中文字符串
|
||||
private static final Pattern EXCEPTION_PATTERN = Pattern.compile(
|
||||
"CoolPreconditions\\.(\\w+)\\s*\\([^;]*?\"([^\"]*[\u4e00-\u9fa5]+[^\"]*)\"", Pattern.MULTILINE
|
||||
);
|
||||
|
||||
private static Map<String, String> processFile(Path path) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
try {
|
||||
String content = Files.readString(path, StandardCharsets.UTF_8);
|
||||
// 去掉注释
|
||||
content = removeComments(content);
|
||||
|
||||
// 仅查找方法体内的 CoolPreconditions 调用
|
||||
Matcher matcher = EXCEPTION_PATTERN.matcher(content);
|
||||
while (matcher.find()) {
|
||||
String chineseText = matcher.group(2).trim();
|
||||
map.put(chineseText, chineseText);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// 移除注释(单行与多行)
|
||||
private static String removeComments(String code) {
|
||||
String noMultiLine = code.replaceAll("/\\*.*?\\*/", ""); // 多行注释
|
||||
return noMultiLine.replaceAll("//.*", ""); // 单行注释
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cool.core.init;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
@@ -8,12 +9,15 @@ import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cool.core.base.service.MapperProviderService;
|
||||
import com.cool.core.mybatis.pg.PostgresSequenceSyncService;
|
||||
import com.cool.core.util.DatabaseDialectUtils;
|
||||
import com.cool.core.util.EntityUtils;
|
||||
import com.cool.modules.base.entity.sys.BaseSysConfEntity;
|
||||
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
|
||||
import com.cool.modules.base.service.sys.BaseSysConfService;
|
||||
import com.cool.modules.base.service.sys.BaseSysMenuService;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -47,6 +51,8 @@ public class DBFromJsonInit {
|
||||
|
||||
final private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
final private PostgresSequenceSyncService postgresSequenceSyncService;
|
||||
|
||||
@Value("${cool.initData}")
|
||||
private boolean initData;
|
||||
|
||||
@@ -56,14 +62,24 @@ public class DBFromJsonInit {
|
||||
return;
|
||||
}
|
||||
// 初始化自定义的数据
|
||||
extractedDb();
|
||||
boolean initFlag = extractedDb();
|
||||
// 初始化菜单数据
|
||||
extractedMenu();
|
||||
initFlag = extractedMenu() || initFlag;
|
||||
// 发送数据库初始化完成事件
|
||||
eventPublisher.publishEvent(new DbInitCompleteEvent(this));
|
||||
if (initFlag) {
|
||||
// 如果是postgresql,同步序列
|
||||
syncIdentitySequences();
|
||||
}
|
||||
log.info("数据初始化完成!");
|
||||
}
|
||||
|
||||
private void syncIdentitySequences() {
|
||||
if (DatabaseDialectUtils.isPostgresql()) {
|
||||
postgresSequenceSyncService.syncIdentitySequences();
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DbInitCompleteEvent {
|
||||
private final Object source;
|
||||
@@ -77,21 +93,23 @@ public class DBFromJsonInit {
|
||||
/**
|
||||
* 解析插入业务数据
|
||||
*/
|
||||
private void extractedDb() {
|
||||
private boolean extractedDb() {
|
||||
try {
|
||||
// 加载 JSON 文件
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = resolver.getResources("classpath:cool/data/db/*.json");
|
||||
// 遍历所有.json文件
|
||||
analysisResources(resources);
|
||||
return analysisResources(resources);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to initialize data", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void analysisResources(Resource[] resources)
|
||||
private boolean analysisResources(Resource[] resources)
|
||||
throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
String prefix = "db_";
|
||||
boolean isInit = false;
|
||||
for (Resource resource : resources) {
|
||||
File resourceFile = new File(resource.getURL().getFile());
|
||||
String fileName = prefix + resourceFile.getName();
|
||||
@@ -110,8 +128,10 @@ public class DBFromJsonInit {
|
||||
baseSysUserEntity.setCValue("success");
|
||||
// 当前文件已加载
|
||||
baseSysConfService.add(baseSysUserEntity);
|
||||
isInit = true;
|
||||
log.info("{} 业务数据初始化成功...", fileName);
|
||||
}
|
||||
return isInit;
|
||||
}
|
||||
|
||||
private void analysisJson(JSONObject jsonObject)
|
||||
@@ -156,7 +176,8 @@ public class DBFromJsonInit {
|
||||
/**
|
||||
* 解析插入菜单数据
|
||||
*/
|
||||
public void extractedMenu() {
|
||||
public boolean extractedMenu() {
|
||||
boolean initFlag = false;
|
||||
try {
|
||||
String prefix = "menu_";
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
@@ -171,10 +192,12 @@ public class DBFromJsonInit {
|
||||
continue;
|
||||
}
|
||||
analysisResources(resource, fileName);
|
||||
initFlag = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to initialize data", e);
|
||||
}
|
||||
return initFlag;
|
||||
}
|
||||
|
||||
private void analysisResources(Resource resource, String fileName) throws IOException {
|
||||
@@ -204,7 +227,19 @@ public class DBFromJsonInit {
|
||||
menuEntity.setParentName(parentMenuEntity.getName());
|
||||
menuEntity.setParentId(parentMenuEntity.getId());
|
||||
}
|
||||
baseSysMenuService.add(menuEntity);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.eq(BaseSysMenuEntity::getName, menuEntity.getName());
|
||||
if (ObjUtil.isNull(menuEntity.getParentId())) {
|
||||
queryWrapper.isNull(BaseSysMenuEntity::getParentId);
|
||||
} else {
|
||||
queryWrapper.eq(BaseSysMenuEntity::getParentId, menuEntity.getParentId());
|
||||
}
|
||||
BaseSysMenuEntity dbBaseSysMenuEntity = baseSysMenuService.getOne(queryWrapper);
|
||||
if (ObjUtil.isNull(dbBaseSysMenuEntity)) {
|
||||
baseSysMenuService.add(menuEntity);
|
||||
} else {
|
||||
menuEntity = dbBaseSysMenuEntity;
|
||||
}
|
||||
// 递归处理子菜单
|
||||
JSONArray childMenus = jsonObj.getJSONArray("childMenus");
|
||||
if (childMenus != null) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.core.leaf.segment.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.UniIndex;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.cool.core.mybatis.handler;
|
||||
|
||||
import com.cool.core.util.DatabaseDialectUtils;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.postgresql.util.PGobject;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
public abstract class BaseJsonTypeHandler<T> extends BaseTypeHandler<T> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
|
||||
if (DatabaseDialectUtils.isPostgresql()) {
|
||||
PGobject jsonObject = new PGobject();
|
||||
jsonObject.setType("json");
|
||||
jsonObject.setValue(toJson(parameter));
|
||||
ps.setObject(i, jsonObject);
|
||||
} else {
|
||||
ps.setString(i, toJson(parameter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
final String json = rs.getString(columnName);
|
||||
return StringUtil.noText(json) ? null : parseJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
final String json = rs.getString(columnIndex);
|
||||
return StringUtil.noText(json) ? null : parseJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
final String json = cs.getString(columnIndex);
|
||||
return StringUtil.noText(json) ? null : parseJson(json);
|
||||
}
|
||||
|
||||
protected abstract T parseJson(String json);
|
||||
|
||||
protected abstract String toJson(T object);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.cool.core.mybatis.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
|
||||
public class Fastjson2TypeHandler extends BaseJsonTypeHandler<Object> {
|
||||
|
||||
private final Class<?> propertyType;
|
||||
private Class<?> genericType;
|
||||
private Type type;
|
||||
|
||||
private boolean supportAutoType = false;
|
||||
|
||||
public Fastjson2TypeHandler(Class<?> propertyType) {
|
||||
this.propertyType = propertyType;
|
||||
this.supportAutoType = propertyType.isInterface() || Modifier.isAbstract(propertyType.getModifiers());
|
||||
}
|
||||
|
||||
|
||||
public Fastjson2TypeHandler(Class<?> propertyType, Class<?> genericType) {
|
||||
this.propertyType = propertyType;
|
||||
this.genericType = genericType;
|
||||
this.type = TypeReference.collectionType((Class<? extends Collection>) propertyType, genericType);
|
||||
|
||||
Type actualTypeArgument = ((ParameterizedType) type).getActualTypeArguments()[0];
|
||||
if (actualTypeArgument instanceof Class) {
|
||||
this.supportAutoType = ((Class<?>) actualTypeArgument).isInterface()
|
||||
|| Modifier.isAbstract(((Class<?>) actualTypeArgument).getModifiers());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object parseJson(String json) {
|
||||
if (genericType != null && Collection.class.isAssignableFrom(propertyType)) {
|
||||
if (supportAutoType) {
|
||||
return JSON.parseArray(json, Object.class, JSONReader.Feature.SupportAutoType);
|
||||
} else {
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (supportAutoType) {
|
||||
return JSON.parseObject(json, Object.class, JSONReader.Feature.SupportAutoType);
|
||||
} else {
|
||||
return JSON.parseObject(json, propertyType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toJson(Object object) {
|
||||
if (supportAutoType) {
|
||||
return JSON.toJSONString(object
|
||||
, JSONWriter.Feature.WriteMapNullValue
|
||||
, JSONWriter.Feature.WriteNullListAsEmpty
|
||||
, JSONWriter.Feature.WriteNullStringAsEmpty, JSONWriter.Feature.WriteClassName
|
||||
);
|
||||
} else {
|
||||
return JSON.toJSONString(object
|
||||
, JSONWriter.Feature.WriteMapNullValue
|
||||
, JSONWriter.Feature.WriteNullListAsEmpty
|
||||
, JSONWriter.Feature.WriteNullStringAsEmpty
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.cool.core.mybatis.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mybatisflex.core.exception.FlexExceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
public class JacksonTypeHandler extends BaseJsonTypeHandler<Object> {
|
||||
|
||||
private static ObjectMapper objectMapper;
|
||||
private final Class<?> propertyType;
|
||||
private Class<?> genericType;
|
||||
private JavaType javaType;
|
||||
|
||||
public JacksonTypeHandler(Class<?> propertyType) {
|
||||
this.propertyType = propertyType;
|
||||
}
|
||||
|
||||
public JacksonTypeHandler(Class<?> propertyType, Class<?> genericType) {
|
||||
this.propertyType = propertyType;
|
||||
this.genericType = genericType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object parseJson(String json) {
|
||||
try {
|
||||
if (genericType != null && Collection.class.isAssignableFrom(propertyType)) {
|
||||
return getObjectMapper().readValue(json, getJavaType());
|
||||
} else {
|
||||
return getObjectMapper().readValue(json, propertyType);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw FlexExceptions.wrap(e, "Can not parseJson by JacksonTypeHandler: " + json);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toJson(Object object) {
|
||||
try {
|
||||
return getObjectMapper().writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw FlexExceptions.wrap(e, "Can not convert object to Json by JacksonTypeHandler: " + object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public JavaType getJavaType() {
|
||||
if (javaType == null){
|
||||
javaType = getObjectMapper().getTypeFactory().constructCollectionType((Class<? extends Collection>) propertyType, genericType);
|
||||
}
|
||||
return javaType;
|
||||
}
|
||||
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
if (null == objectMapper) {
|
||||
objectMapper = new ObjectMapper();
|
||||
}
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
public static void setObjectMapper(ObjectMapper objectMapper) {
|
||||
JacksonTypeHandler.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.cool.core.mybatis.pg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* PostgreSQL Identity 序列同步服务
|
||||
* 解决PostgreSQL 默认的序列机制,序列会自动递增,当手动插入指定id时需调用同步接口,否则id会重复。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PostgresSequenceSyncService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public PostgresSequenceSyncService(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public void syncIdentitySequences() {
|
||||
log.info("⏳ 开始同步 PostgreSQL Identity 序列...");
|
||||
|
||||
// 查询所有 identity 字段
|
||||
String identityColumnQuery = """
|
||||
SELECT table_schema, table_name, column_name
|
||||
FROM information_schema.columns
|
||||
WHERE is_identity = 'YES'
|
||||
AND table_schema = 'public'
|
||||
""";
|
||||
|
||||
List<Map<String, Object>> identityColumns = jdbcTemplate.queryForList(identityColumnQuery);
|
||||
|
||||
for (Map<String, Object> col : identityColumns) {
|
||||
String schema = (String) col.get("table_schema");
|
||||
String table = (String) col.get("table_name");
|
||||
String column = (String) col.get("column_name");
|
||||
|
||||
String fullTable = schema + "." + table;
|
||||
|
||||
// 获取对应的序列名
|
||||
String seqNameSql = "SELECT pg_get_serial_sequence(?, ?)";
|
||||
String seqName = jdbcTemplate.queryForObject(seqNameSql, String.class, fullTable, column);
|
||||
|
||||
if (seqName == null) {
|
||||
log.warn("⚠️ 无法获取序列:{}.{}", table, column);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取当前最大 ID
|
||||
Long maxId = jdbcTemplate.queryForObject(
|
||||
String.format("SELECT COALESCE(MAX(%s), 0) FROM %s", column, fullTable),
|
||||
Long.class
|
||||
);
|
||||
|
||||
if (maxId != null && maxId > 0) { // 正确的:setval 有返回值,必须用 queryForObject
|
||||
String setvalSql = "SELECT setval(?, ?)";
|
||||
Long newVal = jdbcTemplate.queryForObject(setvalSql, Long.class, seqName, maxId);
|
||||
log.info("✅ 同步序列 [{}] -> 当前最大 ID: {}", seqName, newVal);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("✅ PostgreSQL Identity 序列同步完成。");
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ package com.cool.core.plugin.consts;
|
||||
* 常量工具
|
||||
*/
|
||||
public interface PluginConsts {
|
||||
|
||||
/**
|
||||
* 国际化插件
|
||||
*/
|
||||
String i18n = "i18n";
|
||||
/**
|
||||
* 上传文件hook
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.cool.core.plugin.event;
|
||||
|
||||
public enum PluginActionEnum {
|
||||
INSTALL,
|
||||
UNINSTALL,
|
||||
UPDATE,
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cool.core.plugin.event;
|
||||
|
||||
import com.cool.modules.plugin.entity.PluginInfoEntity;
|
||||
import java.time.Clock;
|
||||
import lombok.Getter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class PluginEvent extends ApplicationEvent {
|
||||
@Getter
|
||||
private String key;
|
||||
@Getter
|
||||
private PluginActionEnum actionEnum;
|
||||
@Getter
|
||||
private PluginInfoEntity pluginInfoEntity;
|
||||
public PluginEvent(Object source, String key, PluginActionEnum actionEnum, PluginInfoEntity data) {
|
||||
super(source);
|
||||
this.key = key;
|
||||
this.actionEnum = actionEnum;
|
||||
this.pluginInfoEntity = data;
|
||||
}
|
||||
|
||||
public PluginEvent(Object source, Clock clock) {
|
||||
super(source, clock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.cool.core.plugin.event;
|
||||
|
||||
import static com.cool.core.plugin.consts.PluginConsts.i18n;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.cool.core.i18n.I18nGenerator;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.modules.plugin.entity.PluginInfoEntity;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PluginEventListener implements ApplicationListener<PluginEvent> {
|
||||
private final I18nGenerator i18nGenerator;
|
||||
private final I18nUtil i18nUtil;
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(PluginEvent event) {
|
||||
if (ObjUtil.equals(event.getKey(), i18n)) {
|
||||
// 国际化插件变更
|
||||
PluginActionEnum actionEnum = event.getActionEnum();
|
||||
PluginInfoEntity pluginInfoEntity = event.getPluginInfoEntity();
|
||||
|
||||
if (ObjUtil.equals(actionEnum, PluginActionEnum.INSTALL) && ObjUtil.equals(pluginInfoEntity.getStatus(), 1)) {
|
||||
// 安装插件后,如果插件状态为启用,则生成国际化文件
|
||||
i18nGenerator.run((Map<String, Object>) pluginInfoEntity.getConfig());
|
||||
} else if (ObjUtil.equals(actionEnum, PluginActionEnum.UPDATE)) {
|
||||
if (ObjUtil.equals(pluginInfoEntity.getStatus(), 1)) {
|
||||
// 更新插件配置
|
||||
i18nGenerator.run((Map<String, Object>) pluginInfoEntity.getConfig());
|
||||
} else {
|
||||
// 停用
|
||||
I18nUtil.enable = false;
|
||||
}
|
||||
} else if (ObjUtil.equals(actionEnum, PluginActionEnum.UNINSTALL)) {
|
||||
// 卸载国际化插件,则删除国际化文件
|
||||
i18nUtil.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.cool.core.plugin.event;
|
||||
|
||||
import com.cool.modules.plugin.entity.PluginInfoEntity;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PluginEventPublisher {
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
public void publish(String key, PluginActionEnum actionEnum, PluginInfoEntity data) {
|
||||
PluginEvent event = new PluginEvent(this, key, actionEnum, data);
|
||||
applicationEventPublisher.publishEvent(event);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import com.cool.core.config.PluginJson;
|
||||
import com.cool.core.exception.CoolException;
|
||||
import com.cool.core.exception.CoolPreconditions;
|
||||
import com.cool.core.plugin.config.DynamicJarClassLoader;
|
||||
import com.cool.core.plugin.event.PluginActionEnum;
|
||||
import com.cool.core.plugin.event.PluginEventPublisher;
|
||||
import com.cool.core.util.CoolPluginInvokers;
|
||||
import com.cool.core.util.MapExtUtil;
|
||||
import com.cool.core.util.PathUtils;
|
||||
@@ -24,6 +26,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.exceptions.PersistenceException;
|
||||
@@ -43,14 +46,15 @@ public class CoolPluginService {
|
||||
|
||||
final private PluginInfoService pluginInfoService;
|
||||
|
||||
final private PluginEventPublisher pluginEventPublisher;
|
||||
|
||||
@Value("${cool.plugin.path}")
|
||||
private String pluginPath;
|
||||
|
||||
public void init() {
|
||||
List<PluginInfoEntity> list = pluginInfoService
|
||||
.list(QueryWrapper
|
||||
.create().select(PluginInfoEntity::getId, PluginInfoEntity::getPluginJson,
|
||||
PluginInfoEntity::getKey, PluginInfoEntity::getName)
|
||||
.create()
|
||||
.eq(PluginInfoEntity::getStatus, 1));
|
||||
if (ObjUtil.isEmpty(list)) {
|
||||
log.info("没有可初始化的插件");
|
||||
@@ -77,6 +81,7 @@ public class CoolPluginService {
|
||||
dynamicJarLoaderService.install(pluginJson.getJarPath(), true);
|
||||
// 设置配置
|
||||
CoolPluginInvokers.setPluginJson(entity.getKey(), entity);
|
||||
pluginEventPublisher.publish(entity.getKey(), PluginActionEnum.INSTALL, entity);
|
||||
} catch (Exception e) {
|
||||
log.error("初始化{}插件失败", entity.getName(), e);
|
||||
} finally {
|
||||
@@ -100,9 +105,10 @@ public class CoolPluginService {
|
||||
PluginJson pluginJson = dynamicJarLoaderService.install(jarFilePath, force);
|
||||
key = pluginJson.getKey();
|
||||
// 保存插件信息入库
|
||||
savePluginInfo(pluginJson, jarFilePath, jarFile, force);
|
||||
PluginInfoEntity pluginInfoEntity = savePluginInfo(pluginJson, jarFilePath, jarFile, force);
|
||||
// 把 ApplicationContext 对象传递打插件类中,使其在插件中也能正常使用spring bean对象
|
||||
CoolPluginInvokers.setApplicationContext(pluginJson.getKey());
|
||||
pluginEventPublisher.publish(pluginJson.getKey(), PluginActionEnum.INSTALL, pluginInfoEntity);
|
||||
} catch (PersistenceException persistenceException) {
|
||||
extractedAfterErr(jarFile, key);
|
||||
if (persistenceException.getMessage().contains("Duplicate entry")) {
|
||||
@@ -165,13 +171,14 @@ public class CoolPluginService {
|
||||
boolean flag = pluginInfoEntity.removeById();
|
||||
if (flag) {
|
||||
FileUtil.del(pluginInfoEntity.getPluginJson().getJarPath());
|
||||
pluginEventPublisher.publish(pluginInfoEntity.getKey(), PluginActionEnum.UNINSTALL, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存插件信息
|
||||
*/
|
||||
private void savePluginInfo(PluginJson pluginJson, String jarFilePath ,
|
||||
private PluginInfoEntity savePluginInfo(PluginJson pluginJson, String jarFilePath ,
|
||||
File jarFile,
|
||||
boolean force) {
|
||||
CoolPreconditions.checkEmpty(pluginJson, "插件安装失败");
|
||||
@@ -186,9 +193,11 @@ public class CoolPluginService {
|
||||
closeSameNamePlugin(pluginJson);
|
||||
// 覆盖插件
|
||||
coverPlugin(pluginJson, pluginInfo);
|
||||
return;
|
||||
return pluginInfo;
|
||||
}
|
||||
pluginInfo.setStatus(1);
|
||||
pluginInfo.save();
|
||||
return pluginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +210,7 @@ public class CoolPluginService {
|
||||
String oldJarPath = one.getPluginJson().getJarPath();
|
||||
// 重新加载配置不更新
|
||||
pluginInfo.setConfig(one.getConfig());
|
||||
pluginInfo.getPluginJson().setConfig(one.getConfig());
|
||||
pluginInfo.getPluginJson().setConfig((Map<String, Object>) one.getConfig());
|
||||
// 设置插件配置
|
||||
CoolPluginInvokers.setPluginJson(pluginInfo.getKey(), pluginInfo);
|
||||
CopyOptions options = CopyOptions.create().setIgnoreNullValue(true);
|
||||
@@ -274,10 +283,11 @@ public class CoolPluginService {
|
||||
entity.getId());
|
||||
// 调用插件更新配置标识
|
||||
boolean invokePluginConfig = false;
|
||||
if (!MapExtUtil.compareMaps(entity.getConfig(), dbPluginInfoEntity.getConfig())) {
|
||||
if (!MapExtUtil.compareMaps((Map<String, Object>) entity.getConfig(),
|
||||
(Map<String, Object>) dbPluginInfoEntity.getConfig())) {
|
||||
// 不一致,说明更新了配置
|
||||
entity.setPluginJson(dbPluginInfoEntity.getPluginJson());
|
||||
entity.getPluginJson().setConfig(entity.getConfig());
|
||||
entity.getPluginJson().setConfig((Map<String, Object>) entity.getConfig());
|
||||
// 更新了配置, 且插件是开启状态
|
||||
invokePluginConfig = ObjUtil.equals(dbPluginInfoEntity.getStatus(), 1);
|
||||
}
|
||||
@@ -290,6 +300,8 @@ public class CoolPluginService {
|
||||
CoolPluginInvokers.setPluginJson(dbPluginInfoEntity.getKey(), entity);
|
||||
}
|
||||
pluginInfoService.update(entity);
|
||||
pluginEventPublisher.publish(dbPluginInfoEntity.getKey(), PluginActionEnum.UPDATE, pluginInfoService.getPluginInfoEntityById(
|
||||
entity.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.enums.QueryModeEnum;
|
||||
import com.cool.core.util.ConvertUtil;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.query.QueryCondition;
|
||||
@@ -37,12 +38,18 @@ public class CrudOption<T> {
|
||||
|
||||
private QueryModeEnum queryModeEnum;
|
||||
|
||||
private Transform<Object> transform;
|
||||
private TransformValue<Object> transformValue;
|
||||
|
||||
public interface Transform<B> {
|
||||
private TransformParam<JSONObject> transformParam;
|
||||
|
||||
public interface TransformValue<B> {
|
||||
void apply(B obj);
|
||||
}
|
||||
|
||||
public interface TransformParam<JSONObject> {
|
||||
void apply(JSONObject obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* queryModeEnum 为 CUSTOM,可设置 默认为Map
|
||||
*/
|
||||
@@ -97,7 +104,7 @@ public class CrudOption<T> {
|
||||
public CrudOption<T> queryModeEnum(QueryModeEnum queryModeEnum) {
|
||||
this.queryModeEnum = queryModeEnum;
|
||||
if (ObjUtil.equal(queryModeEnum, QueryModeEnum.CUSTOM)
|
||||
&& ObjUtil.isEmpty(asType)) {
|
||||
&& ObjUtil.isEmpty(asType)) {
|
||||
asType = Map.class;
|
||||
}
|
||||
return this;
|
||||
@@ -112,10 +119,27 @@ public class CrudOption<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换参数,组装数据
|
||||
* 转换值,组装数据
|
||||
*/
|
||||
public CrudOption<T> transform(Transform<Object> transform) {
|
||||
this.transform = transform;
|
||||
public CrudOption<T> transformValue(TransformValue<Object> transformValue) {
|
||||
this.transformValue = transformValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请使用 transformValue
|
||||
*/
|
||||
@Deprecated
|
||||
public CrudOption<T> transform(TransformValue<Object> transformValue) {
|
||||
this.transformValue = transformValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换入参
|
||||
*/
|
||||
public CrudOption<T> transformParam(TransformParam<JSONObject> transformParam) {
|
||||
this.transformParam = transformParam;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -127,32 +151,46 @@ public class CrudOption<T> {
|
||||
private QueryWrapper build(QueryWrapper queryWrapper, Class<T> entityClass) {
|
||||
if (ObjectUtil.isNotEmpty(fieldEq)) {
|
||||
Arrays.stream(fieldEq).toList().forEach(filed -> {
|
||||
Object obj = requestParams.get(StrUtil.toCamelCase(filed.getName()));
|
||||
String filedName = StrUtil.toCamelCase(filed.getName());
|
||||
Object obj = requestParams.get(filedName);
|
||||
if (ObjUtil.isEmpty(obj)) {
|
||||
return;
|
||||
}
|
||||
if (obj instanceof JSONArray) {
|
||||
// 集合
|
||||
queryWrapper.and(filed.in(((JSONArray)obj).toArray()));
|
||||
queryWrapper.and(filed.in(ConvertUtil.covertListByClass(filedName, (JSONArray)obj, entityClass).toArray()));
|
||||
} else {
|
||||
// 对象
|
||||
queryWrapper.and(filed.eq(obj));
|
||||
queryWrapper.and(filed.eq(ConvertUtil.convertByClass(filedName, obj, entityClass)));
|
||||
}
|
||||
});
|
||||
}
|
||||
Object keyWord = requestParams.get("keyWord");
|
||||
if (ObjectUtil.isNotEmpty(this.keyWordLikeFields) && ObjectUtil.isNotEmpty(keyWord)) {
|
||||
// 初始化一个空的 QueryCondition
|
||||
QueryCondition orCondition = null;
|
||||
for (QueryColumn queryColumn : keyWordLikeFields) {
|
||||
QueryCondition condition = queryColumn.like(keyWord);
|
||||
if (orCondition == null) {
|
||||
orCondition = condition;
|
||||
} else {
|
||||
orCondition = orCondition.or(condition);
|
||||
if (ObjectUtil.isNotEmpty(this.keyWordLikeFields)) {
|
||||
Object keyWord = requestParams.get("keyWord");
|
||||
if (ObjectUtil.isEmpty(keyWord)) {
|
||||
// // keyWord值为空,遍历keyWordLikeFields字段,根据queryColumn字段名构建查询条件
|
||||
for (QueryColumn queryColumn : keyWordLikeFields) {
|
||||
String fieldName = queryColumn.getName();
|
||||
String paramName = StrUtil.toCamelCase(fieldName);
|
||||
String paramValue = requestParams.getStr(paramName);
|
||||
if (ObjectUtil.isNotEmpty(paramValue)) {
|
||||
queryWrapper.and(queryColumn.like(paramValue));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// keyWord值非空,使用keyWord构建
|
||||
// 初始化一个空的 QueryCondition
|
||||
QueryCondition orCondition = null;
|
||||
for (QueryColumn queryColumn : keyWordLikeFields) {
|
||||
QueryCondition condition = queryColumn.like(keyWord);
|
||||
if (orCondition == null) {
|
||||
orCondition = condition;
|
||||
} else {
|
||||
orCondition = orCondition.or(condition);
|
||||
}
|
||||
}
|
||||
queryWrapper.and(orCondition);
|
||||
}
|
||||
queryWrapper.and(orCondition);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(select)) {
|
||||
queryWrapper.select(select);
|
||||
@@ -176,12 +214,12 @@ public class CrudOption<T> {
|
||||
tableAlias = queryTable.getName() + ".";
|
||||
}
|
||||
String order = requestParams.getStr("order",
|
||||
tableAnnotation.camelToUnderline() ? "create_time" : "createTime");
|
||||
tableAnnotation.camelToUnderline() ? "create_time" : "createTime");
|
||||
String sort = requestParams.getStr("sort", "desc");
|
||||
if (StrUtil.isNotEmpty(order) && StrUtil.isNotEmpty(sort)) {
|
||||
queryWrapper.orderBy(
|
||||
tableAlias + (tableAnnotation.camelToUnderline() ? StrUtil.toUnderlineCase(order) : order),
|
||||
sort.equals("asc"));
|
||||
tableAlias + (tableAnnotation.camelToUnderline() ? StrUtil.toUnderlineCase(order) : order),
|
||||
sort.equals("asc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,33 @@
|
||||
package com.cool.core.request;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageResult {
|
||||
private List<?> list;
|
||||
private Map<String, Object> pagination;
|
||||
@Schema( title = "分页数据模型" )
|
||||
public class PageResult<T> {
|
||||
@Schema( title = "分页数据" )
|
||||
private List<T> list;
|
||||
private Pagination pagination = new Pagination();
|
||||
|
||||
@Data
|
||||
public static class Pagination {
|
||||
@Schema( title = "页码" )
|
||||
private Long page;
|
||||
@Schema( title = "本页数量" )
|
||||
private Long size;
|
||||
@Schema( title = "总页数" )
|
||||
private Long total;
|
||||
}
|
||||
|
||||
static public <B> PageResult<B> of(Page<B> page ){
|
||||
PageResult<B> result = new PageResult<B>();
|
||||
result.setList(page.getRecords());
|
||||
result.pagination.setPage( page.getPageNumber() );
|
||||
result.pagination.setSize( page.getPageSize() );
|
||||
result.pagination.setTotal( page.getTotalRow() );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,36 @@
|
||||
package com.cool.core.request;
|
||||
|
||||
import java.util.HashMap;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
@Schema(title = "响应数据结构")
|
||||
@Data
|
||||
public class R<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@Schema(title = "编码:1000表示成功,其他值表示失败")
|
||||
private int code = 1000;
|
||||
|
||||
@Schema(title = "消息内容")
|
||||
private String message = "success";
|
||||
|
||||
@Schema(title = "响应数据")
|
||||
private T data;
|
||||
|
||||
public R() {
|
||||
put("code", 1000);
|
||||
put("message", "success");
|
||||
|
||||
}
|
||||
|
||||
public R( int code, String message, T data ) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static R error() {
|
||||
@@ -23,14 +43,14 @@ public class R extends HashMap<String, Object> {
|
||||
|
||||
public static R error(int code, String msg) {
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
r.put("message", msg);
|
||||
r.code = code;
|
||||
r.message = msg;
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R okMsg(String msg) {
|
||||
R r = new R();
|
||||
r.put("message", msg);
|
||||
r.message = msg;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -38,12 +58,17 @@ public class R extends HashMap<String, Object> {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public static R ok(Object data) {
|
||||
return new R().put("data", data);
|
||||
public static <B> R<B> ok(B data) {
|
||||
return new R<B>(1000 , "success", data);
|
||||
}
|
||||
|
||||
public R put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
|
||||
public R<T> put(String key, Object value) {
|
||||
switch (key) {
|
||||
case "code" -> this.code = (int) value;
|
||||
case "message" -> this.message = (String) value;
|
||||
case "data" -> this.data = (T) value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -31,12 +31,17 @@ public class RequestParamsFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
throws IOException, ServletException {
|
||||
// 防止流读取一次后就没有了, 所以需要将流继续写出去
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
JSONObject requestParams = new JSONObject();
|
||||
String language = request.getHeader("language");
|
||||
String coolEid = request.getHeader("cool-admin-eid");
|
||||
Long tenantId = StrUtil.isEmpty(coolEid) ? null : Long.parseLong(coolEid);
|
||||
if (StrUtil.isNotEmpty(request.getContentType()) && request.getContentType().contains("multipart/form-data")) {
|
||||
servletRequest.setAttribute("requestParams", requestParams);
|
||||
servletRequest.setAttribute("cool-language", language);
|
||||
servletRequest.setAttribute("tenantId", tenantId);
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} else {
|
||||
BodyReaderHttpServletRequestWrapper requestWrapper = new BodyReaderHttpServletRequestWrapper(request);
|
||||
@@ -45,38 +50,40 @@ public class RequestParamsFilter implements Filter {
|
||||
body)) {
|
||||
requestParams = JSONUtil.parseObj(body);
|
||||
}
|
||||
|
||||
// 登录状态,设置用户id
|
||||
setUserId(requestParams);
|
||||
|
||||
requestParams.set("body", body);
|
||||
requestParams.putAll(getAllRequestParam(request));
|
||||
|
||||
Object jwtObj = request.getAttribute("tokenInfo");
|
||||
if (jwtObj != null) {
|
||||
requestParams.set("tokenInfo", ((JWT) jwtObj).getPayload().getClaimsJson());
|
||||
}
|
||||
requestWrapper.setAttribute("requestParams", requestParams);
|
||||
// 登录状态,设置用户id
|
||||
Long currTenantId = setUserId(requestParams);
|
||||
if (ObjUtil.isNotNull(currTenantId)) {
|
||||
tenantId = currTenantId;
|
||||
}
|
||||
requestWrapper.setAttribute("cool-language", language);
|
||||
request.setAttribute("tenantId", tenantId);
|
||||
requestParams.set("body", body);
|
||||
requestParams.putAll(getAllRequestParam(request));
|
||||
|
||||
requestWrapper.setAttribute("requestParams", requestParams);
|
||||
filterChain.doFilter(requestWrapper, servletResponse);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUserId(JSONObject requestParams) {
|
||||
private Long setUserId(JSONObject requestParams) {
|
||||
UserTypeEnum userTypeEnum = CoolSecurityUtil.getCurrentUserType();
|
||||
switch (userTypeEnum) {
|
||||
// 只有登录了,才有用户类型, 不然为 UNKNOWN 状态
|
||||
case ADMIN -> {
|
||||
// 管理后台由于之前已经有逻辑再了,怕会影响到,如果自己有传了值不覆盖
|
||||
Object o = requestParams.get("userId");
|
||||
if (ObjUtil.isNotEmpty(o)) {
|
||||
return;
|
||||
if (ObjUtil.isNull(o)) {
|
||||
requestParams.set("userId", CoolSecurityUtil.getCurrentUserId());
|
||||
}
|
||||
requestParams.set("userId", CoolSecurityUtil.getCurrentUserId());
|
||||
}
|
||||
// app端,userId 为当前登录的用户id
|
||||
case APP -> requestParams.set("userId", CoolSecurityUtil.getCurrentUserId());
|
||||
}
|
||||
return CoolSecurityUtil.getTenantId(requestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cool.core.tenant;
|
||||
|
||||
import com.cool.core.util.TenantUtil;
|
||||
import com.mybatisflex.core.tenant.TenantFactory;
|
||||
|
||||
public class CoolTenantFactory implements TenantFactory {
|
||||
public Object[] getTenantIds(){
|
||||
Long tenantId = TenantUtil.getTenantId();
|
||||
if (tenantId == null) {
|
||||
return null;
|
||||
}
|
||||
return new Object[]{tenantId};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cool.core.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AutoTypeConverter {
|
||||
/**
|
||||
* 将字符串自动转换为数字或保留为字符串
|
||||
*
|
||||
* @param input 输入字符串
|
||||
* @return Integer / Long / String
|
||||
*/
|
||||
public static Serializable autoConvert(Object input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (NumberUtil.isInteger(input.toString())) {
|
||||
return Convert.convert(Integer.class, input);
|
||||
} else if (NumberUtil.isLong(input.toString())) {
|
||||
return Convert.convert(Long.class, input);
|
||||
} else {
|
||||
return (Serializable) input;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.cool.core.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -203,4 +200,58 @@ public class ConvertUtil {
|
||||
private static String[] splitCamelCase(String input) {
|
||||
return input.split("(?<=.)(?=[A-Z])");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将给定的字段值转换为可序列化的形式
|
||||
* 此方法旨在将一个对象的特定字段值转换为其相应的可序列化类型
|
||||
* 它在序列化和反序列化过程中特别有用,确保字段值可以被正确处理
|
||||
*
|
||||
* @param fieldName 字段名称,用于查找字段类型
|
||||
* @param fieldValue 待转换的字段值
|
||||
* @param clazz 包含该字段的类
|
||||
* @return 转换后的可序列化字段值,如果无法确定字段类型,则返回原始值
|
||||
*/
|
||||
public static Object convertByClass(String fieldName, Object fieldValue, Class<?> clazz) {
|
||||
// 检查输入参数是否为空,如果字段名或字段值为空,则直接返回字段值
|
||||
if (fieldName == null || fieldValue == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
// 获取字段类型
|
||||
Class<?> fieldType = getFieldType(clazz, fieldName);
|
||||
// 如果字段类型为空,则直接返回字段值
|
||||
if (fieldType == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
// 使用Convert类的convert方法将字段值转换为字段类型
|
||||
return Convert.convert(fieldType, fieldValue);
|
||||
}
|
||||
|
||||
public static List<Object> covertListByClass(String fieldName, List<Object> fieldValue, Class<?> clazz) {
|
||||
// 检查输入参数是否为空,如果字段名或字段值为空,则直接返回字段值
|
||||
if (fieldName == null || fieldValue == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
// 获取字段类型
|
||||
Class<?> fieldType = getFieldType(clazz, fieldName);
|
||||
// 如果字段类型为空,则直接返回字段值
|
||||
if (fieldType == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
return Collections.singletonList(Convert.toList(fieldType, fieldValue));
|
||||
}
|
||||
/**
|
||||
* 获取指定类中指定字段的类型
|
||||
*
|
||||
* @param clazz 目标类
|
||||
* @param fieldName 字段名称
|
||||
* @return 字段的类型 Class,如果字段不存在则返回 null
|
||||
*/
|
||||
public static Class<?> getFieldType(Class<?> clazz, String fieldName) {
|
||||
Field field = ReflectUtil.getField(clazz, fieldName);
|
||||
return field != null ? field.getType() : null;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,12 @@ public class CoolSecurityUtil {
|
||||
return SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
*/
|
||||
public static boolean isSuperAdmin() {
|
||||
return "admin".equals(getAdminUsername());
|
||||
}
|
||||
/**
|
||||
* 获得jwt中的信息
|
||||
*
|
||||
@@ -42,6 +48,14 @@ public class CoolSecurityUtil {
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
public static Long getTenantId(JSONObject requestParams) {
|
||||
JSONObject tokenInfo = requestParams.getJSONObject("tokenInfo");
|
||||
if (tokenInfo != null) {
|
||||
return tokenInfo.getLong("tenantId");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台账号退出登录
|
||||
*
|
||||
|
||||
@@ -12,16 +12,25 @@ import javax.sql.DataSource;
|
||||
public class DatabaseDialectUtils {
|
||||
private static String dialect;
|
||||
|
||||
public static String getDatabaseDialect() {
|
||||
public static String getDatabaseDialect(DataSource dataSource) {
|
||||
if (dialect == null) {
|
||||
dialect = determineDatabaseType();
|
||||
dialect = determineDatabaseType(dataSource);
|
||||
}
|
||||
return dialect;
|
||||
}
|
||||
|
||||
private static String determineDatabaseType() {
|
||||
// 从 DataSource 获取连接
|
||||
public static boolean isPostgresql() {
|
||||
DataSource dataSource = SpringContextUtils.getBean(DataSource.class);
|
||||
return DatabaseDialect.PostgreSQL.equals(getDatabaseDialect(dataSource));
|
||||
}
|
||||
|
||||
public static boolean isPostgresql(DataSource dataSource) {
|
||||
return DatabaseDialect.PostgreSQL.equals(getDatabaseDialect(dataSource));
|
||||
}
|
||||
|
||||
|
||||
private static String determineDatabaseType(DataSource dataSource) {
|
||||
// 从 DataSource 获取连接
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
// 获取元数据
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.cool.core.util;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class I18nUtil {
|
||||
|
||||
public static final String MSG_PREFIX = "msg_";
|
||||
public static final String MENU_PREFIX = "menu_";
|
||||
public static final String DICT_INFO_PREFIX = "dictInfo_";
|
||||
public static final String DICT_TYPE_PREFIX = "dictType_";
|
||||
|
||||
public static boolean enable = false;
|
||||
|
||||
public static String path;
|
||||
public static String getLanguage() {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null) {
|
||||
return null;
|
||||
}
|
||||
return (String) attributes.getAttribute("cool-language", RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
|
||||
private static final Map<String, JSONObject> data = new ConcurrentHashMap<>();
|
||||
|
||||
private void load(String key, File file) {
|
||||
try {
|
||||
String content = FileUtil.readUtf8String(file);
|
||||
data.put(key, JSONUtil.parseObj(content));
|
||||
} catch (Exception e) {
|
||||
log.error("读取国际化文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean exist(String name) {
|
||||
// 获取该目录下所有的 .json 文件
|
||||
List<File> jsonFiles = FileUtil.loopFiles(getPath(), file ->
|
||||
file.isFile() && file.getName().endsWith(".json")
|
||||
);
|
||||
AtomicReference<Boolean> flag = new AtomicReference<>(false);
|
||||
jsonFiles.forEach(file -> {
|
||||
String parentName = file.getParentFile().getName();
|
||||
String key = parentName + "_" + file.getName().replace(".json", "");
|
||||
if (key.equals(name)) {
|
||||
flag.set(true);
|
||||
// 加载
|
||||
load(key, file);
|
||||
}
|
||||
});
|
||||
return flag.get();
|
||||
}
|
||||
|
||||
public static String getI18nMenu(String name) {
|
||||
return getI18n(name, MENU_PREFIX);
|
||||
}
|
||||
|
||||
public static String getI18nMsg(String name) {
|
||||
return getI18n(name, MSG_PREFIX);
|
||||
}
|
||||
|
||||
public static String getI18nDictInfo(String name) {
|
||||
return getI18n(name, DICT_INFO_PREFIX);
|
||||
}
|
||||
public static String getI18nDictType(String name) {
|
||||
return getI18n(name, DICT_TYPE_PREFIX);
|
||||
}
|
||||
private static String getI18n(String name, String prefix) {
|
||||
if (!enable) {
|
||||
return name;
|
||||
}
|
||||
String language = I18nUtil.getLanguage();
|
||||
if (language == null) {
|
||||
return name;
|
||||
}
|
||||
JSONObject jsonObject = data.get(prefix + language);
|
||||
if (jsonObject == null) {
|
||||
return name;
|
||||
}
|
||||
String str = jsonObject.getStr(name);
|
||||
if (str == null) {
|
||||
return name;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public void update(String key, JSONObject object) {
|
||||
data.put(key, object);
|
||||
String[] split = key.split("_");
|
||||
String absolutePath = getPath();
|
||||
File file = FileUtil.file(absolutePath, split[0], split[1] + ".json");
|
||||
// 确保父目录存在
|
||||
FileUtil.mkParentDirs(file);
|
||||
// 写入内容
|
||||
FileUtil.writeUtf8String(JSONUtil.toJsonStr(object), file);
|
||||
}
|
||||
|
||||
private String getPath() {
|
||||
String absolutePath = path;
|
||||
if (!PathUtils.isAbsolutePath(absolutePath)) {
|
||||
absolutePath = PathUtils.getUserDir() + File.separator + absolutePath;
|
||||
}
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
data.clear();
|
||||
List<File> jsonFiles = FileUtil.loopFiles(getPath(), file ->
|
||||
file.isFile() && file.getName().endsWith(".json")
|
||||
);
|
||||
jsonFiles.forEach(File::delete);
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cool.core.util;
|
||||
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
public class TenantUtil {
|
||||
public static Long getTenantId() {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null) {
|
||||
return null;
|
||||
}
|
||||
return (Long) attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.cool.core.annotation.TokenIgnore;
|
||||
import com.cool.core.eps.CoolEps;
|
||||
import com.cool.core.file.FileUploadStrategyFactory;
|
||||
import com.cool.core.request.R;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
|
||||
import com.cool.modules.base.entity.sys.BaseSysUserEntity;
|
||||
import com.cool.modules.base.service.sys.BaseSysLoginService;
|
||||
import com.cool.modules.base.service.sys.BaseSysPermsService;
|
||||
@@ -14,6 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -67,7 +70,10 @@ public class AdminBaseCommController {
|
||||
@Operation(summary = "权限与菜单")
|
||||
@GetMapping("/permmenu")
|
||||
public R permmenu(@RequestAttribute() Long adminUserId) {
|
||||
return R.ok(baseSysPermsService.permmenu(adminUserId));
|
||||
Dict permmenu = baseSysPermsService.permmenu(adminUserId);
|
||||
List<BaseSysMenuEntity> list = (List<BaseSysMenuEntity>) permmenu.getObj("menus");
|
||||
list.forEach(o -> o.setName(I18nUtil.getI18nMenu(o.getName())));
|
||||
return R.ok(permmenu);
|
||||
}
|
||||
|
||||
@Operation(summary = "文件上传")
|
||||
|
||||
+10
@@ -4,7 +4,9 @@ import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.base.BaseController;
|
||||
import com.cool.core.exception.CoolPreconditions;
|
||||
import com.cool.core.request.CrudOption;
|
||||
import com.cool.core.request.R;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
|
||||
import com.cool.modules.base.service.sys.BaseSysMenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -25,6 +27,14 @@ public class AdminBaseSysMenuController extends
|
||||
|
||||
@Override
|
||||
protected void init(HttpServletRequest request, JSONObject requestParams) {
|
||||
CrudOption<BaseSysMenuEntity> transform = createOp()
|
||||
.transformValue(o -> {
|
||||
BaseSysMenuEntity entity = (BaseSysMenuEntity) o;
|
||||
entity.setName(I18nUtil.getI18nMenu(entity.getName()));
|
||||
});
|
||||
setPageOption(transform);
|
||||
setListOption(transform);
|
||||
setInfoOption(transform);
|
||||
}
|
||||
|
||||
@Operation(summary = "创建代码", description = "创建代码")
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cool.modules.base.entity.sys;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.cool.modules.base.entity.sys;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.handler.Fastjson2TypeHandler;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.mybatis.handler.Fastjson2TypeHandler;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cool.modules.base.entity.sys;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.cool.modules.base.entity.sys;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.handler.Fastjson2TypeHandler;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.mybatis.handler.Fastjson2TypeHandler;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.cool.core.base.TenantEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.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 = "系统用户表")
|
||||
public class BaseSysUserEntity extends BaseEntity<BaseSysUserEntity> {
|
||||
public class BaseSysUserEntity extends TenantEntity<BaseSysUserEntity> {
|
||||
@Index
|
||||
@ColumnDefine(comment = "部门ID", type = "bigint")
|
||||
private Long departmentId;
|
||||
@@ -58,4 +62,11 @@ public class BaseSysUserEntity extends BaseEntity<BaseSysUserEntity> {
|
||||
|
||||
@ColumnDefine(comment = "socketId")
|
||||
private String socketId;
|
||||
|
||||
|
||||
@Ignore
|
||||
@Schema( description = "角色列表" )
|
||||
private List<Long> roleIdList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.base.entity.sys;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.cool.modules.base.service.sys;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import com.cool.modules.base.entity.sys.BaseSysMenuEntity;
|
||||
import com.cool.modules.base.entity.sys.BaseSysUserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -88,6 +88,14 @@ public interface BaseSysPermsService {
|
||||
*/
|
||||
Long[] getDepartmentIdsByRoleIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 根据用户ID获得部门ID
|
||||
*
|
||||
* @param userId 角色ID数组
|
||||
* @return 部门ID数组
|
||||
*/
|
||||
Long[] getDepartmentIdsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获得部门ID
|
||||
*
|
||||
@@ -117,7 +125,7 @@ public interface BaseSysPermsService {
|
||||
* @param adminUserId 登录的用户
|
||||
* @return 权限菜单
|
||||
*/
|
||||
Object permmenu(Long adminUserId);
|
||||
Dict permmenu(Long adminUserId);
|
||||
|
||||
/**
|
||||
* 更新角色权限
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cool.modules.base.service.sys.impl;
|
||||
import com.cool.core.exception.CoolPreconditions;
|
||||
import com.cool.modules.base.dto.sys.CodeContentDto;
|
||||
import com.cool.modules.base.service.sys.BaseCodingService;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -11,11 +12,10 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BaseCodingServiceImpl implements BaseCodingService {
|
||||
@@ -69,6 +69,8 @@ public class BaseCodingServiceImpl implements BaseCodingService {
|
||||
}
|
||||
// 写入文件
|
||||
try (FileWriter writer = new FileWriter(filePath.toFile())) {
|
||||
formattedContent = formattedContent.replace("com.tangzc.mybatisflex.autotable.annotation.Index;",
|
||||
"org.dromara.autotable.annotation.Index;");
|
||||
writer.write(formattedContent);
|
||||
}
|
||||
list.add(filePath.toString());
|
||||
|
||||
@@ -122,6 +122,7 @@ public class BaseSysLoginServiceImpl implements BaseSysLoginService {
|
||||
.set("roleIds", roleIds)
|
||||
.set("username", baseSysUserEntity.getUsername())
|
||||
.set("userId", baseSysUserEntity.getId())
|
||||
.set("tenantId", baseSysUserEntity.getTenantId())
|
||||
.set("passwordVersion", baseSysUserEntity.getPasswordV());
|
||||
String token = jwtTokenUtil.generateToken(tokenInfo);
|
||||
if (StrUtil.isEmpty(refreshToken)) {
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.cool.modules.base.service.sys.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.CoolApplication;
|
||||
import com.cool.core.base.BaseServiceImpl;
|
||||
import com.cool.core.base.ModifyEnum;
|
||||
import com.cool.core.eps.CoolEps;
|
||||
import com.cool.core.i18n.I18nGenerator;
|
||||
import com.cool.core.util.CompilerUtils;
|
||||
import com.cool.core.util.CoolSecurityUtil;
|
||||
import com.cool.core.util.PathUtils;
|
||||
@@ -62,6 +64,9 @@ public class BaseSysMenuServiceImpl extends BaseServiceImpl<BaseSysMenuMapper, B
|
||||
baseSysPermsService.refreshPermsByMenuId(id);
|
||||
}
|
||||
}
|
||||
if (ModifyEnum.ADD.equals(type) || ModifyEnum.UPDATE.equals(type)) {
|
||||
SpringUtil.getBean(I18nGenerator.class).asyncGenBaseMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,6 +131,7 @@ public class BaseSysMenuServiceImpl extends BaseServiceImpl<BaseSysMenuMapper, B
|
||||
@Override
|
||||
public boolean importMenu(List<BaseSysMenuEntity> menus) {
|
||||
menus.forEach(this::importMenu);
|
||||
SpringUtil.getBean(I18nGenerator.class).asyncGenBaseMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,11 @@ public class BaseSysPermsServiceImpl implements BaseSysPermsService {
|
||||
return getLongs(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long[] getDepartmentIdsByUserId(Long userId) {
|
||||
return (Long[]) coolCache.get("admin:department:" + userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPermsCache(Long userId) {
|
||||
Object result = coolCache.get("admin:perms:" + userId);
|
||||
@@ -168,7 +173,7 @@ public class BaseSysPermsServiceImpl implements BaseSysPermsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object permmenu(Long adminUserId) {
|
||||
public Dict permmenu(Long adminUserId) {
|
||||
return Dict.create().set("menus", getMenus(adminUserId)).set("perms", getPerms(adminUserId));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,6 +6,8 @@ import static com.cool.modules.base.entity.sys.table.BaseSysUserEntityTableDef.B
|
||||
import static com.cool.modules.base.entity.sys.table.BaseSysUserRoleEntityTableDef.BASE_SYS_USER_ROLE_ENTITY;
|
||||
import static com.mybatisflex.core.query.QueryMethods.groupConcat;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -27,9 +29,11 @@ import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.autotable.core.constants.DatabaseDialect;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*/
|
||||
@@ -49,12 +53,18 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
|
||||
String keyWord = requestParams.getStr("keyWord");
|
||||
Integer status = requestParams.getInt("status");
|
||||
Long[] departmentIds = requestParams.get("departmentIds", Long[].class);
|
||||
JSONObject tokenInfo = CoolSecurityUtil.getAdminUserInfo(requestParams);
|
||||
// 用户的部门权限
|
||||
Long[] permsDepartmentArr = coolCache.get("admin:department:" + tokenInfo.get("userId"),
|
||||
Long[].class);
|
||||
String databaseDialect = DatabaseDialectUtils.getDatabaseDialect();
|
||||
if (databaseDialect.equals(DatabaseDialect.PostgreSQL)) {
|
||||
CoolPreconditions.checkEmpty(departmentIds);
|
||||
Collection<Long> intersectionDep = Convert.toList(Long.class, departmentIds);
|
||||
if (!CoolSecurityUtil.isSuperAdmin()) {
|
||||
// 用户的部门权限
|
||||
Long[] permsDepartmentArr = baseSysPermsService.getDepartmentIdsByUserId(CoolSecurityUtil.getCurrentUserId());
|
||||
CoolPreconditions.returnNoData(permsDepartmentArr);
|
||||
// 取交集
|
||||
intersectionDep = CollUtil.intersection(Convert.toList(Long.class, departmentIds), Convert.toList(Long.class, permsDepartmentArr));
|
||||
CoolPreconditions.returnNoData(intersectionDep);
|
||||
}
|
||||
|
||||
if (DatabaseDialectUtils.isPostgresql()) {
|
||||
// 兼容postgresql
|
||||
qw.select("base_sys_user.id","base_sys_user.create_time","base_sys_user.department_id",
|
||||
"base_sys_user.email","base_sys_user.head_img","base_sys_user.name","base_sys_user.nick_name",
|
||||
@@ -79,9 +89,6 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
|
||||
|
||||
// 不显示admin用户
|
||||
qw.and(BASE_SYS_USER_ENTITY.USERNAME.ne("admin"));
|
||||
// 筛选部门
|
||||
qw.and(BASE_SYS_USER_ENTITY.DEPARTMENT_ID.in(departmentIds,
|
||||
ArrayUtil.isNotEmpty(departmentIds)));
|
||||
// 筛选状态
|
||||
qw.and(BASE_SYS_USER_ENTITY.STATUS.eq(status, status != null));
|
||||
// 搜索关键字
|
||||
@@ -90,11 +97,8 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
|
||||
.or(BASE_SYS_USER_ENTITY.USERNAME.like(keyWord)));
|
||||
}
|
||||
// 过滤部门权限
|
||||
qw.and(BASE_SYS_USER_ENTITY.DEPARTMENT_ID.in(
|
||||
permsDepartmentArr == null || permsDepartmentArr.length == 0 ? new Long[]{null}
|
||||
: permsDepartmentArr,
|
||||
!CoolSecurityUtil.getAdminUsername().equals("admin")));
|
||||
if (databaseDialect.equals(DatabaseDialect.PostgreSQL)) {
|
||||
qw.and(BASE_SYS_USER_ENTITY.DEPARTMENT_ID.in(intersectionDep, ArrayUtil.isNotEmpty(intersectionDep)));
|
||||
if (DatabaseDialectUtils.isPostgresql()) {
|
||||
// 兼容postgresql
|
||||
qw.groupBy("base_sys_user.id","base_sys_user.create_time","base_sys_user.department_id",
|
||||
"base_sys_user.email","base_sys_user.head_img","base_sys_user.name","base_sys_user.nick_name",
|
||||
@@ -171,13 +175,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;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.annotation.TokenIgnore;
|
||||
import com.cool.core.base.BaseController;
|
||||
import com.cool.core.request.CrudOption;
|
||||
import com.cool.core.request.R;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.modules.dict.entity.DictInfoEntity;
|
||||
import com.cool.modules.dict.entity.table.DictInfoEntityTableDef;
|
||||
import com.cool.modules.dict.service.DictInfoService;
|
||||
@@ -26,8 +28,18 @@ public class AdminDictInfoController extends BaseController<DictInfoService, Dic
|
||||
@Override
|
||||
protected void init(HttpServletRequest request, JSONObject requestParams) {
|
||||
setListOption(createOp().fieldEq(DictInfoEntityTableDef.DICT_INFO_ENTITY.TYPE_ID)
|
||||
.keyWordLikeFields(DictInfoEntityTableDef.DICT_INFO_ENTITY.NAME)
|
||||
.queryWrapper(QueryWrapper.create().orderBy(DictInfoEntityTableDef.DICT_INFO_ENTITY.CREATE_TIME, false)));
|
||||
.keyWordLikeFields(DictInfoEntityTableDef.DICT_INFO_ENTITY.NAME)
|
||||
.queryWrapper(QueryWrapper.create().orderBy(DictInfoEntityTableDef.DICT_INFO_ENTITY.CREATE_TIME, false))
|
||||
.transformValue(o -> {
|
||||
DictInfoEntity entity = (DictInfoEntity) o;
|
||||
entity.setName(I18nUtil.getI18nDictInfo(entity.getName()));
|
||||
}));
|
||||
CrudOption<DictInfoEntity> transform = createOp().transformValue(o -> {
|
||||
DictInfoEntity entity = (DictInfoEntity) o;
|
||||
entity.setName(I18nUtil.getI18nDictInfo(entity.getName()));
|
||||
});
|
||||
setPageOption(transform);
|
||||
setInfoOption(transform);
|
||||
}
|
||||
|
||||
@Operation(summary = "获得字典数据", description = "获得字典数据信息")
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.cool.modules.dict.controller.admin;
|
||||
|
||||
import static com.cool.modules.dict.entity.table.DictTypeEntityTableDef.DICT_TYPE_ENTITY;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.base.BaseController;
|
||||
import com.cool.core.request.CrudOption;
|
||||
import com.cool.core.util.I18nUtil;
|
||||
import com.cool.modules.dict.entity.DictTypeEntity;
|
||||
import com.cool.modules.dict.service.DictTypeService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import static com.cool.modules.dict.entity.table.DictTypeEntityTableDef.DICT_TYPE_ENTITY;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@@ -20,6 +22,15 @@ public class AdminDictTypeController extends BaseController<DictTypeService, Dic
|
||||
@Override
|
||||
protected void init(HttpServletRequest request, JSONObject requestParams) {
|
||||
setPageOption(
|
||||
createOp().select(DICT_TYPE_ENTITY.ID, DICT_TYPE_ENTITY.KEY, DICT_TYPE_ENTITY.NAME));
|
||||
createOp().select(DICT_TYPE_ENTITY.ID, DICT_TYPE_ENTITY.KEY, DICT_TYPE_ENTITY.NAME).transformValue(o -> {
|
||||
DictTypeEntity entity = (DictTypeEntity) o;
|
||||
entity.setName(I18nUtil.getI18nDictType(entity.getName()));
|
||||
}));
|
||||
CrudOption<DictTypeEntity> transform = createOp().transformValue(o -> {
|
||||
DictTypeEntity entity = (DictTypeEntity) o;
|
||||
entity.setName(I18nUtil.getI18nDictType(entity.getName()));
|
||||
});
|
||||
setPageOption(transform);
|
||||
setInfoOption(transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cool.modules.dict.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.dict.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.UniIndex;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -8,7 +8,11 @@ import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.base.BaseServiceImpl;
|
||||
import com.cool.core.base.ModifyEnum;
|
||||
import com.cool.core.i18n.I18nGenerator;
|
||||
import com.cool.modules.dict.entity.DictInfoEntity;
|
||||
import com.cool.modules.dict.entity.DictTypeEntity;
|
||||
import com.cool.modules.dict.mapper.DictInfoMapper;
|
||||
@@ -121,4 +125,10 @@ public class DictInfoServiceImpl extends BaseServiceImpl<DictInfoMapper, DictInf
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void modifyAfter(JSONObject requestParams, DictInfoEntity entity, ModifyEnum type) {
|
||||
if (ModifyEnum.ADD.equals(type) || ModifyEnum.UPDATE.equals(type)) {
|
||||
SpringUtil.getBean(I18nGenerator.class).asyncGenBaseDictInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,11 @@ package com.cool.modules.dict.service.impl;
|
||||
import static com.cool.modules.dict.entity.table.DictInfoEntityTableDef.DICT_INFO_ENTITY;
|
||||
import static com.cool.modules.dict.entity.table.DictTypeEntityTableDef.DICT_TYPE_ENTITY;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.cool.core.base.BaseServiceImpl;
|
||||
import com.cool.core.base.ModifyEnum;
|
||||
import com.cool.core.i18n.I18nGenerator;
|
||||
import com.cool.modules.dict.entity.DictTypeEntity;
|
||||
import com.cool.modules.dict.mapper.DictInfoMapper;
|
||||
import com.cool.modules.dict.mapper.DictTypeMapper;
|
||||
@@ -36,4 +40,11 @@ public class DictTypeServiceImpl extends BaseServiceImpl<DictTypeMapper, DictTyp
|
||||
return dictInfoMapper.deleteByQuery(
|
||||
QueryWrapper.create().and(DICT_INFO_ENTITY.TYPE_ID.in((Object) ids))) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyBefore(JSONObject requestParams, DictTypeEntity t, ModifyEnum type) {
|
||||
if (ModifyEnum.ADD.equals(type) || ModifyEnum.UPDATE.equals(type)) {
|
||||
SpringUtil.getBean(I18nGenerator.class).asyncGenBaseDictType();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ package com.cool.modules.plugin.controller.admin;
|
||||
import static com.cool.modules.plugin.entity.table.PluginInfoEntityTableDef.PLUGIN_INFO_ENTITY;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cool.core.annotation.CoolRestController;
|
||||
import com.cool.core.annotation.IgnoreRecycleData;
|
||||
import com.cool.core.base.BaseController;
|
||||
@@ -16,6 +18,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -45,6 +48,11 @@ public class AdminPluginInfoController extends BaseController<PluginInfoService,
|
||||
@PostMapping("/update")
|
||||
protected R update(@RequestBody PluginInfoEntity t,
|
||||
@RequestAttribute() JSONObject requestParams) {
|
||||
if (ObjUtil.isNotEmpty(t.getConfig())) {
|
||||
t.setConfig(JSONUtil.parseObj(t.getConfig()));
|
||||
} else {
|
||||
t.setConfig(new HashMap<>());
|
||||
}
|
||||
coolPluginService.updatePlugin(t);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ import com.cool.core.base.BaseEntity;
|
||||
import com.cool.core.config.PluginJson;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.handler.Fastjson2TypeHandler;
|
||||
import com.mybatisflex.core.handler.JacksonTypeHandler;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.mybatis.handler.Fastjson2TypeHandler;
|
||||
import com.cool.core.mybatis.handler.JacksonTypeHandler;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.UniIndex;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Ignore;
|
||||
@@ -54,7 +53,7 @@ public class PluginInfoEntity extends BaseEntity<PluginInfoEntity> {
|
||||
|
||||
@ColumnDefine(comment = "配置", type = "json")
|
||||
@Column(typeHandler = JacksonTypeHandler.class)
|
||||
private Map<String, Object> config;
|
||||
private Object config;
|
||||
|
||||
@Ignore
|
||||
@Column(ignore = true)
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.cool.modules.recycle.entity;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.handler.Fastjson2TypeHandler;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.mybatis.handler.Fastjson2TypeHandler;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cool.modules.space.entity;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Ignore;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.space.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cool.modules.task.entity;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import java.util.Date;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.cool.modules.task.entity;
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.cool.core.util.AutoTypeConverter;
|
||||
import com.cool.modules.task.entity.TaskInfoEntity;
|
||||
import com.cool.modules.task.entity.TaskLogEntity;
|
||||
import com.cool.modules.task.service.TaskInfoLogService;
|
||||
@@ -36,7 +37,7 @@ public class ScheduleJob extends QuartzJobBean {
|
||||
Scheduler scheduler = SpringUtil.getBean(Scheduler.class);
|
||||
|
||||
TaskInfoEntity taskInfoEntity = taskInfoService
|
||||
.getById(context.getJobDetail().getKey().getName().split("_")[1]);
|
||||
.getById(AutoTypeConverter.autoConvert(context.getJobDetail().getKey().getName().split("_")[1]));
|
||||
if (ObjUtil.isEmpty(taskInfoEntity)) {
|
||||
log.warn("taskInfoEntity is null");
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.user.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.autotable.annotation.Index;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.user.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.UniIndex;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cool.modules.user.entity;
|
||||
|
||||
import com.cool.core.base.BaseEntity;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
|
||||
import com.cool.core.annotation.ColumnDefine;
|
||||
import com.tangzc.mybatisflex.autotable.annotation.UniIndex;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
-144
@@ -1,144 +0,0 @@
|
||||
package org.dromara.autotable.core.strategy.mysql.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.autotable.annotation.enums.IndexTypeEnum;
|
||||
import org.dromara.autotable.core.strategy.IndexMetadata;
|
||||
import org.dromara.autotable.core.strategy.mysql.data.MysqlColumnMetadata;
|
||||
import org.dromara.autotable.core.strategy.mysql.data.MysqlTableMetadata;
|
||||
import org.dromara.autotable.core.utils.StringConnectHelper;
|
||||
import org.dromara.autotable.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* @author don
|
||||
* 临时解决:https://gitee.com/dromara/auto-table/issues/IBPYHU
|
||||
*/
|
||||
@Slf4j
|
||||
public class CreateTableSqlBuilder {
|
||||
|
||||
/**
|
||||
* 构建创建新表的SQL
|
||||
*
|
||||
* @param mysqlTableMetadata 参数
|
||||
* @return sql
|
||||
*/
|
||||
public static String buildSql(MysqlTableMetadata mysqlTableMetadata) {
|
||||
|
||||
String name = mysqlTableMetadata.getTableName();
|
||||
List<MysqlColumnMetadata> mysqlColumnMetadataList = mysqlTableMetadata.getColumnMetadataList();
|
||||
List<IndexMetadata> indexMetadataList = mysqlTableMetadata.getIndexMetadataList();
|
||||
String collate = mysqlTableMetadata.getCollate();
|
||||
String engine = mysqlTableMetadata.getEngine();
|
||||
String characterSet = mysqlTableMetadata.getCharacterSet();
|
||||
String comment = mysqlTableMetadata.getComment();
|
||||
|
||||
// 记录所有修改项,(利用数组结构,便于添加,分割)
|
||||
List<String> addItems = new ArrayList<>();
|
||||
|
||||
// 获取所有主键(至于表字段处理之前,为了主键修改notnull)
|
||||
List<String> primaries = new ArrayList<>();
|
||||
mysqlColumnMetadataList.forEach(columnData -> {
|
||||
// 判断是主键,自动设置为NOT NULL,并记录
|
||||
if (columnData.isPrimary()) {
|
||||
columnData.setNotNull(true);
|
||||
primaries.add(columnData.getName());
|
||||
}
|
||||
});
|
||||
|
||||
// 表字段处理
|
||||
addItems.add(
|
||||
mysqlColumnMetadataList.stream()
|
||||
.sorted(Comparator.comparingInt(MysqlColumnMetadata::getPosition))
|
||||
// 拼接每个字段的sql片段
|
||||
.map(ColumnSqlBuilder::buildSql)
|
||||
.collect(Collectors.joining(","))
|
||||
);
|
||||
|
||||
|
||||
// 主键
|
||||
if (!primaries.isEmpty()) {
|
||||
String primaryKeySql = getPrimaryKeySql(primaries);
|
||||
addItems.add(primaryKeySql);
|
||||
}
|
||||
|
||||
// 索引
|
||||
addItems.add(
|
||||
indexMetadataList.stream()
|
||||
// 例子: UNIQUE INDEX `unique_name_age`(`name` ASC, `age` DESC) COMMENT '姓名、年龄索引' USING BTREE
|
||||
.map(CreateTableSqlBuilder::getIndexSql)
|
||||
// 同类型的索引,排在一起,SQL美化
|
||||
.sorted()
|
||||
.collect(Collectors.joining(","))
|
||||
);
|
||||
|
||||
List<String> tableProperties = getTableProperties(engine, characterSet, collate, comment);
|
||||
|
||||
// 组合sql: 过滤空字符项,逗号拼接
|
||||
String addSql = addItems.stream()
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.joining(","));
|
||||
String propertiesSql = tableProperties.stream()
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
return "CREATE TABLE `{tableName}` ({addItems}) {tableProperties};"
|
||||
.replace("{tableName}", name)
|
||||
.replace("{addItems}", addSql)
|
||||
.replace("{tableProperties}", propertiesSql);
|
||||
}
|
||||
|
||||
public static List<String> getTableProperties(String engine, String characterSet, String collate, String comment) {
|
||||
List<String> tableProperties = new ArrayList<>();
|
||||
|
||||
// 引擎
|
||||
if (StringUtils.hasText(engine)) {
|
||||
tableProperties.add("ENGINE = " + engine);
|
||||
}
|
||||
// 字符集
|
||||
if (StringUtils.hasText(characterSet)) {
|
||||
tableProperties.add("CHARACTER SET = " + characterSet);
|
||||
}
|
||||
// 排序
|
||||
if (StringUtils.hasText(collate)) {
|
||||
tableProperties.add("COLLATE = " + collate);
|
||||
}
|
||||
// 备注
|
||||
if (StringUtils.hasText(comment)) {
|
||||
tableProperties.add(
|
||||
"COMMENT = '{comment}'"
|
||||
.replace("{comment}", comment)
|
||||
);
|
||||
}
|
||||
return tableProperties;
|
||||
}
|
||||
|
||||
public static String getIndexSql(IndexMetadata indexMetadata) {
|
||||
// 例子: UNIQUE INDEX `unique_name_age`(`name` ASC, `age` DESC) COMMENT '姓名、年龄索引',
|
||||
return StringConnectHelper.newInstance("{indexType} INDEX {indexName}({columns}) {method} {indexComment}")
|
||||
.replace("{indexType}", indexMetadata.getType() == IndexTypeEnum.UNIQUE ? "UNIQUE" : "")
|
||||
.replace("{indexName}", indexMetadata.getName())
|
||||
.replace("{columns}", () -> {
|
||||
List<IndexMetadata.IndexColumnParam> columnParams = indexMetadata.getColumns();
|
||||
return columnParams.stream().map(column ->
|
||||
// 例:name ASC
|
||||
"`{column}` {sortMode}"
|
||||
.replace("{column}", column.getColumn())
|
||||
.replace("{sortMode}", column.getSort() != null ? column.getSort().name() : "")
|
||||
).collect(Collectors.joining(","));
|
||||
})
|
||||
.replace("{method}", StringUtils.hasText(indexMetadata.getMethod()) ? "USING " + indexMetadata.getMethod() : "")
|
||||
.replace("{indexComment}", StringUtils.hasText(indexMetadata.getComment()) ? "COMMENT '" + indexMetadata.getComment() + "'" : "")
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static String getPrimaryKeySql(List<String> primaries) {
|
||||
return "PRIMARY KEY ({primaries})"
|
||||
.replace(
|
||||
"{primaries}",
|
||||
String.join(",", primaries)
|
||||
);
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.quartz;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.cool.core.util.DatabaseDialectUtils;
|
||||
import org.quartz.Calendar;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.Trigger;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
||||
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Quartz Scheduler.
|
||||
* 覆盖原始的QuartzAutoConfiguration,兼容postgres数据库
|
||||
* properties.getProperties().put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class, FlywayAutoConfiguration.class })
|
||||
@ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class, PlatformTransactionManager.class })
|
||||
@EnableConfigurationProperties(QuartzProperties.class)
|
||||
public class QuartzAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerFactoryBean quartzScheduler(QuartzProperties properties,
|
||||
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers, ObjectProvider<JobDetail> jobDetails,
|
||||
Map<String, Calendar> calendars, ObjectProvider<Trigger> triggers, ApplicationContext applicationContext) {
|
||||
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
|
||||
SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
|
||||
jobFactory.setApplicationContext(applicationContext);
|
||||
schedulerFactoryBean.setJobFactory(jobFactory);
|
||||
if (properties.getSchedulerName() != null) {
|
||||
schedulerFactoryBean.setSchedulerName(properties.getSchedulerName());
|
||||
}
|
||||
schedulerFactoryBean.setAutoStartup(properties.isAutoStartup());
|
||||
schedulerFactoryBean.setStartupDelay((int) properties.getStartupDelay().getSeconds());
|
||||
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(properties.isWaitForJobsToCompleteOnShutdown());
|
||||
schedulerFactoryBean.setOverwriteExistingJobs(properties.isOverwriteExistingJobs());
|
||||
if (!properties.getProperties().isEmpty()) {
|
||||
schedulerFactoryBean.setQuartzProperties(asProperties(properties.getProperties()));
|
||||
}
|
||||
schedulerFactoryBean.setJobDetails(jobDetails.orderedStream().toArray(JobDetail[]::new));
|
||||
schedulerFactoryBean.setCalendars(calendars);
|
||||
schedulerFactoryBean.setTriggers(triggers.orderedStream().toArray(Trigger[]::new));
|
||||
customizers.orderedStream().forEach((customizer) -> customizer.customize(schedulerFactoryBean));
|
||||
return schedulerFactoryBean;
|
||||
}
|
||||
|
||||
private Properties asProperties(Map<String, String> source) {
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(source);
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnSingleCandidate(DataSource.class)
|
||||
@ConditionalOnProperty(prefix = "spring.quartz", name = "job-store-type", havingValue = "jdbc")
|
||||
@Import(DatabaseInitializationDependencyConfigurer.class)
|
||||
protected static class JdbcStoreTypeConfiguration {
|
||||
|
||||
@Bean
|
||||
@Order(0)
|
||||
public SchedulerFactoryBeanCustomizer dataSourceCustomizer(QuartzProperties properties, DataSource dataSource,
|
||||
@QuartzDataSource ObjectProvider<DataSource> quartzDataSource,
|
||||
ObjectProvider<PlatformTransactionManager> transactionManager,
|
||||
@QuartzTransactionManager ObjectProvider<PlatformTransactionManager> quartzTransactionManager) {
|
||||
return (schedulerFactoryBean) -> {
|
||||
DataSource dataSourceToUse = getDataSource(dataSource, quartzDataSource);
|
||||
schedulerFactoryBean.setDataSource(dataSourceToUse);
|
||||
PlatformTransactionManager txManager = getTransactionManager(transactionManager,
|
||||
quartzTransactionManager);
|
||||
if (txManager != null) {
|
||||
schedulerFactoryBean.setTransactionManager(txManager);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private DataSource getDataSource(DataSource dataSource, ObjectProvider<DataSource> quartzDataSource) {
|
||||
DataSource dataSourceIfAvailable = quartzDataSource.getIfAvailable();
|
||||
return (dataSourceIfAvailable != null) ? dataSourceIfAvailable : dataSource;
|
||||
}
|
||||
|
||||
private PlatformTransactionManager getTransactionManager(
|
||||
ObjectProvider<PlatformTransactionManager> transactionManager,
|
||||
ObjectProvider<PlatformTransactionManager> quartzTransactionManager) {
|
||||
PlatformTransactionManager transactionManagerIfAvailable = quartzTransactionManager.getIfAvailable();
|
||||
return (transactionManagerIfAvailable != null) ? transactionManagerIfAvailable
|
||||
: transactionManager.getIfUnique();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(QuartzDataSourceScriptDatabaseInitializer.class)
|
||||
@Conditional(OnQuartzDatasourceInitializationCondition.class)
|
||||
public QuartzDataSourceScriptDatabaseInitializer quartzDataSourceScriptDatabaseInitializer(
|
||||
DataSource dataSource, @QuartzDataSource ObjectProvider<DataSource> quartzDataSource,
|
||||
QuartzProperties properties) {
|
||||
DataSource dataSourceToUse = getDataSource(dataSource, quartzDataSource);
|
||||
if (DatabaseDialectUtils.isPostgresql(dataSource)) {
|
||||
properties.getProperties().put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
|
||||
}
|
||||
return new QuartzDataSourceScriptDatabaseInitializer(dataSourceToUse, properties);
|
||||
}
|
||||
|
||||
static class OnQuartzDatasourceInitializationCondition extends OnDatabaseInitializationCondition {
|
||||
|
||||
OnQuartzDatasourceInitializationCondition() {
|
||||
super("Quartz", "spring.quartz.jdbc.initialize-schema");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ auto-table:
|
||||
# 建表的时候,父类的字段排序是在子类后面还是前面
|
||||
superInsertPosition: before
|
||||
# 模型包路径
|
||||
model-package: com.cool.**.entity.*
|
||||
model-package: com.cool.**.entity
|
||||
|
||||
# Cool相关配置
|
||||
cool:
|
||||
@@ -30,8 +30,13 @@ springdoc:
|
||||
api-docs:
|
||||
#是否开启文档功能 本地为了配合eps功能不可关闭
|
||||
enabled: true
|
||||
group-configs:
|
||||
- group: app
|
||||
paths-to-match: /app/**
|
||||
- group: admin
|
||||
paths-to-match: /admin/**
|
||||
|
||||
# 设置日志级别
|
||||
logging:
|
||||
level:
|
||||
com.cool: debug
|
||||
com.cool: debug
|
||||
|
||||
@@ -38,14 +38,14 @@ spring:
|
||||
file: assets/cache
|
||||
|
||||
#redis 缓存
|
||||
# cache:
|
||||
# type: redis
|
||||
# data:
|
||||
# redis:
|
||||
# host: 127.0.0.1
|
||||
# port: 6379
|
||||
# database: 0
|
||||
# password:
|
||||
# cache:
|
||||
# type: redis
|
||||
# data:
|
||||
# redis:
|
||||
# host: 127.0.0.1
|
||||
# port: 6379
|
||||
# database: 0
|
||||
# password:
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
jdbc:
|
||||
@@ -148,6 +148,9 @@ cool:
|
||||
max-pool-size-multiplier: 3
|
||||
# 队列容量的倍数
|
||||
queue-capacity-multiplier: 3
|
||||
multi-tenant:
|
||||
# 是否开启多租户,默认关闭
|
||||
enable: false
|
||||
# AutoTable配置,根据实体类自动生成表
|
||||
auto-table:
|
||||
show-banner: false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
✨🌈✨[cool-admin-java-plus](https://gitee.com/hlc4417/cool-admin-java-plus)✨🌈✨
|
||||
🚀🚀🚀 ✨🌈✨[cool-admin-java-plus](https://gitee.com/hlc4417/cool-admin-java-plus)✨🌈✨ 🚀🚀🚀
|
||||
______ ___ ___ _____ _ ______ ____ ____ _____ ____ _____
|
||||
.' ___ | .' `. .' `.|_ _| V7.x / \ |_ _ `.|_ \ / _||_ _||_ \|_ _|
|
||||
.' ___ | .' `. .' `.|_ _| V8.x / \ |_ _ `.|_ \ / _||_ _||_ \|_ _|
|
||||
/ .' \_|/ .-. \/ .-. \ | | ______ / _ \ | | `. \ | \/ | | | | \ | |
|
||||
| | | | | || | | | | | _|______|/ ___ \ | | | | | |\ /| | | | | |\ \| |
|
||||
\ `.___.'\\ `-' /\ `-' /_| |__/ | _/ / \ \_ _| |_.' /_| |_\/_| |_ _| |_ _| |_\ |_
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"router": "/sys",
|
||||
"perms": null,
|
||||
"type": 0,
|
||||
"icon": "icon-system",
|
||||
"icon": "icon-set",
|
||||
"orderNum": 2,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
@@ -809,55 +809,5 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "扩展管理",
|
||||
"router": null,
|
||||
"perms": null,
|
||||
"type": 0,
|
||||
"icon": "icon-favor",
|
||||
"orderNum": 8,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"name": "后端插件",
|
||||
"router": "/helper/plugins/serve",
|
||||
"perms": null,
|
||||
"type": 1,
|
||||
"icon": "icon-component",
|
||||
"orderNum": 2,
|
||||
"viewPath": "modules/helper/views/plugins/serve.vue",
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"name": "权限",
|
||||
"router": null,
|
||||
"perms": "plugin:info:install,plugin:info:delete,plugin:info:update,plugin:info:page,plugin:info:info",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "前端插件",
|
||||
"router": "/helper/plugins/vue",
|
||||
"perms": null,
|
||||
"type": 1,
|
||||
"icon": "icon-vue",
|
||||
"orderNum": 1,
|
||||
"viewPath": "modules/helper/views/plugins/vue.vue",
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,158 @@
|
||||
[
|
||||
{
|
||||
"name": "数据管理",
|
||||
"router": null,
|
||||
"perms": null,
|
||||
"type": 0,
|
||||
"icon": "icon-data",
|
||||
"orderNum": 7,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"name": "字典管理",
|
||||
"router": "/dict/list",
|
||||
"perms": null,
|
||||
"type": 1,
|
||||
"icon": "icon-dict",
|
||||
"orderNum": 3,
|
||||
"viewPath": "modules/dict/views/list.vue",
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"name": "字典类型",
|
||||
"router": null,
|
||||
"perms": "dict:type:delete,dict:type:update,dict:type:info,dict:type:list,dict:type:page,dict:type:add",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
]
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "扩展管理",
|
||||
"router": null,
|
||||
"perms": null,
|
||||
"type": 0,
|
||||
"icon": "icon-favor",
|
||||
"orderNum": 8,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "插件列表",
|
||||
"router": "/helper/plugins",
|
||||
"perms": null,
|
||||
"type": 1,
|
||||
"icon": "icon-list",
|
||||
"orderNum": 1,
|
||||
"viewPath": "modules/helper/views/plugins.vue",
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": [
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "删除",
|
||||
"router": null,
|
||||
"perms": "plugin:info:delete",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "分页查询",
|
||||
"router": null,
|
||||
"perms": "plugin:info:page",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "单个信息",
|
||||
"router": null,
|
||||
"perms": "plugin:info:info",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "安装插件",
|
||||
"router": null,
|
||||
"perms": "plugin:info:install",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "修改",
|
||||
"router": null,
|
||||
"perms": "plugin:info:update",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "列表查询",
|
||||
"router": null,
|
||||
"perms": "plugin:info:list",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
},
|
||||
{
|
||||
"tenantId": null,
|
||||
"name": "新增",
|
||||
"router": null,
|
||||
"perms": "plugin:info:add",
|
||||
"type": 2,
|
||||
"icon": null,
|
||||
"orderNum": 0,
|
||||
"viewPath": null,
|
||||
"keepAlive": true,
|
||||
"isShow": true,
|
||||
"childMenus": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
@@ -11,7 +11,7 @@
|
||||
<link rel="stylesheet" href="css/welcome.css">
|
||||
|
||||
<body>
|
||||
<div class="reveal">HELLO COOL-ADMIN V7.x</div>
|
||||
<div class="reveal">HELLO COOL-ADMIN V8.x</div>
|
||||
<!-- 添加底部说明 -->
|
||||
<div class="footer-bar">
|
||||
<span>提示:系统为前后端分离模式,前端仓库地址</span>
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.cool.core.leaf.segment.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class LeafAllocEntityTableDef extends TableDef {
|
||||
|
||||
public static final LeafAllocEntityTableDef LEAF_ALLOC_ENTITY = new LeafAllocEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn KEY = new QueryColumn(this, "key");
|
||||
|
||||
public final QueryColumn STEP = new QueryColumn(this, "step");
|
||||
|
||||
public final QueryColumn MAX_ID = new QueryColumn(this, "max_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
public final QueryColumn DESCRIPTION = new QueryColumn(this, "description");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, KEY, STEP, MAX_ID, CREATE_TIME, UPDATE_TIME, DESCRIPTION};
|
||||
|
||||
public LeafAllocEntityTableDef() {
|
||||
super("", "leaf_alloc");
|
||||
}
|
||||
|
||||
private LeafAllocEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public LeafAllocEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new LeafAllocEntityTableDef("", "leaf_alloc", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysConfEntityTableDef extends TableDef {
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
*/
|
||||
public static final BaseSysConfEntityTableDef BASE_SYS_CONF_ENTITY = new BaseSysConfEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn C_KEY = new QueryColumn(this, "c_key");
|
||||
|
||||
public final QueryColumn C_VALUE = new QueryColumn(this, "c_value");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, C_KEY, C_VALUE, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysConfEntityTableDef() {
|
||||
super("", "base_sys_conf");
|
||||
}
|
||||
|
||||
private BaseSysConfEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysConfEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysConfEntityTableDef("", "base_sys_conf", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysDepartmentEntityTableDef extends TableDef {
|
||||
|
||||
/**
|
||||
* 系统部门
|
||||
*/
|
||||
public static final BaseSysDepartmentEntityTableDef BASE_SYS_DEPARTMENT_ENTITY = new BaseSysDepartmentEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn ORDER_NUM = new QueryColumn(this, "order_num");
|
||||
|
||||
public final QueryColumn PARENT_ID = new QueryColumn(this, "parent_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, NAME, ORDER_NUM, PARENT_ID, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysDepartmentEntityTableDef() {
|
||||
super("", "base_sys_department");
|
||||
}
|
||||
|
||||
private BaseSysDepartmentEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysDepartmentEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysDepartmentEntityTableDef("", "base_sys_department", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysLogEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysLogEntityTableDef BASE_SYS_LOG_ENTITY = new BaseSysLogEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn IP = new QueryColumn(this, "ip");
|
||||
|
||||
public final QueryColumn ACTION = new QueryColumn(this, "action");
|
||||
|
||||
public final QueryColumn PARAMS = new QueryColumn(this, "params");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, IP, ACTION, PARAMS, USER_ID, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysLogEntityTableDef() {
|
||||
super("", "base_sys_log");
|
||||
}
|
||||
|
||||
private BaseSysLogEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysLogEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysLogEntityTableDef("", "base_sys_log", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysMenuEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysMenuEntityTableDef BASE_SYS_MENU_ENTITY = new BaseSysMenuEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn ICON = new QueryColumn(this, "icon");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn TYPE = new QueryColumn(this, "type");
|
||||
|
||||
public final QueryColumn PERMS = new QueryColumn(this, "perms");
|
||||
|
||||
public final QueryColumn IS_SHOW = new QueryColumn(this, "is_show");
|
||||
|
||||
public final QueryColumn ROUTER = new QueryColumn(this, "router");
|
||||
|
||||
public final QueryColumn ORDER_NUM = new QueryColumn(this, "order_num");
|
||||
|
||||
public final QueryColumn PARENT_ID = new QueryColumn(this, "parent_id");
|
||||
|
||||
public final QueryColumn VIEW_PATH = new QueryColumn(this, "view_path");
|
||||
|
||||
public final QueryColumn KEEP_ALIVE = new QueryColumn(this, "keep_alive");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, ICON, NAME, TYPE, PERMS, IS_SHOW, ROUTER, ORDER_NUM, PARENT_ID, VIEW_PATH, KEEP_ALIVE, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysMenuEntityTableDef() {
|
||||
super("", "base_sys_menu");
|
||||
}
|
||||
|
||||
private BaseSysMenuEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysMenuEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysMenuEntityTableDef("", "base_sys_menu", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysParamEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysParamEntityTableDef BASE_SYS_PARAM_ENTITY = new BaseSysParamEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn DATA = new QueryColumn(this, "data");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn REMARK = new QueryColumn(this, "remark");
|
||||
|
||||
public final QueryColumn KEY_NAME = new QueryColumn(this, "key_name");
|
||||
|
||||
public final QueryColumn DATA_TYPE = new QueryColumn(this, "data_type");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, DATA, NAME, REMARK, KEY_NAME, DATA_TYPE, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysParamEntityTableDef() {
|
||||
super("", "base_sys_param");
|
||||
}
|
||||
|
||||
private BaseSysParamEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysParamEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysParamEntityTableDef("", "base_sys_param", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysRoleDepartmentEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysRoleDepartmentEntityTableDef BASE_SYS_ROLE_DEPARTMENT_ENTITY = new BaseSysRoleDepartmentEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn ROLE_ID = new QueryColumn(this, "role_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
public final QueryColumn DEPARTMENT_ID = new QueryColumn(this, "department_id");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, ROLE_ID, CREATE_TIME, UPDATE_TIME, DEPARTMENT_ID};
|
||||
|
||||
public BaseSysRoleDepartmentEntityTableDef() {
|
||||
super("", "base_sys_role_department");
|
||||
}
|
||||
|
||||
private BaseSysRoleDepartmentEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysRoleDepartmentEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysRoleDepartmentEntityTableDef("", "base_sys_role_department", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysRoleEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysRoleEntityTableDef BASE_SYS_ROLE_ENTITY = new BaseSysRoleEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn LABEL = new QueryColumn(this, "label");
|
||||
|
||||
public final QueryColumn REMARK = new QueryColumn(this, "remark");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
public final QueryColumn RELEVANCE = new QueryColumn(this, "relevance");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn MENU_ID_LIST = new QueryColumn(this, "menu_id_list");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
public final QueryColumn DEPARTMENT_ID_LIST = new QueryColumn(this, "department_id_list");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, NAME, LABEL, REMARK, USER_ID, RELEVANCE, CREATE_TIME, MENU_ID_LIST, UPDATE_TIME, DEPARTMENT_ID_LIST};
|
||||
|
||||
public BaseSysRoleEntityTableDef() {
|
||||
super("", "base_sys_role");
|
||||
}
|
||||
|
||||
private BaseSysRoleEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysRoleEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysRoleEntityTableDef("", "base_sys_role", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysRoleMenuEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysRoleMenuEntityTableDef BASE_SYS_ROLE_MENU_ENTITY = new BaseSysRoleMenuEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn MENU_ID = new QueryColumn(this, "menu_id");
|
||||
|
||||
public final QueryColumn ROLE_ID = new QueryColumn(this, "role_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, MENU_ID, ROLE_ID, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysRoleMenuEntityTableDef() {
|
||||
super("", "base_sys_role_menu");
|
||||
}
|
||||
|
||||
private BaseSysRoleMenuEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysRoleMenuEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysRoleMenuEntityTableDef("", "base_sys_role_menu", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysUserEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysUserEntityTableDef BASE_SYS_USER_ENTITY = new BaseSysUserEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn EMAIL = new QueryColumn(this, "email");
|
||||
|
||||
public final QueryColumn PHONE = new QueryColumn(this, "phone");
|
||||
|
||||
public final QueryColumn REMARK = new QueryColumn(this, "remark");
|
||||
|
||||
public final QueryColumn STATUS = new QueryColumn(this, "status");
|
||||
|
||||
public final QueryColumn HEAD_IMG = new QueryColumn(this, "head_img");
|
||||
|
||||
public final QueryColumn NICK_NAME = new QueryColumn(this, "nick_name");
|
||||
|
||||
public final QueryColumn PASSWORD = new QueryColumn(this, "password");
|
||||
|
||||
public final QueryColumn SOCKET_ID = new QueryColumn(this, "socket_id");
|
||||
|
||||
public final QueryColumn USERNAME = new QueryColumn(this, "username");
|
||||
|
||||
public final QueryColumn PASSWORD_V = new QueryColumn(this, "password_v");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
public final QueryColumn DEPARTMENT_ID = new QueryColumn(this, "department_id");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, NAME, EMAIL, PHONE, REMARK, STATUS, HEAD_IMG, NICK_NAME, PASSWORD, SOCKET_ID, USERNAME, PASSWORD_V, CREATE_TIME, UPDATE_TIME, DEPARTMENT_ID};
|
||||
|
||||
public BaseSysUserEntityTableDef() {
|
||||
super("", "base_sys_user");
|
||||
}
|
||||
|
||||
private BaseSysUserEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysUserEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysUserEntityTableDef("", "base_sys_user", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.cool.modules.base.entity.sys.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class BaseSysUserRoleEntityTableDef extends TableDef {
|
||||
|
||||
public static final BaseSysUserRoleEntityTableDef BASE_SYS_USER_ROLE_ENTITY = new BaseSysUserRoleEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn ROLE_ID = new QueryColumn(this, "role_id");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, ROLE_ID, USER_ID, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public BaseSysUserRoleEntityTableDef() {
|
||||
super("", "base_sys_user_role");
|
||||
}
|
||||
|
||||
private BaseSysUserRoleEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public BaseSysUserRoleEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new BaseSysUserRoleEntityTableDef("", "base_sys_user_role", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package com.cool.modules.dict.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class DictInfoEntityTableDef extends TableDef {
|
||||
|
||||
public static final DictInfoEntityTableDef DICT_INFO_ENTITY = new DictInfoEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn VALUE = new QueryColumn(this, "value");
|
||||
|
||||
public final QueryColumn REMARK = new QueryColumn(this, "remark");
|
||||
|
||||
public final QueryColumn TYPE_ID = new QueryColumn(this, "type_id");
|
||||
|
||||
public final QueryColumn ORDER_NUM = new QueryColumn(this, "order_num");
|
||||
|
||||
public final QueryColumn PARENT_ID = new QueryColumn(this, "parent_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, NAME, VALUE, REMARK, TYPE_ID, ORDER_NUM, PARENT_ID, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public DictInfoEntityTableDef() {
|
||||
super("", "dict_info");
|
||||
}
|
||||
|
||||
private DictInfoEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public DictInfoEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new DictInfoEntityTableDef("", "dict_info", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.cool.modules.dict.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class DictTypeEntityTableDef extends TableDef {
|
||||
|
||||
public static final DictTypeEntityTableDef DICT_TYPE_ENTITY = new DictTypeEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn KEY = new QueryColumn(this, "key");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, KEY, NAME, CREATE_TIME, UPDATE_TIME};
|
||||
|
||||
public DictTypeEntityTableDef() {
|
||||
super("", "dict_type");
|
||||
}
|
||||
|
||||
private DictTypeEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public DictTypeEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new DictTypeEntityTableDef("", "dict_type", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
package com.cool.modules.plugin.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class PluginInfoEntityTableDef extends TableDef {
|
||||
|
||||
public static final PluginInfoEntityTableDef PLUGIN_INFO_ENTITY = new PluginInfoEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn KEY = new QueryColumn(this, "key");
|
||||
|
||||
public final QueryColumn HOOK = new QueryColumn(this, "hook");
|
||||
|
||||
public final QueryColumn LOGO = new QueryColumn(this, "logo");
|
||||
|
||||
public final QueryColumn NAME = new QueryColumn(this, "name");
|
||||
|
||||
public final QueryColumn AUTHOR = new QueryColumn(this, "author");
|
||||
|
||||
public final QueryColumn CONFIG = new QueryColumn(this, "config");
|
||||
|
||||
public final QueryColumn README = new QueryColumn(this, "readme");
|
||||
|
||||
public final QueryColumn STATUS = new QueryColumn(this, "status");
|
||||
|
||||
public final QueryColumn VERSION = new QueryColumn(this, "version");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn PLUGIN_JSON = new QueryColumn(this, "plugin_json");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
public final QueryColumn DESCRIPTION = new QueryColumn(this, "description");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, KEY, HOOK, LOGO, NAME, AUTHOR, CONFIG, README, STATUS, VERSION, CREATE_TIME, PLUGIN_JSON, UPDATE_TIME, DESCRIPTION};
|
||||
|
||||
public PluginInfoEntityTableDef() {
|
||||
super("", "plugin_info");
|
||||
}
|
||||
|
||||
private PluginInfoEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public PluginInfoEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new PluginInfoEntityTableDef("", "plugin_info", alias));
|
||||
}
|
||||
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package com.cool.modules.recycle.entity.table;
|
||||
|
||||
import com.mybatisflex.core.query.QueryColumn;
|
||||
import com.mybatisflex.core.table.TableDef;
|
||||
|
||||
// Auto generate by mybatis-flex, do not modify it.
|
||||
public class RecycleDataEntityTableDef extends TableDef {
|
||||
|
||||
/**
|
||||
* 数据回收站 软删除的时候数据会回收到该表
|
||||
*/
|
||||
public static final RecycleDataEntityTableDef RECYCLE_DATA_ENTITY = new RecycleDataEntityTableDef();
|
||||
|
||||
public final QueryColumn ID = new QueryColumn(this, "id");
|
||||
|
||||
public final QueryColumn URL = new QueryColumn(this, "url");
|
||||
|
||||
public final QueryColumn DATA = new QueryColumn(this, "data");
|
||||
|
||||
public final QueryColumn COUNT = new QueryColumn(this, "count");
|
||||
|
||||
public final QueryColumn PARAMS = new QueryColumn(this, "params");
|
||||
|
||||
public final QueryColumn USER_ID = new QueryColumn(this, "user_id");
|
||||
|
||||
public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");
|
||||
|
||||
public final QueryColumn ENTITY_INFO = new QueryColumn(this, "entity_info");
|
||||
|
||||
public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");
|
||||
|
||||
/**
|
||||
* 所有字段。
|
||||
*/
|
||||
public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");
|
||||
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, URL, DATA, COUNT, PARAMS, USER_ID, CREATE_TIME, ENTITY_INFO, UPDATE_TIME};
|
||||
|
||||
public RecycleDataEntityTableDef() {
|
||||
super("", "recycle_data");
|
||||
}
|
||||
|
||||
private RecycleDataEntityTableDef(String schema, String name, String alisa) {
|
||||
super(schema, name, alisa);
|
||||
}
|
||||
|
||||
public RecycleDataEntityTableDef as(String alias) {
|
||||
String key = getNameWithSchema() + "." + alias;
|
||||
return getCache(key, k -> new RecycleDataEntityTableDef("", "recycle_data", alias));
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user