课程评论修改
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseGuestbook;
|
||||
import com.peanut.modules.master.service.CourseGuestbookService;
|
||||
import com.peanut.modules.master.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@@ -18,11 +24,38 @@ public class CourseGuestbookController {
|
||||
|
||||
@Autowired
|
||||
private CourseGuestbookService service;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
|
||||
@RequestMapping("/getCourseGuestbookList")
|
||||
public R getCourseGuestbookList(@RequestBody Map<String,Object> map){
|
||||
Page courseGuestbookList = service.getCourseGuestbookList(map);
|
||||
return R.ok().put("page",courseGuestbookList);
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
MPJLambdaWrapper<CourseGuestbook> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.eq(CourseGuestbook::getType,map.get("type"));
|
||||
if (StringUtils.isNotEmpty(map.get("courseId").toString())){
|
||||
wrapper.eq(CourseGuestbook::getCourseId,map.get("courseId"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(map.get("chapterId").toString())){
|
||||
wrapper.eq(CourseGuestbook::getChapterId,map.get("chapterId"));
|
||||
}
|
||||
wrapper.eq(CourseGuestbook::getPid,0);
|
||||
wrapper.like(CourseGuestbook::getContent,map.get("content"));
|
||||
wrapper.orderByAsc(CourseGuestbook::getCreateTime);
|
||||
Page<CourseGuestbook> courseGuestbookPage = service.page(new Page<>(page, limit), wrapper);
|
||||
if (courseGuestbookPage != null&&courseGuestbookPage.getRecords().size() > 0){
|
||||
for (CourseGuestbook courseGuestbook : courseGuestbookPage.getRecords()) {
|
||||
courseGuestbook.setUser(userService.getById(courseGuestbook.getUserId()));
|
||||
List<CourseGuestbook> childs = service.list(new LambdaQueryWrapper<CourseGuestbook>()
|
||||
.eq(CourseGuestbook::getPid,courseGuestbook.getId())
|
||||
.orderByAsc(CourseGuestbook::getCreateTime));
|
||||
for (CourseGuestbook childC : childs) {
|
||||
childC.setUser(userService.getById(courseGuestbook.getUserId()));
|
||||
}
|
||||
courseGuestbook.setChildren(childs);
|
||||
}
|
||||
}
|
||||
return R.ok().put("page",courseGuestbookPage);
|
||||
}
|
||||
|
||||
@RequestMapping("/addCourseGuestbook")
|
||||
|
||||
Reference in New Issue
Block a user