package com.newfiber.api.pc.controller.zhz; import com.newfiber.api.core.annotation.SysLog; import com.newfiber.api.core.commons.*; import com.newfiber.api.pc.dto.MeetPlanLevelDTO; import com.newfiber.api.pc.model.meet.MeetPlanLevel; import com.newfiber.api.pc.model.meet.MeetPlanSub; import com.newfiber.api.pc.service.MeetPlanLevelService; import com.sun.org.apache.bcel.internal.generic.RETURN; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; /** * 预案级别管理 * @Author:zzh * @CreateDate:2020/11/26 15:21 * @Description: */ @RestController @RequestMapping("/meet/level/") @Api(value = "MeetPlanSubController",tags = "预案级别管理") public class MeetPlanLevelController { @Autowired private MeetPlanLevelService meetPlanLevelService; @PostMapping("/querPage") @ApiOperation("分页查找级别数据") @SysLog(actionType = "4",value = "分页查找级别数据") public ResultObj<PageResultObject<MeetPlanLevel>> queryPage(@RequestBody PageRequestObject<String> page){ return new ResultObj<PageResultObject<MeetPlanLevel>>(ResultCode.OK,meetPlanLevelService.queryPage(page)); } @PostMapping("/list") @ApiOperation("查找全部数据-不分页") @SysLog(actionType = "4",value = "查找全部数据-不分页") public ResultObj<List<MeetPlanLevel>> list(){ return new ResultObj<List<MeetPlanLevel>>(ResultCode.OK,meetPlanLevelService.selectList(null)); } @PostMapping("/selectById") @ApiOperation("根据主键id查找数据") @SysLog(actionType = "4",value = "根据主键id查找数据") public ResultObj<MeetPlanLevel> selectById(@RequestParam("id")Integer id){ if(StringUtils.isEmpty(id)){ throw new CustomException(ResultCode.PARAM_NULL); } return new ResultObj<MeetPlanLevel>(ResultCode.OK,meetPlanLevelService.selectById(id)); } @PostMapping("/add") @ApiOperation("添加预案级别") @SysLog(actionType = "1",value = "添加预案级别") public ResultObj addMeetLevel(@RequestBody MeetPlanLevelDTO meetPlanLevelDTO, HttpServletRequest request){ if(StringUtils.isEmpty(meetPlanLevelDTO)){ throw new CustomException(ResultCode.PARAM_NULL); } String userNo = request.getHeader("userNo"); MeetPlanLevel meetPlanLevel = new MeetPlanLevel(); meetPlanLevel.setCreateTime(new Date()); meetPlanLevel.setCreateUserNo(userNo); meetPlanLevel.setMLevelName(meetPlanLevelDTO.getMLevelName()); meetPlanLevel.setLowPerson(meetPlanLevelDTO.getLowPerson()); meetPlanLevel.setHightPerson(meetPlanLevelDTO.getHightPerson()); boolean insert = meetPlanLevelService.insert(meetPlanLevel); if(!insert){ throw new CustomException(ResultCode.SAVE_ERROR); } return ResultObj.ok(); } @PostMapping("/update") @ApiOperation("修改预案级别") @SysLog(actionType = "3",value = "修改预案级别") public ResultObj updateLevel(@RequestBody MeetPlanLevelDTO meetPlanLevelDTO){ if(StringUtils.isEmpty(meetPlanLevelDTO.getMLId())){ throw new CustomException(ResultCode.PARAM_NULL); } MeetPlanLevel meetPlanLevel = new MeetPlanLevel(); meetPlanLevel.setMLId(meetPlanLevelDTO.getMLId()); meetPlanLevel.setUpdateTime(new Date()); meetPlanLevel.setMLevelName(meetPlanLevelDTO.getMLevelName()); meetPlanLevel.setLowPerson(meetPlanLevelDTO.getLowPerson()); meetPlanLevel.setHightPerson(meetPlanLevelDTO.getHightPerson()); boolean update = meetPlanLevelService.updateById(meetPlanLevel); if(!update){ throw new CustomException(ResultCode.UPDATE_ERROR); } return ResultObj.ok(); } @PostMapping("/delete") @ApiOperation("删除预案级别") @SysLog(actionType = "2",value = "删除预案级别") public ResultObj deletLevel(@RequestParam("ids") List<Integer> ids){ if(StringUtils.isEmpty(ids)){ throw new CustomException(ResultCode.PARAM_NULL); } boolean batchIds = meetPlanLevelService.deleteBatchIds(ids); if(!batchIds){ throw new CustomException(ResultCode.DELETE_ERROR); } return ResultObj.ok(); } }