无关风月
2025-01-22 99367ea1c11a68b420936e7f7db5fa7367da4f44
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
package com.xinquan.system.controller;
 
 
import com.xinquan.common.core.domain.R;
import com.xinquan.common.core.utils.page.PageDTO;
import com.xinquan.common.log.annotation.Log;
import com.xinquan.common.log.enums.BusinessType;
import com.xinquan.course.api.domain.Course;
import com.xinquan.course.api.domain.CourseCategory;
import com.xinquan.course.api.domain.CourseDTO;
import com.xinquan.course.api.feign.RemoteCourseService;
import com.xinquan.system.domain.Banner;
import com.xinquan.system.service.BannerService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-08-21
 */
@RestController
@RequestMapping("/system/banner")
public class BannerController {
 
    @Autowired
    private BannerService bannerService;
    @Autowired
    private RemoteCourseService remoteCourseService;
 
    @PostMapping("/bannerList")
    @ApiOperation(value = "获取banner列表-分页",tags = "管理后台banner")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"),
            @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer")
    })
    public R<PageDTO<Banner>> bannerList(
            @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return R.ok(bannerService.bannerList(pageCurr, pageSize));
    }
    @PostMapping("/cateList")
    @ApiOperation(value = "课程分类下拉选择列表-不分页",tags = "管理后台banner")
 
    public R<List<CourseCategory>> cateList() {
        List<CourseCategory> data = remoteCourseService.cateList().getData();
        return R.ok(data);
    }
    @GetMapping("/courseList")
    @ApiOperation(value = "选择课程-分页",tags = "管理后台banner")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = false, dataType = "Integer"),
            @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = false, dataType = "Integer"),
            @ApiImplicitParam(value = "课程类型1线上2线下", name = "courseType", required = false, dataType = "Integer"),
            @ApiImplicitParam(value = "课程分类id", name = "cateId", required = false, dataType = "Long"),
            @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"),
            @ApiImplicitParam(value = "导师名称", name = "tutor", required = false, dataType = "String"),
    })
    public R<PageDTO<Course>> courseList(
            Integer pageCurr,
            Integer pageSize,
         Integer courseType,
     Long cateId,
       String courseTitle,
 
            String tutor
            ) {
        CourseDTO courseDTO = new CourseDTO();
        courseDTO.setPageCurr(pageCurr);
        courseDTO.setPageSize(pageSize);
        courseDTO.setCourseType(courseType);
        courseDTO.setCateId(cateId);
        courseDTO.setCourseTitle(courseTitle);
        courseDTO.setTutor(tutor);
        PageDTO<Course> data = remoteCourseService.courseList(courseDTO).getData();
        return R.ok(data);
    }
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "批量删除banner",tags = "管理后台banner")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "ids", name = "ids", required = true, dataType = "String"),
    })
    @Log(title = "【banner】批量删除", businessType = BusinessType.DELETE)
 
    public R deleteBatch(
            @RequestParam(value = "ids") String ids)
    {
        List<Long> list = Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
        bannerService.removeBatchByIds(list);
        return R.ok();
    }
    @PostMapping("/addBanner")
    @ApiOperation(value = "添加banner",tags = "管理后台banner")
    @Log(title = "【banner】添加", businessType = BusinessType.INSERT)
 
    public R addBanner(@RequestBody Banner banner)
    {
        bannerService.save(banner);
        return R.ok();
    }
    @PostMapping("/updateBanner")
    @ApiOperation(value = "修改banner",tags = "管理后台banner")
    @Log(title = "【banner】修改", businessType = BusinessType.UPDATE)
    public R updateBanner(@RequestBody Banner banner)
    {
        bannerService.updateById(banner);
        return R.ok();
    }
    @PostMapping("/bannerDetail")
    @ApiOperation(value = "查看详情",tags = "管理后台banner")
 
    public R<Banner> bannerDetail(String uid)
    {
        Banner byId = bannerService.getById(uid);
        if (byId.getCourseId()!=null){
            Course data = remoteCourseService.getCourseById(byId.getCourseId()).getData();
            if (data!=null){
                byId.setCourseTitle(data.getCourseTitle());
                byId.setCoverUrl(data.getCoverUrl());
                byId.setTutor(data.getTutor());
                byId.setPrice(data.getGeneralPrice());
                if (data.getCateId()!=null){
                    CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData();
                    byId.setCate(data1.getName());
                }
            }
        }
        return R.ok(byId);
    }
 
}