Browse Source

feat(all): 修改价格模版名称唯一校验时无法通过问题

dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
ab7c70dcd7
  1. 15
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java

15
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceTemplateServiceImpl.java

@ -21,6 +21,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity; import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity;
@ -204,14 +205,18 @@ public class BasicdataPriceTemplateServiceImpl extends BaseServiceImpl<Basicdata
default: default:
throw new ServiceException("当前选择的类型不存在"); throw new ServiceException("当前选择的类型不存在");
} }
checkName(priceTemplateEntity.getName()); checkName(priceTemplateEntity.getName(), priceTemplateEntity.getId());
this.baseMapper.updateById(priceTemplateEntity); this.baseMapper.updateById(priceTemplateEntity);
return Boolean.TRUE; return Boolean.TRUE;
} }
private void checkName(String name) { private void checkName(String name, Long id) {
BasicdataPriceTemplateEntity one = this.getOne(Wrappers.<BasicdataPriceTemplateEntity>lambdaQuery() LambdaQueryWrapper<BasicdataPriceTemplateEntity> wrapper = Wrappers.<BasicdataPriceTemplateEntity>lambdaQuery()
.eq(BasicdataPriceTemplateEntity::getName, name) .eq(BasicdataPriceTemplateEntity::getName, name);
if (ObjectUtil.isNotEmpty(id)) {
wrapper.ne(BasicdataPriceTemplateEntity::getId, id);
}
BasicdataPriceTemplateEntity one = this.getOne(wrapper
.last("limit 1") .last("limit 1")
); );
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
@ -240,7 +245,7 @@ public class BasicdataPriceTemplateServiceImpl extends BaseServiceImpl<Basicdata
} else { } else {
basicdataPriceTemplate.setTemplateType("用户"); basicdataPriceTemplate.setTemplateType("用户");
} }
checkName(basicdataPriceTemplate.getName()); checkName(basicdataPriceTemplate.getName(),null);
this.save(basicdataPriceTemplate); this.save(basicdataPriceTemplate);
return basicdataPriceTemplate.getId(); return basicdataPriceTemplate.getId();
} }

Loading…
Cancel
Save