@@ -89,8 +89,8 @@ public class WarningController { | |||
* @param id | |||
* @return | |||
*/ | |||
@PutMapping("/status/{id}/{status}") | |||
public JsonResult editStatusById(@PathVariable("id") Integer id,@PathVariable("status") Integer status){ | |||
return warningService.editStatusById(id,status); | |||
@PutMapping("/messageRead/{id}") | |||
public JsonResult editStatusById(@PathVariable("id") Integer id){ | |||
return warningService.editStatusById(id); | |||
} | |||
} |
@@ -72,4 +72,9 @@ public class Warning extends BaseEntity implements Serializable { | |||
* 处理结果 | |||
*/ | |||
private String checkResult; | |||
/** | |||
* 消息读取标识 0:未读 1已读 | |||
*/ | |||
private Integer messageRead; | |||
} |
@@ -0,0 +1,25 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/3/3 | |||
*/ | |||
public enum MessageReadEnum { | |||
MESSAGE_IS_READ(1,"已读"), | |||
MESSAGE_IS_NO_READ(0,"未读"); | |||
MessageReadEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -75,5 +75,5 @@ public interface IWarningService extends IBaseService<Warning> { | |||
* @param id | |||
* @return | |||
*/ | |||
JsonResult editStatusById(Integer id,Integer status); | |||
JsonResult editStatusById(Integer id); | |||
} |
@@ -104,8 +104,8 @@ public class WarningServiceImpl extends BaseServiceImpl<WarningMapper, Warning> | |||
} | |||
@Override | |||
public JsonResult editStatusById(Integer id,Integer status) { | |||
return warningStatusService.editStatusById(id,status); | |||
public JsonResult editStatusById(Integer id) { | |||
return warningStatusService.editStatusById(id); | |||
} | |||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.enums.MarkTypeEnum; | |||
import com.tuoheng.admin.enums.MessageReadEnum; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -25,14 +26,13 @@ public class WarningStatusService { | |||
/** | |||
* 通知忽略与处理 | |||
* @param id | |||
* @param status | |||
* @return | |||
*/ | |||
public JsonResult editStatusById(Integer id,Integer status) { | |||
public JsonResult editStatusById(Integer id) { | |||
//根据id查询并更新预警状态 | |||
Warning warning = warningMapper.selectById(id); | |||
if(ObjectUtils.isNotEmpty(warning)){ | |||
warning.setStatus(status); | |||
warning.setMessageRead(MessageReadEnum.MESSAGE_IS_READ.getCode()); | |||
int result = warningMapper.updateById(warning); | |||
if(result<=0){ | |||
return JsonResult.error(); |
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.enums.MarkTypeEnum; | |||
import com.tuoheng.admin.enums.MessageReadEnum; | |||
import com.tuoheng.admin.enums.WarningStatusEnum; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -40,6 +41,7 @@ public class WarningNoticeService { | |||
List<Warning> warningList = warningMapper.selectList(Wrappers.<Warning>lambdaQuery() | |||
.eq(Warning::getTenantId, tenantId) | |||
.eq(Warning::getStatus, WarningStatusEnum.WAIT_CONFIRM.getCode()) | |||
.eq(Warning::getMessageRead, MessageReadEnum.MESSAGE_IS_NO_READ.getCode()) | |||
.eq(Warning::getMark, MarkTypeEnum.VALID.getCode())); | |||
if(CollectionUtils.isEmpty(warningList) || warningList.size() == 0){ | |||
return JsonResult.success(); |