移除:插件jar二进制文件入库,

调整:实体字段注解类型,兼容postgresql
This commit is contained in:
ruying408
2024-08-02 01:39:32 +08:00
parent fc16dd2c09
commit 733c290fe5
17 changed files with 114 additions and 71 deletions
@@ -23,7 +23,7 @@ public class BaseSysMenuEntity extends BaseEntity<BaseSysMenuEntity> {
@ColumnDefine(comment = "权限", type = "text")
private String perms;
@ColumnDefine(comment = "类型 0:目录 1:菜单 2:按钮", type = "tinyint", defaultValue = "0")
@ColumnDefine(comment = "类型 0:目录 1:菜单 2:按钮", defaultValue = "0")
private Integer type;
@ColumnDefine(comment = "图标")
@@ -1,10 +1,9 @@
package com.cool.modules.base.entity.sys;
import com.cool.core.base.BaseEntity;
import com.tangzc.autotable.annotation.Index;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import com.mybatisflex.annotation.Table;
import com.tangzc.autotable.annotation.Index;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import lombok.Getter;
import lombok.Setter;
@@ -22,7 +21,7 @@ public class BaseSysParamEntity extends BaseEntity<BaseSysParamEntity> {
@ColumnDefine(comment = "数据", type = "text")
private String data;
@ColumnDefine(comment = "数据类型 0:字符串 1:数组 2:键值对", defaultValue = "0", type = "tinyint")
@ColumnDefine(comment = "数据类型 0:字符串 1:数组 2:键值对", defaultValue = "0")
private Integer dataType;
@ColumnDefine(comment = "备注")
@@ -2,12 +2,10 @@ package com.cool.modules.base.entity.sys;
import com.cool.core.base.BaseEntity;
import com.mybatisflex.annotation.Column;
import com.tangzc.autotable.annotation.Index;
import com.tangzc.autotable.annotation.enums.IndexTypeEnum;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import com.mybatisflex.annotation.Table;
import com.tangzc.autotable.annotation.Index;
import com.tangzc.autotable.annotation.enums.IndexTypeEnum;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import lombok.Getter;
import lombok.Setter;
@@ -47,7 +45,7 @@ public class BaseSysUserEntity extends BaseEntity<BaseSysUserEntity> {
@ColumnDefine(comment = "备注")
private String remark;
@ColumnDefine(comment = "状态 0:禁用 1:启用", defaultValue = "1", type = "tinyint")
@ColumnDefine(comment = "状态 0:禁用 1:启用", defaultValue = "1")
private Integer status;
// 部门名称
@@ -1,5 +1,9 @@
package com.cool.modules.base.service.sys.impl;
import static com.cool.modules.base.entity.sys.table.BaseSysMenuEntityTableDef.BASE_SYS_MENU_ENTITY;
import static com.cool.modules.base.entity.sys.table.BaseSysRoleMenuEntityTableDef.BASE_SYS_ROLE_MENU_ENTITY;
import static com.cool.modules.base.entity.sys.table.BaseSysUserRoleEntityTableDef.BASE_SYS_USER_ROLE_ENTITY;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Dict;
@@ -14,17 +18,12 @@ import com.cool.modules.base.security.CoolSecurityUtil;
import com.cool.modules.base.service.sys.BaseSysPermsService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Row;
import java.util.*;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Service;
import java.util.*;
import static com.cool.modules.base.entity.sys.table.BaseSysMenuEntityTableDef.BASE_SYS_MENU_ENTITY;
import static com.cool.modules.base.entity.sys.table.BaseSysRoleMenuEntityTableDef.BASE_SYS_ROLE_MENU_ENTITY;
import static com.cool.modules.base.entity.sys.table.BaseSysUserRoleEntityTableDef.BASE_SYS_USER_ROLE_ENTITY;
@Service
@RequiredArgsConstructor
public class BaseSysPermsServiceImpl implements BaseSysPermsService {
@@ -65,9 +64,12 @@ public class BaseSysPermsServiceImpl implements BaseSysPermsService {
}
private Long[] getLongs(Long[] roleIds) {
QueryWrapper queryWrapper = QueryWrapper.create();
if (roleIds != null && !CollUtil.toList(roleIds).contains(1L)) {
queryWrapper.in(BaseSysRoleDepartmentEntity::getRoleId, (Object) roleIds);
}
return baseSysRoleDepartmentMapper
.selectListByQuery(QueryWrapper.create().in(BaseSysRoleDepartmentEntity::getRoleId, (Object) roleIds,
roleIds != null && !CollUtil.toList(roleIds).contains(1L)))
.selectListByQuery(queryWrapper)
.stream().map(BaseSysRoleDepartmentEntity::getDepartmentId).toArray(Long[]::new);
}
@@ -26,6 +26,7 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
@@ -44,6 +45,9 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
final private BaseSysDepartmentMapper baseSysDepartmentMapper;
@Value("${spring.datasource.url}")
private String datasourceUrl;
@Override
public Object page(JSONObject requestParams, Page<BaseSysUserEntity> page, QueryWrapper qw) {
String keyWord = requestParams.getStr("keyWord");
@@ -53,11 +57,21 @@ public class BaseSysUserServiceImpl extends BaseServiceImpl<BaseSysUserMapper, B
// 用户的部门权限
Long[] permsDepartmentArr = coolCache.get("admin:department:" + tokenInfo.get("userId"),
Long[].class);
qw.select(BASE_SYS_USER_ENTITY.ALL_COLUMNS,
// TODO 临时兼容 postgresql
if (datasourceUrl.contains("postgresql")) {
qw.select(BASE_SYS_USER_ENTITY.ALL_COLUMNS
// ,
// groupConcat(BASE_SYS_ROLE_ENTITY.NAME).as("roleName"),
// BASE_SYS_DEPARTMENT_ENTITY.NAME.as("departmentName")
);
} else {
qw.select(BASE_SYS_USER_ENTITY.ALL_COLUMNS,
groupConcat(BASE_SYS_ROLE_ENTITY.NAME).as("roleName"),
BASE_SYS_DEPARTMENT_ENTITY.NAME.as("departmentName"))
.from(BASE_SYS_USER_ENTITY).leftJoin(BASE_SYS_USER_ROLE_ENTITY)
BASE_SYS_DEPARTMENT_ENTITY.NAME.as("departmentName")
);
}
qw.from(BASE_SYS_USER_ENTITY).leftJoin(BASE_SYS_USER_ROLE_ENTITY)
.on(BASE_SYS_USER_ENTITY.ID.eq(BASE_SYS_USER_ROLE_ENTITY.USER_ID))
.leftJoin(BASE_SYS_ROLE_ENTITY)
.on(BASE_SYS_USER_ROLE_ENTITY.USER_ID.eq(BASE_SYS_ROLE_ENTITY.ID))
@@ -9,7 +9,6 @@ import com.cool.core.annotation.IgnoreRecycleData;
import com.cool.core.base.BaseController;
import com.cool.core.plugin.service.CoolPluginService;
import com.cool.core.request.R;
import com.cool.core.util.EntityUtils;
import com.cool.modules.plugin.entity.PluginInfoEntity;
import com.cool.modules.plugin.service.PluginInfoService;
import com.mybatisflex.core.query.QueryWrapper;
@@ -38,8 +37,7 @@ public class AdminPluginInfoController extends BaseController<PluginInfoService,
setPageOption(createOp().queryWrapper(
QueryWrapper.create().orderBy(PLUGIN_INFO_ENTITY.UPDATE_TIME, false))
.select(EntityUtils.getFieldNamesWithSuperClass(PLUGIN_INFO_ENTITY.DEFAULT_COLUMNS,
PLUGIN_INFO_ENTITY.JAR_FILE.getName())));
.select(PLUGIN_INFO_ENTITY.DEFAULT_COLUMNS));
}
@Override
@@ -52,9 +52,6 @@ public class PluginInfoEntity extends BaseEntity<PluginInfoEntity> {
@Column(typeHandler = Fastjson2TypeHandler.class)
private PluginJson pluginJson;
@ColumnDefine(comment = "jar二进制文件(可配置是否入库)", type = "longblob")
private byte[] jarFile;
@ColumnDefine(comment = "配置", type = "json")
@Column(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> config;
@@ -3,7 +3,6 @@ package com.cool.modules.plugin.service.impl;
import static com.cool.modules.plugin.entity.table.PluginInfoEntityTableDef.PLUGIN_INFO_ENTITY;
import com.cool.core.base.BaseServiceImpl;
import com.cool.core.util.EntityUtils;
import com.cool.modules.plugin.entity.PluginInfoEntity;
import com.cool.modules.plugin.mapper.PluginInfoMapper;
import com.cool.modules.plugin.service.PluginInfoService;
@@ -18,7 +17,7 @@ public class PluginInfoServiceImpl extends BaseServiceImpl<PluginInfoMapper, Plu
implements PluginInfoService {
/**
* 通过key获取插件信息,不带jar二进制
* 通过key获取插件信息
*/
@Override
public PluginInfoEntity getByKey(String key) {
@@ -28,7 +27,7 @@ public class PluginInfoServiceImpl extends BaseServiceImpl<PluginInfoMapper, Plu
}
/**
* 通过hook获取插件信息,不带jar二进制
* 通过hook获取插件信息
*/
@Override
public PluginInfoEntity getPluginInfoEntityByHook(String hook) {
@@ -38,7 +37,7 @@ public class PluginInfoServiceImpl extends BaseServiceImpl<PluginInfoMapper, Plu
}
/**
* 通过id获取插件信息,不带jar二进制
* 通过id获取插件信息
*/
@Override
public PluginInfoEntity getPluginInfoEntityById(Long id) {
@@ -47,9 +46,9 @@ public class PluginInfoServiceImpl extends BaseServiceImpl<PluginInfoMapper, Plu
}
/**
* 获取查询对象,排除掉 jar二进制
* 获取查询对象
*/
private QueryWrapper getPluginInfoEntityQueryWrapper() {
return QueryWrapper.create().select(EntityUtils.getFieldNamesWithSuperClass(PLUGIN_INFO_ENTITY.DEFAULT_COLUMNS, PLUGIN_INFO_ENTITY.JAR_FILE.getName()));
return QueryWrapper.create();
}
}
@@ -2,11 +2,10 @@ 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.autotable.annotation.Ignore;
import com.tangzc.autotable.annotation.Index;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import com.mybatisflex.annotation.Table;
import lombok.Getter;
import lombok.Setter;
@@ -23,7 +22,7 @@ public class SpaceInfoEntity extends BaseEntity<SpaceInfoEntity> {
@ColumnDefine(comment = "类型", notNull = true)
private String type;
@ColumnDefine(comment = "分类ID", type = "tinyint")
@ColumnDefine(comment = "分类ID")
private Integer classifyId;
@Index()
@@ -1,10 +1,8 @@
package com.cool.modules.space.entity;
import com.cool.core.base.BaseEntity;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import lombok.Getter;
import lombok.Setter;
@@ -18,6 +16,6 @@ public class SpaceTypeEntity extends BaseEntity<SpaceTypeEntity> {
@ColumnDefine(comment = "类别名称", notNull = true)
private String name;
@ColumnDefine(comment = "父分类ID", type = "tinyint")
@ColumnDefine(comment = "父分类ID")
private Integer parentId;
}
@@ -2,14 +2,12 @@ package com.cool.modules.task.entity;
import com.cool.core.base.BaseEntity;
import com.mybatisflex.annotation.Column;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import com.mybatisflex.annotation.Table;
import com.tangzc.mybatisflex.autotable.annotation.ColumnDefine;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@Table(value = "task_info", comment = "任务信息")
@@ -41,7 +39,7 @@ public class TaskInfoEntity extends BaseEntity<TaskInfoEntity> {
@ColumnDefine(comment = "状态 0:cron 1:时间间隔", defaultValue = "0")
private Integer taskType;
@ColumnDefine(comment = "状态 0:系统 1:用户", defaultValue = "0", type = "tinyint")
@ColumnDefine(comment = "状态 0:系统 1:用户", defaultValue = "0")
private Integer type;
@ColumnDefine(comment = "任务数据")