Blame view

StudentController.java 2.1 KB
涂亚平 committed
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
package com.zhongzhi.controller;

import com.zhongzhi.common.constant.Platform;
import com.zhongzhi.common.utils.LoginRequired;
import com.zhongzhi.common.utils.ResponseData;
import com.zhongzhi.dto.student.LoginDTO;
import com.zhongzhi.dto.student.RegisterDTO;
import com.zhongzhi.model.StudentDO;
import com.zhongzhi.service.StudentService;
import com.zhongzhi.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-04-28
 */
@RestController
@Api(tags = "学生")
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping(value = "/register")
    @ApiOperation("注册:name/真实姓名, idCard/身份证, telephone/手机号, code/验证码, " +
            "education/学历层次, school/就读院校, major/就读专业, enrollmentDate/入学年份, graduateDate/毕业年份")
    public ResponseVO register(@RequestBody RegisterDTO registerDTO) {
        return ResponseData.generateCreatedResponse(0, studentService.register(registerDTO));
    }

    @PostMapping(value = "/login")
    @ApiOperation("登陆:telephone/手机号, code/验证码")
    public ResponseVO login(@RequestBody LoginDTO loginDTO) {
        return ResponseData.generateCreatedResponse(0, studentService.login(loginDTO));
    }

    @PostMapping(value = "updateStudentInfo")
    @LoginRequired({ Platform.student })
    @ApiOperation("登陆:id/ID, education/学历, college/就读院校, major/专业, enrollmentDate/入学年份, graduateDate/毕业年份")
    public ResponseVO updateStudentInfo(@RequestBody StudentDO studentDO) {
        studentService.updateStudentInfo(studentDO);
        return ResponseData.generateCreatedResponse(0);
    }
}