update MP字段验证策略更改为 NOT_NULL 个别特殊字段使用注解单独处理
This commit is contained in:
parent
f3d6d1e43b
commit
ab9bc35f9f
@ -200,11 +200,11 @@ mybatis-plus:
|
|||||||
# NOT_EMPTY 非空判断(只对字符串类型字段,其他类型字段依然为非NULL判断)
|
# NOT_EMPTY 非空判断(只对字符串类型字段,其他类型字段依然为非NULL判断)
|
||||||
# DEFAULT 默认的,一般只用于注解里
|
# DEFAULT 默认的,一般只用于注解里
|
||||||
# NEVER 不加入 SQL
|
# NEVER 不加入 SQL
|
||||||
insertStrategy: NOT_EMPTY
|
insertStrategy: NOT_NULL
|
||||||
# 字段验证策略之 update,在 update 的时候的字段验证策略
|
# 字段验证策略之 update,在 update 的时候的字段验证策略
|
||||||
updateStrategy: NOT_EMPTY
|
updateStrategy: NOT_NULL
|
||||||
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
|
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
|
||||||
selectStrategy: NOT_EMPTY
|
selectStrategy: NOT_NULL
|
||||||
|
|
||||||
# Swagger配置
|
# Swagger配置
|
||||||
swagger:
|
swagger:
|
||||||
|
@ -78,6 +78,11 @@ public class SysUser implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 密码
|
* 密码
|
||||||
*/
|
*/
|
||||||
|
@TableField(
|
||||||
|
insertStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
|
updateStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
|
whereStrategy = FieldStrategy.NOT_EMPTY
|
||||||
|
)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
@ -44,6 +44,7 @@ public class GenTableColumn implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 列描述
|
* 列描述
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String columnComment;
|
private String columnComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,36 +66,43 @@ public class GenTableColumn implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 是否主键(1是)
|
* 是否主键(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isPk;
|
private String isPk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否自增(1是)
|
* 是否自增(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isIncrement;
|
private String isIncrement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否必填(1是)
|
* 是否必填(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isRequired;
|
private String isRequired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为插入字段(1是)
|
* 是否为插入字段(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isInsert;
|
private String isInsert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否编辑字段(1是)
|
* 是否编辑字段(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isEdit;
|
private String isEdit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否列表字段(1是)
|
* 是否列表字段(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isList;
|
private String isList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否查询字段(1是)
|
* 是否查询字段(1是)
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private String isQuery;
|
private String isQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@ package com.ruoyi.generator.service;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.GenConstants;
|
import com.ruoyi.common.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||||
@ -131,18 +130,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
int row = baseMapper.updateById(genTable);
|
int row = baseMapper.updateById(genTable);
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
for (GenTableColumn cenTableColumn : genTable.getColumns()) {
|
for (GenTableColumn cenTableColumn : genTable.getColumns()) {
|
||||||
genTableColumnMapper.update(cenTableColumn,
|
genTableColumnMapper.updateById(cenTableColumn);
|
||||||
new LambdaUpdateWrapper<GenTableColumn>()
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getColumnComment()), GenTableColumn::getColumnComment, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsPk()), GenTableColumn::getIsPk, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsIncrement()), GenTableColumn::getIsIncrement, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsInsert()), GenTableColumn::getIsInsert, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsEdit()), GenTableColumn::getIsEdit, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsList()), GenTableColumn::getIsList, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsQuery()), GenTableColumn::getIsQuery, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getIsRequired()), GenTableColumn::getIsRequired, null)
|
|
||||||
.set(StringUtils.isBlank(cenTableColumn.getDictType()), GenTableColumn::getDictType, "")
|
|
||||||
.eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,12 +88,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
public Boolean updateByBo(SysOssConfigBo bo) {
|
public Boolean updateByBo(SysOssConfigBo bo) {
|
||||||
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
|
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
|
||||||
validEntityBeforeSave(config);
|
validEntityBeforeSave(config);
|
||||||
LambdaUpdateWrapper<SysOssConfig> luw = new LambdaUpdateWrapper<>();
|
return setConfigCache(updateById(config), config);
|
||||||
luw.set(StringUtils.isBlank(config.getPrefix()), SysOssConfig::getPrefix, "");
|
|
||||||
luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, "");
|
|
||||||
luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, "");
|
|
||||||
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
|
|
||||||
return setConfigCache(update(config, luw), config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user