StudentController.java 3.2 KB
package com.meishu.controller;


import com.meishu.common.ResponseData;
import com.meishu.common.ResponseVO;
import com.meishu.common.interceptor.LoginRequired;
import com.meishu.dto.campus.BatchUpdateStatusDTO;
import com.meishu.dto.student.*;
import com.meishu.dto.subject.BatchStatusOprDTO;
import com.meishu.model.*;
import com.meishu.service.StudentService;
import com.meishu.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
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 Tuyp
 * @since 2021-04-25
 */
@RestController
@RequestMapping("/student")
@Api(tags = "学生端")
public class StudentController {


    @Autowired
    private StudentService studentService;

    @PostMapping("sendMsg")
    @ApiOperation("小程序---发送短信验证码  {telephone}")
    public ResponseVO sendMsg(@RequestBody StudentDO studentDO){
        return ResponseData.generateCreatedResponse(0,studentService.sendMsg(studentDO));
    }

    @PostMapping("login")
    @ApiOperation("小程序---验证短信验证码  {telephone code}")
    public ResponseVO login(@RequestBody SmsCodeDO smsCodeDO){
        return ResponseData.generateCreatedResponse(0,studentService.login(smsCodeDO));
    }

    @PostMapping("addStudent")
    @ApiOperation("添加学生  {telephone,username,parentTelephone,campusId}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addStudent(@RequestBody StudentDO studentDO){
        return ResponseData.generateCreatedResponse(0,studentService.addStudent(studentDO));
    }

    @PostMapping("updateStudent" )
    @ApiOperation("修改学生  id,username,parentTelephone,campusId,status 0:禁用  1:启用")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateStudent(@RequestBody StudentDO studentDO){
        return ResponseData.generateCreatedResponse(0,studentService.updateStudent(studentDO));
    }

    @PostMapping("batchUpdateStudent")
    @ApiOperation("批量修改学生状态   ids[]  status")
    public ResponseVO batchUpdateStudent(@RequestBody BatchStatusOprDTO batchStatusOprDTO){
        return ResponseData.generateCreatedResponse(0,studentService.batchUpdateStudent(batchStatusOprDTO));
    }

    @PostMapping("deleteStudent")
    @ApiOperation("删除学生  {ids[]}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO deleteStudent(@RequestBody DeleteStudentDTO deleteStudentDTO){
        return ResponseData.generateCreatedResponse(0,studentService.deleteStudent(deleteStudentDTO));
    }

    @PostMapping("queryStudent")
    @ApiOperation("查询单个学生   id")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO queryStudent(@RequestBody StudentDO studentDO){
        return ResponseData.generateCreatedResponse(0,studentService.queryStudent(studentDO));
    }



}