新增返回主键的新增方法

This commit is contained in:
wenc000 2020-04-07 14:05:12 +08:00
parent ca4aaa6119
commit 99f7cda2ae
2 changed files with 33 additions and 2 deletions

View File

@ -44,6 +44,25 @@ public interface IDataDictionaryService {
*/
SuccessResult saveDictionary(String token, DataDictionaryVO dictionaryVO) throws Exception;
/**
* 字典新增
*
* @param dictionaryVO
* @return 新增ID
* @throws Exception
*/
String saveDictionaryReturnId(DataDictionaryVO dictionaryVO) throws Exception;
/**
* 字典新增
*
* @param token
* @param dictionaryVO
* @return 新增ID
* @throws Exception
*/
String saveDictionaryReturnId(String token, DataDictionaryVO dictionaryVO) throws Exception;
/**
* 字典删除
*

View File

@ -52,7 +52,18 @@ public class DataDictionaryServiceImpl extends AbstractService implements IDataD
return new SuccessResult();
}
private void saveDictionaryInfo(String token, DataDictionaryVO dictionaryVO) throws Exception {
@Override
public String saveDictionaryReturnId(DataDictionaryVO dictionaryVO) throws Exception {
return saveDictionaryInfo(null, dictionaryVO);
}
@Override
public String saveDictionaryReturnId(String token, DataDictionaryVO dictionaryVO) throws Exception {
return saveDictionaryInfo(token, dictionaryVO);
}
private String saveDictionaryInfo(String token, DataDictionaryVO dictionaryVO) throws Exception {
String uuid = UUIDUtil.getUUID();
String parentCode = null;
String dictionaryParentId = dictionaryVO.getDictionaryParentId();
if (!StringUtils.equals(dictionaryParentId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) {
@ -62,13 +73,14 @@ public class DataDictionaryServiceImpl extends AbstractService implements IDataD
String dictionaryCode = getCode(parentCode, dictionaryParentId);
Map<String, Object> params = HashMapUtil.beanToMap(dictionaryVO);
params.put("dictionaryCode", dictionaryCode);
params.put("dictionaryId", UUIDUtil.getUUID());
params.put("dictionaryId", uuid);
if (StringUtils.isBlank(token)) {
setSaveInfo(params);
} else {
setSaveInfo(token, params);
}
dictionaryDao.saveDictionary(params);
return uuid;
}
@Override