|
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);
|
}
|
|
}
|