|
@ -14,6 +14,7 @@ import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
@ -45,19 +46,20 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
|
|
|
@RequestParam(value = "size", required = false) Integer size,
|
|
|
@ApiParam(name = "page", value = "页码", defaultValue = "1")
|
|
|
@RequestParam(value = "page", required = false) Integer page) throws Exception {
|
|
|
List<SystemDictEntry> systemDictEntryList = systemDictEntryService.search(fields,filters,sorts,page,size);
|
|
|
return success(systemDictEntryList,(null==systemDictEntryList)?0:systemDictEntryList.size(),page, size);
|
|
|
List<SystemDictEntry> systemDictEntryList = systemDictEntryService.search(fields, filters, sorts, page, size);
|
|
|
int count = (int) systemDictEntryService.getCount(filters);
|
|
|
return success(systemDictEntryList, count, page, size);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "创建字典项")
|
|
|
@PostMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.CREATE)
|
|
|
public ObjEnvelop<SystemDictEntry> createDictEntry (
|
|
|
public ObjEnvelop<SystemDictEntry> createDictEntry(
|
|
|
@ApiParam(name = "entryJson", value = "字典项JSON结构")
|
|
|
@RequestParam(value = "entryJson") String entryJson) throws IOException{
|
|
|
@RequestParam(value = "entryJson") String entryJson) throws IOException {
|
|
|
SystemDictEntry entry = toEntity(entryJson, SystemDictEntry.class);
|
|
|
SystemDict systemDict = dictService.retrieve(entry.getDictId());
|
|
|
if (systemDict == null) {
|
|
|
return failed("所属字典不存在!",ObjEnvelop.class);
|
|
|
return failed("所属字典不存在!", ObjEnvelop.class);
|
|
|
}
|
|
|
int nextSort = systemDictEntryService.getNextSN(entry.getDictId());
|
|
|
entry.setSort(nextSort);
|
|
@ -72,7 +74,7 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "dictId", value = "字典ID", required = true)
|
|
|
@RequestParam(value = "dictId") String dictId,
|
|
|
@ApiParam(name = "code", value = "字典项代码", required = true)
|
|
|
@RequestParam(value = "code") String code) throws Exception{
|
|
|
@RequestParam(value = "code") String code) throws Exception {
|
|
|
SystemDictEntry systemDictEntry = systemDictEntryService.getDictEntry(dictId, code);
|
|
|
return success(systemDictEntry);
|
|
|
}
|
|
@ -83,46 +85,46 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "dictId", value = "字典ID")
|
|
|
@RequestParam(value = "dictId") String dictId,
|
|
|
@ApiParam(name = "code", value = "字典项编码")
|
|
|
@RequestParam(value = "code") String code) throws Exception{
|
|
|
@RequestParam(value = "code") String code) throws Exception {
|
|
|
systemDictEntryService.deleteDictEntry(dictId, code);
|
|
|
return success("success");
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "修改字典项")
|
|
|
@PutMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.UPDATE)
|
|
|
@PutMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.UPDATE)
|
|
|
public ObjEnvelop<SystemDictEntry> updateDictEntry(
|
|
|
@ApiParam(name = "entryJson", value = "字典项JSON结构")
|
|
|
@RequestParam(value = "entryJson") String entryJson) throws IOException {
|
|
|
SystemDictEntry entry = toEntity(entryJson, SystemDictEntry.class);
|
|
|
SystemDictEntry temp = systemDictEntryService.retrieve(new DictEntryKey(entry.getCode(), entry.getDictId()));
|
|
|
if (null == temp) {
|
|
|
failed("字典项不存在!",ObjEnvelop.class);
|
|
|
failed("字典项不存在!", ObjEnvelop.class);
|
|
|
}
|
|
|
entry.setUpdateTime(new Date());
|
|
|
systemDictEntryService.saveDictEntry(entry);
|
|
|
return success(entry);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.ISEXISTSDICTENTRYBYDICTIDANDCODE)
|
|
|
@GetMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.ISEXISTSDICTENTRYBYDICTIDANDCODE)
|
|
|
@ApiOperation(value = "根据dictId和code判断提交的字典项是否已经存在")
|
|
|
public boolean isDictEntryCodeExists(
|
|
|
@ApiParam(name = "dictId", value = "字典id", defaultValue = "")
|
|
|
@RequestParam(value = "dictId",required = true) String dictId,
|
|
|
@RequestParam(value = "dictId", required = true) String dictId,
|
|
|
@ApiParam(name = "code", value = "字典项编码", defaultValue = "")
|
|
|
@RequestParam(value = "code") String code){
|
|
|
@RequestParam(value = "code") String code) {
|
|
|
return systemDictEntryService.isDictContainEntry(dictId, code);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.GETDICTENTRYBYDICTIDANDNAME)
|
|
|
@GetMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.GETDICTENTRYBYDICTIDANDNAME)
|
|
|
@ApiOperation(value = "根据dictId和name判断提交的字典项是否已经存在")
|
|
|
public boolean isDictEntryNameExists(
|
|
|
@ApiParam(name = "dictId", value = "字典id", defaultValue = "")
|
|
|
@RequestParam(value = "dictId",required = true) String dictId,
|
|
|
@RequestParam(value = "dictId", required = true) String dictId,
|
|
|
@ApiParam(name = "name", value = "字典项名称")
|
|
|
@RequestParam(value = "name") String name){
|
|
|
List<SystemDictEntry> systemDictEntryPage= systemDictEntryService.findByDictIdAndValueLike(dictId, name);
|
|
|
if(null!=systemDictEntryPage&&systemDictEntryPage.size()>0){
|
|
|
return true;
|
|
|
@RequestParam(value = "name") String name) {
|
|
|
List<SystemDictEntry> systemDictEntryPage = systemDictEntryService.findByDictIdAndValueLike(dictId, name);
|
|
|
if (null != systemDictEntryPage && systemDictEntryPage.size() > 0) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
@ -131,7 +133,7 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
|
|
|
@ApiOperation(value = "根据dictId获取所有字典项")
|
|
|
public ListEnvelop GetSystemDictEntryListByDictId(
|
|
|
@ApiParam(name = "dictId", value = "字典id")
|
|
|
@RequestParam(value = "dictId") String dictId) throws Exception{
|
|
|
@RequestParam(value = "dictId") String dictId) throws Exception {
|
|
|
List<SystemDictEntry> cardList = systemDictEntryService.getDictEntryCodeAndValueByDictId(dictId);
|
|
|
return success(cardList);
|
|
|
}
|