package cn.com.goldenwater.dcproj.controller.base; import cn.com.goldenwater.dcproj.model.AttBasBase; import cn.com.goldenwater.dcproj.param.AttBasBaseParam; import cn.com.goldenwater.dcproj.service.AttBasBaseService; 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.apache.commons.lang3.StringUtils; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; 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 lune * @date 2019-7-30 */ @Api(value = "ATT 流域机构表管理", tags = "ATT 流域机构表管理") @RestController @RequestMapping("/att/bas/base") public class AttBasBaseController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private AttBasBaseService attBasBaseService; @ApiOperation(value = "添加/修改流域机构表") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "attBasBase", value = "AttBasBase", required = true) @RequestBody AttBasBase attBasBase) { if (StringUtils.isBlank(attBasBase.getBasCode())) { int count = attBasBaseService.selectMax(); count++; if (String.valueOf(count).length() == 4) { attBasBase.setBasCode("00" + count); } if (String.valueOf(count).length() == 5) { attBasBase.setBasCode("0" + count); } if (String.valueOf(count).length() == 6) { attBasBase.setBasCode("" + count); } attBasBaseService.insert(attBasBase); } else { attBasBaseService.update(attBasBase); } return buildSuccessResponse(attBasBase); } @ApiOperation(value = "根据ID删除流域机构表") @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = attBasBaseService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取流域机构表(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { AttBasBase attBasBase = attBasBaseService.get(id); return buildSuccessResponse(attBasBase); } @ApiOperation(value = "获取流域机构表(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) { List attBasBaseList = attBasBaseService.findList(attBasBaseParam); return buildSuccessResponse(attBasBaseList); } @ApiOperation(value = "获取流域机构表(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) { PageInfo attBasBaseList = attBasBaseService.findPageInfo(attBasBaseParam); return buildSuccessResponse(attBasBaseList); } }