| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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<AttBasBase> 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<AttBasBase> 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<AttBasBase>> list(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) {
- List<AttBasBase> attBasBaseList = attBasBaseService.findList(attBasBaseParam);
- return buildSuccessResponse(attBasBaseList);
- }
- @ApiOperation(value = "获取流域机构表(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<AttBasBase>> page(@ApiParam(name = "attBasBaseParam", value = "attBasBaseParam", required = true) @RequestBody AttBasBaseParam attBasBaseParam) {
- PageInfo<AttBasBase> attBasBaseList = attBasBaseService.findPageInfo(attBasBaseParam);
- return buildSuccessResponse(attBasBaseList);
- }
- }
|