| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package cn.com.goldenwater.dcproj.controller.wr;
- import cn.com.goldenwater.dcproj.model.WrGwsB;
- import cn.com.goldenwater.dcproj.param.WrGwsBParam;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.WrGwsBService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.lang3.StringUtils;
- 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.ArrayList;
- import java.util.List;
- import com.alibaba.fastjson.JSONObject;
- /**
- * @author zhengdafei
- * @date 2019-3-3
- */
- @Api(value = "", tags = "地下水水源地基本信息表")
- @RestController
- @RequestMapping("/dc/insp/wrGwsB")
- public class WrGwsBController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private WrGwsBService wrGwsBService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "添加")
- @RequestMapping(value = "/insert", method = RequestMethod.POST)
- public BaseResponse<JSONObject> insert(@ApiParam(name = "wrGwsB", value = "WrGwsB", required = true) @RequestBody WrGwsB wrGwsB) {
- String uuid = "";
- JSONObject json = new JSONObject();
- try {
- if (StringUtils.isNotBlank(wrGwsB.getGwsCd())) {
- String cwsCd = wrGwsB.getGwsCd().substring(0, 6) + "000000";
- wrGwsB.setAdCode(cwsCd);
- }
- uuid = wrGwsBService.add(wrGwsB);
- json.put("id", uuid);
- } catch (Exception e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse(json);
- }
- @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 = wrGwsBService.delete(id);
- JSONObject json = new JSONObject();
- json.put("code", ret);
- return buildSuccessResponse(json);
- }
- @ApiOperation(value = "更新信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse update(@ApiParam(name = "wrGwsB", value = "WrGwsB", required = true) @RequestBody WrGwsB wrGwsB) {
- try {
- wrGwsBService.modify(wrGwsB);
- } catch (Exception e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse(wrGwsB);
- }
- @ApiOperation(value = "根据ID获取(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<WrGwsB> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- WrGwsB wrGwsB = wrGwsBService.get(id);
- return buildSuccessResponse(wrGwsB);
- }
- @ApiOperation(value = "获取列表(分页)")
- @RequestMapping(value = "/queryListByPage", method = {RequestMethod.POST})
- public BaseResponse<PageInfo<WrGwsB>> queryListByPage(@RequestBody WrGwsBParam param) {
- PageInfo<WrGwsB> list = new PageInfo<>();
- param.setProvince(AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(getCurrentOrgId())));
- try {
- String adCode = param.getAdCode();
- if (adCode.contains("00")) {
- adCode = adCode.replace("00", "");
- param.setAdCode(adCode);
- }
- list = wrGwsBService.queryListByPage(param);
- } catch (Exception e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "获取列表")
- @RequestMapping(value = "/queryList", method = {RequestMethod.POST})
- public BaseResponse<List<WrGwsB>> queryList(@RequestBody WrGwsBParam param) {
- List<WrGwsB> list = new ArrayList<>();
- try {
- list = wrGwsBService.queryList(param);
- } catch (Exception e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "获取一个对象")
- @RequestMapping(value = "/getBy", method = {RequestMethod.POST})
- public BaseResponse<WrGwsB> getBy(@RequestBody WrGwsBParam param) {
- WrGwsB one = new WrGwsB();
- try {
- one = wrGwsBService.getBy(param);
- } catch (Exception e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse(one);
- }
- }
|