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){
|
|
}
|
|
|
|
}
|