package com.gk.hotwork.Controller; import com.gk.hotwork.Controller.Base.BaseController; import com.gk.hotwork.Domain.Enum.ErrorCode; import com.gk.hotwork.Domain.UserInfo; import com.gk.hotwork.Domain.Utils.Msg; import com.gk.hotwork.Domain.Utils.PageInfo; import com.gk.hotwork.Domain.Utils.StringUtils; import com.gk.hotwork.Domain.WarningInfo; import com.gk.hotwork.Service.UserService; import com.gk.hotwork.Service.WarningService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * @author : jingjy * @date : 2021/9/10 9:26 */ @Api(tags = "任务流程数据接口") @RestController @RequestMapping("/warning") public class WarningController extends BaseController { @Autowired private WarningService warningService; @Autowired private UserService userService; @GetMapping("/info") public Msg getWarningInfo(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "isDeal", required = false) String isDeal, @RequestParam(value = "type", required = false) String type, @RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime, @RequestParam(defaultValue = "10") Integer pageSize, String sort, String order){ PageInfo pageInfo = new PageInfo(pageIndex, pageSize,sort,order); Map condition = new HashMap<>(4); if (StringUtils.isNotBlank(code)) { condition.put("code", code); } if (StringUtils.isNotBlank(isDeal)) { condition.put("isDeal", isDeal); } if (StringUtils.isNotBlank(type)) { condition.put("type", type); } if (StringUtils.isNotBlank(startTime)){ condition.put("startTime", startTime); } if (StringUtils.isNotBlank(endTime)){ condition.put("endTime", endTime); } pageInfo.setCondition(condition); warningService.selectDataGrid(pageInfo); return success(pageInfo); } @PostMapping("/deal") public Msg dealWarning(String id){ UserInfo userInfo = userService.getById(getUser().getId()); if (StringUtils.isBlank(id)){ return new Msg(ErrorCode.ERROR_10001); } WarningInfo warningInfo = warningService.getById(id); if (warningInfo == null || warningInfo.getIsdeal() == 1){ return new Msg(ErrorCode.ERROR_50001,"警告信息未找到或已处理"); } warningInfo.setIsdeal((byte)1); warningInfo.setDealat(new Date()); warningInfo.setDealby(userInfo.getRealname()); warningService.updateById(warningInfo); return success(); } }