Blame view

DepartmentDictController.java 3.73 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
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));
    }

}