fix: 逻辑删除唯一索引冲突的问题

pull/2/head
gaibu 2022-12-10 11:59:21 +08:00
parent 67435648b2
commit 9e3ed75772
2 changed files with 10 additions and 3 deletions

View File

@ -7,8 +7,11 @@ import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeExpo
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@Mapper @Mapper
@ -39,4 +42,10 @@ public interface DictTypeMapper extends BaseMapperX<DictTypeDO> {
return selectOne(DictTypeDO::getName, name); return selectOne(DictTypeDO::getName, name);
} }
@Delete("UPDATE system_dict_type SET DELETED = 1,DELETED_TIME=#{deletedTime} WHERE id = #{id}")
int deleteById(@Param("id") Long id, @Param("deletedTime") LocalDateTime deletedTime);
default int deleteById(Long id) {
return deleteById(id, LocalDateTime.now());
}
} }

View File

@ -81,9 +81,7 @@ public class DictTypeServiceImpl implements DictTypeService {
throw exception(DICT_TYPE_HAS_CHILDREN); throw exception(DICT_TYPE_HAS_CHILDREN);
} }
// 删除字典类型 // 删除字典类型
dictType.setDeletedTime(LocalDateTime.now()); dictTypeMapper.deleteById(id);
dictType.setDeleted(true);
dictTypeMapper.updateById(dictType);
} }
@Override @Override