package cn.com.goldenwater.dcproj.controller.ducha; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.DictType; import cn.com.goldenwater.dcproj.param.DictTypeParam; import cn.com.goldenwater.dcproj.service.DictTypeService; import cn.com.goldenwater.dcproj.util.CheckUtil; import cn.com.goldenwater.dcproj.utils.Builder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * @author * @date Mar 4, 2022 */ @Api(value = "xxx管理", tags = "xxx管理") @RestController @RequestMapping("/dict/type") public class DictTypeController extends BaseController { @Autowired private DictTypeService dictTypeService; @ApiOperation(value = "修改xxx") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "dictType", value = "DictType", required = true) @RequestBody DictType dictType) { int ret = 0; if (StringUtils.isBlank(dictType.getId())) { ret = dictTypeService.insert(dictType); } else { ret = dictTypeService.update(dictType); } return buildSuccessResponse(dictType); } @ApiOperation(value = "根据ID删除xxx") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = dictTypeService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取xxx(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { DictType dictType = dictTypeService.get(id); return buildSuccessResponse(dictType); } @ApiOperation(value = "根据ID获取xxx(单表)") @GetMapping("/by/{type}") public BaseResponse getByType(@ApiParam(name = "type", value = "type", required = true) @PathVariable String type) { CheckUtil.notEmpty(type, "type no"); String curentOrgId = getCurrentOrgId(); return buildSuccessResponse(dictTypeService.findList(Builder.of(DictTypeParam::new).with(DictTypeParam::setOwnerSystem, type).with(DictTypeParam::setOwnerOfc, curentOrgId).build())); } }