派生自 projectDept/qhighschool

yn147
2023-05-10 96286178ee1c257c130cb2ad964a781f36c4eee5
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
 
package com.qxueyou.scc.operation.topic.action;
 
import com.qxueyou.scc.Sensitive.SensitiveWordFilter;
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) {
        SensitiveWordFilter.loadWordFromFile("D:\\工作\\SensitiveWord\\SensitiveWordList.txt");
        String filter = SensitiveWordFilter.Filter(content);
        return topicService.addComment(filter, 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);
    }
 
}