当前使用版本(必填,否则不予处理)

com.baomidou mybatis-plus-boot-starter 3.3.2

该问题是如何引起的?(确定最新版也有问题再提!!!)

Database unique key restrictions

重现步骤(如果有就写完整)

The first deletion has a unique code. The second time you create a similar code, you will report an error if you delete it If you want to add a fill like fieldfill delete, it will be filled automatically only when you call delete

He should be like that FieldFill.UPDATE Call FieldFill.DELETE

报错信息

Comment From: lyricsqq

我现在新加了一个类 来处理这个问题 给唯一键加了一个时间搓的辅助字段 进行唯一标识。只有在删除的时候才会更新这个字段。默认值 是一个定值 / * @author lyrics * @version 1.0 */ public class LogicDeleteUnique extends AbstractMethod { / mapper 对应的方法名 */ private static final String MAPPER_METHOD = "deleteUnique";

@Override public MappedStatement injectMappedStatement( Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) { String sql; SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID; if (tableInfo.isLogicDelete()) { List fieldInfos = tableInfo.getFieldList().stream() .filter( i -> i.getFieldFill() == FieldFill.UPDATE || i.getFieldFill() == FieldFill.INSERT_UPDATE|| i.getColumn().equals("delLongKey")) .collect(toList()); if (CollectionUtils.isNotEmpty(fieldInfos)) { String sqlSet = "SET " + fieldInfos.stream().map(i -> i.getSqlSet(EMPTY)).collect(joining(EMPTY)) + tableInfo.getLogicDeleteSql(false, true); sql = String.format( sqlMethod.getSql(), tableInfo.getTableName(), sqlSet, tableInfo.getKeyColumn(), tableInfo.getKeyProperty(), tableInfo.getLogicDeleteSql(true, false)); } else { sql = String.format( sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo), tableInfo.getKeyColumn(), tableInfo.getKeyProperty(), tableInfo.getLogicDeleteSql(true, false)); } } else { sqlMethod = SqlMethod.DELETE_BY_ID; sql = String.format( sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty()); } SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass); return addUpdateMappedStatement(mapperClass, modelClass, MAPPER_METHOD, sqlSource); } }

Comment From: miemieYaho

填充只是set到入参的entity里