package cn.com.goldenwater.dcproj.controller.general; import cn.com.goldenwater.dcproj.model.Dic; import cn.com.goldenwater.dcproj.service.DicService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @author lhc * @date 2020-8-5 */ @Api(value = "系统字典管理", tags = "系统字典管理") @RestController @RequestMapping("/bis/insp/dic") public class DicController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private DicService dicService; @ApiOperation(value = "添加系统字典") @RequestMapping(value = "/add", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "dic", value = "Dic", required = true) @RequestBody Dic dic) { int ret = dicService.insert(dic); return buildSuccessResponse(dic); } @ApiOperation(value = "根据ID删除系统字典") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = dicService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新系统字典信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "dic", value = "Dic", required = true) @RequestBody Dic dic) { Assert.notNull(dic.getId(), "主键id为必填参数"); int ret = dicService.update(dic); return buildSuccessResponse(dic); } @ApiOperation(value = "根据ID获取系统字典(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { Dic dic = dicService.get(id); return buildSuccessResponse(dic); } @ApiOperation(value = "根据ID获取系统字典(单表)") @RequestMapping(value = "getDic/{bzCode}/{itemCode}", method = RequestMethod.GET) public BaseResponse> getDic(@ApiParam(name = "bzCode", value = "bzCode", required = true) @PathVariable String bzCode, @ApiParam(name = "itemCode", value = "itemCode", required = true) @PathVariable String itemCode) { List dics = dicService.getDic(bzCode, itemCode); return buildSuccessResponse(dics); } @ApiOperation(value = "根据ID获取系统字典(单表)") @RequestMapping(value = "getDic/{bzCode}/{itemCode}/{code}", method = RequestMethod.GET) public BaseResponse getDicSingle(@ApiParam(name = "bzCode", value = "bzCode", required = true) @PathVariable String bzCode, @ApiParam(name = "itemCode", value = "itemCode", required = true) @PathVariable String itemCode, @ApiParam(name = "code", value = "code", required = true) @PathVariable String code) { Dic dic = dicService.getDicSingle(bzCode, itemCode, code); return buildSuccessResponse(dic ); } }