CollegesDictController.java 13.1 KB
package com.zhongzhi.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongzhi.common.constant.Platform;
import com.zhongzhi.common.utils.LoginRequired;
import com.zhongzhi.common.utils.ResponseData;
import com.zhongzhi.dto.college.*;
import com.zhongzhi.dto.project.EditStatusDTO;
import com.zhongzhi.model.*;
import com.zhongzhi.service.CollegesDictService;
import com.zhongzhi.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
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 org.springframework.web.multipart.MultipartFile;

import java.net.ResponseCache;

/**
 * <p>
 * 院校字典表 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-04-28
 */
@RestController
@Api(tags = "就读院校")
@RequestMapping("/collegesDict")
public class CollegesDictController {

    @Autowired
    public CollegesDictService collegesDictService;

    @PostMapping(value = "/getCollegesList")
    @ApiOperation("查询所有就读院校: name/院校名称, education/学历")
    public ResponseVO getCollegesList(@RequestBody CollegesDictDTO collegesDictDTO) {
        QueryWrapper<CollegesDictDO> queryWrapper = new QueryWrapper();
        if (StringUtils.isNotBlank(collegesDictDTO.getEducation())) {
            if ("中职".equals(collegesDictDTO.getEducation())){
                queryWrapper.lambda().eq(CollegesDictDO::getEducation, collegesDictDTO.getEducation());
            }else {
                queryWrapper.lambda().like(CollegesDictDO::getEducation, collegesDictDTO.getEducation());
            }
        }

        if (StringUtils.isNotBlank(collegesDictDTO.getName())) {
            queryWrapper.lambda().like(CollegesDictDO::getName, collegesDictDTO.getName());
        }
        queryWrapper.lambda().eq(CollegesDictDO::getLoginStatus,1);
        return ResponseData.generateCreatedResponse(0, collegesDictService.list(queryWrapper));
    }

    @PostMapping(value = "/login")
    @ApiOperation("院校端 --- 登录: account/账户, password/密码")
    public ResponseVO login(@RequestBody LoginDTO loginDTO) {
        return ResponseData.generateCreatedResponse(0, collegesDictService.login(loginDTO));
    }

    @PostMapping(value = "updateCollegeById")
    @LoginRequired({Platform.center})
    @ApiOperation("院校端 --- 更新院校信息: id/ID, account/账户,code/代码, name/名称, password/密码")
    public ResponseVO updateCollegeById(@RequestBody CollegesDictDO collegesDictDO) {
        collegesDictService.updateById(collegesDictDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "addContact")
    @LoginRequired({Platform.school})
    @ApiOperation("院校端 --- 新增联系人:leaderName/领导姓名、leaderPost/领导职务、leaderPhone/领导手机号、contactName/联系人姓名、contactPost/联系人职务、contactPhone/联系人手机号")
    public ResponseVO addContact(@RequestBody CollegesDictDO collegesDictDO) {
        collegesDictService.addContact(collegesDictDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/updatePwd")
    @LoginRequired(Platform.school)
    @ApiOperation("院校端 --- 修改密码: password/密码")
    public ResponseVO updatePwd(@RequestBody UpdatePwdDTO updatePwdDTO) {
        collegesDictService.updatePwd(updatePwdDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/projects")
    @LoginRequired(Platform.school)
    @ApiOperation("##院校端 --- 查看某个院校进决赛的项目(除去已经登记过的) matchId ")
    public ResponseVO projects(@RequestBody ProjectDO projectDO) {
        return ResponseData.generateCreatedResponse(0,collegesDictService.projects(projectDO));
    }

    @PostMapping("projectLeader")
    @LoginRequired(Platform.school)
    @ApiOperation("##院校端---自动带出负责人  projectId ")
    public ResponseVO projectLeader(@RequestBody ProjectMemberDO projectMemberDO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.projectLeader(projectMemberDO));
    }

    @PostMapping("projectMembers")
    @LoginRequired(Platform.school)
    @ApiOperation("##院校端---进决赛的项目下的成员  projectId ")
    public ResponseVO projectMembers(@RequestBody ProjectMemberDO projectMemberDO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.projectMembers(projectMemberDO));
    }

    @PostMapping("addProjectMember")
    @LoginRequired({Platform.school})
    @ApiOperation("##院校端---添加参赛人员  matchId studentIds[] 人员id projectId  matchId")
    public ResponseVO addProjectMember(@RequestBody AddProjectMemberDTO addProjectMemberDTO)throws Exception{
        collegesDictService.addProjectMember(addProjectMemberDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping("removeProject")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##院校端---移除参赛人员  projectId  matchId")
    public ResponseVO removeProject(@RequestBody AddProjectMemberDTO addProjectMemberDTO)throws Exception{
        collegesDictService.removeProject(addProjectMemberDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping("addObservations")
    @LoginRequired(Platform.school)
    @ApiOperation("##院校端---添加观摩人员/学校领队 matchId  memberType 观摩人员/学校领队/车 userName 人名/车牌号  telephone  idCardType  idCard")
    public ResponseVO addObservations(@RequestBody FinalMatchMemberDO finalMatchMemberDO)throws Exception {
        collegesDictService.addObservations(finalMatchMemberDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping("updateObservations")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##院校端---修改观摩人员 matchId  id  userName  telephone  idCardType  idCard")
    public ResponseVO updateObservations(@RequestBody FinalMatchMemberDO finalMatchMemberDO)throws Exception{
        collegesDictService.updateObservations(finalMatchMemberDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping("deleteObservations")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##院校端---删除观摩人员 id matchId ")
    public ResponseVO deleteObservations(@RequestBody FinalMatchMemberDO finalMatchMemberDO)throws Exception{
        collegesDictService.deleteObservations(finalMatchMemberDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping("registerMembers")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##查看已登记的参赛人员  collegeId matchId ")
    public ResponseVO registerMembers(@RequestBody RegisterMembersDTO registerMembersDTO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.registerMembers(registerMembersDTO));
    }

    @PostMapping("otherMembers")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##查看已登记的其他人员  collegeId matchId")
    public ResponseVO otherMembers(@RequestBody RegisterMembersDTO registerMembersDTO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.otherMembers(registerMembersDTO));
    }

    @PostMapping("cars")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##查看已登记的车辆  collegeId matchId")
    public ResponseVO cars(@RequestBody RegisterMembersDTO registerMembersDTO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.cars(registerMembersDTO));
    }

    @PostMapping("details")
    @LoginRequired({Platform.school,Platform.center})
    @ApiOperation("##截至时间+最近一次更新时间  id  matchId ")
    public ResponseVO details(@RequestBody RegisterMembersDTO registerMembersDTO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.detail(registerMembersDTO));
    }

    @PostMapping("schools")
    @LoginRequired(Platform.center)
    @ApiOperation("##这届登记的院校+人员数 matchId name")
    public ResponseVO schools(@RequestBody RegisterMembersDTO registerMembersDTO){
        return ResponseData.generateCreatedResponse(0,collegesDictService.schools(registerMembersDTO));
    }

    @PostMapping("exportList")
    @LoginRequired(Platform.center)
    @ApiOperation("##导出总名单  id 届数id collegeId")
    public ResponseVO exportList(@RequestBody FinalMatchMemberDO finalMatchMemberDO){
        collegesDictService.exportList(finalMatchMemberDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/getCollegesPage")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 院校名录分页查询: name/搜索名称, pageNo/当前页数, pageSize/每页显示条数")
    public ResponseVO getCollegesPage(@RequestBody CollegesPageDTO collegesPageDTO) {
        return ResponseData.generateCreatedResponse(0, collegesDictService.getCollegesPage(collegesPageDTO));
    }

    @PostMapping(value = "/createColleges")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 新建院校: name/搜索名称, code/院校代码、 phone/手机号")
    public ResponseVO createColleges(@RequestBody CollegesDictDO collegesDictDO) {
        collegesDictService.createColleges(collegesDictDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/delete")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 删除院校: id/院校ID")
    public ResponseVO delete(@RequestBody CollegesDictDO collegesDictDO) {
        collegesDictService.removeById(collegesDictDO.getId());
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/importColleges")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 导入院校:file/文件(数据格式:Form-Data)")
    public ResponseVO importColleges(MultipartFile file) {
        return ResponseData.generateCreatedResponse(0, collegesDictService.importColleges(file));
    }

    @PostMapping(value = "/downloadErrorData")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 下载导入失败院校数据:errorData/失败数据")
    public ResponseVO downloadErrorData(@RequestBody DownloadErrorDataDTO downloadErrorDataDTO) {
        collegesDictService.downloadErrorData(downloadErrorDataDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/getAwardedListPage")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 查询获奖情况:matchId/赛事年份ID、projectGroup/项目组别(科技创新、红色文创、高职、中职)、name/搜索名称、pageNo/当前页数、pageSize/每页显示条数")
    public ResponseVO getAwardedList(@RequestBody AwardedListDTO awardedListDTO) {
        return ResponseData.generateCreatedResponse(0, collegesDictService.getAwardedList(awardedListDTO));
    }

    @PostMapping(value = "/exportAwardedList")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 导出获奖情况:matchId/赛事年份ID")
    public void exportAwardedList(@RequestBody AwardedListDTO awardedListDTO) {
        collegesDictService.exportAwardedList(awardedListDTO);
    }

    @PostMapping(value = "/exportCollege")
    @LoginRequired(Platform.center)
    @ApiOperation("导出院校名录")
    public ResponseVO exportCollege() {
        collegesDictService.exportCollege();
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "updateAllLoginStatus")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 更新所有登录状态:loginStatus/状态(0:关闭,1:开启)")
    public ResponseVO updateAllLoginStatus(@RequestBody LoginStatusDTO loginStatusDTO) {
        collegesDictService.updateAllLoginStatus(loginStatusDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "batchUpdateLoginStatus")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 批量更新登录状态:ids/院校ID(数组)、loginStatus/状态(0:关闭,1:开启)")
    public ResponseVO batchUpdateLoginStatus(@RequestBody LoginStatusDTO loginStatusDTO) {
        collegesDictService.batchUpdateLoginStatus(loginStatusDTO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "updateLoginStatus")
    @LoginRequired(Platform.center)
    @ApiOperation("中心端 --- 更新登录状态:id/院校ID、loginStatus/状态(0:关闭,1:开启)")
    public ResponseVO updateLoginStatus(@RequestBody LoginStatusDTO loginStatusDTO) {
        collegesDictService.updateLoginStatus(loginStatusDTO);
        return ResponseData.generateCreatedResponse(0);
    }
}