DepartmentDictController.java 3.73 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.department.BatchOprDTO;
import com.meishu.dto.department.GetTeachersDTO;
import com.meishu.dto.subject.GetSubjectTreeDTO;
import com.meishu.model.DepartmentDictDO;
import com.meishu.service.DepartmentDictService;
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-25
 */
@RestController
@Api(tags = "部门字典表")
@RequestMapping("/departmentDict")
public class DepartmentDictController {

    @Autowired
    private DepartmentDictService departmentDictService;

    @PostMapping("getDepartmentInfo")
    @ApiOperation("获取全部部门 包含老师信息和人数信息")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getAllDepartment() {
        return ResponseData.generateCreatedResponse(0, departmentDictService.getDepartmentInfo());
    }

    @PostMapping("getDepartmentList")
    @ApiOperation("获取部门列表")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getDepartmentList(@RequestBody GetSubjectTreeDTO getSubjectTreeDTO) {
        return ResponseData.generateCreatedResponse(0, departmentDictService.getDepartmentList(getSubjectTreeDTO));
    }

    @PostMapping("addDepartment")
    @ApiOperation("新增部门   { departmentName:部门名称  departmentLeaderId:负责人id parentId:父节点 没有父节点传空值} ")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addDepartment(@RequestBody DepartmentDictDO departmentDictDO) {
        return ResponseData.generateCreatedResponse(0, departmentDictService.addDepartment(departmentDictDO));
    }

    @PostMapping("getTeachers")
    @ApiOperation("获取该部门下的老师 departmentId:部门id   userName")
//    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO getTeachers(@RequestBody GetTeachersDTO getTeachersDTO) {
        return ResponseData.generateCreatedResponse(0, departmentDictService.getTeachers(getTeachersDTO));
    }

    @PostMapping("batchOpr")
    @ApiOperation("批量操作部门  {ids 多个部门id  departmentLeaderId:领导人id parentId:挂在这个节点下}")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO batchOpr(@RequestBody BatchOprDTO batchOprDTO){
        return ResponseData.generateCreatedResponse(0,departmentDictService.batchOpr(batchOprDTO));
    }

    @PostMapping("deleteDepartment")
    @ApiOperation("删除部门  id")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO deleteDepartment(@RequestBody BatchOprDTO batchOprDTO){
        return ResponseData.generateCreatedResponse(0,departmentDictService.deleteDepartment(batchOprDTO));
    }

    @PostMapping("updateDepartment")
    @ApiOperation("编辑部门  id departmentName:部门名称  departmentLeaderId:负责人id parentId:父节点 没有父节点传空值")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateDepartment(@RequestBody DepartmentDictDO departmentDictDO){
        return ResponseData.generateCreatedResponse(0,departmentDictService.updateDepartment(departmentDictDO));
    }

}