xuhy
2024-12-11 5be07b1a021f596b003eac001f4cb77416ae6c7b
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
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import com.ruoyi.system.query.CommentQuery;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import javax.naming.ldap.PagedResultsControl;
import java.util.Arrays;
 
/**
 * <p>
 * 课程评论 前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-09-19
 */
@RestController
@RequestMapping("/t-course-comment")
public class TCourseCommentController {
    @Resource
    private TCourseCommentService courseCommentService;
    @Resource
    private TokenService tokenService;
    @Resource
    private TTechnicalTitleService tTechnicalTitleService;
    @Resource
    private TCourseService courseService;
    @Resource
    private TTitleMajorService majorService;
    @Resource
    private TLevelService levelService;
 
    //列表
    @ApiOperation(value = "评价列表",tags = {"后台-评价管理","web教学视频查询"})
    @PostMapping("/list")
    public R<PageInfo<TCourseComment>> list(@RequestBody CommentQuery commentQuery){
        PageInfo<TCourseComment> tCourseCommentPageInfo = courseCommentService.pageQuery(commentQuery);
        for (TCourseComment record : tCourseCommentPageInfo.getRecords()) {
            TCourse byId = courseService.getById(record.getCourseId());
 
            TTechnicalTitle byId1 = tTechnicalTitleService.getById(byId.getTechnicalId() );
            TTitleMajor byId2 = majorService.getById(byId.getMajorId());
            TLevel byId3 = levelService.getById(byId.getLevel());
            record.setClassName(byId1.getTitileName()+"-"+byId2.getMajorName()+"-"+byId3.getName());
            record.setPrice(byId.getCoursePrice());
            record.setCourseCover(byId.getCourseCover());
 
        }
        return R.ok(tCourseCommentPageInfo);
    }
 
 
    @ApiOperation(value = "更改是否显示",tags = "后台-评价管理")
    @PostMapping("/change")
    public R change(Long id, Integer isVision){
        TCourseComment byId = courseCommentService.getById(id);
        byId.setIsVision(isVision);
        courseCommentService.updateById(byId);
        return R.ok();
    }
    //删除
    @ApiOperation(value = "删除",tags = "后台-评价管理")
    @PostMapping("/deleteById")
    public R deleteById(String ids){
        courseCommentService.removeBatchByIds(Arrays.asList(ids.split(",")));
        return R.ok();
    }
 
    @ApiOperation(value = "评论",tags = "web教学视频查询")
    @PostMapping("/course")
    public R comment(@RequestBody TCourseComment tCourseComment){
        Long userId = tokenService.getLoginUser().getUserId();
        tCourseComment.setUserId(userId);
        tCourseComment.setIsVision(0);
        courseCommentService.save(tCourseComment);
 
        return R.ok();
    }
 
}