ny
23 小时以前 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
package jnpf.message.controller;
 
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jnpf.base.ActionResult;
import jnpf.base.DictionaryDataApi;
import jnpf.base.UserInfo;
import jnpf.base.entity.DictionaryDataEntity;
import jnpf.base.entity.SuperBaseEntity;
import jnpf.base.entity.SystemEntity;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.constant.MsgCode;
import jnpf.exception.DataException;
import jnpf.message.NoticeApi;
import jnpf.message.entity.MessageEntity;
import jnpf.message.entity.MessageReceiveEntity;
import jnpf.message.model.*;
import jnpf.message.service.MessageService;
import jnpf.message.util.OnlineUserModel;
import jnpf.message.util.OnlineUserProvider;
import jnpf.message.util.SendFlowMsgUtil;
import jnpf.permission.UserApi;
import jnpf.permission.entity.UserEntity;
import jnpf.util.JsonUtil;
import jnpf.util.JsonUtilEx;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import jnpf.util.context.RequestContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 系统公告
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司(https://www.jnpfsoft.com)
 * @date 2019年9月27日 上午9:18
 */
@Tag(name = "系统公告", description = "Message")
@RestController
@RequestMapping
@Slf4j
public class NoticeController implements NoticeApi {
 
    @Autowired
    private MessageService messageService;
    @Autowired
    private SendFlowMsgUtil sendFlowMsgUtil;
    @Autowired
    private UserApi usersApi;
    @Autowired
    private DictionaryDataApi dictionaryDataApi;
 
    /**
     * 列表(通知公告)
     *
     * @param pagination 分页模型
     * @return ignore
     */
    @Operation(summary = "获取系统公告列表(带分页)")
    @SaCheckPermission("msgCenter.notice")
    @PostMapping("/Notice/List")
    public ActionResult<PageListVO<MessageNoticeVO>> NoticeList(@RequestBody NoticePagination pagination) {
        messageService.updateEnabledMark();
        List<MessageEntity> list = messageService.getNoticeList(pagination);
        List<UserEntity> userList = usersApi.getUserName(list.stream().map(MessageEntity::getCreatorUserId).collect(Collectors.toList()));
        PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
        List<DictionaryDataEntity> noticeType = dictionaryDataApi.getListByCode("NoticeType");
        List<MessageNoticeVO> voList = new ArrayList<>();
        // 判断是否过期
        list.forEach(t -> {
            MessageNoticeVO vo = JsonUtil.getJsonToBean(t, MessageNoticeVO.class);
            // 处理是否过期
            if (t.getExpirationTime() != null) {
                // 已发布的情况下
                if (t.getEnabledMark() == 1) {
                    if (t.getExpirationTime().getTime() < System.currentTimeMillis()) {
                        vo.setEnabledMark(2);
                    }
                }
            }
            DictionaryDataEntity dictionaryDataEntity = noticeType.stream().filter(notice -> notice.getEnCode().equals(t.getCategory())).findFirst().orElse(new DictionaryDataEntity());
            vo.setCategory(dictionaryDataEntity.getFullName());
            // 转换创建人、发布人
            UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
            vo.setCreatorUser(user != null ? user.getRealName() + "/" + user.getAccount() : "");
            if (t.getEnabledMark() != null && t.getEnabledMark() != 0) {
                UserEntity entity = usersApi.getInfoById(t.getLastModifyUserId());
                vo.setLastModifyUserId(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
                vo.setReleaseTime(t.getLastModifyTime() != null ? t.getLastModifyTime().getTime() : null);
                vo.setReleaseUser(vo.getLastModifyUserId());
            }
            voList.add(vo);
        });
        return ActionResult.page(voList, paginationVO);
    }
 
    /**
     * 添加系统公告
     *
     * @param noticeCrForm 新建系统公告模型
     * @return
     */
    @Operation(summary = "添加系统公告")
    @Parameters({
            @Parameter(name = "noticeCrForm", description = "新建系统公告模型", required = true)
    })
    @SaCheckPermission("msgCenter.notice")
    @PostMapping("/Notice")
    public ActionResult create(@RequestBody @Valid NoticeCrForm noticeCrForm) {
        MessageEntity entity = JsonUtil.getJsonToBean(noticeCrForm, MessageEntity.class);
        if (entity != null && StringUtil.isNotEmpty(entity.getBodyText()) && (entity.getBodyText().contains("&lt;") || entity.getBodyText().contains("&amp;lt;"))) {
            return ActionResult.fail(MsgCode.MSERR112.get());
        }
        messageService.create(entity);
        return ActionResult.success(MsgCode.SU001.get());
    }
 
    /**
     * 修改系统公告
     *
     * @param id            主键
     * @param messageUpForm 修改系统公告模型
     * @return
     */
    @Operation(summary = "修改系统公告")
    @Parameters({
            @Parameter(name = "id", description = "主键", required = true),
            @Parameter(name = "messageUpForm", description = "修改系统公告模型", required = true)
    })
    @SaCheckPermission("msgCenter.notice")
    @PutMapping("/Notice/{id}")
    public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid NoticeUpForm messageUpForm) {
        MessageEntity entity = JsonUtil.getJsonToBean(messageUpForm, MessageEntity.class);
        if (entity != null && StringUtil.isNotEmpty(entity.getBodyText()) && (entity.getBodyText().contains("&lt;") || entity.getBodyText().contains("&amp;lt;"))) {
            return ActionResult.fail(MsgCode.MSERR112.get());
        }
        boolean flag = messageService.update(id, entity);
        if (flag == false) {
            return ActionResult.fail(MsgCode.FA002.get());
        }
        return ActionResult.success(MsgCode.SU004.get());
    }
 
    /**
     * 信息
     *
     * @param id 主键值
     * @return
     */
    @Operation(summary = "获取/查看系统公告信息")
    @Parameters({
            @Parameter(name = "id", description = "主键", required = true)
    })
    @SaCheckPermission("msgCenter.notice")
    @GetMapping("/Notice/{id}")
    public ActionResult<NoticeInfoVO> Info(@PathVariable("id") String id) throws DataException {
        MessageEntity entity = messageService.getInfo(id);
        NoticeInfoVO vo = null;
        if (entity != null) {
            UserEntity info = usersApi.getInfoById(entity.getCreatorUserId());
            entity.setCreatorUserId(info != null ? info.getRealName() + "/" + info.getAccount() : "");
            vo = JsonUtilEx.getJsonToBeanEx(entity, NoticeInfoVO.class);
            vo.setReleaseUser(entity.getCreatorUserId());
            vo.setReleaseTime(entity.getLastModifyTime() != null ? entity.getLastModifyTime().getTime() : null);
            UserEntity userEntity = usersApi.getInfoById(entity.getLastModifyUserId());
            if (userEntity != null && StringUtil.isNotEmpty(userEntity.getId())) {
                String realName = userEntity.getRealName();
                String account = userEntity.getAccount();
                if (StringUtil.isNotEmpty(realName)) {
                    vo.setReleaseUser(realName + "/" + account);
                }
            }
        }
        return ActionResult.success(vo);
    }
 
    /**
     * 删除
     *
     * @param id 主键值
     * @return
     */
    @Operation(summary = "删除系统公告")
    @Parameters({
            @Parameter(name = "id", description = "主键", required = true)
    })
    @SaCheckPermission("msgCenter.notice")
    @DeleteMapping("/Notice/{id}")
    public ActionResult delete(@PathVariable("id") String id) {
        MessageEntity entity = messageService.getInfo(id);
        if (entity != null) {
            messageService.delete(entity);
            return ActionResult.success(MsgCode.SU003.get());
        }
        return ActionResult.fail(MsgCode.FA003.get());
    }
 
    /**
     * 发布公告
     *
     * @param id 主键值
     * @return
     */
    @Operation(summary = "发布系统公告")
    @Parameters({
            @Parameter(name = "id", description = "主键", required = true)
    })
    @SaCheckPermission("msgCenter.notice")
    @PutMapping("/Notice/{id}/Actions/Release")
    public ActionResult Release(@PathVariable("id") String id) {
        MessageEntity entity = messageService.getInfo(id);
        if (entity != null) {
            List<String> userIds = null;
            if (StringUtil.isNotEmpty(entity.getToUserIds())) {
                userIds = Arrays.asList(entity.getToUserIds().split(","));
            } else {
                userIds = usersApi.getListId();
            }
            List<String> userIdList = usersApi.getUserIdList(userIds);
            if (sendFlowMsgUtil.sentNotice(userIdList, entity)) {
                return ActionResult.success(MsgCode.SU011.get());
            }
        }
        return ActionResult.fail(MsgCode.FA011.get());
    }
 
//=======================================站内消息、消息中心=================================================
 
 
    /**
     * 获取消息中心列表
     *
     * @param pagination 分页模型
     * @return
     */
    @Operation(summary = "列表(通知公告/系统消息/私信消息)")
    @GetMapping
    public ActionResult<PageListVO<MessageInfoVO>> messageList(PaginationMessage pagination) {
        List<MessageInfoVO> listVO = new ArrayList<>();
        List<MessageReceiveEntity> list = messageService.getMessageList3(pagination);
        List<UserEntity> userList = usersApi.getUserName(list.stream().map(SuperBaseEntity.SuperCBaseEntity::getCreatorUserId).collect(Collectors.toList()));
        list.forEach(t -> {
            MessageInfoVO vo = JsonUtil.getJsonToBean(t, MessageInfoVO.class);
            UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
            if (user != null) {
                vo.setReleaseTime(t.getCreatorTime() != null ? t.getCreatorTime().getTime() : null);
                UserEntity entity = usersApi.getInfoById(t.getCreatorUserId());
                vo.setReleaseUser(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
                vo.setCreatorUser(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
            }
            listVO.add(vo);
        });
        PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
        return ActionResult.page(listVO, paginationVO);
    }
 
 
    /**
     * 读取消息
     *
     * @param id 主键值
     * @return
     */
    @Operation(summary = "读取消息")
    @Parameters({
            @Parameter(name = "id", description = "主键值", required = true)
    })
    @GetMapping("/ReadInfo/{id}")
    public ActionResult<NoticeInfoVO> readInfo(@PathVariable("id") String id) throws DataException {
        MessageReceiveEntity receive = messageService.messageRead(id);
        if (receive != null) {
            UserEntity user = usersApi.getInfoById(receive.getCreatorUserId());
            receive.setCreatorUserId(user != null ? user.getRealName() + "/" + user.getAccount() : "");
            receive.setBodyText(receive.getBodyText());
//            if (entity.getType() == 2) {
//                entity.setBodyText(receive.getBodyText());
//            }
        }
        NoticeInfoVO vo = JsonUtil.getJsonToBean(receive, NoticeInfoVO.class);
        if (Objects.equals(receive.getType(), 1)) {
            try {
                MessageEntity jsonToBean = JsonUtil.getJsonToBean(receive.getBodyText(), MessageEntity.class);
                if (jsonToBean != null) {
                    vo.setCategory(jsonToBean.getCategory());
                    vo.setCoverImage(jsonToBean.getCoverImage());
                    vo.setExcerpt(jsonToBean.getExcerpt());
                    vo.setExpirationTime(jsonToBean.getExpirationTime() != null ? jsonToBean.getExpirationTime().getTime() : null);
                    vo.setFiles(jsonToBean.getFiles());
                    vo.setBodyText(jsonToBean.getBodyText());
                    if (jsonToBean.getId() != null) {
                        MessageEntity info = messageService.getInfo(jsonToBean.getId());
                        if (info != null) {
                            vo.setCategory(info.getCategory());
                            vo.setCoverImage(info.getCoverImage());
                            vo.setExcerpt(info.getExcerpt());
                            vo.setExpirationTime(info.getExpirationTime() != null ? info.getExpirationTime().getTime() : null);
                            vo.setFiles(info.getFiles());
                            vo.setBodyText(info.getBodyText());
                        }
                    }
                }
            } catch (Exception e) {
                vo.setBodyText(receive.getBodyText());
            }
        }
        vo.setReleaseTime(receive.getCreatorTime() != null ? receive.getCreatorTime().getTime() : null);
//        UserEntity info = usersApi.getInfoById(receive.getCreatorUserId());
        vo.setReleaseUser(receive.getCreatorUserId());
        return ActionResult.success(vo);
    }
 
 
    /**
     * 全部已读
     *
     * @param pagination 分页模型
     * @return
     */
    @Operation(summary = "全部已读")
    @Parameters({
            @Parameter(name = "pagination", description = "分页模型", required = true)
    })
    @PostMapping("/Actions/ReadAll")
    public ActionResult allRead(@RequestBody PaginationMessage pagination) {
        List<MessageReceiveEntity> list = messageService.getMessageList3(pagination);
        if (list != null && list.size() > 0) {
            List<String> idList = list.stream().map(SuperBaseEntity.SuperIBaseEntity::getId).collect(Collectors.toList());
            messageService.messageRead(idList);
            return ActionResult.success(MsgCode.SU005.get());
        } else {
            return ActionResult.fail(MsgCode.MSERR113.get());
        }
    }
 
    /**
     * app端获取未读数据
     *
     * @return
     */
    @Operation(summary = "app端获取未读数据")
    @GetMapping("/getUnReadMsgNum")
    public ActionResult<Map<String, String>> getUnReadMsgNum() {
        Map<String, String> map = new HashMap<>();
        UserInfo userInfo = UserProvider.getUser();
        Integer unReadMsg = messageService.getUnreadCount(userInfo.getUserId(), 2);
        Integer unReadSchedule = messageService.getUnreadCount(userInfo.getUserId(), 4);
        Integer unReadNotice = messageService.getUnreadCount(userInfo.getUserId(), 1);
        Integer unReadSystemMsg = messageService.getUnreadCount(userInfo.getUserId(), 3);
        Integer unReadNum = unReadMsg + unReadNotice + unReadSchedule + unReadSystemMsg;
        map.put("unReadMsg", unReadMsg.toString());
        map.put("unReadNotice", unReadNotice.toString());
        map.put("unReadSchedule", unReadSchedule.toString());
        map.put("unReadSystemMsg", unReadSystemMsg.toString());
        map.put("unReadNum", unReadNum.toString());
        return ActionResult.success(map);
    }
 
    /**
     * 删除记录
     *
     * @param recordForm 已读模型
     * @return
     */
    @Operation(summary = "删除消息")
    @Parameters({
            @Parameter(name = "recordForm", description = "已读模型", required = true)
    })
    @DeleteMapping("/Record")
    public ActionResult deleteRecord(@RequestBody MessageRecordForm recordForm) {
        String[] id = recordForm.getIds().split(",");
        List<String> list = Arrays.asList(id);
        messageService.deleteRecord(list);
        return ActionResult.success(MsgCode.SU003.get());
    }
 
    /**
     * 列表(通知公告)
     *
     * @return
     */
    @Override
    @PostMapping("/GetNoticeList")
    public List<NoticeVO> getNoticeList(@RequestBody List<String> list) {
        List<MessageEntity> dashboardNoticeList = messageService.getDashboardNoticeList(list);
        List<UserEntity> userList = usersApi.getUserName(dashboardNoticeList.stream().map(MessageEntity::getCreatorUserId).collect(Collectors.toList()));
        List<DictionaryDataEntity> noticeType = dictionaryDataApi.getListByCode("NoticeType");
        dashboardNoticeList.forEach(t -> {
            // 转换创建人、发布人
            UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
            t.setCreatorUserId(user != null ? user.getRealName() + "/" + user.getAccount() : "");
            if (t.getEnabledMark() != null && t.getEnabledMark() != 0) {
                UserEntity entity = usersApi.getInfoById(t.getLastModifyUserId());
                t.setLastModifyUserId(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
            }
            DictionaryDataEntity dictionaryDataEntity = noticeType.stream().filter(notice -> notice.getEnCode().equals(t.getCategory())).findFirst().orElse(new DictionaryDataEntity());
            t.setCategory(dictionaryDataEntity.getFullName());
        });
        List<NoticeVO> jsonToList = new ArrayList<>();
        dashboardNoticeList.forEach(t -> {
            NoticeVO vo = JsonUtil.getJsonToBean(t, NoticeVO.class);
            vo.setReleaseTime(t.getLastModifyTime() != null ? t.getLastModifyTime().getTime() : null);
            vo.setReleaseUser(t.getLastModifyUserId());
            vo.setCreatorUser(t.getCreatorUserId());
            jsonToList.add(vo);
        });
        return jsonToList;
    }
 
    /**
     * 发送消息
     *
     * @param sentMessageModel
     * @return
     */
    @Override
    @PostMapping("/SentMessage")
    public void sentMessage(@RequestBody SentMessageModel sentMessageModel) {
        messageService.sentMessage(sentMessageModel.getToUserIds(), sentMessageModel.getTitle(), sentMessageModel.getBodyText());
    }
 
    @Override
    @PostMapping("/autoSystem")
    public void autoSystem(@RequestBody Map<String, Object> map) {
        String message = map.get("message").toString();
        SystemEntity entity = JsonUtil.getJsonToBean(map.get("entity"), SystemEntity.class);
        // 如果禁用了系统,则需要将系统
        List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
        for (OnlineUserModel item : onlineUserList) {
            String systemId = item.getSystemId();
            if (entity.getId().equals(systemId)) {
                if (item.getWebSocket().isOpen()) {
                    Map<String, String> maps = new HashMap<>(1);
                    maps.put("method", "logout");
                    maps.put("msg", "应用已被禁用或删除");
                    if (StringUtil.isNotEmpty(UserProvider.getUser().getTenantId())) {
                        if (UserProvider.getUser().getTenantId().equals(item.getTenantId())) {
                            item.getWebSocket().getAsyncRemote().sendText(JsonUtil.getObjectToString(maps));
                        }
                    } else {
                        item.getWebSocket().getAsyncRemote().sendText(JsonUtil.getObjectToString(maps));
                    }
                }
            }
        }
 
    }
 
 
    @Override
    @PostMapping("/sendMessage")
    public void sendMessage(@RequestBody Map<String, Object> objectMap) {
        List<String> userIds = (List<String>) objectMap.get("ids");
        String message = (String) objectMap.get("message");
        //用户不强制下线,websokit推送刷新即可
        List<OnlineUserModel> users = new ArrayList<>();
        List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
        for (OnlineUserModel onlineUserModel : onlineUserList) {
            String userId = onlineUserModel.getUserId();
            if (userIds.contains(userId)) {
                users.add(onlineUserModel);
            }
        }
        if (!ObjectUtils.isEmpty(users)) {
            for (OnlineUserModel user : users) {
                JSONObject obj = new JSONObject();
                obj.put("method", "refresh");
                obj.put("msg", StringUtil.isEmpty(message) ? MsgCode.PS010.get() : message);
                if (user != null) {
                    OnlineUserProvider.sendMessage(user, obj);
                }
            }
        }
    }
 
    @Override
    @GetMapping("/majorStandFreshUser")
    public void majorStandFreshUser() {
        UserInfo userInfo = UserProvider.getUser();
        List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
        for (OnlineUserModel onlineUserModel : onlineUserList) {
            String userId = onlineUserModel.getUserId();
            //当前用户,同平台的其他客户端需要强制刷新
            if (userInfo.getUserId().equals(userId)
                    && Objects.equals(!RequestContext.isOrignPc(), onlineUserModel.getIsMobileDevice())) {
                JSONObject obj = new JSONObject();
                obj.put("method", "refresh");
                obj.put("msg", MsgCode.PS010.get());
                OnlineUserProvider.sendMessage(onlineUserModel, obj);
            }
        }
    }
 
 
    @Override
    @PostMapping("/logoutUser")
    public void logoutUser(@RequestBody Map<String, Object> objectMap) {
        List<String> userIds = (List<String>) objectMap.get("ids");
        String message = (String) objectMap.get("message");
        //用户不强制下线
        List<OnlineUserModel> users = new ArrayList<>();
        List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
        for (OnlineUserModel onlineUserModel : onlineUserList) {
            String userId = onlineUserModel.getUserId();
            if (userIds.contains(userId) && !Objects.equals(UserProvider.getUser().getToken(), onlineUserModel.getToken())) {
                users.add(onlineUserModel);
            }
        }
        if (!ObjectUtils.isEmpty(users)) {
            for (OnlineUserModel user : users) {
                JSONObject obj = new JSONObject();
                obj.put("method", "logout");
                obj.put("msg", StringUtil.isEmpty(message) ? MsgCode.PS011.get() : message);
                if (user != null) {
                    OnlineUserProvider.sendMessage(user, obj);
                }
                //先移除对象, 并推送下线信息, 避免网络原因导致就用户未断开 新用户连不上WebSocket
                OnlineUserProvider.removeModel(user);
                UserProvider.logoutByToken(user.getToken());
            }
        }
    }
 
    @Override
    @GetMapping("/getUserMessageList")
    public List<MessageInfoVO> getUserMessageList() {
        return messageService.getUserMessageList();
    }
 
}