package com.chinaztt.mes.aps.controller;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.chinaztt.mes.aps.entity.ApsResourceGroup;
|
import com.chinaztt.mes.aps.entity.ApsResourceRelation;
|
import com.chinaztt.mes.aps.service.ApsResourceRelationService;
|
import com.chinaztt.mes.aps.service.ApsResourceGroupService;
|
import com.chinaztt.ztt.common.core.util.R;
|
import com.chinaztt.ztt.common.log.annotation.SysLog;
|
import io.swagger.annotations.Api;
|
import lombok.AllArgsConstructor;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.validation.Valid;
|
|
/**
|
* 资源分组
|
*
|
* @author xunxiaoling
|
* @date 2020-08-27 10:32:31
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/apsResourceGroup" )
|
@Api(value = "apsResource", tags = "资源分组")
|
public class ApsResourceGroupController {
|
private final ApsResourceRelationService apsResourceRelationService;
|
|
private final ApsResourceGroupService apsResourceService;
|
/**
|
* 通过ID查询
|
* @param id ID
|
* @return ApsDept
|
*/
|
@GetMapping("/{id}")
|
public R getById(@PathVariable Integer id) {
|
return R.ok(apsResourceService.getResourceById(id));
|
}
|
|
|
/**
|
* 返回树形菜单集合
|
* @return 树形菜单
|
*/
|
@GetMapping(value = "/tree")
|
public R getTree() {
|
return R.ok(apsResourceService.selectTree());
|
}
|
|
/**
|
* 添加
|
* @param apsResource 实体
|
* @return success/false
|
*/
|
@SysLog("添加部门")
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('aps_dept_add')")
|
public R save(@Valid @RequestBody ApsResourceGroup apsResource) {
|
return R.ok(apsResourceService.saveResource(apsResource));
|
}
|
|
/**
|
* 删除
|
* @param id ID
|
* @return success/false
|
*/
|
@SysLog("删除部门")
|
@DeleteMapping("/{id}")
|
@PreAuthorize("@pms.hasPermission('aps_dept_del')")
|
public R removeById(@PathVariable Integer id) {
|
return R.ok(apsResourceService.removeDeptById(id));
|
}
|
/**
|
* 编辑
|
* @param apsDept 实体
|
* @return success/false
|
*/
|
@SysLog("编辑部门")
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('aps_dept_edit')")
|
public R update(@Valid @RequestBody ApsResourceGroup apsDept) {
|
return R.ok(apsResourceService.updateDeptById(apsDept));
|
}
|
|
|
/**
|
* 查收子级列表
|
* @return 返回子级
|
*/
|
@GetMapping(value = "/getDescendantList/{id}")
|
public R getDescendantList(@PathVariable Integer id) {
|
return R.ok(
|
apsResourceRelationService.list(Wrappers.<ApsResourceRelation>lambdaQuery().eq(ApsResourceRelation::getAncestry, id)));
|
}
|
|
}
|