AdministerController.java 11 KB
package com.subsidy.controller;


import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.administer.*;
import com.subsidy.model.AdministerDO;
import com.subsidy.model.ExerciseDoneHistoryDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.MemberDO;
import com.subsidy.service.AdministerService;
import com.subsidy.util.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.net.InetAddress;

/**
 * <p>
 * 管理平台用户 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-10-11
 */
@RestController
@Api(tags = "管理平台用户")
@RequestMapping("/administer")
public class AdministerController {

    @Autowired
    private AdministerService administerService;

//    @GetMapping("getIp")
//    public String getIp()throws Exception{
//        InetAddress addr = InetAddress.getLocalHost();
//        return addr.getHostAddress();
//    }

    @PostMapping("/login")
    @ApiOperation("登录接口 accountName password")
    public ResponseVO login(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.login(administerDO));
    }

    @PostMapping("/getPermissions")
    @ApiOperation("权限查询")
    @LoginRequired
    public ResponseVO getPermissions() {
        return ResponseData.generateCreatedResponse(0, administerService.getPermissions());
    }

    @PostMapping("/administers")
    @ApiOperation("查询所有运营者  { userName pageNum  pageSize }")
//    @LoginRequired
    public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){
        return ResponseData.generateCreatedResponse(0,administerService.operators(operatorsDTO));
    }

    @PostMapping("addAdminister")
    @ApiOperation("添加运营者 id userName 名称  accountName 账号 ")
    @LoginRequired
    public ResponseVO addAdminister(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.addAdminister(administerDO));
    }

    @PostMapping("deleteAdminister")
    @ApiOperation("添加运营者 id ")
    @LoginRequired
    public ResponseVO deleteAdminister(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.deleteAdminister(administerDO));
    }

    @PostMapping("updateAdminister")
    @ApiOperation("编辑运营者 id userName 名称  accountName 账号 password")
    @LoginRequired
    public ResponseVO updateAdminister(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.updateAdminister(administerDO));
    }

    @PostMapping("classSummary")
    @ApiOperation("班级详情--数据概览  id 班级id  ")
    @LoginRequired
    public ResponseVO classSummary(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.classSummary(classDetailDTO));
    }

    @PostMapping("classDetail")
    @ApiOperation("班级管理--班级成员  id 班级id  userName pageSize  pageNum")
    @LoginRequired
    public ResponseVO classDetail(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.classDetail(classDetailDTO));
    }

    @PostMapping("exportClassDetail")
    @ApiOperation("班级管理--班级成员--导出  id 班级id  userName")
    @LoginRequired
    public void exportClassDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
        classDetailDTO.setFlag(true);
       administerService.exportClassDetail(classDetailDTO);
    }

    @PostMapping("signDetail")
    @ApiOperation("班级管理--注册签到  id 班级id  userName  pageSize  pageNum")
    @LoginRequired
    public ResponseVO signDetail(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.signDetail(classDetailDTO));
    }

    @PostMapping("exportSignDetail")
    @ApiOperation("班级管理--注册签到  id 班级id  userName")
    @LoginRequired
    public void exportSignDetail(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
        classDetailDTO.setFlag(true);
        administerService.exportSignDetail(classDetailDTO);
    }

    @PostMapping("exerciseTest")
    @ApiOperation("班级管理--测评成绩  id 班级id  userName paperId  pageSize  pageNum")
    @LoginRequired
    public ResponseVO exerciseTest(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.exerciseTest(classDetailDTO));
    }

    @PostMapping("exportExerciseTest")
    @ApiOperation("班级管理--测评成绩  id 班级id  userName  paperId")
    @LoginRequired
    public void exportExerciseTest(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
        classDetailDTO.setFlag(true);
        administerService.exportExerciseTest(classDetailDTO);
    }

    @PostMapping("getMemberPapers")
    @ApiOperation("获取某个成员某个卷子的做题历史 memberId paperId")
    @LoginRequired
    public ResponseVO getMemberPapers(@RequestBody ExerciseDoneResultDO exerciseDoneResultDO){
        return ResponseData.generateCreatedResponse(0,administerService.getMemberPapers(exerciseDoneResultDO));
    }

    @PostMapping("getPaperDetail")
    @ApiOperation("获取某个卷子做题详情  doneId getMemberPapers接口返回id  memberId成员id")
    @LoginRequired
    public ResponseVO getPaperDetail(@RequestBody ExerciseDoneHistoryDO exerciseDoneHistoryDO){
        return ResponseData.generateCreatedResponse(0,administerService.getPaperDetail(exerciseDoneHistoryDO));
    }

    @PostMapping("answerRecord")
    @ApiOperation("班级管理--答疑  id 班级id  userName")
    @LoginRequired
    public ResponseVO answerRecord(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.answerRecord(classDetailDTO));
    }

    @PostMapping("exportAnswerRecord")
    @ApiOperation("班级管理--答疑  id 班级id  userName")
    @LoginRequired
    public void exportAnswerRecord(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
        classDetailDTO.setFlag(true);
        administerService.exportAnswerRecord(classDetailDTO);
    }

    @PostMapping("classVodInfo")
    @ApiOperation("学习记录---课件进度提醒  {courseId 课程id  classId 班级id  vodName视频名称}")
    @LoginRequired
    public ResponseVO classVodInfo(@RequestBody ClassVodInfoDTO classVodInfoDTO){
        return ResponseData.generateCreatedResponse(0,administerService.classVodInfo(classVodInfoDTO));
    }

    @PostMapping("classDailyInfo")
    @ApiOperation("学习记录---每日学习时长  {courseId 课程id  classId 班级id userName  startDate endDate}")
    @LoginRequired
    public ResponseVO classDailyInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){
        return ResponseData.generateCreatedResponse(0,administerService.classDailyInfo(classDailyInfoDTO));
    }

    @PostMapping("exportClassDailyInfo")
    @ApiParam("每日学习日志")
    @LoginRequired
    public void exportVodInfo(@RequestBody ClassDailyInfoDTO classDailyInfoDTO){
        administerService.exportClassDailyInfo(classDailyInfoDTO);
    }

    @PostMapping("classVodDailyInfo")
    @ApiOperation("学习记录---每日学习时长(视频维度)")
    @LoginRequired
    public ResponseVO classVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){
        return ResponseData.generateCreatedResponse(0,administerService.classVodDailyInfo(classVodDailyInfoDTO));
    }

    @PostMapping("exportClassVodDailyInfo")
    @ApiOperation("学习记录---每日学习时长(视频维度) pageSize  pageNum userName classId")
    @LoginRequired
    public void exportClassVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO ){
        administerService.exportClassVodDailyInfo(classVodDailyInfoDTO);
    }

    @PostMapping("memberStudy")
    @ApiOperation("学员学习日志  pageSize pageNum classId memberId")
    @LoginRequired
    public ResponseVO memberStudy(@RequestBody MemberStudyLogDTO memberStudyLogDTO){
        return ResponseData.generateCreatedResponse(0,administerService.memberStudy(memberStudyLogDTO));
    }

    @PostMapping("memberDetectionRecord")
    @ApiOperation("获取某个班级活跃度检测记录  id userName  pageSize pageNum ")
    @LoginRequired
    public ResponseVO memberDetectionRecord(@RequestBody ClassDetailDTO classDetailDTO ){
        return ResponseData.generateCreatedResponse(0,administerService.memberDetectionRecord(classDetailDTO));
    }

    @PostMapping("exportMemberDetectionRecord")
    @ApiOperation("获取某个班级活跃度检测记录  id userName  ")
    @LoginRequired
    public void exportMemberDetectionRecord(@RequestBody ClassDetailDTO classDetailDTO ){
       administerService.exportMemberDetectionRecord(classDetailDTO);
    }

    @PostMapping("imageCheckDetail")
    @ApiOperation("实名制验证详情   id 班级id  userName   pageSize  pageNum")
    @LoginRequired
    public ResponseVO imageCheckDetail(@RequestBody ClassDetailDTO classDetailDTO){
        return ResponseData.generateCreatedResponse(0,administerService.imageCheckDetail(classDetailDTO));
    }


    @PostMapping("exportZip")
    @ApiOperation("下载压缩包 id 班级id")
    @CrossOrigin
    @LoginRequired
    public void exportZip(@RequestBody ClassDetailDTO classDetailDTO)throws Exception{
        administerService.export(classDetailDTO);
    }

    @PostMapping("memberStudyLog")
    @ApiOperation("学员学习日志  classId memberId")
    @LoginRequired
    public void memberStudyLog(@RequestBody MemberStudyLogDTO memberStudyLogDTO) throws Exception{
        administerService.memberStudyLog(memberStudyLogDTO);
    }

    @PostMapping("importMember")
    @ApiOperation("导入学生  {companyId 公司id  file}")
    @LoginRequired
    public ResponseVO importMember(Long companyId,@RequestParam("file") MultipartFile file)throws Exception{
        return ResponseData.generateCreatedResponse(0,administerService.importMember(companyId,file));
    }

    @PostMapping("manageMember")
    @ApiOperation("用户管理  {pageSize pageNum userName:名字     【废弃】}")
    @LoginRequired
    public ResponseVO manageMember(@RequestBody ManageMemberDTO manageMemberDTO){
        return ResponseData.generateCreatedResponse(0,administerService.manageMember(manageMemberDTO));
    }
}