| | |
| | | package com.dsh.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; |
| | | import com.dsh.account.util.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.account.entity.TStudent; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassInfoVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuListVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuPhysicalVo; |
| | | 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.classInsVo.*; |
| | | import com.dsh.account.model.vo.commentDetail.StuCommentsVo; |
| | | import com.dsh.account.model.vo.exploreDetail.LonLatRequest; |
| | | import com.dsh.account.model.vo.medalDetail.GongVo; |
| | | import com.dsh.account.model.vo.medalDetail.StuMedalVo; |
| | | 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 io.swagger.annotations.*; |
| | | import com.dsh.account.util.DateUtil; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.TokenUtil; |
| | | import com.dsh.account.util.ToolUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | 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") |
| | | @RequestMapping("") |
| | | public class ClassDetailsController { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger("business-log"); |
| | |
| | | @Autowired |
| | | private TAppUserService tappuService; |
| | | |
| | | @Autowired |
| | | private EvaluateStudentService evalstuService; |
| | | |
| | | @Autowired |
| | | private StudentHonorService honorService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/stu/queryStudentData") |
| | | @ApiOperation(value = "根据登录用户ID查询学员信息", tags = {"用户——学员信息"}, notes = "") |
| | | @PostMapping("/api/startCource/queryStudentData") |
| | | @ApiOperation(value = "上课首页", tags = {"APP-开始上课"}) |
| | | @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){ |
| | | public ResultUtil<ClassInfoVo> queryCouponRecord(LonLatRequest lonLatRequest){ |
| | | try { |
| | | return tappuService.queryUserOfStus(id); |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(tappuService.queryUserOfStus(userIdFormRedis,lonLatRequest.getLongitude(),lonLatRequest.getLatitude())); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取学员测试报告 |
| | | */ |
| | | @PostMapping("/stu/queryPhysical") |
| | | public StuPhysicalVo getStuPhysicalInfo(@RequestBody Integer stuID){ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/queryPhysical") |
| | | @ApiOperation(value = "获取学员测试报告", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "学员id", name = "stuID", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<StuPhysicalVo> getStuPhysicalInfo(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; |
| | | TStudent tStudent = istuService.getById(stuID); |
| | | if (ToolUtil.isNotEmpty(tStudent)){ |
| | | vo.setBmi(tStudent.getBmi()); |
| | | vo.setUrl(tStudent.getLateralSurface()); |
| | | vo.setHeight(tStudent.getHeight()); |
| | | vo.setWeight(tStudent.getWeight()); |
| | | } |
| | | return ResultUtil.success(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); |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/addData") |
| | | @ApiOperation(value = "添加学员信息", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | @Transactional |
| | | public ResultUtil addStu(StuDetailsReq stu){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return istuService.addStuOfAppUser(stu,userIdFormRedis); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(ResultUtil.ERROR); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 该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()); |
| | | }); |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/listOfStu") |
| | | @ApiOperation(value = "学员列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<StuListVo>> queryStuList(){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<StuListVo> stuListVos = new ArrayList<>(); |
| | | List<TStudent> tStudents = istuService.list(new QueryWrapper<TStudent>() |
| | | .eq("appUserId",userIdFormRedis)); |
| | | 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()); |
| | | stuListVos.add(vo); |
| | | }); |
| | | } |
| | | return ResultUtil.success(stuListVos); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | return stuListVos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 切换学员 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/switchStu") |
| | | @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<List<StuListVo>> dealSwitchStudents(Integer stuId){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(istuService.switchStudentActions(userIdFormRedis,stuId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课时详情 |
| | | */ |
| | | @PostMapping("/stu/lessonDetails") |
| | | public void coursePackageDetails(@RequestBody Integer lessonId){ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/lessonDetails") |
| | | @ApiOperation(value = "课时详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "课包id", name = "lessonId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil<ClassDetailsInsVo> coursePackageDetails(Integer lessonId, Integer stuId){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | |
| | | return ResultUtil.success(istuService.querySessionDetailsDt(userIdFormRedis,lessonId,stuId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 课时详情-记录列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/recordDetails") |
| | | @ApiOperation(value = "课时详情-记录列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<PurchaseRecordVo>> recordList(RecordTimeRequest timeRequest){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(istuService.queryDeduRecordDetails(timeRequest,userIdFormRedis)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课时详情-续课课包详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/renewal") |
| | | @ApiOperation(value = "课时详情-续课课包详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "课包id", name = "lessonId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil<CourseDetailsOfContinuationResp> renewalOfCourses(Integer lessonId, Integer stuId){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(istuService.queryStuOfCourseDetails(lessonId,stuId,userIdFormRedis)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课时详情-选择优惠券 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/conponList") |
| | | @ApiOperation(value = "课时详情-选择优惠券", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CouponStuAvailableVo>> queryCouponList(){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(istuService.queryStuOfConponDetails(userIdFormRedis)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 课时详情-支付 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/payment") |
| | | @ApiOperation(value = "课时详情-支付", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil continuationOperation(ClasspaymentRequest request){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return istuService.renewClassPayment(userIdFormRedis,request); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员评语 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/stuComment") |
| | | @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<List<StuCommentsVo>> queryStuComment( Integer stuId){ |
| | | try { |
| | | return ResultUtil.success(evalstuService.queryStuCommentsList(stuId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员勋章详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/stuMedal") |
| | | @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<List<StuMedalVo>> queryStuMedal( Integer stuId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(honorService.queryHonorDetails(stuId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员勋章 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/stuGoog") |
| | | @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<List<GongVo>> queryStuGoog(Integer stuId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(honorService.queryStuOfMedalData(stuId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上课预约记录 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/stuAppointList") |
| | | @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<AppointmentRecordVo> cgeClassAppointmentRecordList(Integer stuId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 取消预约 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/cancelCourse") |
| | | @ApiOperation(value = "上课预约-取消预约", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "上课记录id", name = "courseStuRecordId", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil cancelReservation(Integer courseStuRecordId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return istuService.cancelReservationOfCourse(courseStuRecordId); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | } |