派生自 projectDept/qhighschool

胡仁荣
2022-10-31 fe7381d6e8ec1f427408de0297ac7f41533202f6
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
package com.qxueyou.scc.controller;
 
import java.util.List;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.druid.util.StringUtils;
import com.qxueyou.scc.base.model.Pager;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.QBeanUtils;
import com.qxueyou.scc.msg.model.MsgInfo;
import com.qxueyou.scc.msg.service.IMsgInfoService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
@Api(tags="ÏûÏ¢¹ÜÀí½Ó¿Ú")
@Controller
@CrossOrigin(origins="*",maxAge=3600)
@RequestMapping(value = "/msg/msg/")
public class MsgInfoController {
 
    // ·ÖÒ³²éѯÖУ¬Ä¬ÈϼǼÌõÊýºÍÒ³Êý
    private static final int DEFAULT_PAGE_SIZE = 10;
    private static final int DEFAULT_PAGE_NUM = 1;
 
    @Autowired
    IMsgInfoService msgInfoService;
    
    /**
     * ÏûÏ¢Áбí
     */
    @ApiOperation(value = "»ñÈ¡ÏûÏ¢Áбí")
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public @ResponseBody Result list(Short type,Integer pageSize,Integer pageNum) {
        pageSize = pageSize != null && pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE;
        pageNum = pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM;
        
        //ÏûÏ¢ÊýÁ¿
        int totalCount = msgInfoService.listCount(type);
        Pager pager = new Pager(pageSize,pageNum);
        pager.setTotalCount(totalCount);
        
        List<MsgInfo> list = msgInfoService.list(type,pageSize,pageNum);
        
        List<Map<String, Object>> listResult =QBeanUtils.listBean2ListMap(list,
                CollectionUtils.newStringMap("msgId", "msgId", "type", "type", "content", "content",
                        "readFlag","readFlag","createTime", "createTime"));
 
        return new Result(true,"",CollectionUtils.newObjectMap("msgList",listResult,"page",pager));
    }
    
    /**
     *  É¾³ýÏûÏ¢
     * @param msgIds
     * @return
     */
    @ApiOperation(value = "ɾ³ýÏûÏ¢")
    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public @ResponseBody Result deleteUserMsg(String  msgIds){
        if(StringUtils.isEmpty(msgIds)){
            return new Result(false,"²ÎÊý´íÎó£¡");
        }
        
        return this.msgInfoService.deleteUserMsg(msgIds.split(","));
    }
 
    /**
     * Çå¿Õ¸öÈËÏûÏ¢
     * 
     * @return
     */
    @ApiOperation(value = "Çå¿ÕÏûÏ¢")
    @RequestMapping(value = "clear", method = RequestMethod.GET)
    public @ResponseBody Result deleteAllUserMsg(Short type){
        return this.msgInfoService.deleteAllUserMsg(type);
    }
    
    /**
     *  ÐÞ¸ÄÒѶÁ±ê־λ
     * @param msgId
     * @return
     */
    @ApiOperation(value = "¸üÐÂΪÒѶÁ")
    @RequestMapping(value = "read", method = RequestMethod.GET)
    public @ResponseBody Result updateReadFlag(String msgIds){
        return this.msgInfoService.updateReadStatus(msgIds.split(","));
    }
    
    /**
     *  È«²¿ÒѶÁ
     * @param msgId
     * @return
     */
    @ApiOperation(value = "È«²¿¸üÐÂΪÒѶÁ")
    @RequestMapping(value = "readall", method = RequestMethod.GET)
    public @ResponseBody Result updateAllUserReadFlag(Short type){
        return this.msgInfoService.updateUserAllReadStatus(type);
    }
    
    
   /**
     *  ×î½üµÄÌáÐÑÏûÏ¢
     * @param msgId
     * @return
     */
   @ApiOperation(value = "×î½üµÄÒ»ÌõÌáÐÑÐÅÏ¢")
   @RequestMapping(value = "last", method = RequestMethod.GET)
   public @ResponseBody Result getLatest(){
       return new Result(true,"",this.msgInfoService.readLastRemindMsg());
   }
    
   
   /**
     *  ×î½üµÄÌáÐÑÏûÏ¢
     * @param msgId
     * @return
     */
   @ApiOperation(value = "°´ÀàÐÍ»ñȡδ¶ÁÏûÏ¢µÄÊýÁ¿")
   @RequestMapping(value = "count", method = RequestMethod.GET)
   public @ResponseBody Result queryUnReadMsgCountByType(){
       return new Result(true,"",this.msgInfoService.queryUnReadMsgCountByType());
   }
   
   /**
     *  ²éѯδ¶ÁÏûÏ¢×ÜÊý
     * @param msgId
     * @return
     */
   @ApiOperation(value = "²éѯÓû§Î´¶ÁÏûÏ¢×ÜÊý")
   @RequestMapping(value = "totalcount", method = RequestMethod.GET)
   public @ResponseBody Result queryUnReadTotalCount(){
       return new Result(true,"",CollectionUtils.newObjectMap("totalCount",this.msgInfoService.queryUnReadTotalCount()));
   }
   
}