|
@@ -1,18 +1,30 @@
|
|
|
package com.yonge.cooleshow.student.controller;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
|
|
|
import com.yonge.cooleshow.biz.dal.support.Condition;
|
|
|
import com.yonge.cooleshow.biz.dal.support.Query;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentHomeVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
+import org.apache.commons.beanutils.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
@@ -27,74 +39,110 @@ public class StudentController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private StudentService studentService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询学员")
|
|
|
+ @GetMapping("/queryUser")
|
|
|
+ public HttpResponseResult<Student> queryUser() throws Exception {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ Student student = studentService.getById(user.getId());
|
|
|
+ return succeed(student);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询学员基本信息")
|
|
|
+ @GetMapping("/queryUserInfo")
|
|
|
+ public HttpResponseResult<StudentHomeVo> queryUserInfo() throws Exception {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ Student student = studentService.getById(user.getId());
|
|
|
+ StudentHomeVo studentHomeVo = new StudentHomeVo();
|
|
|
+ BeanUtils.copyProperties(studentHomeVo, student);
|
|
|
+
|
|
|
+ studentHomeVo.setHeardUrl(user.getAvatar());
|
|
|
+ studentHomeVo.setUsername(user.getUsername());
|
|
|
+ int num = DateUtil.daysBetween(new Date(), student.getMembershipEndTime());
|
|
|
+ studentHomeVo.setMembershipDays(num < 0 ? 0 : num);
|
|
|
+ //todo 学员我的-统计数据
|
|
|
+ return succeed(studentHomeVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "修改", notes = "传入student")
|
|
|
+ public HttpResponseResult update(@Valid @RequestBody Student student) {
|
|
|
+ return status(studentService.updateById(student));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询单条
|
|
|
*/
|
|
|
@GetMapping("/detail")
|
|
|
@ApiOperation(value = "详情", notes = "传入student")
|
|
|
public HttpResponseResult<Student> detail(Student student) {
|
|
|
- Student detail = studentService.getOne(Condition.getQueryWrapper(student));
|
|
|
- return succeed(detail);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ Student detail = studentService.getOne(Condition.getQueryWrapper(student));
|
|
|
+ return succeed(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询集合
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperation(value = "查询集合", notes = "传入student")
|
|
|
public HttpResponseResult<List<Student>> list(Student student) {
|
|
|
- List<Student> list = studentService.list();
|
|
|
- return succeed(list);
|
|
|
- }
|
|
|
-
|
|
|
+ List<Student> list = studentService.list();
|
|
|
+ return succeed(list);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询分页
|
|
|
*/
|
|
|
@GetMapping("/page")
|
|
|
@ApiOperation(value = "查询分页", notes = "传入student")
|
|
|
public HttpResponseResult<PageInfo<Student>> page(Student student, Query query) {
|
|
|
- IPage<Student> pages = studentService.selectPage(Condition.getPage(query), student);
|
|
|
+ IPage<Student> pages = studentService.selectPage(Condition.getPage(query), student);
|
|
|
return succeed(Condition.pageInfo(pages));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增
|
|
|
- */
|
|
|
- @PostMapping("/save")
|
|
|
- @ApiOperation(value = "新增", notes = "传入student")
|
|
|
- public HttpResponseResult save(@Valid @RequestBody Student student) {
|
|
|
- return status(studentService.save(student));
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- @PostMapping("/update")
|
|
|
- @ApiOperation(value = "修改", notes = "传入student")
|
|
|
- public HttpResponseResult update(@Valid @RequestBody Student student) {
|
|
|
- return status(studentService.updateById(student));
|
|
|
- }
|
|
|
-
|
|
|
+ * 新增
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperation(value = "新增", notes = "传入student")
|
|
|
+ public HttpResponseResult save(@Valid @RequestBody Student student) {
|
|
|
+ return status(studentService.save(student));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 新增或修改
|
|
|
- */
|
|
|
+ * 新增或修改
|
|
|
+ */
|
|
|
@PostMapping("/submit")
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入student")
|
|
|
- public HttpResponseResult submit(@RequestBody Student student) {
|
|
|
+ public HttpResponseResult submit(@RequestBody Student student) {
|
|
|
return status(studentService.saveOrUpdate(student));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- */
|
|
|
- @PostMapping("/remove")
|
|
|
- @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
- public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
+ public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
if (StringUtil.isEmpty(ids)) {
|
|
|
- return failed("参数不能为空");
|
|
|
- }
|
|
|
- return status(studentService.removeByIds(StringUtil.toLongList(ids)));
|
|
|
- }
|
|
|
+ return failed("参数不能为空");
|
|
|
+ }
|
|
|
+ return status(studentService.removeByIds(StringUtil.toLongList(ids)));
|
|
|
+ }
|
|
|
}
|