UserRoleController.java 3.78 KB
package com.meishu.controller;


import com.meishu.common.ResponseData;
import com.meishu.common.ResponseVO;
import com.meishu.dto.sms.VerifyCodeDTO;
import com.meishu.dto.userrole.AccountLoginDTO;
import com.meishu.dto.userrole.AddStudentsDTO;
import com.meishu.dto.userrole.QueryStudentsDTO;
import com.meishu.model.UserRoleDO;
import com.meishu.service.UserRoleService;
import com.meishu.util.excel.ExcelUtil;
import com.meishu.vo.semester.GetSemesterScoreVO;
import com.meishu.vo.student.QueryStudentVO;
import com.meishu.vo.userrole.QueryStudentsVO;
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;
import io.swagger.annotations.Api;

import java.util.List;

/**
 * <p>
 * 学生表 前端控制器
 * </p>
 *
 * @author Tuyp
 * @since 2021-08-16
 */
@RestController
@Api(tags = "学生表")
@RequestMapping("/userRole")
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;

    @PostMapping(value = "/login")
    @ApiOperation("手机端:实验室预约登录:phone/手机号, verifyCode/验证码")
    public ResponseVO login(@RequestBody VerifyCodeDTO verifyCodeDTO) {
        return ResponseData.generateCreatedResponse(0, userRoleService.login(verifyCodeDTO));
    }

    @PostMapping(value = "/accountLogin")
    @ApiOperation("手机端:实验室预约账户登录:idCard/身份证, password/密码")
    public ResponseVO accountLogin(@RequestBody AccountLoginDTO accountLoginDTO) {
        return ResponseData.generateCreatedResponse(0, userRoleService.accountLogin(accountLoginDTO));
    }

    @PostMapping(value = "/userInfo")
    @ApiOperation("获取用户信息:id/学生ID")
    public ResponseVO userInfo(@RequestBody UserRoleDO userRoleDO) {
        return ResponseData.generateCreatedResponse(0, userRoleService.userInfo(userRoleDO.getUserId()));
    }

    @PostMapping("queryStudents")
    @ApiOperation("学生管理--查询所有学生    {pageSize  pageNum userName 学生名称 grade 年级 session 入读时间  userStatus 状态 }")
    public ResponseVO queryStudents(@RequestBody QueryStudentsDTO queryStudentsDTO){
        return ResponseData.generateCreatedResponse(0,userRoleService.queryStudents(queryStudentsDTO));
    }

    @PostMapping("addStudents")
    @ApiOperation("学生管理--添加学生  {userName:学生姓名 studyCode:学籍号 phone:手机号  idCard:身份证号 session:入学年份 gender:性别 email:邮箱 }")
    public ResponseVO addStudents(@RequestBody UserRoleDO userRoleDO){
        return ResponseData.generateCreatedResponse(0,userRoleService.addStudents(userRoleDO));
    }

    @PostMapping("updateStudent")
    @ApiOperation("学生管理--编辑学生 {id userName:学生姓名 studyCode:学籍号 phone:手机号  idCard:身份证号 session:入学年份 gender:性别 email:邮箱}")
    public ResponseVO updateStudent(@RequestBody UserRoleDO userRoleDO){
        return ResponseData.generateCreatedResponse(0,userRoleService.updateStudent(userRoleDO));
    }

    @PostMapping("exportStudents")
    @ApiOperation("学生管理--导出  { userName 学生名称 grade 年级 session 入读时间  userStatus 状态 0:归档  1:在读 2:休学}")
    public void exportStudents(@RequestBody QueryStudentsDTO queryStudentsDTO){
        List<QueryStudentsVO> queryStudentsVOS = userRoleService.exportStudents(queryStudentsDTO);
        ExcelUtil.writeExcel(queryStudentsVOS, QueryStudentsVO.class);
    }

    @PostMapping("studycode")
    public void studycode(){
        userRoleService.studycode();
    }

}