package com.qxueyou.scc.operation.topic.action; import com.qxueyou.scc.Sensitive.SensitiveFilterService; 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("C:\\Users\\Administrator\\Desktop\\SensitiveWordList.txt"); // String filter = SensitiveWordFilter.Filter(content); SensitiveFilterService filter = SensitiveFilterService.getInstance(); String filterContentHou = filter.replaceSensitiveWord(content, 1, "*"); return topicService.addComment(filterContentHou, 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); } }