|
@ -1,9 +1,10 @@
|
|
|
package com.yihu.ehr.resource.controller;
|
|
|
|
|
|
import com.yihu.ehr.constants.ServiceApi;
|
|
|
import com.yihu.ehr.constants.ApiVersion;
|
|
|
import com.yihu.ehr.constants.ServiceApi;
|
|
|
import com.yihu.ehr.controller.EnvelopRestEndPoint;
|
|
|
import com.yihu.ehr.model.resource.MRsDictionaryEntry;
|
|
|
import com.yihu.ehr.resource.constants.MicroServiceApi;
|
|
|
import com.yihu.ehr.resource.model.RsDictionaryEntry;
|
|
|
import com.yihu.ehr.resource.service.RsDictionaryEntryService;
|
|
|
import io.swagger.annotations.Api;
|
|
@ -50,7 +51,6 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@ApiOperation(value = "创建标准字典项", notes = "创建标准字典项")
|
|
|
public MRsDictionaryEntry createRsDictionaryEntry(
|
|
@ -60,7 +60,7 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
RsDictionaryEntry dictionaryEntry = toEntity(jsonData, RsDictionaryEntry.class);
|
|
|
String code = dictionaryEntry.getCode();
|
|
|
String dictCode = dictionaryEntry.getDictCode();
|
|
|
if(isExistence(dictCode,code)){
|
|
|
if (isExistence(dictCode, code)) {
|
|
|
throw new Exception("字典项代码不能重复");
|
|
|
}
|
|
|
rsDictionaryEntryService.insert(dictionaryEntry);
|
|
@ -68,7 +68,7 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value =ServiceApi.Resources.DictEntries, method = RequestMethod.PUT)
|
|
|
@RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "修改标准字典项", notes = "修改标准字典项")
|
|
|
public MRsDictionaryEntry updateRsDictionaryEntry(
|
|
|
@ApiParam(name = "json_data", value = "")
|
|
@ -78,7 +78,7 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
RsDictionaryEntry d = rsDictionaryEntryService.findById(dictionaryEntry.getId());
|
|
|
String code = dictionaryEntry.getCode();
|
|
|
String dictCode = dictionaryEntry.getDictCode();
|
|
|
if(!d.getCode().equals(code) && isExistence(dictCode,code)){
|
|
|
if (!d.getCode().equals(code) && isExistence(dictCode, code)) {
|
|
|
throw new Exception("字典代码不可修改");
|
|
|
}
|
|
|
rsDictionaryEntryService.save(dictionaryEntry);
|
|
@ -105,26 +105,25 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
|
|
|
@RequestMapping(value = ServiceApi.Resources.DictEntriesByDictCode, method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "根据dict_code获取获取标准字典")
|
|
|
public List<MRsDictionaryEntry> getRsDictionaryEntryByDictCode(
|
|
|
public List<MRsDictionaryEntry> getRsDictionaryEntryByDictCode(
|
|
|
@ApiParam(name = "dict_code", value = "", defaultValue = "")
|
|
|
@RequestParam(value = "dict_code") String dict_code)
|
|
|
{
|
|
|
@RequestParam(value = "dict_code") String dict_code) {
|
|
|
List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.findByDictCode(dict_code);
|
|
|
return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class,null);
|
|
|
return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class, null);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = ServiceApi.Resources.DictEntriesExistence,method = RequestMethod.GET)
|
|
|
@RequestMapping(value = ServiceApi.Resources.DictEntriesExistence, method = RequestMethod.GET)
|
|
|
@ApiOperation("根据过滤条件判断是否存在")
|
|
|
public boolean isExistence(
|
|
|
@ApiParam(name="filters",value="filters",defaultValue = "")
|
|
|
@RequestParam(value="filters") String filters) throws Exception {
|
|
|
@ApiParam(name = "filters", value = "filters", defaultValue = "")
|
|
|
@RequestParam(value = "filters") String filters) throws Exception {
|
|
|
|
|
|
List ls = rsDictionaryEntryService.search("",filters,"", 1, 1);
|
|
|
return ls!=null && ls.size()>0;
|
|
|
List ls = rsDictionaryEntryService.search("", filters, "", 1, 1);
|
|
|
return ls != null && ls.size() > 0;
|
|
|
}
|
|
|
|
|
|
public boolean isExistence(String dictCode,String code) {
|
|
|
return rsDictionaryEntryService.findByFields(new String[]{"dictCode","code"},new String[]{dictCode,code}).size() != 0;
|
|
|
public boolean isExistence(String dictCode, String code) {
|
|
|
return rsDictionaryEntryService.findByFields(new String[]{"dictCode", "code"}, new String[]{dictCode, code}).size() != 0;
|
|
|
}
|
|
|
|
|
|
|
|
@ -136,4 +135,20 @@ public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
|
|
|
List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.search(filters);
|
|
|
return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class, "");
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = MicroServiceApi.Resource.DICT_ENTRY, method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "根据code从缓存获取字典项值")
|
|
|
public String getCacheValue(
|
|
|
@ApiParam(name = "dict") @RequestParam(value = "dict") String dict,
|
|
|
@ApiParam(name = "code") @RequestParam(value = "code") String code) {
|
|
|
|
|
|
return rsDictionaryEntryService.getCacheValue(dict, code);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = MicroServiceApi.Resource.DICT_ENTRY, method = RequestMethod.DELETE)
|
|
|
@ApiOperation(value = "清空缓存字典项")
|
|
|
public void deleteCacheValue(
|
|
|
@ApiParam(name = "dict") @RequestParam(value = "dict") String dict) {
|
|
|
rsDictionaryEntryService.deleteCacheValue(dict);
|
|
|
}
|
|
|
}
|