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()));
|
}
|
}
|