|
|
@@ -53,17 +53,17 @@ public class DictionaryService extends SuperService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent addDictionary(AddDictionaryParam param){
|
|
|
- Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getKey());
|
|
|
- if (byProjectIdAndKey != null){
|
|
|
- return ResultContent.buildFail("字典编码已存在");
|
|
|
- }
|
|
|
-
|
|
|
if (StringUtils.isNotBlank(param.getId())){
|
|
|
UpdateDictionaryParam updateParam = new UpdateDictionaryParam();
|
|
|
BeanUtils.copyProperties(param, updateParam);
|
|
|
return updateDictionary(updateParam);
|
|
|
}
|
|
|
|
|
|
+ Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getKey());
|
|
|
+ if (byProjectIdAndKey != null){
|
|
|
+ return ResultContent.buildFail("字典编码已存在");
|
|
|
+ }
|
|
|
+
|
|
|
Dictionary dictionary = new Dictionary();
|
|
|
|
|
|
BeanUtils.copyProperties(param, dictionary);
|
|
|
@@ -95,7 +95,7 @@ public class DictionaryService extends SuperService {
|
|
|
if (byProjectIdAndKey != null && !byProjectIdAndKey.getId().equals(param.getId())){
|
|
|
return ResultContent.buildFail("字典编码已存在");
|
|
|
}
|
|
|
- com.zhongshu.card.server.core.util.BeanUtils.copyPropertiesWithoutNull(param, dictionary);
|
|
|
+ com.zhongshu.card.server.core.util.BeanUtils.copyProperties(param, dictionary,"id");
|
|
|
dictionaryDao.save(dictionary);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -141,6 +141,11 @@ public class DictionaryService extends SuperService {
|
|
|
* 添加项
|
|
|
*/
|
|
|
public ResultContent addItem(AddDictionaryItemParam param){
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(param.getId())){
|
|
|
+ return updateItem(param);
|
|
|
+ }
|
|
|
Dictionary dictionary = dictionaryDao.findTopById(param.getDictionaryId());
|
|
|
if (dictionary == null){
|
|
|
return ResultContent.buildFail("字典不存在");
|
|
|
@@ -150,6 +155,11 @@ public class DictionaryService extends SuperService {
|
|
|
return ResultContent.buildFail("标准字典不允许添加项");
|
|
|
}
|
|
|
|
|
|
+ DictionaryItem updateItem = dictionaryItemDao.findTopByDictionary_IdAndKey(param.getDictionaryId(), param.getKey());
|
|
|
+ if (updateItem != null && !updateItem.getId().equals(param.getId())){
|
|
|
+ return ResultContent.buildFail("项编码已存在");
|
|
|
+ }
|
|
|
+
|
|
|
DictionaryItem dictionaryItem = new DictionaryItem();
|
|
|
BeanUtils.copyProperties(param, dictionaryItem, "id");
|
|
|
dictionaryItem.setType(DictionaryType.Customize);
|
|
|
@@ -158,6 +168,10 @@ public class DictionaryService extends SuperService {
|
|
|
dictionaryItem.setId(id);
|
|
|
dictionaryItem.setIdString(id);
|
|
|
dictionaryItem.setCreateTime(System.currentTimeMillis());
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(param.getParentId())){
|
|
|
+ dictionaryItem.setParentId(null);
|
|
|
+ }
|
|
|
dictionaryItemDao.save(dictionaryItem);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|