|
@@ -12,6 +12,7 @@ import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.mapper.dict.DictTenantDataMapper;
|
|
|
import com.fjhx.tenant.service.dict.DictCommonDataService;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
+import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -51,21 +52,34 @@ public class DictTenantDataServiceImpl extends ServiceImpl<DictTenantDataMapper,
|
|
|
public void add(DictTenantDataDto dictTenantDataDto) {
|
|
|
|
|
|
long dictTenantDataKeyCount = count(q -> q
|
|
|
+ .eq(DictTenantData::getDictCode, dictTenantDataDto.getDictCode())
|
|
|
.eq(DictTenantData::getDictKey, dictTenantDataDto.getDictKey())
|
|
|
.eq(DictTenantData::getTenantId, dictTenantDataDto.getTenantId()));
|
|
|
if (dictTenantDataKeyCount > 0) {
|
|
|
- throw new ServiceException("key已存在");
|
|
|
+ throw new ServiceException("租户字典key已存在");
|
|
|
}
|
|
|
|
|
|
long dictTenantDataValueCount = count(q -> q
|
|
|
+ .eq(DictTenantData::getDictCode, dictTenantDataDto.getDictCode())
|
|
|
.eq(DictTenantData::getDictValue, dictTenantDataDto.getDictValue())
|
|
|
.eq(DictTenantData::getTenantId, dictTenantDataDto.getTenantId()));
|
|
|
if (dictTenantDataValueCount > 0) {
|
|
|
- throw new ServiceException("value已存在");
|
|
|
+ throw new ServiceException("租户字典value已存在");
|
|
|
}
|
|
|
|
|
|
- dictCommonDataService.nameDuplication(DictCommonData::getDictKey, dictTenantDataDto.getDictKey(), "key已存在");
|
|
|
- dictCommonDataService.nameDuplication(DictCommonData::getDictValue, dictTenantDataDto.getDictValue(), "value已存在");
|
|
|
+ long dictCommonDataKeyCount = dictCommonDataService.count(q -> q
|
|
|
+ .eq(DictCommonData::getDictCode, dictTenantDataDto.getDictCode())
|
|
|
+ .eq(DictCommonData::getDictKey, dictTenantDataDto.getDictKey()));
|
|
|
+ if (dictCommonDataKeyCount > 0) {
|
|
|
+ throw new ServiceException("业务字典key已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ long dictCommonDataValueCount = dictCommonDataService.count(q -> q
|
|
|
+ .eq(DictCommonData::getDictCode, dictTenantDataDto.getDictCode())
|
|
|
+ .eq(DictCommonData::getDictValue, dictTenantDataDto.getDictValue()));
|
|
|
+ if (dictCommonDataValueCount > 0) {
|
|
|
+ throw new ServiceException("业务字典value已存在");
|
|
|
+ }
|
|
|
|
|
|
this.save(dictTenantDataDto);
|
|
|
}
|
|
@@ -78,24 +92,43 @@ public class DictTenantDataServiceImpl extends ServiceImpl<DictTenantDataMapper,
|
|
|
throw new ServiceException("id不能为空");
|
|
|
}
|
|
|
|
|
|
+ dictTenantDataDto.setDictCode(null);
|
|
|
+
|
|
|
+ DictTenantData dictTenantData = getById(id);
|
|
|
+
|
|
|
long dictTenantDataKeyCount = count(q -> q
|
|
|
+ .eq(DictTenantData::getDictCode, dictTenantData.getDictCode())
|
|
|
.eq(DictTenantData::getDictKey, dictTenantDataDto.getDictKey())
|
|
|
.eq(DictTenantData::getTenantId, dictTenantDataDto.getTenantId())
|
|
|
- .ne(DictTenantData::getId, id));
|
|
|
+ .ne(BaseIdPo::getId, id)
|
|
|
+ );
|
|
|
if (dictTenantDataKeyCount > 0) {
|
|
|
- throw new ServiceException("key已存在");
|
|
|
+ throw new ServiceException("租户字典key已存在");
|
|
|
}
|
|
|
|
|
|
long dictTenantDataValueCount = count(q -> q
|
|
|
+ .eq(DictTenantData::getDictCode, dictTenantData.getDictCode())
|
|
|
.eq(DictTenantData::getDictValue, dictTenantDataDto.getDictValue())
|
|
|
.eq(DictTenantData::getTenantId, dictTenantDataDto.getTenantId())
|
|
|
- .ne(DictTenantData::getId, id));
|
|
|
+ .ne(BaseIdPo::getId, id)
|
|
|
+ );
|
|
|
if (dictTenantDataValueCount > 0) {
|
|
|
- throw new ServiceException("value已存在");
|
|
|
+ throw new ServiceException("租户字典value已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ long dictCommonDataKeyCount = dictCommonDataService.count(q -> q
|
|
|
+ .eq(DictCommonData::getDictCode, dictTenantData.getDictCode())
|
|
|
+ .eq(DictCommonData::getDictKey, dictTenantDataDto.getDictKey()));
|
|
|
+ if (dictCommonDataKeyCount > 0) {
|
|
|
+ throw new ServiceException("业务字典key已存在");
|
|
|
}
|
|
|
|
|
|
- dictCommonDataService.nameDuplication(DictCommonData::getDictKey, dictTenantDataDto.getDictKey(), id, "key已存在");
|
|
|
- dictCommonDataService.nameDuplication(DictCommonData::getDictValue, dictTenantDataDto.getDictValue(), id, "value已存在");
|
|
|
+ long dictCommonDataValueCount = dictCommonDataService.count(q -> q
|
|
|
+ .eq(DictCommonData::getDictCode, dictTenantData.getDictCode())
|
|
|
+ .eq(DictCommonData::getDictValue, dictTenantDataDto.getDictValue()));
|
|
|
+ if (dictCommonDataValueCount > 0) {
|
|
|
+ throw new ServiceException("业务字典value已存在");
|
|
|
+ }
|
|
|
|
|
|
this.updateById(dictTenantDataDto);
|
|
|
}
|