hjl
2024-05-22 ddee28676ae16b682651eea38f0c1071cf1565b8
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
package com.ruoyi.study.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.RedisConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.GlobalException;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.goods.api.feignClient.GoodsClient;
import com.ruoyi.goods.api.model.TGoodsVO;
import com.ruoyi.study.domain.*;
import com.ruoyi.study.dto.*;
import com.ruoyi.study.service.*;
import com.ruoyi.study.vo.*;
import com.ruoyi.system.api.model.LoginUserParent;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 学习类型前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-04-26
 */
@RestController
@RequestMapping("/base/study")
@Api(tags = "学习端-主接口")
public class TStudyController {
    @Autowired
    private ITStudyAnswerService studyAnswerService;
    @Autowired
    private ITStudyInductionService studyInductionService;
    @Autowired
    private ITStudyLookService studyLookService;
    @Autowired
    private ITStudyListenService studyListenService;
    @Autowired
    private ITStudyPairService studyPairService;
    @Autowired
    private ITGameService gameService;
    @Autowired
    private ITStoryListenService storyListenService;
    @Autowired
    private ITSubjectService subjectService;
    @Autowired
    private ITStoryService storyService;
    @Autowired
    private ITStudyService studyService;
    @Resource
    private GoodsClient goodsClient;
    @Resource
    private ITGameRecordService gameRecordService;
    @Resource
    private ITUserStudyService userStudyService;
    @Resource
    private ITIntegralRecordService integralRecordService;
    @Resource
    private RedisService redisService;
    @Resource
    private ITUserService userService;
    @Resource
    private TokenService tokenService;
 
    @PostMapping("/storyList")
    @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"})
    public R<PageInfo<TStory>> storyList(@RequestBody ChoiceStory query) {
        PageInfo<TStory> res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
        QueryWrapper<TStory> wrapper = new QueryWrapper<>();
        if (StringUtils.hasLength(query.getName())) {
            wrapper.like("name", query.getName());
        }
        if (StringUtils.hasLength(query.getEnglish())) {
            wrapper.like("english", query.getEnglish());
        }
        if (StringUtils.hasLength(query.getType())) {
            wrapper.like("type", query.getType());
        }
        wrapper.eq("state", 1);
        switch (query.getStoryType()) {
            case 2:
                List<TStory> list = storyService.list(wrapper);
                res.setRecords(list);
                res.setTotal(list.size());
                return R.ok(res);
            case 1:
                // 查询出error字段不为空的数据
                wrapper.isNotNull("error");
                List<TStory> list1 = storyService.list(wrapper);
                res.setRecords(list1);
                res.setTotal(list1.size());
                return R.ok(res);
 
        }
        List<TStory> objects = new ArrayList<>();
        res.setRecords(objects);
        res.setTotal(0);
        return R.ok(res);
    }
 
    @PostMapping("/subjectList")
    @ApiOperation(value = "配置学习类型选择题目", tags = {"题目管理"})
    public R<PageInfo<TSubject>> subjectList(@RequestBody ChoiceSubject query) {
        PageInfo<TSubject> res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
        QueryWrapper<TSubject> wrapper = new QueryWrapper<>();
        if (StringUtils.hasLength(query.getName())) {
            wrapper.like("name", query.getName());
        }
        if (StringUtils.hasLength(query.getEnglish())) {
            wrapper.like("english", query.getEnglish());
        }
        if (StringUtils.hasLength(query.getType())) {
            wrapper.like("type", query.getType());
        }
        wrapper.eq("state", 1);
        switch (query.getStudyType()) {
            case 1:
                List<TSubject> list = subjectService.list(wrapper);
                res.setRecords(list);
                res.setTotal(list.size());
                return R.ok(res);
            case 2:
                // 查询出error字段不为空的数据
                wrapper.isNotNull("error");
                List<TSubject> list1 = subjectService.list(wrapper);
                res.setRecords(list1);
                res.setTotal(list1.size());
                return R.ok(res);
            case 3:
                List<TSubject> list2 = subjectService.list(wrapper);
                res.setRecords(list2);
                res.setTotal(list2.size());
                return R.ok(res);
            case 4:
                List<TSubject> list3 = subjectService.list(wrapper);
                res.setRecords(list3);
                res.setTotal(list3.size());
                return R.ok(res);
            case 5:
                List<TSubject> list4 = subjectService.list(wrapper);
                res.setRecords(list4);
                res.setTotal(list4.size());
                return R.ok(res);
        }
        List<TSubject> objects = new ArrayList<>();
        res.setRecords(objects);
        res.setTotal(0);
        return R.ok(res);
    }
 
    /**
     * 添加学习配置
     *
     * @param dto
     * @return
     */
    @PostMapping("/addStudySet")
    public R<Object> addStudySet(@RequestBody AddStudySetDTO dto) {
        Integer week = dto.getWeek();
        Integer day = dto.getDay();
        Integer type = dto.getType();
        TStudy one = studyService.getOne(new QueryWrapper<TStudy>()
                .eq("week", week)
                .eq("type", type));
        GameDTO game = dto.getGame();
        StoryListenDTO storyListen = dto.getStoryListen();
        if (day == 6) {
            // 先判断有没有配置
            TGame studyId = gameService.getOne(new QueryWrapper<TGame>()
                    .eq("studyId", one.getId())
                    .eq("week", week));
            if (studyId != null) {
                studyId.setWeek(dto.getWeek());
                studyId.setStudyId(one.getId());
                studyId.setCount(game.getCount());
                studyId.setIntegral(game.getIntegral());
                studyId.setTime(game.getTime());
                studyId.setAnswerTime(game.getAnswerTime());
                studyId.setAnswerIntegral(game.getAnswerIntegral());
                studyId.setAnswerCount(game.getAnswerCount());
                gameService.updateById(studyId);
            } else {
                TGame tGame = new TGame();
                tGame.setWeek(dto.getWeek());
                tGame.setStudyId(one.getId());
                tGame.setCount(game.getCount());
                tGame.setIntegral(game.getIntegral());
                tGame.setTime(game.getTime());
                tGame.setAnswerTime(game.getAnswerTime());
                tGame.setAnswerIntegral(game.getAnswerIntegral());
                tGame.setAnswerCount(game.getAnswerCount());
                gameService.save(tGame);
            }
 
        } else if (day == 7) {
            String story = storyListen.getStory();
            TStoryListen studyId = storyListenService.getOne(new QueryWrapper<TStoryListen>()
                    .eq("studyId", one.getId())
                    .eq("week", week));
            if (studyId != null) {
                String sort = storyListen.getSort();
                String lookStory = storyListen.getLookStory();
                String lookSort = storyListen.getLookSort();
                Integer integral = storyListen.getIntegral();
                Integer lookIntegral = storyListen.getLookIntegral();
                studyId.setLookIntegral(lookIntegral);
                studyId.setIntegral(integral);
                studyId.setWeek(week);
                studyId.setStory(story);
                studyId.setSort(sort);
                studyId.setLookStory(lookStory);
                studyId.setLookSort(lookSort);
                studyId.setStudyId(one.getId());
                storyListenService.updateById(studyId);
            } else {
                String sort = storyListen.getSort();
                String lookStory = storyListen.getLookStory();
                String lookSort = storyListen.getLookSort();
                Integer integral = storyListen.getIntegral();
                Integer lookIntegral = storyListen.getLookIntegral();
                TStoryListen tStoryListen = new TStoryListen();
                tStoryListen.setLookIntegral(lookIntegral);
                tStoryListen.setIntegral(integral);
                tStoryListen.setWeek(week);
                tStoryListen.setStory(story);
                tStoryListen.setSort(sort);
                tStoryListen.setLookStory(lookStory);
                tStoryListen.setLookSort(lookSort);
                tStoryListen.setStudyId(one.getId());
                storyListenService.save(tStoryListen);
            }
        } else {
            // 删除原有数据
            studyListenService.remove(new QueryWrapper<TStudyListen>()
                    .eq("studyId", one.getId())
                    .eq("week", week)
                    .eq("day", day));
            List<StudyListenDTO> studyListen = dto.getStudyListen();
            for (StudyListenDTO studyListenDTO : studyListen) {
                TStudyListen tStudyListen = new TStudyListen();
                tStudyListen.setStudyId(one.getId());
                tStudyListen.setDay(day);
                tStudyListen.setSubject(studyListenDTO.getSubject());
                tStudyListen.setIntegral(studyListenDTO.getIntegral());
                tStudyListen.setWeek(week);
                tStudyListen.setIsVip(studyListenDTO.getIsVip());
                studyListenService.save(tStudyListen);
            }
            studyLookService.remove(new QueryWrapper<TStudyLook>()
                    .eq("studyId", one.getId())
                    .eq("week", week)
                    .eq("day", day));
            List<StudyLookDTO> studyLook = dto.getStudyLook();
            for (StudyLookDTO studyLookDTO : studyLook) {
                TStudyLook tStudyLook = new TStudyLook();
                tStudyLook.setStudyId(one.getId());
                tStudyLook.setDay(day);
                tStudyLook.setSubject(studyLookDTO.getSubject());
                tStudyLook.setIntegral(studyLookDTO.getIntegral());
                tStudyLook.setWeek(week);
                tStudyLook.setIsVip(studyLookDTO.getIsVip());
                studyLookService.save(tStudyLook);
            }
            studyInductionService.remove(new QueryWrapper<TStudyInduction>()
                    .eq("studyId", one.getId())
                    .eq("week", week)
                    .eq("day", day));
            List<StudyInductionDTO> studyInduction = dto.getStudyInduction();
            for (StudyInductionDTO studyInductionDTO : studyInduction) {
                TStudyInduction tStudyInduction = new TStudyInduction();
                tStudyInduction.setStudyId(one.getId());
                tStudyInduction.setDay(day);
                tStudyInduction.setSubject(studyInductionDTO.getSubject());
                tStudyInduction.setIntegral(studyInductionDTO.getIntegral());
                tStudyInduction.setWeek(week);
                tStudyInduction.setIsVip(studyInductionDTO.getIsVip());
            }
            studyAnswerService.remove(new QueryWrapper<TStudyAnswer>()
                    .eq("studyId", one.getId())
                    .eq("week", week)
                    .eq("day", day));
            List<StudyAnswerDTO> studyAnswer = dto.getStudyAnswer();
            for (StudyAnswerDTO studyAnswerDTO : studyAnswer) {
                TStudyAnswer tStudyAnswer = new TStudyAnswer();
                tStudyAnswer.setStudyId(one.getId());
                tStudyAnswer.setDay(day);
                tStudyAnswer.setIsAnswer(studyAnswerDTO.getIsAnswer());
                tStudyAnswer.setSubject(studyAnswerDTO.getSubject());
                tStudyAnswer.setAnswerSubject(studyAnswerDTO.getAnswerSubject());
                tStudyAnswer.setIntegral(studyAnswerDTO.getIntegral());
                tStudyAnswer.setWeek(week);
                tStudyAnswer.setIsVip(studyAnswerDTO.getIsVip());
                studyAnswerService.save(tStudyAnswer);
            }
            studyPairService.remove(new QueryWrapper<TStudyPair>()
                    .eq("studyId", one.getId())
                    .eq("week", week)
                    .eq("day", day));
            List<StudyPairDTO> studyPair = dto.getStudyPair();
            for (StudyPairDTO studyPairDTO : studyPair) {
                TStudyPair tStudyPair = new TStudyPair();
                tStudyPair.setStudyId(one.getId());
                tStudyPair.setDay(day);
                tStudyPair.setSubject(studyPairDTO.getSubject());
                tStudyPair.setIntegral(studyPairDTO.getIntegral());
                tStudyPair.setWeek(week);
                tStudyPair.setIsVip(studyPairDTO.getIsVip());
                studyPairService.save(tStudyPair);
            }
        }
        return R.ok();
    }
 
    /**
     * 添加周目
     *
     * @param dto
     * @return
     */
    @PostMapping("/addWeek")
    public R<Object> addWeek(@RequestBody AddWeekDTO dto) {
        TStudy tStudy = new TStudy();
        tStudy.setType(dto.getType());
        tStudy.setWeek(dto.getWeek());
        tStudy.setTitle(dto.getTitle());
        tStudy.setQuarter(dto.getQuarter());
        studyService.save(tStudy);
        return R.ok();
    }
 
    /**
     * 学习类型列表查询
     *
     * @return
     */
    @PostMapping("/getStudyList")
    public R<List<StudyListVO>> getStudyList() {
        List<StudyListVO> res = new ArrayList<>();
        StudyListVO studyListVO = new StudyListVO();
        List<TStudy> count = studyService.list(new QueryWrapper<TStudy>()
                .eq("type", 1));
        studyListVO.setWeeks(count.size());
 
        // todo 补充开始学习人数
        studyListVO.setCount(0);
        studyListVO.setName("听");
        // 查询听类型有多少周目
        res.add(studyListVO);
        // 后续类型 不在1.0功能中
        StudyListVO studyListVO1 = new StudyListVO();
        studyListVO1.setWeeks(0);
        studyListVO1.setCount(0);
        studyListVO1.setName("说");
        res.add(studyListVO1);
        StudyListVO studyListVO2 = new StudyListVO();
        studyListVO2.setWeeks(0);
        studyListVO2.setCount(0);
        studyListVO2.setName("认读");
        res.add(studyListVO2);
        StudyListVO studyListVO3 = new StudyListVO();
        studyListVO3.setWeeks(0);
        studyListVO3.setCount(0);
        studyListVO3.setName("阅读");
        res.add(studyListVO3);
        StudyListVO studyListVO4 = new StudyListVO();
        studyListVO4.setWeeks(0);
        studyListVO4.setCount(0);
        studyListVO4.setName("练习");
        res.add(studyListVO4);
        StudyListVO studyListVO5 = new StudyListVO();
        studyListVO5.setWeeks(0);
        studyListVO5.setCount(0);
        studyListVO5.setName("智能互动问答");
        res.add(studyListVO5);
        StudyListVO studyListVO6 = new StudyListVO();
        studyListVO6.setWeeks(0);
        studyListVO6.setCount(0);
        studyListVO6.setName("智能识别");
        res.add(studyListVO6);
        return R.ok(res);
    }
 
    /**
     * 通过类型、周目、day查询学习配置
     *
     * @return
     */
    @PostMapping("/getStudySet")
    public R<StudyVO> getStudySet(@RequestBody StudyDTO dto) {
        StudyVO res = new StudyVO();
        // todo 开始学习人数后续补充
        res.setCount(0);
        int type = studyService.list(new QueryWrapper<TStudy>()
                .eq("type", dto.getType())).size();
        res.setWeeks(type);
        List<StudyListenVO> listenVOS = new ArrayList<>();
        List<GameVO> gameVOS = new ArrayList<>();
        List<StoryVO> storyVOS = new ArrayList<>();
        List<StudyAnswerVO> answerVOS = new ArrayList<>();
        List<StudyInductionVO> inductionVOS = new ArrayList<>();
        List<StudyLookVO> lookVOS = new ArrayList<>();
        List<StudyPairVO> pairVOS = new ArrayList<>();
//        Integer type = dto.getType();
        Integer week = dto.getWeek();
        Integer day = dto.getDay();
        // 根据类型 周目 day 查询对应数据
        // 听音选图
        List<TStudyListen> list = studyListenService.list(new QueryWrapper<TStudyListen>()
                .eq("week", week)
                .eq("day", day));
        for (TStudyListen tStudyListen : list) {
            StringBuilder temp = new StringBuilder();
            StudyListenVO studyListenVO = new StudyListenVO();
            for (String s : tStudyListen.getSubject().split(",")) {
                TSubject byId = subjectService.getById(s);
                temp.append(byId.getName()).append(",");
            }
            String string = temp.toString();
            studyListenVO.setName(string.substring(0, string.length() - 1));
            studyListenVO.setIntegral(tStudyListen.getIntegral());
            listenVOS.add(studyListenVO);
        }
        // 看音选图
        List<TStudyLook> list1 = studyLookService.list(new QueryWrapper<TStudyLook>()
                .eq("week", week)
                .eq("day", day)
        );
        for (TStudyLook tStudyLook : list1) {
            int index = 0;
            StringBuilder names = new StringBuilder();
            StringBuilder sorts = new StringBuilder();
            StudyLookVO studyLookVO1 = new StudyLookVO();
            for (String s : tStudyLook.getSubject().split(",")) {
                TSubject byId = subjectService.getById(s);
                names.append(byId.getName()).append(",");
                String[] split = tStudyLook.getSort().split(",");
                String s1 = split[index];
                sorts.append(s1).append(",");
                index++;
            }
            String string = names.toString();
            String string1 = sorts.toString();
            studyLookVO1.setName(string.substring(0, string.length() - 1));
            studyLookVO1.setSort(string1.substring(0, string1.length() - 1));
            studyLookVO1.setIntegral(tStudyLook.getIntegral());
            lookVOS.add(studyLookVO1);
        }
        // 归纳排除
        List<TStudyInduction> list2 = studyInductionService.list(new QueryWrapper<TStudyInduction>()
                .eq("week", week)
                .eq("day", day)
        );
        for (TStudyInduction tStudyInduction : list2) {
            StringBuilder names = new StringBuilder();
            StudyInductionVO studyInductionVO = new StudyInductionVO();
            for (String s : tStudyInduction.getSubject().split(",")) {
                String replace = s.replace("-", "");
                if (s.contains("-")) {
                    TSubject byId = subjectService.getById(replace);
                    names.append("-").append(byId.getName()).append(",");
                } else {
                    TSubject byId = subjectService.getById(s);
                    names.append(byId.getName()).append(",");
                }
            }
            String string = names.toString();
            studyInductionVO.setName(string.substring(0, string.length() - 1));
            studyInductionVO.setIntegral(tStudyInduction.getIntegral());
            inductionVOS.add(studyInductionVO);
        }
        // 有问有答
        List<TStudyAnswer> list3 = studyAnswerService.list(new QueryWrapper<TStudyAnswer>()
                .eq("week", week)
                .eq("day", day));
        for (TStudyAnswer tStudyAnswer : list3) {
            StringBuilder names = new StringBuilder();
            StudyAnswerVO studyAnswerVO = new StudyAnswerVO();
            if (tStudyAnswer.getIsAnswer() == 1) {
                TSubject byId = subjectService.getById(tStudyAnswer.getSubject());
                names.append("-").append(byId.getName()).append(",");
                TSubject byId1 = subjectService.getById(tStudyAnswer.getAnswerSubject());
                names.append("-").append(byId1.getName()).append(",");
            } else {
                TSubject byId = subjectService.getById(tStudyAnswer.getSubject());
                names.append(byId.getName()).append(",");
                TSubject byId1 = subjectService.getById(tStudyAnswer.getAnswerSubject());
                names.append("-").append(byId1.getName()).append(",");
            }
            String string = names.toString();
            studyAnswerVO.setName(string.substring(0, string.length() - 1));
            studyAnswerVO.setIntegral(tStudyAnswer.getIntegral());
            answerVOS.add(studyAnswerVO);
        }
        // 音图相配
        List<TStudyPair> list4 = studyPairService.list(new QueryWrapper<TStudyPair>()
                .eq("week", week)
                .eq("day", day)
        );
        for (TStudyPair tStudyPair : list4) {
            StringBuilder names = new StringBuilder();
            StudyPairVO studyPairVO = new StudyPairVO();
            for (String s : tStudyPair.getSubject().split(",")) {
                TSubject byId = subjectService.getById(s);
                names.append(byId.getName()).append(",");
            }
            String string = names.toString();
            studyPairVO.setName(string.substring(0, string.length() - 1));
            studyPairVO.setIntegral(tStudyPair.getIntegral());
            pairVOS.add(studyPairVO);
        }
        List<TGame> list5 = gameService.list(new QueryWrapper<TGame>()
                .eq("week", week));
        for (TGame tGame : list5) {
            GameVO gameVO = new GameVO();
            gameVO.setIntegral(tGame.getIntegral());
            gameVO.setTime(tGame.getTime());
            gameVO.setCount(tGame.getCount());
            gameVO.setAnswerTime(tGame.getAnswerTime());
            gameVO.setAnswerIntegral(tGame.getAnswerIntegral());
            gameVO.setAnswerCount(tGame.getAnswerCount());
            gameVOS.add(gameVO);
        }
        List<TStoryListen> list6 = storyListenService.list(new QueryWrapper<TStoryListen>()
                .eq("week", week));
        for (TStoryListen tStory : list6) {
            StoryVO storyVO = new StoryVO();
            StringBuilder names = new StringBuilder();
            StringBuilder names1 = new StringBuilder();
            StringBuilder sort = new StringBuilder();
            StringBuilder sort1 = new StringBuilder();
            for (String s : tStory.getStory().split(",")) {
                TStory byId = storyService.getById(s);
                names.append(byId.getName()).append(",");
            }
            for (String s : tStory.getLookStory().split(",")) {
                TStory byId = storyService.getById(s);
                names1.append(byId.getName()).append(",");
            }
            for (String s : tStory.getSort().split(",")) {
                sort.append(s).append(",");
            }
            for (String s : tStory.getLookSort().split(",")) {
                sort1.append(s).append(",");
            }
            storyVO.setName(names.substring(0, names.length() - 1));
            storyVO.setSort(sort.substring(0, sort.length() - 1));
            storyVO.setIntegral(tStory.getIntegral());
            storyVO.setLookName(names1.substring(0, names.length() - 1));
            storyVO.setLookSort(sort1.substring(0, sort.length() - 1));
            storyVO.setLookIntegral(tStory.getLookIntegral());
            storyVOS.add(storyVO);
        }
        int temp = 0;
        if (!list.isEmpty()) {
            temp = list.get(0).getStudyId();
        }
        if (!list1.isEmpty()) {
            temp = list1.get(0).getStudyId();
        }
        if (!list2.isEmpty()) {
            temp = list2.get(0).getStudyId();
        }
        if (!list3.isEmpty()) {
            temp = list3.get(0).getStudyId();
        }
        if (!list4.isEmpty()) {
            temp = list4.get(0).getStudyId();
        }
        if (!list5.isEmpty()) {
            temp = list5.get(0).getStudyId();
        }
        if (!list6.isEmpty()) {
            temp = list6.get(0).getStudyId();
        }
        if (temp == 0) {
            res.setTitle("");
        } else {
            res.setTitle(studyService.getById(temp).getTitle());
        }
        res.setAnswer(answerVOS);
        res.setPair(pairVOS);
        res.setListen(listenVOS);
        res.setLook(lookVOS);
        res.setInduction(inductionVOS);
        res.setGame(gameVOS);
        res.setStory(storyVOS);
        return R.ok(res);
    }
 
    /**
     * 查询周目列表
     *
     * @param type    所属类型
     * @param quarter 季度
     */
    @GetMapping("/weekList")
    @ApiOperation(value = "周目列表", tags = {"周目列表"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "所属类型", name = "type", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "季度", name = "quarter", dataType = "Integer", required = true)
    })
    public AjaxResult<List<StudyWeekDTO>> weekList(@RequestParam(defaultValue = "1") Integer type, @RequestParam Integer quarter) {
        List<StudyWeekDTO> result = studyService.weekList(type, quarter);
        return AjaxResult.success(result);
    }
 
    /**
     * 首次页面加载时调用,获取学习进度及学习时长等信息
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/studySchedule")
    @ApiOperation(value = "获取用户学习进度", tags = {"获取用户学习进度"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<TUserStudy> studySchedule(@RequestParam Integer week, @RequestParam Integer day) {
        TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week, day);
        return AjaxResult.success(result);
    }
 
    /**
     * 可兑换商品推荐
     */
    @GetMapping("/goodRecommend")
    @ApiOperation(value = "可兑换商品推荐", tags = {"可兑换商品推荐"})
    public AjaxResult<List<TGoodsVO>> studySchedule() {
        return AjaxResult.success(goodsClient.goodRecommend());
    }
 
    /**
     * 退出学习,记录学习进度、当日学习时长...
     */
    @PostMapping("/exitLearning")
    @ApiOperation(value = "退出学习(记录学习进度等信息)", tags = {"退出学习(记录学习进度等信息)"})
    public AjaxResult<Boolean> exitLearning(@RequestBody TUserStudy userStudy) {
        // 学习时长处理
        return AjaxResult.success(userStudyService.updateById(userStudy));
    }
 
    /**
     * 自主学习1-听音选图
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/listenSelectPicture")
    @ApiOperation(value = "自主学习1-听音选图", tags = {"自主学习1-听音选图"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyListenResultVO> listenSelectPicture(@RequestParam Integer week, @RequestParam Integer day) {
        // 判断当前登录用户是否为 会员
        Boolean isVip = userService.isVip();
        LambdaQueryChainWrapper<TStudyListen> wrapper = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week)
                .eq(TStudyListen::getDay, day).eq(TStudyListen::getDisabled, 0);
        // 非会员只能查看非会员题目,会员可以查看所有题目
        if (!isVip) {
            wrapper.eq(TStudyListen::getIsVip, 0);
        }
        List<TStudyListen> studyListens = wrapper.list();
        return AjaxResult.success(studyService.listenSelectPicture(week, day, studyListens));
    }
 
    /**
     * 自主学习2-看图选音
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/pictureSelectVoice")
    @ApiOperation(value = "自主学习2-看图选音", tags = {"自主学习2-看图选音"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyLookResultVO> pictureSelectVoice(@RequestParam Integer week, @RequestParam Integer day) {
        // 判断当前登录用户是否为 会员
        Boolean isVip = userService.isVip();
        LambdaQueryChainWrapper<TStudyLook> wrapper = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week)
                .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0);
        // 非会员只能查看非会员题目,会员可以查看所有题目
        if (!isVip) {
            wrapper.eq(TStudyLook::getIsVip, 0);
        }
        List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week)
                .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0).list();
        return AjaxResult.success(studyService.pictureSelectVoice(week, day, lookList));
    }
 
    /**
     * 自主学习3-归纳排除
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/induceExclude")
    @ApiOperation(value = "自主学习3-归纳排除", tags = {"自主学习3-归纳排除"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyInductionResultVO> induceExclude(@RequestParam Integer week, @RequestParam Integer day) {
        // 判断当前登录用户是否为 会员
        Boolean isVip = userService.isVip();
        LambdaQueryChainWrapper<TStudyInduction> wrapper = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week)
                .eq(TStudyInduction::getDay, day).eq(TStudyInduction::getDisabled, 0);
        // 非会员只能查看非会员题目,会员可以查看所有题目
        if (!isVip) {
            wrapper.eq(TStudyInduction::getIsVip, 0);
        }
        List<TStudyInduction> inductionList = wrapper.list();
        return AjaxResult.success(studyService.induceExclude(week, day, inductionList));
    }
 
    /**
     * 自主学习4-有问有答
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/questionsAndAnswers")
    @ApiOperation(value = "自主学习4-有问有答", tags = {"自主学习4-有问有答"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyAnswerResultVO> questionsAndAnswers(@RequestParam Integer week, @RequestParam Integer day) {
        // 判断当前登录用户是否为 会员
        Boolean isVip = userService.isVip();
        LambdaQueryChainWrapper<TStudyAnswer> wrapper = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getWeek, week)
                .eq(TStudyAnswer::getDay, day).eq(TStudyAnswer::getDisabled, 0);
        // 非会员只能查看非会员题目,会员可以查看所有题目
        if (!isVip) {
            wrapper.eq(TStudyAnswer::getIsVip, 0);
        }
        List<TStudyAnswer> answerList = wrapper.list();
        return AjaxResult.success(studyService.questionsAndAnswers(week, day, answerList));
    }
 
    /**
     * 自主学习5-音图相配
     *
     * @param week 周目
     * @param day  所属day
     */
    @GetMapping("/pictureMateVoice")
    @ApiOperation(value = "自主学习5-音图相配", tags = {"自主学习5-音图相配"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyPairResultVO> pictureMateVoice(@RequestParam Integer week, @RequestParam Integer day) {
        // 判断当前登录用户是否为 会员
        Boolean isVip = userService.isVip();
        LambdaQueryChainWrapper<TStudyPair> wrapper = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week)
                .eq(TStudyPair::getDay, day).eq(TStudyPair::getDisabled, 0);
        // 非会员只能查看非会员题目,会员可以查看所有题目
        if (!isVip) {
            wrapper.eq(TStudyPair::getIsVip, 0);
        }
        TStudyPair pair = wrapper.one();
        return AjaxResult.success(studyService.pictureMateVoice(week, day, pair));
    }
 
    /**
     * 自主游戏1-超级听力
     *
     * @param difficulty 难度(0入门、1中级、2困难)
     * @param week       所属周目
     */
    @GetMapping("/gameHearing")
    @ApiOperation(value = "自主游戏1-超级听力", tags = {"自主游戏1-超级听力(difficulty: 0入门、1中级、2高级)"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyGamerResultVO> gameHearing(@RequestParam Integer difficulty, @RequestParam Integer week) {
        TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week)
                .eq(TGame::getDisabled, 0).one();
        game.setIntegral(game.getIntegral().split(",")[difficulty]);
        game.setTime(game.getTime().split(",")[difficulty]);
        // 检验是否完成难度
        studyService.checkDifficulty(difficulty, week, game);
        List<String> subjectId = getSubjectId(week);
        // 判断周目下题目是否足够
        if (subjectId.size() < game.getCount()) {
            throw new GlobalException("当前周目下day1 - day5题目不足!");
        }
        // 根据游戏设置数量获取图片及语音
        List<String> subjectData = new ArrayList<>();
        Random random = new Random();
        // 获取列表大小
        int dataSize = subjectId.size();
        // 生成随机索引并获取数据
        for (int i = 0; i < game.getCount(); i++) {
            // 生成随机索引
            int randomIndex = random.nextInt(dataSize);
            // 获取对应的数据并加入结果列表
            subjectData.add(subjectId.get(randomIndex));
        }
        return AjaxResult.success(new StudyGamerResultVO(game,
                subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list()));
    }
 
    /**
     * 自主游戏2-超级记忆
     *
     * @param difficulty 难度(0入门、1中级、2困难)
     * @param week       所属周目
     */
    @GetMapping("/gameMemory")
    @ApiOperation(value = "自主游戏2-超级记忆", tags = {"自主游戏2-超级记忆(difficulty: 0入门、1中级、2高级)"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyGamerResultVO> gameMemory(@RequestParam Integer difficulty, @RequestParam Integer week) {
        TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week).eq(TGame::getDisabled, 0).one();
        // 检验是否完成难度
        studyService.checkDifficulty(difficulty, week, game);
        List<String> subjectId = getSubjectId(week);
        // 判断周目下题目是否足够
        if (subjectId.size() < game.getCount()) {
            throw new GlobalException("当前周目下day1 - day5题目不足!");
        }
        // 根据游戏设置数量获取图片及语音
        List<String> subjectData = new ArrayList<>();
        Random random = new Random();
        // 获取列表大小
        int dataSize = subjectId.size();
        // 生成随机索引并获取数据
        for (int i = 0; i < game.getCount(); i++) {
            // 生成随机索引
            int randomIndex = random.nextInt(dataSize);
            // 获取对应的数据并加入结果列表
            subjectData.add(subjectId.get(randomIndex));
        }
        return AjaxResult.success(new StudyGamerResultVO(game,
                subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list()));
    }
 
    /**
     * 自主游戏完成
     * 记录游戏测试成绩
     *
     * @param completeStudy 学习信息
     */
    @PostMapping("/gameAchievement")
    @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"完成游戏-记录游戏测试成绩"})
    public AjaxResult<Boolean> gameAchievement(@RequestBody CompleteGameDTO completeStudy) {
        TGame game = gameService.getById(completeStudy.getGameId());
        // 游戏测试记录
        Boolean add = gameRecordService.add(completeStudy);
        // 添加积分明细记录
        add = add && integralRecordService.add(game.getIntegral(), completeStudy.getMethod());
        // 用户账户添加积分
        return AjaxResult.success(add);
    }
 
    private List<String> getSubjectId(Integer week) {
        // 当前week下day1 - day5所有题目
        List<String> subjectId = redisService.getCacheList(RedisConstants.HEARING_TREE);
        if (null == subjectId || subjectId.isEmpty()) {
            List<String> listenSubject = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week)
                    .eq(TStudyListen::getDisabled, 0).list().stream().map(TStudyListen::getSubject).collect(Collectors.toList());
            List<String> inductionSubject = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week)
                    .eq(TStudyInduction::getDisabled, 0).list().stream().map(TStudyInduction::getSubject).collect(Collectors.toList());
            List<String> lookSubject = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week)
                    .eq(TStudyLook::getDisabled, 0).list().stream().map(TStudyLook::getSubject).collect(Collectors.toList());
            List<String> pairSubject = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week)
                    .eq(TStudyPair::getDisabled, 0).list().stream().map(TStudyPair::getSubject).collect(Collectors.toList());
            listenSubject.addAll(inductionSubject);
            listenSubject.addAll(lookSubject);
            listenSubject.addAll(pairSubject);
            // 获取具体subject信息
            subjectId = new ArrayList<>();
            for (String subject : listenSubject) {
                subjectId.addAll(Arrays.asList(subject.split(",")));
            }
            redisService.setCacheList(RedisConstants.HEARING_TREE, subjectId);
        }
        return subjectId;
    }
 
    /**
     * 自主故事1-看图配音
     *
     * @param week 周目
     */
    @GetMapping("/lookPictureDbu")
    @ApiOperation(value = "自主故事1-看图配音", tags = {"自主故事1-看图配音"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer week) {
        // 看图配音信息
        TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one();
        // 获取对应图片语音
        List<String> list = Arrays.asList(listen.getLookStory().split(","));
        return AjaxResult.success(new StudyStoryListenResultVO(listen,
                subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list()));
    }
 
    /**
     * 自主故事2-框架记忆
     *
     * @param week 周目
     */
    @GetMapping("/frameworkMemory")
    @ApiOperation(value = "自主故事2-框架记忆", tags = {"自主故事2-框架记忆"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
    })
    public AjaxResult<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer week) {
        // 看图配音信息
        TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one();
        // 获取对应图片语音
        List<String> list = Arrays.asList(listen.getStory().split(","));
        return AjaxResult.success(new StudyStoryListenResultVO(listen,
                subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list()));
    }
 
    /**
     * 学习完成,生成学习记录,积分明细记录
     *
     * @param completeStudy 完成学习信息
     */
    @PostMapping("/completeLearning")
    @ApiOperation(value = "完成学习", tags = {"完成学习/其他积分来源(分享...)"})
    public AjaxResult<Boolean> completeLearning(@RequestBody CompleteStudyDTO completeStudy) {
        // 登录用户id
        Integer userId = tokenService.getLoginUserStudy().getUserid();
        // 获取user详细信息,改变积分
        TUser user = userService.getById(userId);
        user.setIntegral(user.getIntegral() + completeStudy.getIntegral());
        boolean update = userService.updateById(user);
        // 生成积分明细记录
        TIntegralRecord integralRecord = new TIntegralRecord();
        integralRecord.setIntegral(String.valueOf(completeStudy.getIntegral()));
        integralRecord.setMethod(completeStudy.getMethod());
        integralRecord.setUserId(userId);
        return AjaxResult.success(update && integralRecordService.save(integralRecord));
    }
 
    /**
     * 完成故事类型
     */
    @GetMapping("/completeStory")
    @ApiOperation(value = "完成故事学习", tags = {"完成故事学习"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "积分数量", name = "integral", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "完成答题/完成听故事", name = "method", dataType = "String", required = true)
    })
    public AjaxResult<Boolean> completeStory(@RequestParam Integer integral, @RequestParam Integer storyId,
                                             @RequestParam String method) {
        // 添加积分明细记录
        Boolean add = integralRecordService.add(String.valueOf(integral), method);
        // 用户信息
        Integer userId = tokenService.getLoginUserStudy().getUserid();
        TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one();
        // 返回结果
        user.setIntegral(user.getIntegral() + integral);
        return AjaxResult.success(add && userService.updateById(user));
    }
 
    @GetMapping("/studyRecord")
    @ApiOperation(value = "个人中心-学习记录", tags = {"个人中心-学习记录"})
    public AjaxResult<StudyRecordResultVO> studyRecord() {
        Integer userId = tokenService.getLoginUserStudy().getUserid();
        // 学习记录
        TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
                .eq(TUserStudy::getDisabled, 0).one();
        // 游戏测试成绩
        List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId)
                .eq(TGameRecord::getDisabled, 0).list();
        return AjaxResult.success(new StudyRecordResultVO(studyRecord,gameRecordList));
    }
 
    @GetMapping("/integralDetail")
    @ApiOperation(value = "个人中心-积分明细", tags = {"个人中心-积分明细"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "查询时间", name = "time", dataType = "Integer"),
            @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "每页显示条数", name = "pageSize", dataType = "Integer", required = true)
    })
    public AjaxResult<IPage<TIntegralRecord>> integralDetail(String time,
                                                             @RequestParam("pageNum") Integer pageNum,
                                                             @RequestParam("pageSize") Integer pageSize) {
        return AjaxResult.success(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUserStudy().getUserid(), time));
    }
 
    /**
     * 生成积分明细-用于远程调用
     *
     * @param integral 积分变动信息
     * @param method   变动源
     */
    @GetMapping("/addIntegralDetail")
    @ApiOperation(value = "添加-积分明细", tags = {"添加-积分明细"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "积分数量", name = "integral", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "变动源(完成学习、完成游戏...)", name = "method", dataType = "String", required = true)
    })
    public R<Boolean> addIntegralDetail(@RequestParam("integral") String integral, @RequestParam("method") String method) {
        // 当前登录用户
        LoginUserParent userStudy = tokenService.getLoginUserStudy();
        // 生成积分明细信息
        TIntegralRecord integralRecord = new TIntegralRecord();
        integralRecord.setIntegral(integral);
        integralRecord.setMethod(method);
        integralRecord.setUserId(userStudy.getUserid());
        integralRecord.setDisabled(Boolean.FALSE);
        integralRecord.setCreateBy(userStudy.getPhone());
        integralRecord.setCreateTime(new Date());
        integralRecord.setUpdateBy(userStudy.getPhone());
        integralRecord.setUpdateTime(new Date());
        return R.ok(integralRecordService.save(integralRecord));
    }
 
    /**
     * 用户积分变动(增加或减少)-用于远程调用
     *
     * @param integral 积分变动信息
     * @param method   变动源
     */
    @GetMapping("/exchangeIntegral")
    @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"})
    public R<Boolean> exchangeIntegral(@RequestParam("integral") Integer integral, @RequestParam("method") String method) {
        TUser user = userService.getById(tokenService.getLoginUserStudy().getUserid());
        if (Constants.BURDEN.equals(method)) {
            user.setIntegral(user.getIntegral() - integral);
        } else {
            user.setIntegral(user.getIntegral() + integral);
        }
        return R.ok(userService.updateById(user));
    }
 
}