diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/api/WebSocketMessageController.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/api/WebSocketMessageController.java new file mode 100644 index 00000000..1a29c6ee --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/api/WebSocketMessageController.java @@ -0,0 +1,72 @@ +package ink.wgink.module.instantmessage.controller.api; + +import ink.wgink.annotation.CheckRequestBodyAnnotation; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.module.instantmessage.pojo.bos.NoticeBO; +import ink.wgink.module.instantmessage.pojo.bos.NoticeTargetBO; +import ink.wgink.module.instantmessage.pojo.vos.MessageVO; +import ink.wgink.module.instantmessage.service.IMessageService; +import ink.wgink.pojo.result.ErrorResult; +import ink.wgink.pojo.result.SuccessResult; +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 + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: MessageController + * @Description: 消息 + * @Author: wanggeng + * @Date: 2021/1/14 3:25 下午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "消息接口") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/websocket/message") +public class WebSocketMessageController { + + @Autowired + private IMessageService messageService; + + @ApiOperation(value = "通知消息", notes = "通知消息接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("notice/{clientName}") + @CheckRequestBodyAnnotation + public SuccessResult notice(@PathVariable("clientName") String clientName, @RequestBody MessageVO messageVO) { + NoticeBO noticeBO = new NoticeBO(); + noticeBO.setTitle(messageVO.getTitle()); + noticeBO.setContent(messageVO.getContent()); + noticeBO.setTo(messageVO.getTo()); + messageService.notice(clientName, noticeBO); + return new SuccessResult(); + } + + @ApiOperation(value = "通知消息", notes = "通知消息接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("notice-target/{clientName}") + @CheckRequestBodyAnnotation + public SuccessResult saveNoticeWithTargetAndSave(@PathVariable("clientName") String clientName, @RequestBody MessageVO messageVO) { + NoticeTargetBO noticeTargetBO = new NoticeTargetBO(); + noticeTargetBO.setTitle(messageVO.getTitle()); + noticeTargetBO.setContent(messageVO.getContent()); + noticeTargetBO.setTo(messageVO.getTo()); + noticeTargetBO.setTarget(messageVO.getTarget()); + messageService.notice(clientName, noticeTargetBO); + return new SuccessResult(); + } + + @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(); + } + +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/route/WebSocketDemoRouteController.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/route/WebSocketDemoRouteController.java new file mode 100644 index 00000000..76250e7b --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/controller/route/WebSocketDemoRouteController.java @@ -0,0 +1,38 @@ +package ink.wgink.module.instantmessage.controller.route; + +import ink.wgink.common.component.SecurityComponent; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.properties.websocket.WebSocketProperties; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +/** + * @ClassName: WebSocketDemoStaticController + * @Description: websocket示例资源 + * @Author: wanggeng + * @Date: 2021/9/13 11:08 下午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户路由接口") +@Controller +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/websocket") +public class WebSocketDemoRouteController { + + @Autowired + private SecurityComponent securityComponent; + @Autowired + private WebSocketProperties webSocketProperties; + + @GetMapping("chat-demo") + public ModelAndView chatDemo() { + ModelAndView modelAndView = new ModelAndView("chat-demo"); + modelAndView.addObject("currentUserId", securityComponent.getCurrentUser().getUserId()); + modelAndView.addObject("webSocketUrl", String.format("%s:%s/%s", webSocketProperties.getUrl(), webSocketProperties.getPort(), webSocketProperties.getContext())); + return modelAndView; + } + +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/dao/INoticeDao.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/dao/INoticeDao.java new file mode 100644 index 00000000..e12bdaa0 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/dao/INoticeDao.java @@ -0,0 +1,104 @@ +package ink.wgink.module.instantmessage.dao; + +import ink.wgink.exceptions.RemoveException; +import ink.wgink.exceptions.SaveException; +import ink.wgink.exceptions.SearchException; +import ink.wgink.exceptions.UpdateException; +import ink.wgink.interfaces.init.IInitBaseTable; +import ink.wgink.module.instantmessage.pojo.pos.NoticePO; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: INoticeDao + * @Description: 消息通知 + * @Author: wanggeng + * @Date: 2021/3/29 4:37 下午 + * @Version: 1.0 + */ +@Repository +public interface INoticeDao extends IInitBaseTable { + + /** + * 保存 + * + * @param params + * @throws SaveException + */ + void save(Map params) throws SaveException; + + /** + * 修改已办 + * + * @param params + * @throws UpdateException + */ + void updateHandle(Map params) throws UpdateException; + + /** + * 详情 + * + * @param params + * @return + * @throws SearchException + */ + NoticePO getPO(Map params) throws SearchException; + + /** + * 列表 + * + * @param params + * @return + * @throws SearchException + */ + List listPO(Map params) throws SearchException; + + /** + * 系统列表 + * + * @param params + * @return + * @throws SearchException + */ + List listSystems(Map params) throws SearchException; + + /** + * 模块列表 + * + * @param params + * @return + * @throws SearchException + */ + List listModules(Map params) throws SearchException; + + /** + * 菜单列表 + * + * @param params + * @return + * @throws SearchException + */ + List listMenus(Map params) throws SearchException; + + /** + * 统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer count(Map params) throws SearchException; + + /** + * 删除 + * + * @param params + * @throws RemoveException + */ + void delete(Map params) throws RemoveException; +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeBO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeBO.java new file mode 100644 index 00000000..8d22bf38 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeBO.java @@ -0,0 +1,47 @@ +package ink.wgink.module.instantmessage.pojo.bos; + +import ink.wgink.annotation.CheckEmptyAnnotation; + +/** + * @ClassName: MessageSimpleBO + * @Description: 简单消息 + * @Author: wanggeng + * @Date: 2021/9/13 6:00 下午 + * @Version: 1.0 + */ +public class NoticeBO { + + /** + * 接收人用户ID,多个用英文逗号分割 + */ + @CheckEmptyAnnotation(name = "接收人") + private String to; + @CheckEmptyAnnotation(name = "标题") + private String title; + @CheckEmptyAnnotation(name = "内容") + private String content; + + public String getTo() { + return to == null ? "" : to.trim(); + } + + public void setTo(String to) { + this.to = to; + } + + public String getTitle() { + return title == null ? "" : title.trim(); + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content == null ? "" : content.trim(); + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeTargetBO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeTargetBO.java new file mode 100644 index 00000000..9b735225 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/bos/NoticeTargetBO.java @@ -0,0 +1,24 @@ +package ink.wgink.module.instantmessage.pojo.bos; + +import ink.wgink.annotation.CheckEmptyAnnotation; + +/** + * @ClassName: NoticeTargetBO + * @Description: 带目标通知 + * @Author: wanggeng + * @Date: 2021/9/13 6:02 下午 + * @Version: 1.0 + */ +public class NoticeTargetBO extends NoticeBO { + + @CheckEmptyAnnotation(name = "目标") + private String target; + + public String getTarget() { + return target == null ? "" : target.trim(); + } + + public void setTarget(String target) { + this.target = target; + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/pos/NoticePO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/pos/NoticePO.java new file mode 100644 index 00000000..f8fa9f27 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/pos/NoticePO.java @@ -0,0 +1,198 @@ +package ink.wgink.module.instantmessage.pojo.pos; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: NoticePO + * @Description: 消息通知 + * @Author: wanggeng + * @Date: 2021/3/29 4:39 下午 + * @Version: 1.0 + */ +public class NoticePO { + + private Long id; + private String noticeId; + private String noticeTitle; + private String noticeMsg; + private String noticeTarget; + private String noticeSystem; + private String noticeModule; + private String noticeMenu; + private String noticeServiceId; + private String userId; + private Integer isHandle; + private String gmtCreate; + private String creator; + private String gmtModified; + private String modifier; + private Integer isDelete; + + public Long getId() { + return id == null ? 0 : id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getNoticeId() { + return noticeId == null ? "" : noticeId; + } + + public void setNoticeId(String noticeId) { + this.noticeId = noticeId; + } + + public String getNoticeTitle() { + return noticeTitle == null ? "" : noticeTitle; + } + + public void setNoticeTitle(String noticeTitle) { + this.noticeTitle = noticeTitle; + } + + public String getNoticeMsg() { + return noticeMsg == null ? "" : noticeMsg; + } + + public void setNoticeMsg(String noticeMsg) { + this.noticeMsg = noticeMsg; + } + + public String getNoticeTarget() { + return noticeTarget == null ? "" : noticeTarget; + } + + public void setNoticeTarget(String noticeTarget) { + this.noticeTarget = noticeTarget; + } + + public String getNoticeSystem() { + return noticeSystem == null ? "" : noticeSystem; + } + + public void setNoticeSystem(String noticeSystem) { + this.noticeSystem = noticeSystem; + } + + public String getNoticeModule() { + return noticeModule == null ? "" : noticeModule; + } + + public void setNoticeModule(String noticeModule) { + this.noticeModule = noticeModule; + } + + public String getNoticeMenu() { + return noticeMenu == null ? "" : noticeMenu; + } + + public void setNoticeMenu(String noticeMenu) { + this.noticeMenu = noticeMenu; + } + + public String getNoticeServiceId() { + return noticeServiceId == null ? "" : noticeServiceId; + } + + public void setNoticeServiceId(String noticeServiceId) { + this.noticeServiceId = noticeServiceId; + } + + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getIsHandle() { + return isHandle == null ? 0 : isHandle; + } + + public void setIsHandle(Integer isHandle) { + this.isHandle = isHandle; + } + + public String getGmtCreate() { + return gmtCreate == null ? "" : gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public String getCreator() { + return creator == null ? "" : creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtModified() { + return gmtModified == null ? "" : gmtModified; + } + + public void setGmtModified(String gmtModified) { + this.gmtModified = gmtModified; + } + + public String getModifier() { + return modifier == null ? "" : modifier; + } + + public void setModifier(String modifier) { + this.modifier = modifier; + } + + public Integer getIsDelete() { + return isDelete == null ? 0 : isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"id\":") + .append(id); + sb.append(",\"noticeId\":\"") + .append(noticeId).append('\"'); + sb.append(",\"noticeTitle\":\"") + .append(noticeTitle).append('\"'); + sb.append(",\"noticeMsg\":\"") + .append(noticeMsg).append('\"'); + sb.append(",\"noticeTarget\":\"") + .append(noticeTarget).append('\"'); + sb.append(",\"noticeSystem\":\"") + .append(noticeSystem).append('\"'); + sb.append(",\"noticeModule\":\"") + .append(noticeModule).append('\"'); + sb.append(",\"noticeMenu\":\"") + .append(noticeMenu).append('\"'); + sb.append(",\"noticeServiceId\":\"") + .append(noticeServiceId).append('\"'); + sb.append(",\"userId\":\"") + .append(userId).append('\"'); + sb.append(",\"isHandle\":") + .append(isHandle); + sb.append(",\"gmtCreate\":\"") + .append(gmtCreate).append('\"'); + sb.append(",\"creator\":\"") + .append(creator).append('\"'); + sb.append(",\"gmtModified\":\"") + .append(gmtModified).append('\"'); + sb.append(",\"modifier\":\"") + .append(modifier).append('\"'); + sb.append(",\"isDelete\":") + .append(isDelete); + sb.append('}'); + return sb.toString(); + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/MessageVO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/MessageVO.java new file mode 100644 index 00000000..23ddeee7 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/MessageVO.java @@ -0,0 +1,53 @@ +package ink.wgink.module.instantmessage.pojo.vos; + +import ink.wgink.annotation.CheckEmptyAnnotation; + +/** + * @ClassName: MessageVO + * @Description: 消息VO + * @Author: wanggeng + * @Date: 2021/9/13 9:40 下午 + * @Version: 1.0 + */ +public class MessageVO { + + @CheckEmptyAnnotation(name = "接收人") + private String to; + @CheckEmptyAnnotation(name = "标题") + private String title; + @CheckEmptyAnnotation(name = "内容") + private String content; + private String target; + + public String getTo() { + return to == null ? "" : to.trim(); + } + + public void setTo(String to) { + this.to = to; + } + + public String getTitle() { + return title == null ? "" : title.trim(); + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content == null ? "" : content.trim(); + } + + public void setContent(String content) { + this.content = content; + } + + public String getTarget() { + return target == null ? "" : target.trim(); + } + + public void setTarget(String target) { + this.target = target; + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeDeleteServiceVO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeDeleteServiceVO.java new file mode 100644 index 00000000..6d673659 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeDeleteServiceVO.java @@ -0,0 +1,42 @@ +package ink.wgink.module.instantmessage.pojo.vos; + +import ink.wgink.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 serviceIds; + + public List getServiceIds() { + return serviceIds; + } + + public void setServiceIds(List serviceIds) { + this.serviceIds = serviceIds; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"serviceIds\":") + .append(serviceIds); + sb.append('}'); + return sb.toString(); + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeVO.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeVO.java new file mode 100644 index 00000000..70a5dbe5 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/pojo/vos/NoticeVO.java @@ -0,0 +1,119 @@ +package ink.wgink.module.instantmessage.pojo.vos; + +import ink.wgink.annotation.CheckListAnnotation; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +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 NoticeVO { + + @ApiModelProperty(name = "noticies", value = "通知列表") + @CheckListAnnotation(name = "通知列表") + private List notices; + + public List getNotices() { + return notices == null ? new ArrayList<>() : notices; + } + + public void setNotices(List notices) { + this.notices = notices; + } + + @ApiModel + public static class Notice { + @ApiModelProperty(name = "userIds", value = "用户ID列表") + private List userIds; + @ApiModelProperty(name = "title", value = "消息标题") + private String title; + @ApiModelProperty(name = "msg", value = "消息体") + private String msg; + @ApiModelProperty(name = "target", value = "目标字符串") + private String target; + @ApiModelProperty(name = "system", value = "系统") + private String system; + @ApiModelProperty(name = "module", value = "模块") + private String module; + @ApiModelProperty(name = "menu", value = "菜单") + private String menu; + @ApiModelProperty(name = "serviceId", value = "业务ID") + private String serviceId; + + public List getUserIds() { + return userIds == null ? new ArrayList<>() : userIds; + } + + public void setUserIds(List userIds) { + this.userIds = userIds; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getSystem() { + return system == null ? "" : system; + } + + public void setSystem(String system) { + this.system = system; + } + + public String getModule() { + return module == null ? "" : module; + } + + public void setModule(String module) { + this.module = module; + } + + public String getMenu() { + return menu == null ? "" : menu; + } + + public void setMenu(String menu) { + this.menu = menu; + } + + public String getServiceId() { + return serviceId == null ? "" : serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + } + +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/IMessageService.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/IMessageService.java new file mode 100644 index 00000000..871e4624 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/IMessageService.java @@ -0,0 +1,64 @@ +package ink.wgink.module.instantmessage.service; + +import ink.wgink.module.instantmessage.pojo.bos.NoticeBO; +import ink.wgink.module.instantmessage.pojo.bos.NoticeTargetBO; +import ink.wgink.module.instantmessage.pojo.vos.NoticeVO; + +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IMessageService + * @Description: 消息 + * @Author: wanggeng + * @Date: 2021/1/14 3:28 下午 + * @Version: 1.0 + */ +public interface IMessageService { + + /** + * 通知 + * + * @param noticeBO 通知内容 + */ + void notice(NoticeBO noticeBO); + + /** + * 通知 + * + * @param clientName 客户端名称 + * @param noticeBO 通知内容 + */ + void notice(String clientName, NoticeBO noticeBO); + + /** + * 通知 + * + * @param noticeTargetBO 通知内容 + */ + void notice(NoticeTargetBO noticeTargetBO); + + /** + * 通知 + * + * @param clientName 客户端名称 + * @param noticeTargetBO 通知内容 + */ + void notice(String clientName, NoticeTargetBO noticeTargetBO); + + /** + * 通知并保存 + * + * @param noticeBO + */ + void saveNotice(NoticeVO noticeVO, boolean isSave) throws Exception; + + /** + * 删除通知 + * + * @param serviceIds + */ + void delete(List serviceIds); +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/INoticeService.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/INoticeService.java new file mode 100644 index 00000000..e91ebe9b --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/INoticeService.java @@ -0,0 +1,172 @@ +package ink.wgink.module.instantmessage.service; + +import ink.wgink.module.instantmessage.pojo.bos.NoticeBO; +import ink.wgink.module.instantmessage.pojo.bos.NoticeTargetBO; +import ink.wgink.module.instantmessage.pojo.pos.NoticePO; +import ink.wgink.module.instantmessage.pojo.vos.NoticeVO; +import ink.wgink.module.instantmessage.websocket.pojo.body.CountNeedToDealWithBody; + +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: INoticeService + * @Description: 消息通知 + * @Author: wanggeng + * @Date: 2021/3/29 4:36 下午 + * @Version: 1.0 + */ +public interface INoticeService { + + /** + * 保存 + * + * @param userId + * @param notice + */ + void save(String userId, NoticeVO.Notice notice) throws Exception; + + /** + * 更新已办状态 + * + * @param userId + * @param countNeedToDealWithBody + */ + void updateHandleStatus(String userId, CountNeedToDealWithBody countNeedToDealWithBody); + + /** + * 通知详情 + * + * @param params + * @return + */ + NoticePO getPO(Map params); + + /** + * 通知详情 + * + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param module + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String module, String serviceId, String userId); + + /** + * 通知详情 + * + * @param system + * @param module + * @param menu + * @param serviceId + * @param userId + * @return + */ + NoticePO getPO(String system, String module, String menu, String serviceId, String userId); + + /** + * 通知列表 + * + * @param params + * @return + */ + List listPO(Map params); + + /** + * 通知列表 + * + * @param serviceId + * @param userId + * @return + */ + List listPO(String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param module + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String module, String serviceId, String userId); + + /** + * 通知列表 + * + * @param system + * @param module + * @param menu + * @param serviceId + * @param userId + * @return + */ + List listPO(String system, String module, String menu, String serviceId, String userId); + + /** + * 通知数量 + * + * @param userId + * @param countNeedToDealWithBody + * @return + */ + List listNoticeCount(String userId, CountNeedToDealWithBody countNeedToDealWithBody); + + /** + * 统计 + * + * @param params + * @return + */ + Integer count(Map params); + + /** + * 删除 + * + * @param serviceIds + */ + void deleteByServiceIds(List serviceIds); + + /** + * 通知列表 + * + * @param serviceIds + * @return + */ + List listPO(List serviceIds); + +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/MessageServiceImpl.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/MessageServiceImpl.java new file mode 100644 index 00000000..8b40d24d --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/MessageServiceImpl.java @@ -0,0 +1,190 @@ +package ink.wgink.module.instantmessage.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SearchException; +import ink.wgink.module.instantmessage.pojo.bos.NoticeBO; +import ink.wgink.module.instantmessage.pojo.bos.NoticeTargetBO; +import ink.wgink.module.instantmessage.pojo.pos.NoticePO; +import ink.wgink.module.instantmessage.pojo.vos.NoticeVO; +import ink.wgink.module.instantmessage.service.IMessageService; +import ink.wgink.module.instantmessage.service.INoticeService; +import ink.wgink.module.instantmessage.websocket.enums.ClientSocketTypeEnum; +import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager; +import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage; +import ink.wgink.module.instantmessage.websocket.pojo.WebSocketSession; +import ink.wgink.module.instantmessage.websocket.pojo.body.CountNeedToDealWithBody; +import ink.wgink.module.instantmessage.websocket.pojo.body.NoticeBody; +import ink.wgink.util.BeanPropertyCheckUtil; +import io.netty.channel.Channel; +import org.apache.commons.compress.utils.Sets; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +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; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: MessageServiceImpl + * @Description: 消息 + * @Author: wanggeng + * @Date: 2021/1/14 3:28 下午 + * @Version: 1.0 + */ +@Service +public class MessageServiceImpl extends DefaultBaseService implements IMessageService { + + @Autowired + private INoticeService noticeService; + private ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(2); + + @Override + public void notice(NoticeBO noticeBO) { + notice(null, noticeBO); + } + + @Override + public void notice(String clientName, NoticeBO noticeBO) { + List webSocketSessions = listWebSocketSessions(clientName, noticeBO); + NoticeBody noticeBody = new NoticeBody(noticeBO.getTitle(), noticeBO.getContent()); + WebSocketClientMessage webSocketClientMessage = new WebSocketClientMessage(ClientSocketTypeEnum.NOTICE.getValue(), + true, + WebSocketChannelManager.FORM_SYSTEM, + noticeBO.getTo(), + JSONObject.toJSONString(noticeBody)); + notice(webSocketSessions, webSocketClientMessage); + } + + @Override + public void notice(NoticeTargetBO noticeTargetBO) { + notice(null, noticeTargetBO); + } + + @Override + public void notice(String clientName, NoticeTargetBO noticeTargetBO) { + List webSocketSessions = listWebSocketSessions(clientName, noticeTargetBO); + NoticeBody noticeBody = new NoticeBody(noticeTargetBO.getTitle(), noticeTargetBO.getContent(), noticeTargetBO.getTarget()); + WebSocketClientMessage webSocketClientMessage = new WebSocketClientMessage(ClientSocketTypeEnum.NOTICE_TARGET_MESSAGE.getValue(), + true, + WebSocketChannelManager.FORM_SYSTEM, + noticeTargetBO.getTo(), + JSONObject.toJSONString(noticeBody)); + notice(webSocketSessions, webSocketClientMessage); + } + + @Override + public void saveNotice(NoticeVO noticeVO, boolean isSave) throws Exception { + for (NoticeVO.Notice notice : noticeVO.getNotices()) { + if (notice.getUserIds() == null || notice.getUserIds().isEmpty()) { + continue; + } + if (StringUtils.isBlank(notice.getTitle())) { + notice.setTitle("系统消息"); + } + if (StringUtils.isBlank(notice.getMsg())) { + notice.setMsg("您有一条系统消息"); + } + + List webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(notice.getUserIds()); + scheduledExecutorService.schedule(() -> { + for (WebSocketSession webSocketSession : webSocketSessions) { + NoticeBody noticeBody = new NoticeBody(notice.getTitle(), notice.getMsg(), notice.getTarget()); + WebSocketClientMessage webSocketClientMessage = new WebSocketClientMessage(ClientSocketTypeEnum.NOTICE_TARGET_MESSAGE.getValue(), + true, + WebSocketChannelManager.FORM_SYSTEM, + webSocketSession.getUserId(), + JSONObject.toJSONString(noticeBody)); + // 发送通知 + WebSocketChannelManager.getInstance().sendText(webSocketSession.getChannel(), webSocketClientMessage); + } + }, 3, TimeUnit.SECONDS); + if (isSave) { + // 保存通知记录 + List userIds = notice.getUserIds(); + for (String userId : userIds) { + noticeService.save(userId, notice); + } + } + } + } + + /** + * 会话列表 + * + * @param clientName + * @param noticeBO + * @return + */ + private List listWebSocketSessions(String clientName, NoticeBO noticeBO) { + BeanPropertyCheckUtil.checkField(noticeBO); + List userIds = new ArrayList<>(Sets.newHashSet(noticeBO.getTo().split(","))); + List webSocketSessions; + if (StringUtils.isBlank(clientName)) { + webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(userIds); + } else { + webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(userIds, clientName); + } + if (webSocketSessions.isEmpty()) { + throw new SearchException("用户不存在"); + } + return webSocketSessions; + } + + /** + * 通知 + * + * @param webSocketSessions + * @param webSocketClientMessage + */ + private void notice(List webSocketSessions, WebSocketClientMessage webSocketClientMessage) { + for (WebSocketSession webSocketSession : webSocketSessions) { + WebSocketChannelManager.getInstance().sendText(webSocketSession.getChannel(), webSocketClientMessage); + } + } + + @Override + public void delete(List serviceIds) { + List noticePOs = noticeService.listPO(serviceIds); + Set noticeUserIdSet = new HashSet<>(); + noticePOs.forEach(noticePO -> { + noticeUserIdSet.add(noticePO.getUserId()); + }); + // 删除通知 + noticeService.deleteByServiceIds(serviceIds); + // 重新推送数量 + List webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(new ArrayList<>(noticeUserIdSet)); + // 3s后通知,保证事务提交 + scheduledExecutorService.schedule(() -> { + // 更新状态待办 + for (WebSocketSession webSocketSession : webSocketSessions) { + for (NoticePO noticePO : noticePOs) { + if (StringUtils.equals(webSocketSession.getUserId(), noticePO.getUserId())) { + Channel channel = webSocketSession.getChannel(); + CountNeedToDealWithBody countNeedToDealWithBody = new CountNeedToDealWithBody(); + countNeedToDealWithBody.setSystem(noticePO.getNoticeSystem()); + // 查询待办状态 + List counts = noticeService.listNoticeCount(webSocketSession.getUserId(), countNeedToDealWithBody); + WebSocketClientMessage webSocketClientMessage = new WebSocketClientMessage(ClientSocketTypeEnum.SEARCH_COUNT_NEED_TO_DEALT_WITH.getValue(), + true, + WebSocketChannelManager.FORM_SYSTEM, + webSocketSession.getUserId(), + JSONArray.toJSONString(counts)); + WebSocketChannelManager.getInstance().sendText(channel, webSocketClientMessage); + break; + } + } + + } + }, 3, TimeUnit.SECONDS); + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/NoticeServiceImpl.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/NoticeServiceImpl.java new file mode 100644 index 00000000..29a80d0a --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/service/impl/NoticeServiceImpl.java @@ -0,0 +1,285 @@ +package ink.wgink.module.instantmessage.service.impl; + + +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.module.instantmessage.dao.INoticeDao; +import ink.wgink.module.instantmessage.pojo.pos.NoticePO; +import ink.wgink.module.instantmessage.pojo.vos.NoticeVO; +import ink.wgink.module.instantmessage.service.INoticeService; +import ink.wgink.module.instantmessage.websocket.pojo.body.CountNeedToDealWithBody; +import ink.wgink.util.UUIDUtil; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: NoticeServiceImpl + * @Description: 消息通知 + * @Author: wanggeng + * @Date: 2021/3/29 4:36 下午 + * @Version: 1.0 + */ +@Service +public class NoticeServiceImpl extends DefaultBaseService implements INoticeService { + + @Autowired + private INoticeDao noticeDao; + + @Override + public void save(String userId, NoticeVO.Notice notice) throws Exception { + if (StringUtils.isBlank(userId)) { + return; + } + if (StringUtils.isBlank(notice.getSystem())) { + return; + } + if (StringUtils.isBlank(notice.getServiceId())) { + return; + } + List noticePOs = listPO(notice.getSystem(), notice.getModule(), notice.getMenu(), notice.getServiceId(), userId); + if (!noticePOs.isEmpty()) { + LOG.debug("通知已经存在"); + return; + } + Map params = getHashMap(16); + params.put("noticeId", UUIDUtil.getUUID()); + params.put("userId", userId); + params.put("noticeTitle", notice.getTitle()); + params.put("noticeMsg", notice.getMsg()); + params.put("noticeTarget", notice.getTarget()); + params.put("noticeSystem", notice.getSystem()); + params.put("noticeModule", notice.getModule()); + params.put("noticeMenu", notice.getMenu()); + params.put("noticeServiceId", notice.getServiceId()); + params.put("isHandle", 0); + setSaveInfoByUserId(params, "1"); + noticeDao.save(params); + } + + @Override + public void updateHandleStatus(String userId, CountNeedToDealWithBody countNeedToDealWithBody) { + if (StringUtils.isBlank(countNeedToDealWithBody.getSystem())) { + return; + } + if (StringUtils.isBlank(countNeedToDealWithBody.getServiceId())) { + return; + } + Map params = getHashMap(6); + params.put("isHandle", 1); + params.put("noticeSystem", countNeedToDealWithBody.getSystem()); + params.put("noticeServiceId", countNeedToDealWithBody.getServiceId()); + setUpdateInfoByUserId(params, userId); + noticeDao.updateHandle(params); + } + + @Override + public NoticePO getPO(Map params) { + return noticeDao.getPO(params); + } + + @Override + public NoticePO getPO(String serviceId, String userId) { + Map params = getHashMap(4); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String serviceId, String userId) { + Map params = getHashMap(6); + params.put("noticeSystem", system); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String module, String serviceId, String userId) { + Map params = getHashMap(8); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public NoticePO getPO(String system, String module, String menu, String serviceId, String userId) { + Map params = getHashMap(10); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeMenu", menu); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return getPO(params); + } + + @Override + public List listPO(Map params) { + return noticeDao.listPO(params); + } + + @Override + public List listPO(String serviceId, String userId) { + Map params = getHashMap(4); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String serviceId, String userId) { + Map params = getHashMap(6); + params.put("noticeSystem", system); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String module, String serviceId, String userId) { + Map params = getHashMap(8); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listPO(String system, String module, String menu, String serviceId, String userId) { + Map params = getHashMap(10); + params.put("noticeSystem", system); + params.put("noticeModule", module); + params.put("noticeMenu", menu); + params.put("noticeServiceId", serviceId); + params.put("userId", userId); + return listPO(params); + } + + @Override + public List listNoticeCount(String userId, CountNeedToDealWithBody countNeedToDealWithBody) { + List noticeCounts = new ArrayList<>(); + Map params = getHashMap(10); + params.put("userId", userId); + params.put("isHandle", 0); + if (StringUtils.isBlank(countNeedToDealWithBody.getSystem())) { + // 系统为空,按系统统计 + List systems = listSystems(userId); + for (String system : systems) { + params.put("noticeSystem", system); + CountNeedToDealWithBody systemCount = new CountNeedToDealWithBody(); + systemCount.setSystem(system); + systemCount.setCount(count(params)); + noticeCounts.add(systemCount); + } + } else if (StringUtils.isBlank(countNeedToDealWithBody.getModule())) { + // 模块为空,按模块统计 + List modules = listModules(userId, countNeedToDealWithBody.getSystem()); + params.put("noticeSystem", countNeedToDealWithBody.getSystem()); + for (String module : modules) { + CountNeedToDealWithBody systemCount = new CountNeedToDealWithBody(); + systemCount.setSystem(countNeedToDealWithBody.getSystem()); + systemCount.setModule(module); + params.put("noticeModule", module); + systemCount.setCount(count(params)); + noticeCounts.add(systemCount); + } + } else if (StringUtils.isBlank(countNeedToDealWithBody.getMenu())) { + // 菜单为空,按菜单统计 + List menus = listMenus(userId, countNeedToDealWithBody.getSystem(), countNeedToDealWithBody.getModule()); + params.put("noticeSystem", countNeedToDealWithBody.getSystem()); + params.put("noticeModule", countNeedToDealWithBody.getModule()); + for (String menu : menus) { + CountNeedToDealWithBody systemCount = new CountNeedToDealWithBody(); + systemCount.setSystem(countNeedToDealWithBody.getSystem()); + systemCount.setModule(countNeedToDealWithBody.getModule()); + systemCount.setMenu(menu); + params.put("noticeMenu", menu); + systemCount.setCount(count(params)); + noticeCounts.add(systemCount); + } + } else { + // 都不为空,具体菜单数量 + CountNeedToDealWithBody systemCount = new CountNeedToDealWithBody(); + systemCount.setSystem(countNeedToDealWithBody.getSystem()); + systemCount.setModule(countNeedToDealWithBody.getModule()); + systemCount.setMenu(countNeedToDealWithBody.getMenu()); + params.put("noticeSystem", countNeedToDealWithBody.getSystem()); + params.put("noticeModule", countNeedToDealWithBody.getModule()); + params.put("noticeModule", countNeedToDealWithBody.getModule()); + params.put("noticeMenu", countNeedToDealWithBody.getMenu()); + systemCount.setCount(count(params)); + noticeCounts.add(systemCount); + } + return noticeCounts; + } + + @Override + public Integer count(Map params) { + Integer count = noticeDao.count(params); + return count == null ? 0 : count; + } + + @Override + public void deleteByServiceIds(List serviceIds) { + Map params = getHashMap(2); + params.put("serviceIds", serviceIds); + noticeDao.delete(params); + } + + @Override + public List listPO(List serviceIds) { + Map params = getHashMap(2); + params.put("serviceIds", serviceIds); + return listPO(params); + } + + /** + * 系统列表 + * + * @param userId + * @return + */ + private List listSystems(String userId) { + Map params = getHashMap(2); + params.put("userId", userId); + return noticeDao.listSystems(params); + } + + /** + * 模块列表 + * + * @param userId + * @return + */ + private List listModules(String userId, String noticeSystem) { + Map params = getHashMap(4); + params.put("userId", userId); + params.put("noticeSystem", noticeSystem); + return noticeDao.listModules(params); + } + + /** + * 菜单列表 + * + * @param userId + * @return + */ + private List listMenus(String userId, String noticeSystem, String noticeModule) { + Map params = getHashMap(6); + params.put("userId", userId); + params.put("noticeSystem", noticeSystem); + params.put("noticeModule", noticeModule); + return noticeDao.listMenus(params); + } + +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/handler/text/WebSocketTextHandler.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/handler/text/WebSocketTextHandler.java index 3e7e4b14..3a6d300a 100644 --- a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/handler/text/WebSocketTextHandler.java +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/handler/text/WebSocketTextHandler.java @@ -8,6 +8,7 @@ import ink.wgink.module.instantmessage.websocket.exception.*; import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager; import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage; import ink.wgink.module.instantmessage.websocket.pojo.WebSocketSession; +import ink.wgink.module.instantmessage.websocket.pojo.body.IdsBody; import ink.wgink.module.instantmessage.websocket.pojo.body.RegisterBody; import ink.wgink.module.instantmessage.websocket.pojo.body.SendStatusBody; import io.netty.channel.Channel; @@ -17,7 +18,9 @@ import org.apache.commons.compress.utils.Sets; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * @ClassName: WebSocketTextHandler @@ -67,6 +70,7 @@ public class WebSocketTextHandler { } catch (JSONException e) { clientSocketMessage = new WebSocketClientMessage(); clientSocketMessage.setSystem(true); + clientSocketMessage.setType(ClientSocketTypeEnum.SYSTEM_MESSAGE.getValue()); clientSocketMessage.setFrom(WebSocketChannelManager.FORM_SYSTEM); sendStatusBody = new SendStatusBody(SendStatusEnum.TO_ERROR.getValue(), SendStatusEnum.MESSAGE_ERROR, e.getMessage()); } finally { @@ -142,8 +146,32 @@ public class WebSocketTextHandler { } } - private void listOnlineUser(Channel channel, WebSocketClientMessage clientSocketMessage) { - + /** + * 在线用户列表 + * + * @param channel 通道 + * @param webSocketClientMessage 消息体 + * @throws UserSessionException + * @throws UserErrorException + */ + private void listOnlineUser(Channel channel, WebSocketClientMessage webSocketClientMessage) throws UserSessionException, UserErrorException { + webSocketClientMessage.setSystem(true); + webSocketClientMessage.setTo(webSocketClientMessage.getFrom()); + IdsBody idsBody = JSONObject.parseObject(webSocketClientMessage.getBody(), IdsBody.class); + if (idsBody.getIds() == null || idsBody.getIds().isEmpty()) { + sendTextFailed(channel, webSocketClientMessage, "用户ID列表为空"); + return; + } + List webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(idsBody.getIds()); + Set idSets = new HashSet<>(); + for (WebSocketSession webSocketSession : webSocketSessions) { + idSets.add(webSocketSession.getUserId()); + } + idsBody = new IdsBody(); + idsBody.setIds(new ArrayList<>(idSets)); + webSocketClientMessage.setType(ClientSocketTypeEnum.SEND_STATUS_ONLINE.getValue()); + webSocketClientMessage.setBody(JSONObject.toJSONString(idsBody)); + sendText(channel, webSocketClientMessage); } /** diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/manager/WebSocketChannelManager.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/manager/WebSocketChannelManager.java index 151ef70d..34c74f44 100644 --- a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/manager/WebSocketChannelManager.java +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/manager/WebSocketChannelManager.java @@ -217,15 +217,41 @@ public class WebSocketChannelManager { return null; } + /** + * 全部发 + * + * @param tws + */ public void sendAll(TextWebSocketFrame tws) { globalGroup.writeAndFlush(tws); } + /** + * 单发 + * + * @param channel + * @param webSocketClientMessage + */ public void sendText(Channel channel, WebSocketClientMessage webSocketClientMessage) { + if (channel == null || !channel.isOpen() || !channel.isActive()) { + return; + } TextWebSocketFrame textWebSocketFrame = new TextWebSocketFrame(JSONObject.toJSONString(webSocketClientMessage)); channel.writeAndFlush(textWebSocketFrame); } + /** + * 群发 + * + * @param channels + * @param webSocketClientMessage + */ + public void sendGroupText(List channels, WebSocketClientMessage webSocketClientMessage) { + for (Channel channel : channels) { + sendText(channel, webSocketClientMessage); + } + } + private static class WebSocketChannelManagerBuilder { public static final WebSocketChannelManager webSocketChannelManager = new WebSocketChannelManager(); } diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/CountNeedToDealWithBody.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/CountNeedToDealWithBody.java new file mode 100644 index 00000000..039348b9 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/CountNeedToDealWithBody.java @@ -0,0 +1,56 @@ +package ink.wgink.module.instantmessage.websocket.pojo.body; + +/** + * @ClassName: CountNeedToDealWithBody + * @Description: 待办数量统计 + * @Author: wanggeng + * @Date: 2021/9/13 5:39 下午 + * @Version: 1.0 + */ +public class CountNeedToDealWithBody { + private String system; + private String module; + private String menu; + private String serviceId; + private Integer count; + + public String getSystem() { + return system == null ? "" : system.trim(); + } + + public void setSystem(String system) { + this.system = system; + } + + public String getModule() { + return module == null ? "" : module.trim(); + } + + public void setModule(String module) { + this.module = module; + } + + public String getMenu() { + return menu == null ? "" : menu.trim(); + } + + public void setMenu(String menu) { + this.menu = menu; + } + + public String getServiceId() { + return serviceId == null ? "" : serviceId.trim(); + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public Integer getCount() { + return count == null ? 0 : count; + } + + public void setCount(Integer count) { + this.count = count; + } +} diff --git a/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/IdsBody.java b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/IdsBody.java new file mode 100644 index 00000000..45ad5746 --- /dev/null +++ b/module-instant-message/src/main/java/ink/wgink/module/instantmessage/websocket/pojo/body/IdsBody.java @@ -0,0 +1,23 @@ +package ink.wgink.module.instantmessage.websocket.pojo.body; + +import java.util.List; + +/** + * @ClassName: IdsBody + * @Description: ID列表 + * @Author: wanggeng + * @Date: 2021/9/13 9:09 上午 + * @Version: 1.0 + */ +public class IdsBody { + + private List ids; + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } +} diff --git a/module-instant-message/src/main/resources/mybatis/mapper/notice-mapper.xml b/module-instant-message/src/main/resources/mybatis/mapper/notice-mapper.xml new file mode 100644 index 00000000..56df1d03 --- /dev/null +++ b/module-instant-message/src/main/resources/mybatis/mapper/notice-mapper.xml @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + CREATE TABLE IF NOT EXISTS `socket_notice` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `notice_id` char(36) DEFAULT NULL COMMENT '主键', + `notice_title` varchar(255) DEFAULT NULL COMMENT '通知标题', + `notice_msg` varchar(255) DEFAULT NULL COMMENT '通知内容', + `notice_target` varchar(255) DEFAULT NULL COMMENT '通知触发目标', + `notice_system` varchar(255) DEFAULT NULL COMMENT '通知业务系统', + `notice_module` varchar(255) DEFAULT NULL COMMENT '通知业务模块', + `notice_service_id` varchar(255) DEFAULT NULL COMMENT '通知业务ID', + `user_id` char(36) DEFAULT NULL COMMENT '通知人', + `is_handle` int(1) DEFAULT '0' COMMENT '是否处理', + `gmt_create` datetime DEFAULT NULL COMMENT '创建时间', + `creator` char(36) DEFAULT NULL COMMENT '创建人', + `gmt_modified` datetime DEFAULT NULL COMMENT '修改时间', + `modifier` char(36) DEFAULT NULL COMMENT '修改人', + `is_delete` int(1) DEFAULT '0' COMMENT '是否删除', + PRIMARY KEY (`id`), + UNIQUE KEY `notice_id` (`notice_id`) USING BTREE, + KEY `notice_title` (`notice_title`) USING BTREE, + KEY `notice_msg` (`notice_msg`) USING BTREE, + KEY `notice_target` (`notice_target`) USING BTREE, + KEY `notice_module` (`notice_module`) USING BTREE, + KEY `notice_service_id` (`notice_service_id`) USING BTREE, + KEY `user_id` (`user_id`) USING BTREE, + KEY `is_handle` (`is_handle`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小程序用户'; + + + + + INSERT INTO socket_notice ( + notice_id, + notice_title, + notice_msg, + notice_target, + notice_system, + notice_module, + notice_menu, + notice_service_id, + user_id, + is_handle, + gmt_create, + creator, + gmt_modified, + modifier, + is_delete + ) VALUES( + #{noticeId}, + #{noticeTitle}, + #{noticeMsg}, + #{noticeTarget}, + #{noticeSystem}, + #{noticeModule}, + #{noticeMenu}, + #{noticeServiceId}, + #{userId}, + #{isHandle}, + #{gmtCreate}, + #{creator}, + #{gmtModified}, + #{modifier}, + #{isDelete} + ) + + + + + UPDATE + socket_notice + SET + is_handle = #{isHandle}, + gmt_modified = #{gmtModified}, + modifier = #{modifier} + WHERE + notice_system = #{noticeSystem} + AND + notice_service_id = #{noticeServiceId} + + + + + DELETE FROM + socket_notice + WHERE + + notice_service_id IN + + #{serviceIds[${index}]} + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/module-instant-message/src/main/resources/templates/chat-demo.html b/module-instant-message/src/main/resources/templates/chat-demo.html new file mode 100644 index 00000000..515bdf16 --- /dev/null +++ b/module-instant-message/src/main/resources/templates/chat-demo.html @@ -0,0 +1,207 @@ + + + + + + 聊天测试 + + + + +
+
+ + +
+
+ 当前用户ID +
+
+ 接收用户ID +
+
+ + + +
+
+ 状态:未登录 +
+
+ +
+
+ + +
+
+ + + + + + + + \ No newline at end of file