| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.account.entity.TStudent; |
| | | import com.dsh.account.model.StudentVo; |
| | | import com.dsh.account.service.TAppUserService; |
| | | import com.dsh.account.service.TStudentService; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.TokenUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private TStudentService studentService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | |
| | | /** |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/student/queryDefaultStudent") |
| | | public TStudent queryDefaultStudent(@RequestBody Integer appUserId){ |
| | | try { |
| | | TStudent one = studentService.getOne(new QueryWrapper<TStudent>().eq("appUserId", appUserId).eq("isDefault", 1).eq("state", 1)); |
| | | return one; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/student/queryStudentList") |
| | | @ApiOperation(value = "获取学员列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = true), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<StudentVo>> queryStudentList(){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<TStudent> list = studentService.list(new QueryWrapper<TStudent>().eq("appUserId", uid).eq("state", 1)); |
| | | List<StudentVo> listVo = new ArrayList<>(); |
| | | for (TStudent tStudent : list) { |
| | | StudentVo studentVo = new StudentVo(); |
| | | studentVo.setId(tStudent.getId()); |
| | | studentVo.setPhone(tStudent.getPhone()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday()))); |
| | | listVo.add(studentVo); |
| | | } |
| | | return ResultUtil.success(listVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | } |