package cn.com.goldenwater.dcproj.controller.vill; import cn.com.goldenwater.dcproj.dto.BisInspSecsurveyVlgDcdxDto; import cn.com.goldenwater.dcproj.dto.BisInspSecsurveyVlgDto; import cn.com.goldenwater.dcproj.dto.VillRgstrDto; import cn.com.goldenwater.dcproj.model.BisInspSecsurveyVlg; import cn.com.goldenwater.dcproj.param.BisInspSecsurveyVlgParam; import cn.com.goldenwater.dcproj.param.GetVillPageByNodeIdParam; import cn.com.goldenwater.dcproj.service.BisInspSecsurveyVlgService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.target.VerifyBean; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; 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.ArrayList; import java.util.List; /** * @author zhengdafei * @date 2019-2-19 */ @Api(value = "", tags = "农村暗访调研行政村登记") @RestController @RequestMapping("/dc/insp/secsurveyVlg") public class BisInspSecsurveyVlgController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspSecsurveyVlgService bisInspSecsurveyVlgService; @ApiOperation(value = "添加") @RequestMapping(value = "/insert", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspSecsurveyVlg", value = "BisInspSecsurveyVlg", required = true) @RequestBody BisInspSecsurveyVlg bisInspSecsurveyVlg) { String uuid = ""; JSONObject json = new JSONObject(); try { uuid = bisInspSecsurveyVlgService.add(bisInspSecsurveyVlg); 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 = "/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspSecsurveyVlgService.delete(id); JSONObject json = new JSONObject(); json.put("id", id); return buildSuccessResponse(json); } @ApiOperation(value = "更新信息") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "bisInspSecsurveyVlg", value = "BisInspSecsurveyVlg", required = true) @RequestBody BisInspSecsurveyVlg bisInspSecsurveyVlg) { int ret = 0; try { ret = bisInspSecsurveyVlgService.modify(bisInspSecsurveyVlg); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(bisInspSecsurveyVlg); } @ApiOperation(value = "根据ID获取(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspSecsurveyVlg bisInspSecsurveyVlg = bisInspSecsurveyVlgService.get(id); if (bisInspSecsurveyVlg == null) { bisInspSecsurveyVlg = new BisInspSecsurveyVlg(); } return buildSuccessResponse(bisInspSecsurveyVlg); } @ApiOperation(value = "获取列表(分页)") @RequestMapping(value = "/queryListByPage", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse> queryListByPage(@RequestBody BisInspSecsurveyVlgParam param) { PageInfo list = new PageInfo<>(); try { list = bisInspSecsurveyVlgService.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.GET, RequestMethod.POST}) public BaseResponse> queryList(@RequestBody BisInspSecsurveyVlgParam param) { List list = new ArrayList<>(); try { list = bisInspSecsurveyVlgService.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.GET, RequestMethod.POST}) public BaseResponse getBy(@RequestBody BisInspSecsurveyVlgParam param) { BisInspSecsurveyVlgDto list = new BisInspSecsurveyVlgDto(); try { list = bisInspSecsurveyVlgService.getOne(param); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(list); } @ApiOperation(value = "获取单个最新村(带状态)") @RequestMapping(value = "/getNearBy", method = RequestMethod.POST) public BaseResponse getNearBy(@RequestBody BisInspSecsurveyVlgParam param) { BisInspSecsurveyVlgDto list = new BisInspSecsurveyVlgDto(); try { list = bisInspSecsurveyVlgService.getNearOne(param); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(list); } @ApiOperation(value = "根据行政区划编码和人员id获取列表(不分页)") @RequestMapping(value = "/getListByCodeAndPerId", method = RequestMethod.POST) public BaseResponse> getListByCodeAndPerId(@RequestBody VillRgstrDto villRgstrDto) { List list = new ArrayList<>(); try { list = bisInspSecsurveyVlgService.getListByCodeAndPerId(villRgstrDto); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(list); } @ApiOperation(value = "根据行政区划编码和人员id获取列表(分页)") @RequestMapping(value = "/getPageByCodeAndPerId", method = RequestMethod.POST) public BaseResponse> getPageByCodeAndPerId(@RequestBody VillRgstrDto villRgstrDto) { try { PageInfo list = bisInspSecsurveyVlgService.getPageByCodeAndPerId(villRgstrDto); return buildSuccessResponse(list); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } } @VerifyBean @ApiOperation(value = "根据节点id以及其他条件获取列表(分页)") @RequestMapping(value = "/getPageByNodeId", method = RequestMethod.POST) public BaseResponse> getPageByNodeId(@RequestBody GetVillPageByNodeIdParam p) throws Exception { PageInfo list = bisInspSecsurveyVlgService.getPageByNodeId(p); return buildSuccessResponse(list); } }