package com.lxzn.base.controller; import com.lxzn.api.base.SingleDictionaryControllerApi; import com.lxzn.base.service.ISingleDictionaryService; import com.lxzn.framework.domain.base.SingleDictionary; import com.lxzn.framework.domain.base.request.SingleDictionaryRequest; import com.lxzn.framework.model.response.CommonCode; import com.lxzn.framework.model.response.QueryListResponseResult; import com.lxzn.framework.model.response.QueryPageResponseResult; import com.lxzn.framework.model.response.ResponseResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @RestController @RequestMapping("/base/single") public class SingleDictionaryController implements SingleDictionaryControllerApi { @Autowired private ISingleDictionaryService dictionaryService; @Override @PostMapping("/add") public ResponseResult addDictionary(@RequestBody SingleDictionary dictionary) { boolean b = dictionaryService.addDictionary(dictionary); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @Override @GetMapping("/find/page/{page}/{size}") public QueryPageResponseResult findPageList(@PathVariable("page") int page, @PathVariable("size") int size, SingleDictionaryRequest requestParams) { return dictionaryService.findPageList(page, size, requestParams); } @Override @PutMapping("/edit/{id}") public ResponseResult editDictionary(@PathVariable("id") String id,@RequestBody SingleDictionary dictionary) { boolean b = dictionaryService.editDictionary(id,dictionary); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @Override @DeleteMapping("/delete") public ResponseResult deleteDictionary(@RequestParam("id") String id) { boolean b = dictionaryService.deleteDictionaryById(id); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @Override @GetMapping("/find/list") public QueryListResponseResult findListByTypeCode(@RequestParam("typeCode") String typeCode) { List list = dictionaryService.findListFromTypeCode(typeCode); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult(CommonCode.SUCCESS, list); } }