派生自 projectDept/qhighschool

EricsHu
2023-11-25 79ab2cbd31c022916a8e696903d5eb34b70aa403
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
package com.qxueyou.scc.controller;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.msg.service.IChatroomMsgService;
 
@Controller
@RequestMapping(value = "/msg/chatroom/")
public class MsgChatroomMsgCtrl {
 
    @Autowired
    IChatroomMsgService service;
 
    @RequestMapping(value = "/sendMsg")
    public @ResponseBody
    Result send(
            String chatroomId,
            String senderId,
            String imgPath,
            String alias,
            String content,
            Integer type,
            String userType) {
        try {
            if (StringUtils.isEmpty(chatroomId) || StringUtils.isEmpty(senderId) || StringUtils.isEmpty(content)) {
                return new Result(false, "参数错误");
            }
            return service.doSendMessage(chatroomId, senderId, imgPath, alias, content, type, userType);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "系统异常");
        }
    }
 
    @RequestMapping(value = "/historyMsg")
    public @ResponseBody
    Result historyMsg(String chatroomId, Integer pageNum) {
        try {
            return service.getHistoryMes(chatroomId, pageNum);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "系统异常");
        }
    }
 
    @RequestMapping(value = "/latestMsg")
    public @ResponseBody
    Result latestMsg(String chatroomId) {
        try {
            return service.latestMsg(chatroomId);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "系统异常");
        }
    }
}