xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
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
98
99
100
101
102
103
104
105
106
107
package com.nuvole.four.controller.pc;
 
import com.github.pagehelper.PageHelper;
import com.nuvole.common.domain.result.CommonResult;
import com.nuvole.common.domain.result.PageBean;
import com.nuvole.four.controller.BaseController;
import com.nuvole.four.domain.SysOrg;
import com.nuvole.four.service.SysOrgService;
import com.nuvole.util.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
/**
 * 类描述: 机构管理
 *
 * @author dqh
 * @date  2024-04-11 11:01
 * @version 1.0
 **/
@Api(value = "后台机构接口", tags = "后台机构接口")
@Slf4j
@RestController
@RequestMapping(value = "/v1/four/pc/org")
public class SysOrgController extends BaseController {
 
    @Autowired
    private SysOrgService sysOrgService;
 
 
    /**
     * 方法描述: 查询机构树形列表
     *
     * @date  2024-04-11 11:00
     **/
    @ApiOperation(value = "查询机构树形列表", notes = "查询机构树形列表")
    @GetMapping("/getOrgsTree")
    public CommonResult<List<Map>> getOrgs() {
        List<Map> list = sysOrgService.getTreeOrg(new HashMap());
        return new CommonResult<>(list);
    }
 
    /**
     * 方法描述: 查询机构下级列表
     *
     * @date  2024-04-11 11:01
     **/
    @ApiOperation(value = "查询机构下级列表", notes = "查询机构下级列表")
    @GetMapping("/getChildrenOrg")
    public CommonResult<PageBean<SysOrg>> getChildrenOrg(
            @ApiParam(name = "id", value = "主键ID") Long id,
            @ApiParam(name = "name", value = "机构名称") String name,
            @ApiParam(name = "userOrgCode", value = "机构编号") String userOrgCode,
            @ApiParam(name = "state", value = "机构状态") Integer state,
            @ApiParam(name = "pageNumber", value = "页码", defaultValue = "1", required = true) Integer pageNumber,
            @ApiParam(name = "pageSize", value = "条数", defaultValue = "10", required = true) Integer pageSize,
            @ApiParam(name = "sortName", value = "排序名称") String sortName,
            @ApiParam(name = "sortOrder", value = "排序方式") String sortOrder
    ) {
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            PageHelper.orderBy(PageUtils.orderParser(sortName, sortOrder));
        } else {
            PageHelper.orderBy("sort_no");
        }
        SysOrg sto = new SysOrg();
        sto.setId(id);
        sto.setName(name);
        sto.setUserOrgCode(userOrgCode);
        sto.setState(state);
        SysOrg s = new SysOrg();
        BeanUtils.copyProperties(sto, s);
        PageHelper.startPage(pageNumber, pageSize);
        return new CommonResult<>(new PageBean(sysOrgService.selectListByPid(s.getId(), s.getName(), s.getUserOrgCode(), s.getState())));
    }
 
    /**
     * 方法描述: 查询机构列表(懒加载)
     *
     * @date  2024-04-11 11:01
     **/
    @ApiOperation(value = "查询机构列表(懒加载)", notes = "查询机构列表(懒加载)")
    @GetMapping("/getOrgList")
    public CommonResult<List<SysOrg>> getOrgList(
            @ApiParam(name = "pid", value = "父级id") Long pid,
            @ApiParam(name = "state", value = "机构状态") Integer state
    ) {
        PageHelper.orderBy("sort_no");
        SysOrg sto = new SysOrg();
        sto.setPid(pid);
        sto.setState(state);
        SysOrg s = new SysOrg();
        BeanUtils.copyProperties(sto, s);
        return new CommonResult<>(sysOrgService.selectListByPid(s.getPid(), null, null, s.getState()));
    }
}