新增删除业务通知方法
This commit is contained in:
parent
e60b80b664
commit
bd71a0bfd6
@ -10,6 +10,8 @@ import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
@ -65,4 +67,14 @@ public class MessageController {
|
||||
return messageService.saveNoticeWithTarget(noticeVO, true);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除通知", notes = "删除通知接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "serviceIds", value = "业务ID", paramType = "path"),
|
||||
})
|
||||
@DeleteMapping("delete/{serviceIds}")
|
||||
public SuccessResult delete(@PathVariable("serviceIds") String serviceIds) {
|
||||
messageService.delete(Arrays.asList(serviceIds.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.websocket.pojo.vos.message.NoticeDeleteServiceVO;
|
||||
import com.cm.websocket.pojo.vos.message.NoticeVO;
|
||||
import com.cm.websocket.service.IMessageService;
|
||||
import io.swagger.annotations.*;
|
||||
@ -53,4 +54,15 @@ public class MessageResourceController {
|
||||
return messageService.saveNoticeWithTarget(noticeVO, true);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除通知", notes = "删除通知接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "serviceIds", value = "业务ID", paramType = "path"),
|
||||
})
|
||||
@PostMapping("delete")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult delete(@RequestBody NoticeDeleteServiceVO noticeDeleteServiceVO) {
|
||||
messageService.delete(noticeDeleteServiceVO.getServiceIds());
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.cm.websocket.dao;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
@ -92,4 +93,11 @@ public interface INoticeDao {
|
||||
*/
|
||||
Integer count(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.cm.websocket.pojo.vos.message;
|
||||
|
||||
import com.cm.common.annotation.CheckListAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: NoticeMessageVO
|
||||
* @Description: 通知消息
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/1/19 5:04 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@ApiModel
|
||||
public class NoticeDeleteServiceVO {
|
||||
|
||||
@ApiModelProperty(name = "serviceIds", value = "业务ID列表")
|
||||
@CheckListAnnotation(name = "业务ID列表")
|
||||
private List<String> serviceIds;
|
||||
|
||||
public List<String> getServiceIds() {
|
||||
return serviceIds;
|
||||
}
|
||||
|
||||
public void setServiceIds(List<String> serviceIds) {
|
||||
this.serviceIds = serviceIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"serviceIds\":")
|
||||
.append(serviceIds);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import com.cm.websocket.pojo.AppSocketMessage;
|
||||
import com.cm.websocket.pojo.vos.message.NoticeVO;
|
||||
|
||||
import javax.websocket.Session;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -53,4 +54,11 @@ public interface IMessageService {
|
||||
* @param appSocketMessage
|
||||
*/
|
||||
void sendGroupTextMessage(Session fromSession, AppSocketMessage appSocketMessage) throws SessionException;
|
||||
|
||||
/**
|
||||
* 删除通知
|
||||
*
|
||||
* @param serviceIds
|
||||
*/
|
||||
void delete(List<String> serviceIds);
|
||||
}
|
||||
|
@ -153,4 +153,18 @@ public interface INoticeService {
|
||||
*/
|
||||
Integer count(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param serviceIds
|
||||
*/
|
||||
void deleteByServiceIds(List<String> serviceIds);
|
||||
|
||||
/**
|
||||
* 通知列表
|
||||
*
|
||||
* @param serviceIds
|
||||
* @return
|
||||
*/
|
||||
List<NoticePO> listPO(List<String> serviceIds);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.cm.websocket.exception.SessionException;
|
||||
import com.cm.websocket.manager.AppSocketSessionManager;
|
||||
import com.cm.websocket.pojo.AppSocketMessage;
|
||||
import com.cm.websocket.pojo.AppSocketSession;
|
||||
import com.cm.websocket.pojo.pos.NoticePO;
|
||||
import com.cm.websocket.pojo.vos.message.NoticeVO;
|
||||
import com.cm.websocket.service.IMessageService;
|
||||
import com.cm.websocket.service.INoticeService;
|
||||
@ -23,7 +24,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.websocket.Session;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -166,4 +169,40 @@ public class MessageServiceImpl extends AbstractService implements IMessageServi
|
||||
WebSocket.send(socketSession.getSession(), appSocketMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> serviceIds) {
|
||||
List<NoticePO> noticePOs = noticeService.listPO(serviceIds);
|
||||
Set<String> noticeUserIdSet = new HashSet<>();
|
||||
noticePOs.forEach(noticePO -> {
|
||||
noticeUserIdSet.add(noticePO.getUserId());
|
||||
});
|
||||
// 删除通知
|
||||
noticeService.deleteByServiceIds(serviceIds);
|
||||
// 重新推送数量
|
||||
List<AppSocketSession> appSocketSessions = AppSocketSessionManager.getInstance().listSessionByUserIds(new ArrayList<>(noticeUserIdSet));
|
||||
// 3s后通知,保证事务提交
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
// 更新状态待办
|
||||
for (AppSocketSession appSocketSession : appSocketSessions) {
|
||||
for (NoticePO noticePO : noticePOs) {
|
||||
if (StringUtils.equals(appSocketSession.getUserId(), noticePO.getUserId())) {
|
||||
Session session = appSocketSession.getSession();
|
||||
AppSocketMessage.CountNeedToDealWithBody countNeedToDealWithBody = new AppSocketMessage.CountNeedToDealWithBody();
|
||||
countNeedToDealWithBody.setSystem(noticePO.getNoticeSystem());
|
||||
// 查询待办状态
|
||||
List<AppSocketMessage.CountNeedToDealWithBody> counts = noticeService.listNoticeCount(appSocketSession.getUserId(), countNeedToDealWithBody);
|
||||
AppSocketMessage appSocketMessage = new AppSocketMessage(AppSocketTypeEnum.SEARCH_COUNT_NEED_TO_DEALT_WITH.getValue(),
|
||||
true,
|
||||
AppSocketSessionManager.FORM_SYSTEM,
|
||||
appSocketSession.getUserId(),
|
||||
JSONArray.toJSONString(counts));
|
||||
WebSocket.send(session, appSocketMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -228,6 +228,20 @@ public class NoticeServiceImpl extends AbstractService implements INoticeService
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByServiceIds(List<String> serviceIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("serviceIds", serviceIds);
|
||||
noticeDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NoticePO> listPO(List<String> serviceIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("serviceIds", serviceIds);
|
||||
return listPO(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统列表
|
||||
*
|
||||
|
@ -72,6 +72,19 @@
|
||||
notice_service_id = #{noticeServiceId}
|
||||
</update>
|
||||
|
||||
<!-- 删除 -->
|
||||
<delete id="delete" parameterType="map">
|
||||
DELETE FROM
|
||||
socket_notice
|
||||
WHERE
|
||||
<if test="serviceIds != null and serviceIds.size > 0">
|
||||
notice_service_id IN
|
||||
<foreach collection="serviceIds" index="index" open="(" separator="," close=")">
|
||||
#{serviceIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<!-- 详情 -->
|
||||
<select id="getPO" parameterType="map" resultMap="noticePO">
|
||||
SELECT
|
||||
@ -166,6 +179,17 @@
|
||||
AND
|
||||
is_handle = #{isHandle}
|
||||
</if>
|
||||
<if test="serviceId != null and serviceId != ''">
|
||||
AND
|
||||
notice_service_id = #{serviceId}
|
||||
</if>
|
||||
<if test="serviceIds != null and serviceIds.size > 0">
|
||||
AND
|
||||
notice_service_id IN
|
||||
<foreach collection="serviceIds" index="index" open="(" separator="," close=")">
|
||||
#{serviceIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 系统列表 -->
|
||||
|
Loading…
Reference in New Issue
Block a user