mitao
2025-03-28 4922e5fb02c3a095791a6f6e65c70883054fa3d9
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
95
96
97
package com.sinata.web.controller.backend.system;
 
import com.sinata.common.core.domain.R;
import com.sinata.system.domain.dto.SysDepartmentDTO;
import com.sinata.system.domain.vo.SysDepartmentVO;
import com.sinata.system.service.SysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
 
/**
 * <p>
 * 区域表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-12-02
 */
@Api(tags = {"区域管理相关接口"})
@RestController
@Validated
@RequestMapping("/backend/sysDepartment")
@RequiredArgsConstructor
public class SysDepartmentController {
    private final SysDepartmentService sysDepartmentService;
 
    /**
     * 获取区域树
     * @return
     */
    @ApiOperation("获取区域树")
    @GetMapping("/regionTree")
    @ApiImplicitParam(name = "keyword", value = "关键字", required = false)
    public R<List<SysDepartmentVO>> getRegionTree(@RequestParam(required = false) String keyword) {
        return R.ok(sysDepartmentService.getRegionTree(keyword));
    }
 
    /**
     * 获取区域树
     *
     * @return
     */
    @ApiOperation(value = "获取全部/区域/医疗机构/处置单位/监管单位树-搜索框用", notes = "0:全部 1:区域 2:医疗机构 3:处置单位 4:监管单位 5:医疗机构、处置单位 6:医疗机构、监管单位 7:处置单位、监管单位")
    @GetMapping("/departmentSearchTree")
    @ApiImplicitParam(name = "type", value = "查询类型", required = true)
    public R<List<SysDepartmentVO>> getDepartmentSearchTree(@RequestParam(value = "type", required = true) @NotNull(message = "类型不能为空") Integer type) {
        return R.ok(sysDepartmentService.listByType(type));
    }
 
    /**
     * 新增区域
     *
     * @param dto
     * @return
     */
    @ApiOperation("新增区域")
    @PostMapping("/add")
    public R<?> addRegion(@Valid @RequestBody SysDepartmentDTO dto) {
        sysDepartmentService.addRegion(dto);
        return R.ok();
    }
 
    /**
     * 编辑区域
     *
     * @param dto
     * @return
     */
    @ApiOperation("编辑区域")
    @PostMapping("/edit")
    public R<?> editRegion(@Valid @RequestBody SysDepartmentDTO dto) {
        sysDepartmentService.editRegion(dto);
        return R.ok();
    }
 
    @ApiOperation("删除区域")
    @DeleteMapping("/{id}")
    public R<?> deleteRegion(@ApiParam(name = "id", value = "区域id", required = true) @NotNull(message = "区域id不能为空") @PathVariable("id") Long id) {
        sysDepartmentService.deleteRegion(id);
        return R.ok();
    }
}