RoleDictController.java 3.33 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.role.AddPermissionDTO;
import com.meishu.dto.role.DeletePermissionDTO;
import com.meishu.dto.role.GetRoleTeachersDTO;
import com.meishu.dto.role.RoleTeacherDTO;
import com.meishu.mapper.RoleAdministerMappingMapper;
import com.meishu.model.RoleAdministerMappingDO;
import com.meishu.service.RoleDictService;
import com.meishu.util.ConstantUtils;
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;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author Tuyp
 * @since 2021-04-26
 */
@RestController
@Api(tags = "角色字典表")
@RequestMapping("/roleDict")
public class RoleDictController {

    @Autowired
    private RoleDictService roleDictService;

    @PostMapping("getAllRoles")
    @ApiOperation("获取所有的角色")
//    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getAllRoles(){
        return ResponseData.generateCreatedResponse(0,roleDictService.getAllRoles());
    }

    @PostMapping("getRoleTeachers")
    @ApiOperation("获取某一角色下的所有老师  {roleId :角色id  userName:老师名字  pageSize  pageNum}")
//    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getRoleTeachers(@RequestBody GetRoleTeachersDTO getRoleTeachersDTO){
        return ResponseData.generateCreatedResponse(0,roleDictService.getRoleTeachers(getRoleTeachersDTO));
    }

    @PostMapping("removeTeacher")
    @ApiOperation("移除某一角色下的老师  ids {映射id}  roleId :角色id")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO removeTeacher(@RequestBody RoleTeacherDTO roleTeacherDTO){
        return ResponseData.generateCreatedResponse(0,roleDictService.removeTeacher(roleTeacherDTO));
    }

    @PostMapping("roleTeacher")
    @ApiOperation("添加老师的角色  ids:老师id[]  roleId :角色id ")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO roleTeacher(@RequestBody RoleTeacherDTO roleTeacherDTO){
        return ResponseData.generateCreatedResponse(0,roleDictService.roleTeacher(roleTeacherDTO));
    }

    @PostMapping("addPermission")
    @ApiOperation("给角色添加权限 {roleId 角色id permissionIds 多个权限}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addPermission(@RequestBody AddPermissionDTO addPermissionDTO){
        return ResponseData.generateCreatedResponse(0,roleDictService.addPermission(addPermissionDTO));
    }

    @PostMapping("deletePermission")
    @ApiOperation("给角色删除权限 {roleId 角色id permissionIds 多个权限ids}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO deletePermission(@RequestBody DeletePermissionDTO deletePermissionDTO){
        return ResponseData.generateCreatedResponse(0,roleDictService.deletePermission(deletePermissionDTO));
    }


}