package cn.com.goldenwater.dcproj.controller.ducha; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers; import cn.com.goldenwater.dcproj.model.BisInspMtprgSms; import cn.com.goldenwater.dcproj.param.BisInspMtprgSmsParam; import cn.com.goldenwater.dcproj.service.BisInspMtprgSmsService; import cn.com.goldenwater.dcproj.vo.BisInspMtprgSmsVo; import cn.com.goldenwater.target.CheckException; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Optional; /** * @author * @date 2022-2-7 */ @Api(value = "月报短信提醒管理", tags = "月报短信提醒管理") @RestController @RequestMapping("/bis/insp/mtprg/sms") public class BisInspMtprgSmsController extends BaseController { @Autowired private BisInspMtprgSmsService bisInspMtprgSmsService; @ApiOperation(value = "修改月报短信提醒") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspMtprgSms", value = "BisInspMtprgSms", required = true) @RequestBody BisInspMtprgSms bisInspMtprgSms) { bisInspMtprgSms.setCreaterId(getCurrentPersId()); bisInspMtprgSms.setOrgId(getCurrentOrgId()); int ret = bisInspMtprgSmsService.insert(bisInspMtprgSms); return buildSuccessResponse(bisInspMtprgSms); } @ApiOperation(value = "修改月报短信提醒") @RequestMapping(value = "/update", method = RequestMethod.POST) public BaseResponse update(@ApiParam(name = "bisInspMtprgSms", value = "BisInspMtprgSms", required = true) @RequestBody BisInspMtprgSms bisInspMtprgSms) { bisInspMtprgSms.setCreaterId(getCurrentPersId()); Optional.of(bisInspMtprgSms).map(BisInspMtprgSms::getId).orElseThrow(() -> new CheckException("id.no")); int ret = bisInspMtprgSmsService.update(bisInspMtprgSms); return buildSuccessResponse(bisInspMtprgSms); } @ApiOperation(value = "修改月报短信提醒") @RequestMapping(value = "/batch", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "bisInspMtprgSms", value = "BisInspMtprgSms", required = true) @RequestBody List bisInspMtprgSmsList) { bisInspMtprgSmsList.stream().distinct().forEach(this::insert); return buildSuccessResponse(); } @ApiOperation(value = "根据ID删除月报短信提醒") @RequestMapping(value = "delete/{id}", method = RequestMethod.POST) public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { int ret = bisInspMtprgSmsService.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) { BisInspMtprgSms bisInspMtprgSms = bisInspMtprgSmsService.get(id); return buildSuccessResponse(bisInspMtprgSms); } @ApiOperation("根据guid及组id查询不在改组名单内的人员列表") @RequestMapping(value = "/listByNotMonthReport", method = RequestMethod.POST) public BaseResponse> listByNotMonthReport(@RequestBody BisInspMtprgSmsParam param) { param.setOrgId(getCurrentOrgId()); return buildSuccessResponse(bisInspMtprgSmsService.listByNotMonthReport(param)); } @ApiOperation("根据guid及组id查询不在改组名单内的人员列表") @RequestMapping(value = "/findPage", method = RequestMethod.POST) public BaseResponse> findPage(@RequestBody(required = false) BisInspMtprgSmsParam param) { param.setOrgId(getCurrentOrgId()); return buildSuccessResponse(bisInspMtprgSmsService.listOfPage(param)); } @ApiOperation(value = "批量修改月报短信提醒") @RequestMapping(value = "/updateBatch", method = RequestMethod.POST) public BaseResponse> updateBatch(@ApiParam(name = "bisInspMtprgSms", value = "BisInspMtprgSms", required = true) @RequestBody List bisInspMtprgSmsList) { for (BisInspMtprgSms bisInspMtprgSms : bisInspMtprgSmsList) { bisInspMtprgSms.setCreaterId(getCurrentPersId()); Optional.of(bisInspMtprgSms).map(BisInspMtprgSms::getId).orElseThrow(() -> new CheckException("id.no")); } int ret = bisInspMtprgSmsService.updateBatch(bisInspMtprgSmsList); return buildSuccessResponse(bisInspMtprgSmsList); } @ApiOperation(value = "批量删除月报短信提醒") @RequestMapping(value = "/deleteBatch", method = RequestMethod.POST) public BaseResponse deleteBatch(@ApiParam(name = "bisInspMtprgSms", value = "BisInspMtprgSms", required = true) @RequestBody List smsIdList) { int ret = bisInspMtprgSmsService.deleteBatch(smsIdList); return buildSuccessResponse(); } }