feat:{信息的状态判断,规则的添加}

dev.vehicleGateway
15285 2024-09-22 20:36:53 +08:00
parent 9e6ca8a8ff
commit 882819a6e0
7 changed files with 105 additions and 28 deletions

View File

@ -34,6 +34,11 @@ public class FaultMessage {
*/ */
@Schema(defaultValue = "消息发送人",type = "String",description = "消息发送人") @Schema(defaultValue = "消息发送人",type = "String",description = "消息发送人")
private String faultMessageRemoveName; private String faultMessageRemoveName;
/**
*
*/
@Schema(defaultValue = "消息内容",type = "String",description = "消息内容")
private String faultMessageContent;
/** /**
* *
*/ */

View File

@ -1,6 +1,9 @@
package com.muyu.fault.controller; package com.muyu.fault.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.fault.common.FaultMessage; import com.muyu.fault.common.FaultMessage;
import com.muyu.fault.service.impl.FaultMessageService; import com.muyu.fault.service.impl.FaultMessageService;
@ -20,42 +23,59 @@ public class FaultMessageController {
* @return * @return
*/ */
@RequestMapping(value = "/faultMessageList",method = RequestMethod.GET) @RequestMapping(value = "/faultMessageList",method = RequestMethod.GET)
public Result faultMessageList(){ public Result faultMessageList(@RequestBody FaultMessage faultMessage){
List<FaultMessage> list = faultMessageService.faultMessageList(); String username = SecurityUtils.getUsername();
return Result.success(list); LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultMessage.getFaultMessageSendName())) {
queryWrapper.eq(FaultMessage::getFaultMessageSendName,username);
}
return Result.success(faultMessageService.list(queryWrapper));
} }
/** /**
* *
* @param faultMessage * @param faultMessage
* @return * @return
*/ */
@RequestMapping(value = "/insertMessage",method = RequestMethod.POST) @RequestMapping(value = "/insertMessage",method = RequestMethod.POST)
public Result insertMessage(@RequestBody FaultMessage faultMessage){ public Result insertMessage(@RequestBody FaultMessage faultMessage){
String username = SecurityUtils.getUsername();
//消息发送人 //消息发送人
faultMessage.setFaultMessageSendName(SecurityUtils.getUsername()); faultMessage.setFaultMessageSendName(username);
return Result.success(faultMessageService.save(faultMessage)); return Result.success(faultMessageService.save(faultMessage));
} }
/** /**
* (faultMessageState==1) * (faultMessageState==1)
* @param faultMessageId
* @return * @return
*/ */
@RequestMapping(value = "/selectOne/{faultMessageId}",method = RequestMethod.POST) @RequestMapping(value = "/selectOne",method = RequestMethod.POST)
public Result selectOne(@PathVariable Long faultMessageId){ public Result selectOne(){
List<FaultMessage> one = faultMessageService.selectOne(faultMessageId); List<FaultMessage> one = faultMessageService.selectOne();
return Result.success(one); return Result.success(one);
} }
/** /**
* * (faultMessageState==2)
* @return
*/
@RequestMapping(value = "/selectTwo",method = RequestMethod.POST)
public Result selectTwo(){
List<FaultMessage> one = faultMessageService.selectTwo();
return Result.success(one);
}
/**
*
* @param faultMessageId * @param faultMessageId
* @return * @return
*/ */
@RequestMapping(value = "/selectTwo/{faultMessageId}",method = RequestMethod.POST) @RequestMapping(value = "/updateTwo/{faultMessageId}",method = RequestMethod.POST)
public Result selectTwo(@PathVariable Long faultMessageId){ public Result updateTwo(@PathVariable Long faultMessageId){
List<FaultMessage> one = faultMessageService.selectTwo(faultMessageId); LambdaUpdateWrapper<FaultMessage> updateWrapper = new LambdaUpdateWrapper<>();
return Result.success(one); updateWrapper.set(FaultMessage::getFaultMessageState,2);
updateWrapper.eq(FaultMessage::getFaultMessageId,faultMessageId);
faultMessageService.update(updateWrapper);
return Result.success(faultMessageId,"消息已读");
} }
} }

View File

@ -2,14 +2,16 @@ package com.muyu.fault.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.fault.common.FaultLog;
import com.muyu.fault.common.FaultMessage;
import com.muyu.fault.common.FaultrRule; import com.muyu.fault.common.FaultrRule;
import com.muyu.fault.common.SysCarFault; import com.muyu.fault.common.SysCarFault;
import com.muyu.fault.service.impl.FaultrRuleService; import com.muyu.fault.service.impl.FaultrRuleService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List; import java.util.List;
@RestController @RestController
@ -26,4 +28,48 @@ public class FaultrRuleController {
List<FaultrRule> list = faultrRuleService.faultRuleList(faultrRule); List<FaultrRule> list = faultrRuleService.faultRuleList(faultrRule);
return Result.success(list); return Result.success(list);
} }
/**
*
* @param faultrRule
* @return
*/
@RequestMapping(value = "/insertRule",method = RequestMethod.POST)
public Result insertRule(@RequestBody FaultrRule faultrRule){
return Result.success(faultrRuleService.save(faultrRule));
}
/**
*
* @param faultrRule
* @return
*/
@RequestMapping(value = "/updateRule",method = RequestMethod.POST)
public Result updateRule(@RequestBody FaultrRule faultrRule){
return Result.success(faultrRuleService.updateById(faultrRule));
}
/**
*
* @param faultRuleId
* @return
*/
@RequestMapping(value = "/byidRuleId/{faultRuleId}",method = RequestMethod.GET)
public Result byidRuleId(@PathVariable Long faultRuleId){
FaultrRule byid = faultrRuleService.byidRuleId(faultRuleId);
return Result.success(byid);
}
/**
*
*/
@RequestMapping(value = "/remove/{ids}",method = RequestMethod.DELETE)
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
faultrRuleService.removeBatchByIds(Arrays.asList(ids));
return Result.success();
}
} }

View File

@ -6,9 +6,8 @@ import com.muyu.fault.common.FaultMessage;
import java.util.List; import java.util.List;
public interface FaultMessageService extends IService<FaultMessage> { public interface FaultMessageService extends IService<FaultMessage> {
List<FaultMessage> faultMessageList();
List<FaultMessage> selectOne(Long faultMessageId); List<FaultMessage> selectOne();
List<FaultMessage> selectTwo(Long faultMessageId); List<FaultMessage> selectTwo();
} }

View File

@ -10,14 +10,9 @@ import java.util.List;
@Service @Service
public class FaultMessageServiceImpl extends ServiceImpl<FaultMessageMapper, FaultMessage> implements FaultMessageService{ public class FaultMessageServiceImpl extends ServiceImpl<FaultMessageMapper, FaultMessage> implements FaultMessageService{
@Override
public List<FaultMessage> faultMessageList() {
LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>();
return this.list(queryWrapper);
}
@Override @Override
public List<FaultMessage> selectOne(Long faultMessageId) { public List<FaultMessage> selectOne() {
LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>();
//查询消息状态为1的未读数据 //查询消息状态为1的未读数据
queryWrapper.eq(FaultMessage::getFaultMessageState, 1); queryWrapper.eq(FaultMessage::getFaultMessageState, 1);
@ -25,7 +20,7 @@ public class FaultMessageServiceImpl extends ServiceImpl<FaultMessageMapper, Fau
} }
@Override @Override
public List<FaultMessage> selectTwo(Long faultMessageId) { public List<FaultMessage> selectTwo() {
LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FaultMessage> queryWrapper = new LambdaQueryWrapper<>();
//查询消息状态为2的已读数据 //查询消息状态为2的已读数据
queryWrapper.eq(FaultMessage::getFaultMessageState, 2); queryWrapper.eq(FaultMessage::getFaultMessageState, 2);

View File

@ -7,4 +7,6 @@ import java.util.List;
public interface FaultrRuleService extends IService<FaultrRule> { public interface FaultrRuleService extends IService<FaultrRule> {
List<FaultrRule> faultRuleList(FaultrRule faultrRule); List<FaultrRule> faultRuleList(FaultrRule faultrRule);
FaultrRule byidRuleId(Long faultRuleId);
} }

View File

@ -2,9 +2,11 @@ package com.muyu.fault.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.fault.common.FaultLog;
import com.muyu.fault.common.FaultrRule; import com.muyu.fault.common.FaultrRule;
import com.muyu.fault.mapper.FaultrRuleMapper; import com.muyu.fault.mapper.FaultrRuleMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List; import java.util.List;
@ -16,4 +18,12 @@ public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrR
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
return this.list(queryWrapper); return this.list(queryWrapper);
} }
@Override
public FaultrRule byidRuleId(Long faultRuleId) {
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(faultRuleId, "规则ID不可为空");
queryWrapper.eq(FaultrRule::getFaultRuleId, faultRuleId);
return this.getOne(queryWrapper);
}
} }