无关风月
16 小时以前 02bb94e413f6950b9786c5ee86c0937bc20f8ae8
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
88
89
90
91
92
93
94
package com.ruoyi.web.controller.api;
 
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.dto.DeptDTO;
import com.ruoyi.system.dto.KnowledgeDTO;
import com.ruoyi.system.model.TDept;
import com.ruoyi.system.model.TKnowledge;
import com.ruoyi.system.query.DeptListQuery;
import com.ruoyi.system.query.KnowledgeListQuery;
import com.ruoyi.system.service.TDeptService;
import com.ruoyi.system.service.TKnowledgeService;
import com.ruoyi.system.vo.system.DeptListVO;
import com.ruoyi.system.vo.system.KnowledgeListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
 
/**
 * <p>
 * 项目部 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-05-28
 */
@Api(tags = "部门管理")
@RestController
@RequestMapping("/t-dept")
public class TDeptController {
    @Resource
    private TDeptService deptService;
 
 
    @ApiOperation(value = "部门分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<DeptListVO>> pageList(@RequestBody DeptListQuery query) {
        return R.ok(deptService.pageList(query));
    }
    @ApiOperation(value = "部门不分页列表")
    @PostMapping(value = "/listAll")
    public R<List<TDept>> listAll() {
        List<TDept> depts = deptService.list();
        return R.ok(depts);
    }
    @Log(title = "新增部门", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增部门")
    @PostMapping(value = "/add")
    public R<Boolean> add(@RequestBody DeptDTO dto) {
        deptService.save(dto);
        return R.ok();
    }
    @Log(title = "编辑部门", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "编辑部门")
    @PostMapping(value = "/edit")
    public R<Boolean> edit(@RequestBody DeptDTO dto) {
        deptService.updateById(dto);
        return R.ok();
    }
    @Log(title = "详情部门", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "编辑部门")
    @GetMapping(value = "/detail")
    public R<TDept> detail(@RequestParam String id) {
        return R.ok(deptService.getById(id));
    }
    @Log(title = "批量删除部门", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除部门")
    @DeleteMapping(value = "/delete")
    public R<Boolean> edit(@RequestParam String ids) {
        String[] split = ids.split(",");
        deptService.removeBatchByIds(Arrays.asList(split));
        return R.ok();
    }
    @Log(title = "启用/禁用部门", businessType = BusinessType.OTHER)
    @ApiOperation(value = "启用/禁用部门")
    @GetMapping(value = "/editStatus")
    public R<Boolean> editStatus(@RequestParam String id) {
        TDept byId = deptService.getById(id);
        if (byId.getStatus()==1){
            byId.setStatus(2);
        }else{
            byId.setStatus(1);
        }
        deptService.updateById(byId);
        return R.ok();
    }
}