无关风月
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
package com.xinquan.system.controller;
 
 
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.xinquan.common.core.constant.CacheConstants;
import com.xinquan.common.core.domain.R;
import com.xinquan.common.core.exception.ServiceException;
import com.xinquan.common.core.utils.DateUtils;
import com.xinquan.common.core.utils.WebUtils;
import com.xinquan.common.core.utils.page.BeanUtils;
import com.xinquan.common.core.utils.page.PageDTO;
import com.xinquan.common.core.web.domain.BaseModel;
import com.xinquan.common.log.annotation.Log;
import com.xinquan.common.log.enums.BusinessType;
import com.xinquan.common.redis.service.RedisService;
import com.xinquan.common.security.utils.SecurityUtils;
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.meditation.api.feign.RemoteMeditationService;
import com.xinquan.order.api.domain.Order;
import com.xinquan.order.api.domain.vo.HomeDto;
import com.xinquan.order.api.feign.RemoteOrderService;
import com.xinquan.system.api.domain.SysUser;
import com.xinquan.system.api.domain.vo.HomeVO;
import com.xinquan.system.domain.Banner;
import com.xinquan.system.domain.Turn;
import com.xinquan.system.domain.Version;
import com.xinquan.system.domain.export.HomeExport;
import com.xinquan.system.service.BannerService;
import com.xinquan.system.service.ISysUserService;
import com.xinquan.system.service.TurnService;
import com.xinquan.user.api.feign.RemoteAppUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-08-21
 */
@RestController
@RequestMapping("/system/home")
public class HomeController {
 
    @Resource
    private BannerService bannerService;
    @Resource
    private RemoteCourseService remoteCourseService;
    @Resource
    private RemoteAppUserService remoteAppUserService;
    @Resource
    private RemoteMeditationService remoteMeditationService;
    @Resource
    private RemoteOrderService remoteOrderService;
    @Resource
    private ISysUserService sysUserService;
    @Resource
    private RedisService redisService;
    @Resource
    private TurnService turnService;
    @GetMapping("/getTurn")
    @ApiOperation(value = "IOS获取是否跳转三方支付", tags = "IOS获取是否跳转三方支付")
    public R getTurn() {
        Turn one = turnService.getOne(null);
        if (one.getIsTurn()==1){
            return R.ok(true);
        }else{
            return R.ok(false);
        }
    }
 
 
 
    @GetMapping("/updatePassword")
    @ApiOperation(value = "管理后台-修改密码", tags = "管理后台-修改密码")
    @Log(title = "【修改密码】修改密码", businessType = BusinessType.UPDATE)
 
    public R updatePassword(String userName,String password) {
        SysUser one = sysUserService.lambdaQuery()
                .eq(SysUser::getUserType, "00")
                .eq(SysUser::getDelFlag, "0")
                .eq(SysUser::getUserName, userName).one();
 
        if (one!=null){
//            if (one.getStatus().equals("1")){
//                return R.fail("账号已被冻结");
//            }
            one.setPassword(SecurityUtils.encryptPassword(password));
            sysUserService.updateById(one);
            return R.ok();
        }
        return R.fail("修改失败,账号不存在");
    }
    @PostMapping("/homeStatistics")
    @ApiOperation(value = "首页统计",tags = "管理后台-首页统计")
    public R<HomeVO> bannerList(@RequestBody HomeDto homeDto) {
        HomeVO homeVO = new HomeVO();
//        homeVO.setOrderMoney();
//        homeVO.setOrderCount();
//        homeVO.setOrderList();
//        homeVO.setOrderTimeList();
        // 查询用户总数、非会员数、月卡会员数、季卡会员数、年卡会员数
        String data = remoteAppUserService.getUserCount().getData();
        if (data!=null){
            String[] split = data.split(",");
            homeVO.setUserCount(split[0]);
            homeVO.setNoVip(split[1]);
            homeVO.setVipMonth(split[2]);
            homeVO.setVipQuarter(split[3]);
            homeVO.setVipYear(split[4]);
        }
        // 查询课程总数 免费、会员免费、单独收费、线下课程数
        String data1 = remoteCourseService.getCourseCount().getData();
        if (data1!=null){
            String[] split = data1.split(",");
            homeVO.setCourseCount(split[0]);
            homeVO.setCourseFree(split[1]);
            homeVO.setCourseVip(split[2]);
            homeVO.setCoursePay(split[3]);
            homeVO.setCourseOffOnline(split[4]);
        }
        // 查询疗愈总数 免费、会员免费、单独收费
        String data2 = remoteMeditationService.getMeditationCount().getData();
        if (data2!=null){
            String[] split = data2.split(",");
            homeVO.setMeditationCount(split[0]);
            homeVO.setMeditationFree(split[1]);
            homeVO.setMeditationVip(split[2]);
            homeVO.setMeditationPay(split[3]);
        }
        String data3 = remoteMeditationService.getQuestionCount().getData();
        if (data3!=null){
            homeVO.setQuestionRecord(data3);
        }
        String data4 = remoteAppUserService.getPrizeRecordCount().getData();
        if (data4!=null){
            homeVO.setPrizeRecord(data4);
        }
        // 查询用户总数列表变化趋势
        Map<String, Object> data5 = remoteAppUserService.getUserListCount().getData();
        homeVO.setUserList(data5);
        // 查询时间范围内的订单列表 课程 疗愈 会员
        if (!StringUtils.hasLength(homeDto.getTime())){
            homeDto.setTime("1");
        }
        if (homeDto.getTimeType()==null){
            homeDto.setTimeType(5);
        }
 
        List<Order> data6 = remoteOrderService.getOrderList(homeDto.getStatus(), homeDto.getTimeType(), homeDto.getTime()).getData();
        homeVO.setOrderCount(data6.size()+"");
        BigDecimal bigDecimal = new BigDecimal("0");
        for (Order order : data6) {
            if (order.getRealPayAmount()!=null){
                bigDecimal= bigDecimal.add(order.getRealPayAmount());
            }
        }
        homeVO.setOrderMoney(bigDecimal+"");
        Map<String, Object> x = new HashMap<>();
        Map<String, Object> x1 = new HashMap<>();
        Map<String, Object> x2 = new HashMap<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("d");
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        switch (homeDto.getTimeType()){
            case 1:
                // 年
                x.put("1",0);
                x.put("2",0);
                x.put("3",0);
                x.put("4",0);
                x.put("5",0);
                x.put("6",0);
                x.put("7",0);
                x.put("8",0);
                x.put("9",0);
                x.put("10",0);
                x.put("11",0);
                x.put("12",0);
 
                x1.put("1",0);
                x1.put("2",0);
                x1.put("3",0);
                x1.put("4",0);
                x1.put("5",0);
                x1.put("6",0);
                x1.put("7",0);
                x1.put("8",0);
                x1.put("9",0);
                x1.put("10",0);
                x1.put("11",0);
                x1.put("12",0);
 
                x2.put("1",0);
                x2.put("2",0);
                x2.put("3",0);
                x2.put("4",0);
                x2.put("5",0);
                x2.put("6",0);
                x2.put("7",0);
                x2.put("8",0);
                x2.put("9",0);
                x2.put("10",0);
                x2.put("11",0);
                x2.put("12",0);
                break;
            case 2:
                // 获取当前日期格式为 yyyy-MM-dd
                Date date = new Date();
                String format = simpleDateFormat.format(date);
                x.put(format,0);
                x1.put(format,0);
                x2.put(format,0);
                break;
            case 3:
                // 周
                // 获取本周7天 格式为dd
 
                calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
                for (int i = 1; i <= 7; i++) {
                    Date time = calendar.getTime();
                    String format1 = simpleDateFormat.format(time);
                    x.put(format1,0);
                    x1.put(format1,0);
                    x2.put(format1,0);
                    calendar.add(Calendar.DAY_OF_WEEK, 1);
                }
                break;
            case 4:
                // 月
                // 获取本月31天 格式为dd
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                for (int i = 1; i <= 31; i++) {
                    Date time = calendar.getTime();
                    String format1 = simpleDateFormat.format(time);
                    x.put(format1,0);
                    x1.put(format1,0);
                    x2.put(format1,0);
                    calendar.add(Calendar.DAY_OF_MONTH, 1);
                }
                break;
            case 5:
                String startTime = null;
                String endTime = null;
                if (org.springframework.util.StringUtils.hasLength(homeDto.getTime())){
                    String[] split = homeDto.getTime().split(" - ");
                    startTime = split[0];
                    endTime = split[1];
                    // 将其转化为LocalDate
                    LocalDate startLocalDate = LocalDate.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    LocalDate endLocalDate = LocalDate.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    // 将startLocalDate到endLocalDate之间的每一天的日期,包括startLocalDate和endLocalDate
                    List<LocalDate> localDates = new ArrayList<>();
                    while (!startLocalDate.isAfter(endLocalDate)) {
                        // 将startLocalDate转化为格式为yyyy-MM-dd格式字符串
                        String format1 = startLocalDate.format(DateTimeFormatter.ofPattern("d"));
                        x.put(format1,0);
                        x1.put(format1,0);
                        x2.put(format1,0);
                        localDates.add(startLocalDate);
                        startLocalDate = startLocalDate.plusDays(1);
 
                    }
                }
 
                break;
        }
//        if (StringUtils.hasLength(homeDto.getTime())&&(!homeDto.getTime().equals("1"))){
//            List<LocalDate> localDates = generateDateList(homeDto.getTime());
//            for (LocalDate localDate : localDates) {
//                x.put(localDate+"",0);
//                x1.put(localDate+"",0);
//                x2.put(localDate+"",0);
//            }
//
//        }
        for (Order order : data6) {
            int value = order.getCreateTime().getMonth().getValue();
            int value1 = order.getCreateTime().getDayOfMonth();
            LocalDateTime createTime = order.getCreateTime();
            LocalDate localDate = createTime.toLocalDate();
            switch (order.getOrderFrom()){
                case 1:
                    switch (homeDto.getTimeType()){
                        case 1:
                            // 获取订单月份
                            if (StringUtils.hasLength(homeDto.getTime())&&x.get(value+"")!=null){
                                x.put(value+"",(int)x.get(value+"")+1);
                            }
                            break;
                        case 2:
                            Date date = new Date();
                            String format = simpleDateFormat.format(date);
                            if (StringUtils.hasLength(homeDto.getTime())&&x.get(value1+"")!=null){
                                x.put(value1+"",(int)x.get(value1+"")+1);
                            }
                            break;
                        case 3:
                            if (StringUtils.hasLength(homeDto.getTime())&&x.get(value1+"")!=null){
                                x.put(value1+"",(int)x.get(value1+"")+1);
                            }
                            break;
                        case 4:
                            if (StringUtils.hasLength(homeDto.getTime())&&x.get(value1+"")!=null){
                                x.put(value1+"",(int)x.get(value1+"")+1);
                            }
                            break;
                        case 5:
                            if (StringUtils.hasLength(homeDto.getTime())&&x.get(value1+"")!=null){
                                x.put(value1+"",(int)x.get(value1+"")+1);
                            }
                            break;
                    }
                    break;
                case 2:
                    switch (homeDto.getTimeType()){
                        case 1:
                            // 获取订单月份
                            if (StringUtils.hasLength(homeDto.getTime())&&x1.get(value+"")!=null){
                                x1.put(value+"",(int)x1.get(value+"")+1);
                            }
                            break;
                        case 2:
                            Date date = new Date();
                            String format = simpleDateFormat.format(date);
                            if (StringUtils.hasLength(homeDto.getTime())&&x1.get(value1+"")!=null){
                                x1.put(value1+"",(int)x1.get(value1+"")+1);
 
                            }
                            break;
                        case 3:
                            if (StringUtils.hasLength(homeDto.getTime())&&x1.get(value1+"")!=null){
                                x1.put(value1+"",(int)x1.get(value1+"")+1);
                            }
                            break;
                        case 4:
                            if (StringUtils.hasLength(homeDto.getTime())&&x1.get(value1+"")!=null){
                                x1.put(value1+"",(int)x1.get(value1+"")+1);
                            }
                            break;
                        case 5:
                            if (StringUtils.hasLength(homeDto.getTime())&&x1.get(value1+"")!=null){
                                x1.put(value1+"",(int)x1.get(value1+"")+1);
                            }
                            break;
                    }
                    break;
                case 3:
                    switch (homeDto.getTimeType()){
                        case 1:
                            // 获取订单月份
                            if (StringUtils.hasLength(homeDto.getTime())&&x2.get(value+"")!=null){
                                x2.put(value+"",(int)x2.get(value+"")+1);
                            }
                            break;
                        case 2:
                            Date date = new Date();
                            String format = simpleDateFormat.format(date);
                            if (StringUtils.hasLength(homeDto.getTime())&&x2.get(value1+"")!=null){
                                x2.put(value1+"",(int)x2.get(value1+"")+1);
 
                            }
                            break;
                        case 3:
                            if (StringUtils.hasLength(homeDto.getTime())&&x2.get(value1+"")!=null){
 
                                x2.put(value1+"",(int)x2.get(value1+"")+1);
                            }
                            break;
                        case 4:
                            if (StringUtils.hasLength(homeDto.getTime())&&x2.get(value1+"")!=null){
 
                                x2.put(value1+"",(int)x2.get(value1+"")+1);
                            }
                            break;
                        case 5:
                            if (StringUtils.hasLength(homeDto.getTime())&&x2.get(value1+"")!=null){
                                x2.put(value1+"",(int)x2.get(value1+"")+1);
                            }
                            break;
                    }
                    break;
            }
        }
 
        // 对x的key值进行从小到大排序
        Map<String, Object> sortedMap = new TreeMap<>(Comparator.reverseOrder());
        sortedMap.putAll(x);
        Map<String, Object> sortedMap1 = new TreeMap<>(Comparator.reverseOrder());
        sortedMap1.putAll(x1);
        Map<String, Object> sortedMap2 = new TreeMap<>(Comparator.reverseOrder());
        sortedMap2.putAll(x2);
        homeVO.setOrderMeditationList(sortedMap);
        homeVO.setOrderCourseList(sortedMap1);
        homeVO.setOrderVipList(sortedMap2);
        return R.ok(homeVO);
    }
    public static List<LocalDate> generateDateList(String dateRange) {
        // 定义日期格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
 
        // 解析日期范围字符串
        String[] dates = dateRange.split(" - ");
        LocalDate startDate = LocalDate.parse(dates[0], formatter);
        LocalDate endDate = LocalDate.parse(dates[1], formatter);
 
        // 创建日期列表
        List<LocalDate> dateList = new ArrayList<>();
        for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
            dateList.add(date);
        }
 
        return dateList;
    }
    @PutMapping("/homeStatisticsExport")
    @ApiOperation(value = "首页统计-导出",tags = "管理后台-首页统计")
    public void homeStatisticsExport() {
        HomeVO homeVO = new HomeVO();
        // 查询用户总数、非会员数、月卡会员数、季卡会员数、年卡会员数
        String data = remoteAppUserService.getUserCount().getData();
        if (data!=null){
            String[] split = data.split(",");
            homeVO.setUserCount(split[0]);
            homeVO.setNoVip(split[1]);
            homeVO.setVipMonth(split[2]);
            homeVO.setVipQuarter(split[3]);
            homeVO.setVipYear(split[4]);
        }
        // 查询课程总数 免费、会员免费、单独收费、线下课程数
        String data1 = remoteCourseService.getCourseCount().getData();
        if (data1!=null){
            String[] split = data1.split(",");
            homeVO.setCourseCount(split[0]);
            homeVO.setCourseFree(split[1]);
            homeVO.setCourseVip(split[2]);
            homeVO.setCoursePay(split[3]);
            homeVO.setCourseOffOnline(split[4]);
        }
        // 查询疗愈总数 免费、会员免费、单独收费
        String data2 = remoteMeditationService.getMeditationCount().getData();
        if (data2!=null){
            String[] split = data2.split(",");
            homeVO.setMeditationCount(split[0]);
            homeVO.setMeditationFree(split[1]);
            homeVO.setMeditationVip(split[2]);
            homeVO.setMeditationPay(split[3]);
        }
        String data3 = remoteMeditationService.getQuestionCount().getData();
        if (data3!=null){
            homeVO.setQuestionRecord(data3);
        }
        String data4 = remoteAppUserService.getPrizeRecordCount().getData();
        if (data4!=null){
            homeVO.setPrizeRecord(data4);
        }
 
 
        HomeExport homeExport = new HomeExport();
        BeanUtils.copyProperties(homeVO, homeExport);
        if (data1!=null){
            String[] split = data1.split(",");
            homeVO.setCourseCount(split[0]);
            homeVO.setCourseFree(split[1]);
            homeVO.setCourseVip(split[2]);
            homeVO.setCoursePay(split[3]);
            homeVO.setCourseOffOnline(split[4]);
            Integer i = Integer.valueOf(homeExport.getCourseCount());
            Integer i1 = Integer.valueOf(split[4]);
        }
        List<HomeExport> homeExports = new ArrayList<>();
        homeExports.add(homeExport);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), HomeExport.class, homeExports);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("首页统计导出.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @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】批量删除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);
    }
 
}