AdministerController.java 4.32 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.administer.AddAdministerDTO;
import com.meishu.dto.administer.ChangeStatusDTO;
import com.meishu.dto.administer.PublishTasksDTO;
import com.meishu.dto.administer.UpdateAdministerDTO;
import com.meishu.dto.exercise.UpdateStatusDTO;
import com.meishu.dto.test.PublishTestDTO;
import com.meishu.model.AdministerDO;
import com.meishu.model.SmsCodeDO;
import com.meishu.service.AdministerService;
import com.meishu.util.ConstantUtils;
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 Tuyp
 * @since 2021-04-25
 */
@RestController
@Api(tags= "管理平台用户")
@RequestMapping("/administer")
public class AdministerController {

    @Autowired
    private AdministerService administerService;

    @PostMapping("sendMsg")
    @ApiOperation("发送短信验证码  {telephone}")
    public ResponseVO sendMsg(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.sendMsg(administerDO));
    }

    @PostMapping("login")
    @ApiOperation("登录 {telephone  code}")
    public ResponseVO login(@RequestBody SmsCodeDO smsCodeDO){
        return ResponseData.generateCreatedResponse(0,administerService.login(smsCodeDO));
    }

    @PostMapping("passwordLogin")
    @ApiOperation("密码登录  telephone  password")
    public ResponseVO passwordLogin(@RequestBody AdministerDO administerDO){
        return ResponseData.generateCreatedResponse(0,administerService.passwordLogin(administerDO));
    }

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

    @PostMapping("getParentPermission")
    @ApiOperation("获取所有父权限")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getParentPermission(){
        return ResponseData.generateCreatedResponse(0,administerService.getParentPermission());
    }

    @PostMapping("addAdminister")
    @ApiOperation("添加成员 {telephone,userName,img,departmentId  campusIds[]校区数组  departmentIds[] 部门id  subjectIds[]  科目id intro 简介 roleIds[]  角色id} ")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addAdminister(@RequestBody AddAdministerDTO addAdministerDTO){
        return ResponseData.generateCreatedResponse(0,administerService.addAdminister(addAdministerDTO));
    }

    @PostMapping("getPermissionTree")
    @ApiOperation("获取所有权限列表")
    public ResponseVO getPermissionTree(){
        return ResponseData.generateCreatedResponse(0,administerService.getPermissionTree());
    }

    @PostMapping("/changeStatus")
    @ApiOperation("操作离职  ids  status")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO changeStatus(@RequestBody ChangeStatusDTO changeStatusDTO){
        return ResponseData.generateCreatedResponse(0,administerService.changeStatus(changeStatusDTO));
    }

    @PostMapping("updateAdminister")
    @ApiOperation("修改成员信息  id telephone,userName,img,departmentId campusIds[]  departmentIds[] 部门id  intro简介 roleIds[]  角色id")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateAdminister(@RequestBody UpdateAdministerDTO updateAdministerDTO){
        return ResponseData.generateCreatedResponse(0,administerService.updateAdminister(updateAdministerDTO));
    }

    @PostMapping("getAllAdminister")
    @ApiOperation("获取所有老师")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getAllAdminister(){
        return ResponseData.generateCreatedResponse(0,administerService.getAllAdminister());
    }


}