lisy
2023-06-14 6a4b079181d22a54a11dfdafd5400b171a1f3fc4
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
package com.dsh.app.controller;
 
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.dsh.account.util.DateUtil;
import com.dsh.app.entity.TStudent;
import com.dsh.app.model.vo.classDetails.classInsVo.ClassInfoVo;
import com.dsh.app.model.vo.classDetails.classInsVo.StuDetailsReq;
import com.dsh.app.model.vo.classDetails.classInsVo.StuListVo;
import com.dsh.app.model.vo.classDetails.classInsVo.StuPhysicalVo;
import com.dsh.app.service.TAppUserService;
import com.dsh.app.service.TStudentService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
 
/**
 * 学员上课情况 接口
 */
@Api
@CrossOrigin
@RestController
@RequestMapping("/startCource")
public class ClassDetailsController {
 
    private Logger logger = LoggerFactory.getLogger("business-log");
 
    @Autowired
    private TStudentService istuService;
 
    @Autowired
    private TAppUserService tappuService;
 
 
 
    @ResponseBody
    @PostMapping("/stu/queryStudentData")
    @ApiOperation(value = "根据登录用户ID查询学员信息", tags = {"用户——学员信息"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ClassInfoVo queryCouponRecord(@RequestBody Integer id){
        try {
            return tappuService.queryUserOfStus(id);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
 
 
    /**
     * 获取学员测试报告
     */
    @PostMapping("/stu/queryPhysical")
    public StuPhysicalVo getStuPhysicalInfo(@RequestBody Integer stuID){
        StuPhysicalVo vo = new StuPhysicalVo();
        TStudent tStudent = istuService.selectById(stuID);
        vo.setBmi(tStudent.getBmi());
        vo.setUrl(tStudent.getLateralSurface());
        vo.setHeight(tStudent.getHeight());
        vo.setWeight(tStudent.getWeight());
        return vo;
    }
 
    /**
     * 添加学员信息
     */
    @PostMapping("/stu/addData")
    public void addStu(@RequestBody StuDetailsReq stu){
        TStudent student = new TStudent();
        student.setAppUserId(stu.getUserID());
        student.setName(stu.getName());
        student.setHeadImg(stu.getHeadImg());
        student.setPhone(stu.getPhone());
        student.setSex(stu.getSex());
        student.setIdCard(stu.getIdCard());
        student.setBirthday(new Date(stu.getBirthday()));
        student.setHeight(stu.getHeight());
        student.setWeight(stu.getWeight());
        BigDecimal bigDecimal = BigDecimal.valueOf(stu.getWeight());
        BigDecimal multiply = bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight())).multiply(bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight())));
        multiply.setScale(2);
        student.setBmi(multiply.doubleValue());
        student.setInsertTime(new Date());
        student.setState(1);
        istuService.insert(student);
    }
 
    /**
     * 该APP用户下的学员列表
     */
    @PostMapping("/stu/listOfStu")
    public List<StuListVo> queryStuList(@RequestBody Integer appUserID){
        List<StuListVo> stuListVos = new ArrayList<>();
        List<TStudent> tStudents = istuService.selectList(new EntityWrapper<TStudent>()
                .eq("appUserId",appUserID));
        if (tStudents.size() > 0){
            tStudents.forEach(sts -> {
                StuListVo vo = new StuListVo();
                vo.setStuId(sts.getId());
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                vo.setBirthday(simpleDateFormat.format(sts.getBirthday()));
                vo.setStuName(sts.getName());
                vo.setStuAge(DateUtil.age(sts.getBirthday()));
                vo.setStuHeight(sts.getHeight());
                vo.setStuWeight(sts.getWeight());
                vo.setIsNot(sts.getIsDefault());
            });
        }
        return stuListVos;
    }
 
    /**
     * 课时详情
     */
    @PostMapping("/stu/lessonDetails")
    public void coursePackageDetails(@RequestBody Integer lessonId){
 
    }
 
 
 
}