package cn.com.goldenwater.dcproj.controller.system; import cn.com.goldenwater.dcproj.model.RelOrgInspType; import cn.com.goldenwater.dcproj.service.RelOrgInspTypeService; 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-4-2 */ @Api(value = "机构对应督查类型关系管理", tags = "机构对应督查类型关系管理") @RestController @RequestMapping("/bis/insp/rel/org/insp/type") public class RelOrgInspTypeController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private RelOrgInspTypeService relOrgInspTypeService; @ApiOperation(value = "添加机构对应督查类型关系") @RequestMapping(value = "/add", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "relOrgInspType", value = "RelOrgInspType", required = true) @RequestBody RelOrgInspType relOrgInspType) { int ret = relOrgInspTypeService.insert(relOrgInspType); return buildSuccessResponse(relOrgInspType); } @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 = relOrgInspTypeService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "更新机构对应督查类型关系信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "relOrgInspType", value = "RelOrgInspType", required = true) @RequestBody RelOrgInspType relOrgInspType) { Assert.notNull(relOrgInspType.getId(), "主键id为必填参数"); int ret = relOrgInspTypeService.update(relOrgInspType); return buildSuccessResponse(relOrgInspType); } @ApiOperation(value = "根据ID获取机构对应督查类型关系(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { RelOrgInspType relOrgInspType = relOrgInspTypeService.get(id); return buildSuccessResponse(relOrgInspType); } @ApiOperation(value = "添加多个机构对应督查类型关系") @RequestMapping(value = "/addList", method = RequestMethod.POST) public BaseResponse> addList(@ApiParam(name = "relOrgInspType", value = "RelOrgInspType", required = true) @RequestBody List relOrgInspTypes) { if (relOrgInspTypes.size() < 0) { return buildFailResponse("必须添加大于一个的督查类型"); } else { int ret = relOrgInspTypeService.addList(relOrgInspTypes); return buildSuccessResponse(relOrgInspTypes); } } @ApiOperation(value = "根据机构ID获取可以管理的督查类型") @RequestMapping(value = "/getInspTypeByOrgId/{orgId}", method = RequestMethod.GET) public BaseResponse> getInspTypeByOrgId(@ApiParam(name = "orgId", value = "机构ID", required = false) @PathVariable String orgId) { orgId = getCurrentOrgId(); String persId = getCurrentPersId(); List relOrgInspTypes = relOrgInspTypeService.getInspTypeByOrgId(orgId, persId); return buildSuccessResponse(relOrgInspTypes); } @ApiOperation(value = "根据个人获取可以管理的督查类型") @RequestMapping(value = "/getInspTypeByOrgIdPers/{orgId}", method = RequestMethod.GET) public BaseResponse> getInspTypeByOrgIdPers(@ApiParam(name = "orgId", value = "机构ID", required = false) @PathVariable String orgId) { orgId = getCurrentOrgId(); String persId = getCurrentPersId(); List relOrgInspTypes = relOrgInspTypeService.getInspTypeByOrgIdPers(orgId, persId); return buildSuccessResponse(relOrgInspTypes); } }