From 1aa309700fb7e12d85f98bed22a45bdac448ec1c Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期六, 16 九月 2023 11:18:46 +0800
Subject: [PATCH] app 2.0

---
 cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java |  185 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 172 insertions(+), 13 deletions(-)

diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java
index d757092..c7f2a49 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java
@@ -1,12 +1,13 @@
 package com.dsh.account.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dsh.account.entity.TAppGift;
 import com.dsh.account.entity.TStudent;
 import com.dsh.account.feignclient.competition.model.PurchaseRecordVo;
-import com.dsh.account.model.vo.classDetails.AppointmentRecordVo;
-import com.dsh.account.model.vo.classDetails.ClasspaymentRequest;
-import com.dsh.account.model.vo.classDetails.CourseVenue;
+import com.dsh.account.feignclient.course.model.RecordAppoint;
+import com.dsh.account.model.vo.classDetails.*;
 import com.dsh.account.model.vo.classDetails.classInsVo.*;
 import com.dsh.account.model.vo.commentDetail.StuCommentsVo;
 import com.dsh.account.model.vo.medalDetail.GongVo;
@@ -14,10 +15,7 @@
 import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo;
 import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp;
 import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest;
-import com.dsh.account.service.EvaluateStudentService;
-import com.dsh.account.service.StudentHonorService;
-import com.dsh.account.service.TAppUserService;
-import com.dsh.account.service.TStudentService;
+import com.dsh.account.service.*;
 import com.dsh.account.util.*;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -25,6 +23,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -60,6 +59,9 @@
     @Autowired
     private TokenUtil tokenUtil;
 
+    @Autowired
+    private TAppGiftService appGiftService;
+
 
 
     @ResponseBody
@@ -89,8 +91,8 @@
             @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
             @ApiImplicitParam(value = "查询时间yyyy-MM-dd", name = "time", required = true, dataType = "string"),
             @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
-            @ApiImplicitParam(value = "用户经度", name = "longitude", required = true, dataType = "string"),
-            @ApiImplicitParam(value = "用户纬度", name = "latitude", required = true, dataType = "string"),
+            @ApiImplicitParam(value = "用户经度", name = "longitude", required = false, dataType = "string"),
+            @ApiImplicitParam(value = "用户纬度", name = "latitude", required = false, dataType = "string"),
     })
     public ResultUtil<List<CourseVenue>> queryWeeksOfClassInfo(String time,Integer stuId, String longitude, String latitude){
         try {
@@ -104,6 +106,60 @@
             return ResultUtil.runErr();
         }
 
+    }
+
+    @ResponseBody
+    @PostMapping("/api/startCource/weeksOfGetHours")
+    @ApiOperation(value = "上课首页获取未分配课时-课程列表", tags = {"APP-开始上课"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+    })
+    public ResultUtil<Integer> weeksOfGetHours(){
+        try {
+            Integer appUserId = tokenUtil.getUserIdFormRedis();
+            if(null == appUserId){
+                return ResultUtil.tokenErr();
+            }
+            TAppGift one = appGiftService.getOne(new LambdaQueryWrapper<TAppGift>().eq(TAppGift::getUserId, appUserId));
+
+            return ResultUtil.success(one==null?0:one.getNum());
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
+    }
+
+
+    @ResponseBody
+    @PostMapping("/api/startCource/weeksOfAddHours")
+    @ApiOperation(value = "上课首页分配课时-课程列表", tags = {"APP-开始上课"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+            @ApiImplicitParam(value = "分配给课包id", name = "packetId", required = true, dataType = "string"),
+    })
+    public ResultUtil<Integer> weeksOfAddHours(Integer packetId){
+        try {
+            Integer appUserId = tokenUtil.getUserIdFormRedis();
+            if(null == appUserId){
+                return ResultUtil.tokenErr();
+            }
+            TAppGift one = appGiftService.getOne(new LambdaQueryWrapper<TAppGift>().eq(TAppGift::getUserId, appUserId));
+            Boolean b= false;
+            if(one!=null && one.getNum()>0){
+                 b =appGiftService.weeksOfAddHours(packetId,appUserId,one.getNum());
+            }
+            if(b){
+                // 送完清0
+                one.setNum(0);
+                appGiftService.updateById(one);
+                return ResultUtil.success();
+            }else {
+                return ResultUtil.runErr();
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
     }
 
 
@@ -171,6 +227,9 @@
                 tStudents.forEach(sts -> {
                     StuListVo vo = new StuListVo();
                     vo.setStuId(sts.getId());
+                    vo.setStuHeadImg(sts.getHeadImg());
+                    vo.setStuPhone(ToolUtil.isEmpty(sts.getPhone()) ? "" : sts.getPhone());
+                    vo.setIdCard(ToolUtil.isEmpty(sts.getIdCard()) ? "":sts.getIdCard());
                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                     vo.setBirthday(simpleDateFormat.format(sts.getBirthday()));
                     vo.setStuName(sts.getName());
@@ -178,6 +237,7 @@
                     vo.setStuHeight(sts.getHeight());
                     vo.setStuWeight(sts.getWeight());
                     vo.setIsNot(sts.getIsDefault());
+                    vo.setStuPhone(sts.getPhone());
                     stuListVos.add(vo);
                 });
             }
@@ -208,9 +268,104 @@
         }catch (Exception e){
             return ResultUtil.runErr();
         }
-
-
     }
+
+
+
+    /**
+     * 编辑学员详情
+     */
+    @ResponseBody
+    @PostMapping("/api/startCource/editStu")
+    @ApiOperation(value = "编辑学员详情", tags = {"APP-开始上课"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+            @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
+    })
+    public ResultUtil<StuDetailsVo> editStudentInfo(Integer stuId){
+        try {
+            TStudent byId = istuService.getById(stuId);
+            if (ToolUtil.isEmpty(byId)){
+                ResultUtil.error("未查询到该学员!");
+            }
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            StuDetailsVo detailsVo = new StuDetailsVo();
+            detailsVo.setStuId(byId.getId());
+            detailsVo.setStuHeadImg(byId.getHeadImg());
+            detailsVo.setStuName(byId.getName());
+            detailsVo.setBirthday(simpleDateFormat.format(byId.getBirthday()));
+            detailsVo.setStuHeight(byId.getHeight());
+            detailsVo.setStuWeight(byId.getWeight());
+            detailsVo.setIdCard(ToolUtil.isEmpty(byId.getIdCard()) ? "": byId.getIdCard());
+            detailsVo.setStuPhone(ToolUtil.isEmpty(byId.getPhone()) ?  "" : byId.getPhone());
+            return ResultUtil.success(detailsVo);
+        }catch (Exception e){
+            return ResultUtil.runErr();
+        }
+    }
+
+
+
+    /**
+     * 提交编辑学员
+     */
+    @ResponseBody
+    @PostMapping("/api/startCource/commitEditStu")
+    @ApiOperation(value = "提交编辑学员", tags = {"APP-开始上课"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+            @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
+    })
+    public ResultUtil commitEditStu(StuEditInfoReq stu){
+        try {
+            Integer userIdFormRedis = tokenUtil.getUserIdFormRedis();
+            if(null == userIdFormRedis){
+                return ResultUtil.tokenErr();
+            }
+            return ResultUtil.success(istuService.commitEditStudentInfo(stu,userIdFormRedis));
+        }catch (Exception e){
+            return ResultUtil.runErr();
+        }
+    }
+
+
+
+    /**
+     * 学员设为默认
+     */
+    @ResponseBody
+    @PostMapping("/api/startCource/editDefault")
+    @ApiOperation(value = "设为默认", tags = {"APP-开始上课"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+            @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
+    })
+    public ResultUtil editDefault(Integer stuId){
+        try {
+            Integer userIdFormRedis = tokenUtil.getUserIdFormRedis();
+            if(null == userIdFormRedis){
+                return ResultUtil.tokenErr();
+            }
+            TStudent byId = istuService.getById(stuId);
+            if (ToolUtil.isEmpty(byId)){
+                ResultUtil.error("未查询到该学员!");
+            }
+            byId.setIsDefault(1);
+            istuService.updateById(byId);
+            List<TStudent> list = istuService.list(new LambdaQueryWrapper<TStudent>()
+                    .eq(TStudent::getAppUserId,userIdFormRedis)
+                    .ne(TStudent::getId,byId.getId()));
+            for (TStudent tStudent : list) {
+                tStudent.setIsDefault(2);
+                istuService.updateById(tStudent);
+            }
+            return ResultUtil.success();
+        }catch (Exception e){
+            return ResultUtil.runErr();
+        }
+    }
+
+
 
 
     /**
@@ -328,6 +483,7 @@
             }
             return istuService.renewClassPayment(userIdFormRedis,request);
         }catch (Exception e){
+            e.printStackTrace();
             return ResultUtil.runErr();
         }
 
@@ -407,14 +563,17 @@
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
             @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
+            @ApiImplicitParam(value = "预约状态 0=全部 1=待上课 2=已完成 3=已取消", name = "appointStatus", required = false, dataType = "int"),
+            @ApiImplicitParam(value = "时间类型 0=全部 1=近一周 2=近一个月 3=近一年", name = "timeType", required = false, dataType = "int"),
+            @ApiImplicitParam(value = "课程名称", name = "appointStatus", required = false, dataType = "string"),
     })
-    public ResultUtil<AppointmentRecordVo> cgeClassAppointmentRecordList(Integer stuId){
+    public ResultUtil<List<RecordAppoint>> cgeClassAppointmentRecordList(Integer stuId, Integer appointStatus, Integer timeType, String search){
         try {
             Integer appUserId = tokenUtil.getUserIdFormRedis();
             if(null == appUserId){
                 return ResultUtil.tokenErr();
             }
-            return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId));
+            return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId,appointStatus,timeType,search));
         }catch (Exception e){
             return ResultUtil.runErr();
         }

--
Gitblit v1.7.1