mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-17 10:56:39 +08:00
v3.22.0 【新增】优化代码生成;【新增】优化角色列宽
This commit is contained in:
parent
3adb7376dd
commit
922e49b27e
@ -103,6 +103,11 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-pool2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-text</artifactId>
|
<artifactId>commons-text</artifactId>
|
||||||
|
@ -40,6 +40,12 @@ import java.util.Optional;
|
|||||||
@Service
|
@Service
|
||||||
public class CodeGeneratorService {
|
public class CodeGeneratorService {
|
||||||
|
|
||||||
|
private static final String COLUMN_NULLABLE_IDENTIFY = "NO";
|
||||||
|
|
||||||
|
private static final String COLUMN_PRIMARY_KEY = "PRI";
|
||||||
|
|
||||||
|
private static final String COLUMN_AUTO_INCREASE = "auto_increment";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CodeGeneratorDao codeGeneratorDao;
|
private CodeGeneratorDao codeGeneratorDao;
|
||||||
|
|
||||||
@ -57,7 +63,13 @@ public class CodeGeneratorService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<TableColumnVO> getTableColumns(String tableName) {
|
public List<TableColumnVO> getTableColumns(String tableName) {
|
||||||
return codeGeneratorDao.selectTableColumn(tableName);
|
List<TableColumnVO> tableColumns = codeGeneratorDao.selectTableColumn(tableName);
|
||||||
|
for (TableColumnVO tableColumn : tableColumns) {
|
||||||
|
tableColumn.setNullableFlag(!COLUMN_NULLABLE_IDENTIFY.equalsIgnoreCase(tableColumn.getIsNullable()));
|
||||||
|
tableColumn.setPrimaryKeyFlag(COLUMN_PRIMARY_KEY.equalsIgnoreCase(tableColumn.getColumnKey()));
|
||||||
|
tableColumn.setAutoIncreaseFlag(SmartStringUtil.isNotEmpty(tableColumn.getExtra()) && COLUMN_AUTO_INCREASE.equalsIgnoreCase(tableColumn.getExtra()));
|
||||||
|
}
|
||||||
|
return tableColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,13 +156,13 @@ public class CodeGeneratorService {
|
|||||||
List<TableColumnVO> tableColumns = getTableColumns(form.getTableName());
|
List<TableColumnVO> tableColumns = getTableColumns(form.getTableName());
|
||||||
if (null != form.getDeleteInfo() && form.getDeleteInfo().getIsSupportDelete() && !form.getDeleteInfo().getIsPhysicallyDeleted()) {
|
if (null != form.getDeleteInfo() && form.getDeleteInfo().getIsSupportDelete() && !form.getDeleteInfo().getIsPhysicallyDeleted()) {
|
||||||
Optional<TableColumnVO> any = tableColumns.stream().filter(e -> e.getColumnName().equals(CodeGeneratorConstant.DELETED_FLAG)).findAny();
|
Optional<TableColumnVO> any = tableColumns.stream().filter(e -> e.getColumnName().equals(CodeGeneratorConstant.DELETED_FLAG)).findAny();
|
||||||
if (!any.isPresent()) {
|
if (any.isEmpty()) {
|
||||||
return ResponseDTO.userErrorParam("表结构中没有假删字段:" + CodeGeneratorConstant.DELETED_FLAG + ",请仔细排查");
|
return ResponseDTO.userErrorParam("表结构中没有假删字段:" + CodeGeneratorConstant.DELETED_FLAG + ",请仔细排查");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验表必须有主键
|
// 校验表必须有主键
|
||||||
if(!tableColumns.stream().filter( e -> "PRI".equalsIgnoreCase(e.getColumnKey())).findAny().isPresent()){
|
if (tableColumns.stream().noneMatch(e -> COLUMN_PRIMARY_KEY.equalsIgnoreCase(e.getColumnKey()))) {
|
||||||
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +211,7 @@ public class CodeGeneratorService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载代码
|
* 下载代码
|
||||||
|
*
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -128,16 +128,6 @@ public class DataTracerChangeContentService {
|
|||||||
return this.getAddDeleteContent(object);
|
return this.getAddDeleteContent(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析批量bean的内容
|
|
||||||
*
|
|
||||||
* @param objectList 对象列表
|
|
||||||
* @return 单个内容
|
|
||||||
*/
|
|
||||||
public <T> String getChangeContent(List<T> objectList) {
|
|
||||||
return this.getObjectListContent(objectList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------- 以下 是 私有private 方法 ----------------------------
|
// ---------------------------- 以下 是 私有private 方法 ----------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,6 +160,15 @@ public class DataTracerChangeContentService {
|
|||||||
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析批量bean的内容
|
||||||
|
*
|
||||||
|
* @param objectList 对象列表
|
||||||
|
* @return 单个内容
|
||||||
|
*/
|
||||||
|
public <T> String getChangeContent(List<T> objectList) {
|
||||||
|
return this.getObjectListContent(objectList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个对象的内容信息
|
* 获取一个对象的内容信息
|
||||||
|
@ -47,8 +47,6 @@
|
|||||||
<log4j-spring-boot.version>2.23.1</log4j-spring-boot.version>
|
<log4j-spring-boot.version>2.23.1</log4j-spring-boot.version>
|
||||||
<hutool.version>5.7.22</hutool.version>
|
<hutool.version>5.7.22</hutool.version>
|
||||||
<velocity-engine-core.version>2.3</velocity-engine-core.version>
|
<velocity-engine-core.version>2.3</velocity-engine-core.version>
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
|
||||||
<jwks-rsa.version>0.9.0</jwks-rsa.version>
|
|
||||||
<velocity-tools.version>3.1</velocity-tools.version>
|
<velocity-tools.version>3.1</velocity-tools.version>
|
||||||
<sa-token.version>1.41.0</sa-token.version>
|
<sa-token.version>1.41.0</sa-token.version>
|
||||||
<ip2region.version>2.7.0</ip2region.version>
|
<ip2region.version>2.7.0</ip2region.version>
|
||||||
@ -225,19 +223,6 @@
|
|||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
<version>${jjwt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.auth0</groupId>
|
|
||||||
<artifactId>jwks-rsa</artifactId>
|
|
||||||
<version>${jwks-rsa.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--velocity begin-->
|
<!--velocity begin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
@ -208,16 +208,6 @@
|
|||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.auth0</groupId>
|
|
||||||
<artifactId>jwks-rsa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
@ -40,6 +40,12 @@ import java.util.Optional;
|
|||||||
@Service
|
@Service
|
||||||
public class CodeGeneratorService {
|
public class CodeGeneratorService {
|
||||||
|
|
||||||
|
private static final String COLUMN_NULLABLE_IDENTIFY = "NO";
|
||||||
|
|
||||||
|
private static final String COLUMN_PRIMARY_KEY = "PRI";
|
||||||
|
|
||||||
|
private static final String COLUMN_AUTO_INCREASE = "auto_increment";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CodeGeneratorDao codeGeneratorDao;
|
private CodeGeneratorDao codeGeneratorDao;
|
||||||
|
|
||||||
@ -57,7 +63,13 @@ public class CodeGeneratorService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<TableColumnVO> getTableColumns(String tableName) {
|
public List<TableColumnVO> getTableColumns(String tableName) {
|
||||||
return codeGeneratorDao.selectTableColumn(tableName);
|
List<TableColumnVO> tableColumns = codeGeneratorDao.selectTableColumn(tableName);
|
||||||
|
for (TableColumnVO tableColumn : tableColumns) {
|
||||||
|
tableColumn.setNullableFlag(!COLUMN_NULLABLE_IDENTIFY.equalsIgnoreCase(tableColumn.getIsNullable()));
|
||||||
|
tableColumn.setPrimaryKeyFlag(COLUMN_PRIMARY_KEY.equalsIgnoreCase(tableColumn.getColumnKey()));
|
||||||
|
tableColumn.setAutoIncreaseFlag(SmartStringUtil.isNotEmpty(tableColumn.getExtra()) && COLUMN_AUTO_INCREASE.equalsIgnoreCase(tableColumn.getExtra()));
|
||||||
|
}
|
||||||
|
return tableColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +162,7 @@ public class CodeGeneratorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验表必须有主键
|
// 校验表必须有主键
|
||||||
if(!tableColumns.stream().filter( e -> "PRI".equalsIgnoreCase(e.getColumnKey())).findAny().isPresent()){
|
if (tableColumns.stream().noneMatch(e -> COLUMN_PRIMARY_KEY.equalsIgnoreCase(e.getColumnKey()))) {
|
||||||
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
return ResponseDTO.userErrorParam("表必须有主键,请联系后端查看下数据库表结构");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +211,7 @@ public class CodeGeneratorService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载代码
|
* 下载代码
|
||||||
|
*
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -128,16 +128,6 @@ public class DataTracerChangeContentService {
|
|||||||
return this.getAddDeleteContent(object);
|
return this.getAddDeleteContent(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析批量bean的内容
|
|
||||||
*
|
|
||||||
* @param objectList 对象列表
|
|
||||||
* @return 单个内容
|
|
||||||
*/
|
|
||||||
public <T> String getChangeContent(List<T> objectList) {
|
|
||||||
return this.getObjectListContent(objectList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------- 以下 是 私有private 方法 ----------------------------
|
// ---------------------------- 以下 是 私有private 方法 ----------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,6 +160,15 @@ public class DataTracerChangeContentService {
|
|||||||
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
return "【原数据】:<br/>" + oldContent + "<br/>" + "【新数据】:<br/>" + newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析批量bean的内容
|
||||||
|
*
|
||||||
|
* @param objectList 对象列表
|
||||||
|
* @return 单个内容
|
||||||
|
*/
|
||||||
|
public <T> String getChangeContent(List<T> objectList) {
|
||||||
|
return this.getObjectListContent(objectList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个对象的内容信息
|
* 获取一个对象的内容信息
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: [Array, String],
|
value: [Array, String, Number],
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '请选择字典',
|
default: '请选择字典',
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dictCode: String,
|
dictCode: String,
|
||||||
value: [Array, String],
|
value: [Array, String, Number],
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'combobox',
|
default: 'combobox',
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: [Array, String],
|
value: [Array, String, Number],
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '请选择字典',
|
default: '请选择字典',
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dictCode: String,
|
dictCode: String,
|
||||||
value: [Array, String],
|
value: [Array, String, Number],
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'combobox',
|
default: 'combobox',
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.height100 {
|
.height100 {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
.role-setting {
|
.role-setting {
|
||||||
width: calc(100% - 250px);
|
width: calc(100% - 250px);
|
||||||
|
Loading…
Reference in New Issue
Block a user