parent
b34345b0a4
commit
e5dbb4e9e5
33 changed files with 911 additions and 537 deletions
@ -0,0 +1,25 @@ |
||||
package com.nov.KgLowDurable.annotation; |
||||
|
||||
import com.auth0.jwt.interfaces.Payload; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
@Documented |
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Repeatable(NotEmpty.List.class) |
||||
public @interface NotEmpty { |
||||
String message() default "{jakarta.validation.constraints.NotEmpty.message}"; |
||||
|
||||
Class<?>[] groups() default {}; |
||||
|
||||
Class<? extends Payload>[] payload() default {}; |
||||
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface List { |
||||
NotEmpty[] value(); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,88 @@ |
||||
package com.nov.KgLowDurable.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.nov.KgLowDurable.pojo.entity.Role; |
||||
import com.nov.KgLowDurable.pojo.entity.User; |
||||
import com.nov.KgLowDurable.pojo.vo.GrantVO; |
||||
import com.nov.KgLowDurable.pojo.vo.RoleVO; |
||||
import com.nov.KgLowDurable.service.IRoleService; |
||||
import com.nov.KgLowDurable.util.Condition; |
||||
import com.nov.KgLowDurable.util.Result; |
||||
import com.nov.KgLowDurable.wrapper.RoleWrapper; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/role") |
||||
@Api(value = "角色", description = "角色") |
||||
public class LdRoleController { |
||||
|
||||
private final IRoleService roleService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情", notes = "传入role") |
||||
public Result<Role> detail(@RequestParam Long id) { |
||||
return Result.OK(roleService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 列表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "roleName", value = "参数名称"), |
||||
@ApiImplicitParam(name = "roleAlias", value = "角色别名") |
||||
}) |
||||
@ApiOperation(value = "列表", notes = "传入role") |
||||
public Result<List<RoleVO>> list(@ApiParam(hidden = true) @RequestParam Map<String, Object> role) { |
||||
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
||||
List<Role> list = roleService.list(queryWrapper); |
||||
return Result.OK(RoleWrapper.build().listNodeVO(list)); |
||||
} |
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperation(value = "新增或修改", notes = "传入role") |
||||
public Result submit(@RequestBody Role role) { |
||||
return Result.OK(roleService.submit(role)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "删除", notes = "传入ids") |
||||
public Result remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return Result.OK(roleService.removeRole(ids)); |
||||
} |
||||
|
||||
/** |
||||
* 设置角色权限 |
||||
*/ |
||||
@PostMapping("/grant") |
||||
@ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
||||
public Result grant(@RequestBody GrantVO grantVO) { |
||||
try { |
||||
boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds()); |
||||
return Result.OK(temp); |
||||
} catch (Exception e) { |
||||
return Result.fail("操作失败"); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -1,156 +0,0 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.nov.KgLowDurable.pojo.entity.Role; |
||||
import com.nov.KgLowDurable.pojo.entity.User; |
||||
import com.nov.KgLowDurable.pojo.vo.RoleVO; |
||||
import com.nov.KgLowDurable.service.IRoleService; |
||||
import com.nov.KgLowDurable.util.Condition; |
||||
import com.nov.KgLowDurable.util.Result; |
||||
import com.nov.KgLowDurable.wrapper.RoleWrapper; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/role") |
||||
@Api(value = "角色", description = "角色") |
||||
public class RoleController { |
||||
|
||||
private final IRoleService roleService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情", notes = "传入role") |
||||
public Result<Role> detail(@RequestParam Long id) { |
||||
return Result.OK(roleService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 列表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "roleName", value = "参数名称"), |
||||
@ApiImplicitParam(name = "roleAlias", value = "角色别名") |
||||
}) |
||||
@ApiOperation(value = "列表", notes = "传入role") |
||||
public Result<List<RoleVO>> list(@ApiParam(hidden = true) @RequestParam Map<String, Object> role) { |
||||
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
||||
List<Role> list = roleService.list(queryWrapper); |
||||
return Result.OK(RoleWrapper.build().listNodeVO(list)); |
||||
} |
||||
|
||||
/** |
||||
* 获取角色树形结构 |
||||
*/ |
||||
// @GetMapping("/tree")
|
||||
// @ApiOperation(value = "树形结构", notes = "树形结构")
|
||||
// public Result<List<RoleVO>> tree(Tuser bladeUser) {
|
||||
// List<RoleVO> tree = roleService.tree(bladeUser.getUserId());
|
||||
// return Result.OK(tree);
|
||||
// }
|
||||
|
||||
/** |
||||
* 获取指定角色树形结构 |
||||
*/ |
||||
@GetMapping("/tree-by-id") |
||||
@ApiOperation(value = "树形结构", notes = "树形结构") |
||||
public Result<List<RoleVO>> treeById(Long roleId, User bladeUser) { |
||||
List<RoleVO> tree = roleService.tree(bladeUser.getUserId()); |
||||
return Result.OK(tree); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperation(value = "新增或修改", notes = "传入role") |
||||
public Result submit(@RequestBody Role role) { |
||||
return Result.OK(roleService.submit(role)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "删除", notes = "传入ids") |
||||
public Result remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return Result.OK(roleService.removeRole(ids)); |
||||
} |
||||
|
||||
/** |
||||
* 设置角色权限 |
||||
*/ |
||||
// @PostMapping("/grant")
|
||||
// @ApiOperationSupport(order = 7)
|
||||
// @Operation(summary = "权限设置", description = "传入roleId集合以及menuId集合")
|
||||
// public R grant(@RequestBody GrantVO grantVO) {
|
||||
// CacheUtil.clear(SYS_CACHE);
|
||||
// CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
// boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
|
||||
// return R.status(temp);
|
||||
// }
|
||||
|
||||
/** |
||||
* 下拉数据源 |
||||
*/ |
||||
// @GetMapping("/select")
|
||||
// @Operation(summary = "下拉数据源", description = "传入id集合")
|
||||
// public R<List<Role>> select(Long userId, String roleId) {
|
||||
// if (Func.isNotEmpty(userId)) {
|
||||
// User user = UserCache.getUser(userId);
|
||||
// roleId = user.getRoleId();
|
||||
// }
|
||||
// List<Role> list = roleService.list(Wrappers.<Role>lambdaQuery().in(Role::getId, Func.toLongList(roleId)));
|
||||
// return R.data(list);
|
||||
// }
|
||||
|
||||
/** |
||||
* 获取现有角色别名列表 |
||||
*/ |
||||
@GetMapping("/alias") |
||||
@ApiOperation(value = "获取角色别名", notes = "获取角色别名") |
||||
public Result<List<Role>> alias() { |
||||
return Result.OK(roleService.alias()); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,41 @@ |
||||
package com.nov.KgLowDurable.enums; |
||||
|
||||
import com.nov.KgLowDurable.exception.IResultCode; |
||||
import lombok.Generated; |
||||
|
||||
public enum ResultCode implements IResultCode { |
||||
SUCCESS(200, "操作成功"), |
||||
FAILURE(400, "业务异常"), |
||||
UN_AUTHORIZED(401, "请求未授权"), |
||||
CLIENT_UN_AUTHORIZED(401, "客户端请求未授权"), |
||||
NOT_FOUND(404, "404 没找到请求"), |
||||
MSG_NOT_READABLE(400, "消息不能读取"), |
||||
METHOD_NOT_SUPPORTED(405, "不支持当前请求方法"), |
||||
MEDIA_TYPE_NOT_SUPPORTED(415, "不支持当前媒体类型"), |
||||
REQ_REJECT(403, "请求被拒绝"), |
||||
INTERNAL_SERVER_ERROR(500, "请求未完成,请联系管理员"), |
||||
PARAM_MISS(400, "缺少必要的请求参数"), |
||||
PARAM_TYPE_ERROR(400, "请求参数类型错误"), |
||||
PARAM_BIND_ERROR(400, "请求参数绑定错误"), |
||||
PARAM_VALID_ERROR(400, "参数校验失败"); |
||||
|
||||
final int code; |
||||
final String message; |
||||
|
||||
@Generated |
||||
public int getCode() { |
||||
return this.code; |
||||
} |
||||
|
||||
@Generated |
||||
public String getMessage() { |
||||
return this.message; |
||||
} |
||||
|
||||
@Generated |
||||
private ResultCode(final int code, final String message) { |
||||
this.code = code; |
||||
this.message = message; |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,9 @@ |
||||
package com.nov.KgLowDurable.exception; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public interface IResultCode extends Serializable { |
||||
String getMessage(); |
||||
|
||||
int getCode(); |
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
package com.nov.KgLowDurable.exception; |
||||
|
||||
import com.nov.KgLowDurable.enums.ResultCode; |
||||
import lombok.Generated; |
||||
|
||||
public class ServiceException extends RuntimeException { |
||||
private static final long serialVersionUID = 2359767895161832954L; |
||||
private final IResultCode resultCode; |
||||
|
||||
public ServiceException(String message) { |
||||
super(message); |
||||
this.resultCode = ResultCode.FAILURE; |
||||
} |
||||
|
||||
public ServiceException(IResultCode resultCode) { |
||||
super(resultCode.getMessage()); |
||||
this.resultCode = resultCode; |
||||
} |
||||
|
||||
public ServiceException(IResultCode resultCode, Throwable cause) { |
||||
super(cause); |
||||
this.resultCode = resultCode; |
||||
} |
||||
|
||||
public Throwable fillInStackTrace() { |
||||
return this; |
||||
} |
||||
|
||||
public Throwable doFillInStackTrace() { |
||||
return super.fillInStackTrace(); |
||||
} |
||||
|
||||
@Generated |
||||
public IResultCode getResultCode() { |
||||
return this.resultCode; |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,38 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenu; |
||||
|
||||
/** |
||||
* 顶部菜单表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
public interface TopMenuMapper extends BaseMapper<TopMenu> { |
||||
|
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenuSetting; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface TopMenuSettingMapper extends BaseMapper<TopMenuSetting> { |
||||
|
||||
} |
||||
@ -0,0 +1,73 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.nov.KgLowDurable.annotation.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 顶部菜单表实体类 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
@Data |
||||
@TableName("blade_top_menu") |
||||
@Schema(description = "顶部菜单表") |
||||
public class TopMenu implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 顶部菜单编号 |
||||
*/ |
||||
@Schema(description = "顶部菜单编号") |
||||
private String code; |
||||
/** |
||||
* 顶部菜单名 |
||||
*/ |
||||
@Schema(description = "顶部菜单名") |
||||
private String name; |
||||
/** |
||||
* 顶部菜单资源 |
||||
*/ |
||||
@Schema(description = "顶部菜单资源") |
||||
private String source; |
||||
/** |
||||
* 顶部菜单路由 |
||||
*/ |
||||
@Schema(description = "顶部菜单路由") |
||||
private String path; |
||||
/** |
||||
* 顶部菜单排序 |
||||
*/ |
||||
@Schema(description = "顶部菜单排序") |
||||
private Integer sort; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
package com.nov.KgLowDurable.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* TopMenuSetting |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("blade_top_menu_setting") |
||||
public class TopMenuSetting { |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 顶部菜单id |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long topMenuId; |
||||
|
||||
/** |
||||
* 菜单id |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long menuId; |
||||
|
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
package com.nov.KgLowDurable.pojo.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class CheckedTreeVO { |
||||
|
||||
private List<String> menu; |
||||
|
||||
private List<String> dataScope; |
||||
|
||||
private List<String> apiScope; |
||||
|
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
package com.nov.KgLowDurable.pojo.vo; |
||||
|
||||
import com.nov.KgLowDurable.common.TreeNode; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class GrantTreeVO implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private List<TreeNode> menu; |
||||
|
||||
private List<TreeNode> dataScope; |
||||
|
||||
private List<TreeNode> apiScope; |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,28 @@ |
||||
package com.nov.KgLowDurable.pojo.vo; |
||||
|
||||
import com.nov.KgLowDurable.annotation.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class GrantVO implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@Schema(description = "roleIds集合") |
||||
private List<Long> roleIds; |
||||
|
||||
@Schema(description = "menuIds集合") |
||||
private List<Long> menuIds; |
||||
|
||||
@Schema(description = "topMenuIds集合") |
||||
private List<Long> topMenuIds; |
||||
|
||||
@Schema(description = "dataScopeIds集合") |
||||
private List<Long> dataScopeIds; |
||||
|
||||
@Schema(description = "apiScopeIds集合") |
||||
private List<Long> apiScopeIds; |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenu; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 顶部菜单表 服务类 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
public interface ITopMenuService extends IService<TopMenu> { |
||||
|
||||
/** |
||||
* 顶部菜单配置 |
||||
* |
||||
* @param topMenuIds 顶部菜单id集合 |
||||
* @param menuIds 菜单id集合 |
||||
* @return 是否成功 |
||||
*/ |
||||
boolean grant(List<Long> topMenuIds, List<Long> menuIds); |
||||
|
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenuSetting; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ITopMenuSettingService extends IService<TopMenuSetting> { |
||||
|
||||
} |
||||
@ -0,0 +1,73 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.service.Impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.nov.KgLowDurable.annotation.NotEmpty; |
||||
import com.nov.KgLowDurable.mapper.TopMenuMapper; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenu; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenuSetting; |
||||
import com.nov.KgLowDurable.service.ITopMenuService; |
||||
import com.nov.KgLowDurable.service.ITopMenuSettingService; |
||||
import lombok.AllArgsConstructor; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 顶部菜单表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
*/ |
||||
//@Master
|
||||
@Service |
||||
@AllArgsConstructor |
||||
public class TopMenuServiceImpl extends ServiceImpl<TopMenuMapper, TopMenu> implements ITopMenuService { |
||||
|
||||
private final ITopMenuSettingService topMenuSettingService; |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public boolean grant(@NotEmpty List<Long> topMenuIds, @NotEmpty List<Long> menuIds) { |
||||
// 删除顶部菜单配置的菜单集合
|
||||
topMenuSettingService.remove(Wrappers.<TopMenuSetting>update().lambda().in(TopMenuSetting::getTopMenuId, topMenuIds)); |
||||
// 组装配置
|
||||
List<TopMenuSetting> menuSettings = new ArrayList<>(); |
||||
topMenuIds.forEach(topMenuId -> menuIds.forEach(menuId -> { |
||||
TopMenuSetting menuSetting = new TopMenuSetting(); |
||||
menuSetting.setTopMenuId(topMenuId); |
||||
menuSetting.setMenuId(menuId); |
||||
menuSettings.add(menuSetting); |
||||
})); |
||||
// 新增配置
|
||||
topMenuSettingService.saveBatch(menuSettings); |
||||
return true; |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@ |
||||
/** |
||||
* BladeX Commercial License Agreement |
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p> |
||||
* Use of this software is governed by the Commercial License Agreement |
||||
* obtained after purchasing a license from BladeX. |
||||
* <p> |
||||
* 1. This software is for development use only under a valid license |
||||
* from BladeX. |
||||
* <p> |
||||
* 2. Redistribution of this software's source code to any third party |
||||
* without a commercial license is strictly prohibited. |
||||
* <p> |
||||
* 3. Licensees may copyright their own code but cannot use segments |
||||
* from this software for such purposes. Copyright of this software |
||||
* remains with BladeX. |
||||
* <p> |
||||
* Using this software signifies agreement to this License, and the software |
||||
* must not be used for illegal purposes. |
||||
* <p> |
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
||||
* not liable for any claims arising from secondary or illegal development. |
||||
* <p> |
||||
* Author: Chill Zhuang (bladejava@qq.com) |
||||
*/ |
||||
package com.nov.KgLowDurable.service.Impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.nov.KgLowDurable.mapper.TopMenuSettingMapper; |
||||
import com.nov.KgLowDurable.pojo.entity.TopMenuSetting; |
||||
import com.nov.KgLowDurable.service.ITopMenuSettingService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
//@Master
|
||||
@Service |
||||
public class TopMenuSettingServiceImpl extends ServiceImpl<TopMenuSettingMapper, TopMenuSetting> implements ITopMenuSettingService { |
||||
|
||||
} |
||||
@ -0,0 +1,22 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.nov.KgLowDurable.mapper.TopMenuMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="topMenuResultMap" type="com.nov.KgLowDurable.pojo.entity.TopMenu"> |
||||
<!-- <result column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_dept" property="createDept"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/>--> |
||||
<result column="code" property="code"/> |
||||
<result column="name" property="name"/> |
||||
<result column="source" property="source"/> |
||||
<result column="path" property="path"/> |
||||
<result column="sort" property="sort"/> |
||||
</resultMap> |
||||
|
||||
</mapper> |
||||
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.nov.KgLowDurable.mapper.TopMenuSettingMapper"> |
||||
|
||||
</mapper> |
||||
Loading…
Reference in new issue