派生自 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
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
 
package com.qxueyou.scc.operation.topic.action;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import com.qxueyou.scc.base.model.Pager;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.util.ClientUtils;
import com.qxueyou.scc.base.util.CommonUtils;
import com.qxueyou.scc.operation.topic.model.TopicInfo;
import com.qxueyou.scc.operation.topic.service.ITopicService;
import com.qxueyou.scc.user.service.IUserService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
 
/**
 * Ñ§Ï°¶Ë »°Ìâǰ¶Ë¿ØÖÆÆ÷
 * 
 * @author chenjunliang
 *
 */
@Api(tags="ÌÖÂÛ½Ó¿Ú")
@RestController
@CrossOrigin(origins="*",maxAge=3600)
@RequestMapping(value = "/stu/topic")
public class StuTopicController {
 
    @Autowired
    private ITopicService topicService;
 
    @Autowired
    IUserService userService;
    
    /**
     * »ñÈ¡ÈÈÃÅ»°ÌâÁбí
     * 
     * @param classId
     *            °à¼¶id
     * @param keyword
     *            Ë÷Ëѹؼü×Ö
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * @return status (0,Ϊ¿ªÊ¼¡£1,ÌÖÂÛÖС£2,ÒѽáÊø¡£)
     */
    @ApiOperation(value = "»ñÈ¡ÈÈÃÅ»°ÌâÁбí", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "°à¼¶id", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "type", value = "1ÈÈÃÅ£¬2×î½ü", required = true, paramType="query", dataType = "int"),
        @ApiImplicitParam(name = "scope", value = "1°à¼¶£¬2»ú¹¹", required = true, paramType="query", dataType = "int"),
    })
    @GetMapping(value = "getHotTopicLst")
    public Result getClassTopicLst(String classId, @RequestParam(defaultValue="")String keyword, Pager pager, int type, int scope) {
//        System.out.println(classId);
        return new Result(true, "success", topicService.getHotTopicLst(CommonUtils.getClassId(classId), keyword, pager.getPageSize(), pager.getOffset(), type, scope));
    }
    
    /**
     * ÎҵĻظ´
     * 
     * @param pageSize
     *            Ã¿Ò³ÏÔʾ¶àÉÙÌõ
     * @param currentPage
     *            µ±Ç°Ò³Âë
     */
    @ApiOperation(value = "app¶Ë½Ó¿Ú-ÎҵĻظ´", notes = "")
    @GetMapping(value = "/app/myComment")
    public Result appMyComment(Pager pager) {
        return topicService.appMyComment(ClientUtils.getUserId(), pager);
    }
    
    /**
     * app¶Ë½Ó¿Ú-»Ø¸´ÎҵĻñÈ¡Áбí
     * 
     * @param pager
     * @return
     */
    @ApiOperation(value = "app¶Ë½Ó¿Ú-»Ø¸´ÎҵĻñÈ¡Áбí", notes = "")
    @GetMapping(value = "/app/commentToMe")
    public Result commentToMe(Pager pager) {
        return topicService.commentToMe(ClientUtils.getUserId(), pager);
    }
    
    /**
     * app¶Ë½Ó¿Ú-ÎҵĵãÔÞ
     * 
     * @param pager
     * @return
     */
    @ApiOperation(value = "app¶Ë½Ó¿Ú-ÎҵĵãÔÞ", notes = "")
    @GetMapping(value = "/app/myPraise")
    public Result appMyPraise(Pager pager) {
 
        return topicService.appMyPraise(ClientUtils.getUserId(), pager);
    }
    
    /**
     * app¶Ë½Ó¿Ú-¸øÎÒÔÞµÄ
     * 
     * @param pager
     * @return
     */
    @ApiOperation(value = "app¶Ë½Ó¿Ú-¸øÎÒÔÞµÄ", notes = "")
    @GetMapping(value = "/app/praiseToMe")
    public Result praiseToMe(Pager pager) {
        return topicService.praiseToMe(ClientUtils.getUserId(), pager);
    }
 
    /**
     * »ñÈ¡»°ÌâÁбí
     * 
     * @param classId
     *            °à¼¶id
     * @param keyword
     *            Ë÷Ëѹؼü×Ö
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * @return status (0,Ϊ¿ªÊ¼¡£1,ÌÖÂÛÖС£2,ÒѽáÊø¡£)
     */
    @ApiOperation(value = "»ñÈ¡»°ÌâÁбí", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "°à¼¶id", required = true, paramType="query", dataType = "String")
    })
    @GetMapping(value = "getTopicLst")
    public Result getTopicLst(String classId, String keyword, Integer limit, Integer pageNum) {
        if (userService.isAdmin()) {
            return topicService.getTopicLstOfAdmin(classId, limit, pageNum, keyword);
        }
        if (userService.isTeacher()) {
            return topicService.getTopicLstOfTeacher(classId, limit, pageNum, keyword);
        }
        return topicService.getTopicLst(classId, keyword, limit, pageNum);
    }
 
    /**
     * Ñ§Ï°¶Ë ·¢²¼/¸üл°Ìâ
     * 
     * @param topicName
     *            »°ÌâÃû³Æ
     * @param topicDesc
     *            »°ÌâÃèÊö
     * @param starTime
     *            ¿ªÊ¼Ê±¼ä
     * @param endTime
     *            ½áÊøÊ±¼ä
     * @param classId
     *            °à¼¶id(¿ÉÒÔ¶à¸ö)
     */
    @ApiOperation(value = "·¢²¼/¸üл°Ìâ", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "classId", value = "°à¼¶ids", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "topicName", value = "ÌÖÂÛÃû³Æ", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "topicDesc", value = "ÄÚÈÝ", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "startTime", value = "¿ªÊ¼Ê±¼ä", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "endTime", value = "½áÊøÊ±¼ä", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "topicId", value = "ÌÖÂÛid", required = true, paramType="query", dataType = "String"),
    })
    @PostMapping(value = "addOrUpdateTopic")
    public Result addOrUpdateTopic(@RequestBody TopicInfo topicInfo) {
        if (StringUtils.isBlank(topicInfo.getTopicId())) {
            return topicService.addTopicInfo(topicInfo);
        }
        return topicService.updateTopicInfo(topicInfo);
    }
 
    /**
     * Ñ§Ï°¶ËÌÖÂÛÇø
     * 
     * @param keyword
     *            ËÑË÷¹Ø¼ü×Ö
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     */
    @GetMapping(value = "lstCommonTopic")
    public Result lstCommonTopic(String keyword, Integer limit, Integer pageNum, String classId) {
        return topicService.lstCommonTopic(keyword, 6, 0, classId);
    }
 
    /**
     * Ñ§Ï°¶Ë ÌÖÂÛͳ¼Æ
     */
    @ApiOperation(value = "ѧϰ¶Ë ÌÖÂÛͳ¼Æ", notes = "")
    @GetMapping(value = "commentDetail")
    public Result commentDetail() {
        return topicService.commentDetail(ClientUtils.getUserId());
    }
 
    /**
     * °à¼¶ÂÛ̳
     */
    @GetMapping(value = "getClassForumLst")
    public Result getClassForum() {
 
        return topicService.getClassForum();
    }
 
    /**
     * Ñ§Ï°¶Ë»ñÈ¡°à¼¶ÂÛ̳ÏêÇé
     */
    @GetMapping(value = "getClassForumDetail")
    public Result getClassForumDetail(String classId) {
 
        return topicService.getClassForumDetail(classId);
    }
 
    /**
     * »ñÈ¡»°ÌâÏêÇé
     * 
     * @param topicId
     *            »°Ìâid
     */
    @ApiOperation(value = "»ñÈ¡»°ÌâÏêÇé", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "topicId", value = "ÌÖÂÛid", required = true, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "getTopicDetails")
    public Result getTopicDetails(String topicId) {
        return topicService.doTopicDetails(topicId);
    }
 
    /**
     * »ñÈ¡ÏêÇé »ñÈ¡ÆÀÂÛÁбí
     * 
     * @param topicId
     *            »°Ìâid
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     */
    @ApiOperation(value = "»ñÈ¡ÏêÇé »ñÈ¡ÆÀÂÛÁбí", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "topicId", value = "ÌÖÂÛid", required = false, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "getCommentLst")
    public Result getCommentLst(String topicId, Integer pageSize, Integer pageNum) {
 
        return topicService.getCommentLst(topicId, pageSize, pageNum);
    }
 
    /**
     * ÎÒ·¢²¼µÄ»°Ìâ
     * 
     * @param pageSize
     *            Ã¿Ò³ÏÔʾ¶àÉÙÌõ
     * @param pageNum
     *            µ±Ç°Ò³Âë
     */
    @ApiOperation(value = "ÎÒ·¢²¼µÄ»°Ìâ", notes = "")
    @GetMapping(value = "myTopic")
    public Result myTopic(Integer pageSize, Integer pageNum) {
 
        return topicService.myTopic(pageSize, pageNum);
    }
 
    /**
     * ÎҵĻظ´
     * 
     * @param pageSize
     *            Ã¿Ò³ÏÔʾ¶àÉÙÌõ
     * @param currentPage
     *            µ±Ç°Ò³Âë
     */
    @ApiOperation(value = "ÎҵĻظ´", notes = "")
    @GetMapping(value = "myComment")
    public Result myComment(Integer pageSize, Integer pageNum) {
 
        return topicService.myComment(pageSize, pageNum);
    }
    
    /**
     * ÎҵĻظ´
     * 
     * @param pageSize
     *            Ã¿Ò³ÏÔʾ¶àÉÙÌõ
     * @param currentPage
     *            µ±Ç°Ò³Âë
     */
    @ApiOperation(value = "ÎҵĵãÔÞ", notes = "")
    @GetMapping(value = "myPraise")
    public Result myPraise(Integer pageSize, Integer pageNum) {
 
        return topicService.myComment(pageSize, pageNum);
    }
 
    /**
     * É¾³ýÎҵĻظ´
     */
    @ApiOperation(value = "ɾ³ýÎҵĻظ´", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "commentId", value = "ÆÀÂÛid", required = false, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "deleteMycomment")
    public Result deleteMycomment(String commentId) {
        return topicService.deleteMycomment(commentId);
    }
 
    /**
     * »Ø¸´ÎҵĻñÈ¡Áбí
     * 
     * @param keyword
     *            »°Ìâid
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * 
     */
    @ApiOperation(value = "»Ø¸´ÎҵĻñÈ¡Áбí", notes = "")
    @GetMapping(value = "getCommentLstToMe")
    public Result gerCommentLstToMe(Integer pageSize, Integer pageNum) {
        return topicService.getCommentLstToMe(pageSize, pageNum);
    }
 
    /**
     * »ñÈ¡ÎҵĵãÔÞ
     */
    @ApiOperation(value = "»ñÈ¡ÎҵĵãÔÞ", notes = "")
    @GetMapping(value = "getPraiseLst")
    public Result getPraiseLst(Integer pageSize, Integer pageNum) {
        return topicService.getPraiseLst(pageSize, pageNum);
    }
 
    /**
     * »°Ìâ»Ø¸´ÆÀÂÛ
     * 
     * @param content
     *            ÆÀÂÛÄÚÈÝ
     * @param topicId
     *            »°Ìâid
     * @param »Ø¸´ÆÀÂÛµÄid
     */
    /**
     * »ñÈ¡ÎҵĵãÔÞ
     */
    @ApiOperation(value = "»°Ìâ»Ø¸´ÆÀÂÛ", notes = "")
        @ApiImplicitParams({
            @ApiImplicitParam(name = "commentedId", value = "±»ÆÀÂÛµÄid", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "content", value = "»Ø¸´ÄÚÈÝ", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "commentObjectId", value = "ÆÀÂÛ»°Ìâid", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "commentParentId", value = "¸¸ÆÀÂÛid", required = true, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "commentedName", value = "±»ÆÀÂÛÕß", required = false, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "addComment")
    public Result addComment(String content, String commentObjectId, String commentParentId, String commentedId,
            String commentedName) {
        return topicService.addComment(content, commentObjectId, commentParentId, commentedId, commentedName);
    }
 
    /**
     * µãÔÞ»°Ìâ/ÆÀÂÛ
     * 
     * @param commentId
     *            ÆÀÂÛid
     * @param topicId
     *            »°Ìâid
     */
    @ApiOperation(value = "µãÔÞ»°Ìâ/ÆÀÂÛ", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "commentId", value = "µãÔÞÆÀÂÛid", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "commentObjectId", value = "µãÔÞ»°Ìâid", required = false, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "addPraise")
    public Result addPraise(String commentId, String commentObjectId) {
        return topicService.addPraise(commentId, commentObjectId);
    }
 
    /**
     * É¾³ý»°Ìâ
     * 
     * @param topicId
     *            »°Ìâid
     */
    @ApiOperation(value = "ɾ³ýÌÖÂÛ", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "topicId", value = "ÌÖÂÛid", required = false, paramType="query", dataType = "String"),
    })
    @PostMapping(value = "deleteTopic")
    public Result deleteTopic(String topicId) {
        return topicService.deleteTopic(topicId);
    }
 
}