package cn.com.goldenwater.dcproj.controller.vill; import cn.com.goldenwater.dcproj.model.BisInspVillRgstr; import cn.com.goldenwater.dcproj.param.BisInspVillRgstrParam; import cn.com.goldenwater.dcproj.service.BisInspVillRgstrService; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; 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.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.RequestParam; 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/villRgstr") public class BisInspVillRgstrController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private BisInspVillRgstrService bisInspVillRgstrService; @ApiOperation(value = "添加") @RequestMapping(value = "/insert", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspVillRgstr", value = "BisInspVillRgstr", required = true) @RequestBody BisInspVillRgstr bisInspVillRgstr) { String uuid = ""; JSONObject json = new JSONObject(); try { bisInspVillRgstr.setOrgId(getCurrentOrgId()); uuid = bisInspVillRgstrService.add(bisInspVillRgstr); 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 = bisInspVillRgstrService.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 = "bisInspVillRgstr", value = "BisInspVillRgstr", required = true) @RequestBody BisInspVillRgstr bisInspVillRgstr) { String ret = ""; try { ret = bisInspVillRgstrService.modify(bisInspVillRgstr); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(bisInspVillRgstr); } @ApiOperation(value = "根据ID获取(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { BisInspVillRgstr bisInspVillRgstr = bisInspVillRgstrService.get(id); if (bisInspVillRgstr == null) { bisInspVillRgstr = new BisInspVillRgstr(); } return buildSuccessResponse(bisInspVillRgstr); } @ApiOperation(value = "获取列表(分页)") @RequestMapping(value = "/queryListByPage", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse> queryListByPage(@RequestBody BisInspVillRgstrParam param) { PageInfo list = new PageInfo<>(); try { param.setOrgId(getCurrentOrgId()); list = bisInspVillRgstrService.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 BisInspVillRgstrParam param) { List list = new ArrayList<>(); try { param.setOrgId(getCurrentOrgId()); list = bisInspVillRgstrService.queryList(param); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(list); } @ApiOperation(value = "根据人员id获取农村饮用水列表") @RequestMapping(value = "/findListByPersId", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse> findListByPersId(@RequestParam("persId") String persId) { List list = new ArrayList<>(); try { list = bisInspVillRgstrService.findListByPersId(persId,getCurrentOrgId()); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(list); } @ApiOperation(value = "根据督查对象ID获取登记表ID") @RequestMapping(value = "/getEngId", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse findTCList(@RequestParam("objId") String objId, @RequestParam(value = "persId", required = false) String persId) { String engId = ""; JSONObject json = new JSONObject(); try { engId = bisInspVillRgstrService.getEngId(objId, persId); json.put("engId", engId); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); return buildFailResponse(e.getMessage()); } return buildSuccessResponse(json); } }