trigger: verify valid_volumes after runner restart
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
package com.freedom.admin.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.freedom.admin.base.BaseController;
|
||||
import com.freedom.admin.common.Result;
|
||||
import com.freedom.admin.entity.TSysDept;
|
||||
import com.freedom.admin.entity.TSysPermission;
|
||||
import com.freedom.admin.service.TSysPermissionService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhangjiaxun
|
||||
* @date 2021/2/4 11:00
|
||||
* @description 控制层-系统权限
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys-permission")
|
||||
@Log4j2
|
||||
public class TSysPermissionController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
TSysPermissionService tSysPermissionService;
|
||||
|
||||
/**
|
||||
* 登录成功时,获取登录用户权限数据
|
||||
*
|
||||
* @return Result
|
||||
* */
|
||||
@RequestMapping("/getPermissionList")
|
||||
@PreAuthorize("permitAll()")
|
||||
public Result<Map<String,Object>> getPermissionList(){
|
||||
List<Map<String, Object>> permissionList = tSysPermissionService.getPermissionListByUserId(getUser().getId());
|
||||
return Result.ok().setData(permissionList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限tree数据
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/getTreeList")
|
||||
@PreAuthorize("permitAll()")
|
||||
public Result<Map<String,Object>> getTreeList(){
|
||||
List<Map<String, Object>> treeList = tSysPermissionService.getTreeList();
|
||||
return Result.ok().setData(treeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限TreeSelect数据
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/getTreeSelectList")
|
||||
@PermitAll
|
||||
public Result<TSysDept> getTreeSelectList() {
|
||||
List<Map<String, Object>> treeSelectListList = tSysPermissionService.getTreeSelectList();
|
||||
return Result.ok().setData(treeSelectListList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单权限页面-获取菜单列表数据
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/findPageList")
|
||||
@PreAuthorize("permitAll()")
|
||||
public Result findPageList(@Param("pageNum") long pageNum,
|
||||
@Param("pageSize") long pageSize,
|
||||
TSysPermission tSysPermission){
|
||||
QueryWrapper<TSysPermission> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("del_flag",0);
|
||||
queryWrapper.eq(tSysPermission.getParentId() != null,"parent_id", tSysPermission.getParentId());
|
||||
queryWrapper.like(StringUtils.isNotBlank(tSysPermission.getPermissionName()),"permission_name", tSysPermission.getPermissionName());
|
||||
Page<TSysPermission> page = tSysPermissionService.page(new Page<>(pageNum,pageSize), queryWrapper);
|
||||
return Result.ok().setData(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单权限页面-获取菜单树
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/getTreeListByRoleId")
|
||||
@PreAuthorize("permitAll()")
|
||||
public Result getTreeListByRoleId(@Param("roleId") Long roleId){
|
||||
List<Map<String, Object>> treeList = tSysPermissionService.getTreeListByRoleId(roleId);
|
||||
log.info("treeList:{}",treeList);
|
||||
return Result.ok().setData(treeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param tSysPermission
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/add")
|
||||
@PermitAll
|
||||
public Result<TSysDept> add(TSysPermission tSysPermission) {
|
||||
boolean save = tSysPermissionService.save(tSysPermission);
|
||||
return Result.ok().setData(save);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param tSysPermission
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@PermitAll
|
||||
public Result<TSysPermission> update(TSysPermission tSysPermission) {
|
||||
log.info("先查询出父级权限,将要更新的子级部门level+1");
|
||||
if (tSysPermission.getParentId() != null){
|
||||
Long parentId = 0L;
|
||||
if (parentId.equals(tSysPermission.getParentId())){
|
||||
tSysPermission.setLevel(1);
|
||||
}else {
|
||||
QueryWrapper<TSysPermission> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id",tSysPermission.getParentId());
|
||||
TSysPermission parentPermission = tSysPermissionService.getOne(queryWrapper);
|
||||
if (parentPermission == null){
|
||||
return Result.error().message("父级菜单不存在");
|
||||
}
|
||||
tSysPermission.setLevel(parentPermission.getLevel() + 1);
|
||||
}
|
||||
}
|
||||
boolean update = tSysPermissionService.updateById(tSysPermission);
|
||||
return Result.ok().setData(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单权限(前端 /delete 与 /remove 兼容)
|
||||
*
|
||||
* @param tSysPermission
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@PermitAll
|
||||
public Result<TSysPermission> delete(TSysPermission tSysPermission) {
|
||||
try {
|
||||
boolean remove = tSysPermissionService.removeByPermissionId(tSysPermission.getId());
|
||||
return Result.ok().setData(remove);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除页面
|
||||
*
|
||||
* @param tSysPermission
|
||||
* @return Result
|
||||
*/
|
||||
@RequestMapping("/remove")
|
||||
@PermitAll
|
||||
public Result<TSysPermission> remove(TSysPermission tSysPermission) {
|
||||
log.info("先查询出父级权限,将要更新的子级部门level+1");
|
||||
try {
|
||||
boolean remove = tSysPermissionService.removeByPermissionId(tSysPermission.getId());
|
||||
return Result.ok().setData(remove);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user