review code.

This commit is contained in:
lijiahang
2023-09-14 17:26:24 +08:00
parent a210fb93fd
commit 1665820459
17 changed files with 31 additions and 40 deletions

View File

@@ -56,6 +56,7 @@
import { create${vue.featureFirstUpper}, update${vue.featureFirstUpper} } from '@/api/${vue.module}/${vue.feature}';
import { Message } from '@arco-design/web-vue';
import { } from '../types/enum.types';
import { } from '../types/const';
import { toOptions } from '@/utils/enum';
const { visible, setVisible } = useVisible();

View File

@@ -116,6 +116,7 @@
import columns from '../types/table.columns';
import { defaultPagination, defaultRowSelection } from '@/types/table';
import { } from '../types/enum.types';
import { } from '../types/const';
import { toOptions } from '@/utils/enum';
const tableRenderData = ref<${vue.featureFirstUpper}QueryResponse[]>();

View File

@@ -114,7 +114,7 @@ public class HostController {
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/get-config-all")
@Operation(summary = "查询主机配置-全部")
@Operation(summary = "查询主机配置 - 全部")
@Parameter(name = "hostId", description = "hostId", required = true)
@PreAuthorize("@ss.hasPermission('asset:host:query')")
public List<HostConfigVO> getHostConfig(@RequestParam("hostId") Long hostId) {

View File

@@ -40,6 +40,7 @@ public class HostCreateRequest implements Serializable {
@Schema(description = "主机地址")
private String address;
@Size(max = 5)
@Schema(description = "tags")
private List<Long> tags;

View File

@@ -45,6 +45,7 @@ public class HostUpdateRequest implements Serializable {
@Schema(description = "主机地址")
private String address;
@Size(max = 5)
@Schema(description = "tags")
private List<Long> tags;

View File

@@ -1,5 +1,6 @@
package com.orion.ops.module.asset.entity.vo;
import com.orion.ops.module.infra.entity.dto.tag.TagDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -8,6 +9,7 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@@ -54,7 +56,7 @@ public class HostVO implements Serializable {
private Boolean favorite;
@Schema(description = "tags")
private Map<Long, String> tags;
private List<TagDTO> tags;
@Schema(description = "configs")
private Map<String, HostConfigVO> configs;

View File

@@ -31,7 +31,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -306,18 +305,7 @@ public class HostServiceImpl implements HostService {
List<List<TagDTO>> tagList = null;
if (tagsFuture != null && (tagList = tagsFuture.get()) != null) {
for (int i = 0; i < hosts.size(); i++) {
List<TagDTO> tags = tagList.get(i);
if (Lists.isEmpty(tags)) {
continue;
}
Map<Long, String> tagMap = tags.stream()
.collect(Collectors.toMap(
TagDTO::getId,
TagDTO::getName,
(v1, v2) -> v2,
LinkedHashMap::new
));
hosts.get(i).setTags(tagMap);
hosts.get(i).setTags(tagList.get(i));
}
}
// 设置收藏信息

View File

@@ -5,7 +5,7 @@ import com.orion.ops.framework.common.annotation.IgnoreLog;
import com.orion.ops.framework.common.annotation.RestWrapper;
import com.orion.ops.framework.common.constant.IgnoreLogMode;
import com.orion.ops.framework.common.valid.group.Page;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleBindMenuRequest;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleGrantMenuRequest;
import com.orion.ops.module.infra.entity.request.role.SystemRoleCreateRequest;
import com.orion.ops.module.infra.entity.request.role.SystemRoleQueryRequest;
import com.orion.ops.module.infra.entity.request.role.SystemRoleStatusRequest;
@@ -107,11 +107,11 @@ public class SystemRoleController {
return systemRoleService.deleteSystemRoleById(id);
}
@PutMapping("/bind")
@PutMapping("/grant-menu")
@Operation(summary = "绑定角色菜单")
@PreAuthorize("@ss.hasPermission('infra:system-role:bind-menu')")
public Integer bindRoleMenu(@RequestBody SystemRoleBindMenuRequest request) {
return systemRoleMenuService.bindRoleMenu(request);
@PreAuthorize("@ss.hasPermission('infra:system-role:grant-menu')")
public Integer grantRoleMenu(@RequestBody SystemRoleGrantMenuRequest request) {
return systemRoleMenuService.grantRoleMenu(request);
}
}

View File

@@ -68,9 +68,9 @@ public class SystemUserController {
return systemUserService.updateUserStatus(request);
}
@PutMapping("/update-role")
@Operation(summary = "修改用户角色")
@PreAuthorize("@ss.hasPermission('infra:system-user:update-role')")
@PutMapping("/grant-role")
@Operation(summary = "分配用户角色")
@PreAuthorize("@ss.hasPermission('infra:system-user:grant-role')")
public Integer updateUserRole(@Validated @RequestBody SystemUserUpdateRoleRequest request) {
if (Lists.isEmpty(request.getRoleIdList())) {
// 删除用户角色

View File

@@ -10,7 +10,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -37,25 +36,22 @@ public class TagController {
private TagService tagService;
@PostMapping("/create")
@Operation(summary = "创建标签枚举")
@PreAuthorize("@ss.hasPermission('infra:tag:create')")
@Operation(summary = "创建标签")
public Long createTag(@Validated @RequestBody TagCreateRequest request) {
return tagService.createTag(request);
}
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/list")
@Operation(summary = "查询标签枚举")
@Operation(summary = "查询标签")
@Parameter(name = "type", description = "type", required = true)
@PreAuthorize("@ss.hasPermission('infra:tag:query')")
public List<TagVO> getTagListAll(@RequestParam("type") String type) {
return tagService.getTagList(type);
}
@DeleteMapping("/delete")
@Operation(summary = "通过 id 删除标签枚举")
@Operation(summary = "通过 id 删除标签")
@Parameter(name = "id", description = "id", required = true)
@PreAuthorize("@ss.hasPermission('infra:tag:delete')")
public Integer deleteTag(@RequestParam("id") Long id) {
return tagService.deleteTagById(id);
}

View File

@@ -24,6 +24,7 @@ public interface TagRelConvert {
TagRelDO to(TagRelQueryRequest request);
@Mapping(target = "name", source = "tagName")
@Mapping(target = "id", source = "tagId")
TagCacheDTO toCache(TagRelDO domain);
List<TagCacheDTO> toCacheList(List<TagRelDO> list);

View File

@@ -22,8 +22,8 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemRoleBindMenuRequest", description = "角色 绑定菜单请求对象")
public class SystemRoleBindMenuRequest implements Serializable {
@Schema(name = "SystemRoleGrantMenuRequest", description = "角色 绑定菜单请求对象")
public class SystemRoleGrantMenuRequest implements Serializable {
@NotNull
@Schema(description = "roleId")

View File

@@ -1,6 +1,6 @@
package com.orion.ops.module.infra.service;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleBindMenuRequest;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleGrantMenuRequest;
import java.util.List;
@@ -14,12 +14,12 @@ import java.util.List;
public interface SystemRoleMenuService {
/**
* 绑定角色菜单
* 分配角色菜单
*
* @param request request
* @return effect
*/
Integer bindRoleMenu(SystemRoleBindMenuRequest request);
Integer grantRoleMenu(SystemRoleGrantMenuRequest request);
/**
* 获取角色菜单 id

View File

@@ -68,7 +68,7 @@ public class FavoriteServiceImpl implements FavoriteService {
int effect = favoriteDAO.deleteFavorite(type, userId, relId);
// 删除缓存
String key = FavoriteCacheKeyDefine.FAVORITE.format(type, userId);
redisTemplate.opsForList().remove(key, 1, relId);
redisTemplate.opsForList().remove(key, 1, relId.toString());
return effect;
}

View File

@@ -14,7 +14,7 @@ import com.orion.ops.module.infra.entity.domain.SystemMenuDO;
import com.orion.ops.module.infra.entity.domain.SystemRoleDO;
import com.orion.ops.module.infra.entity.domain.SystemRoleMenuDO;
import com.orion.ops.module.infra.entity.dto.SystemMenuCacheDTO;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleBindMenuRequest;
import com.orion.ops.module.infra.entity.request.menu.SystemRoleGrantMenuRequest;
import com.orion.ops.module.infra.service.PermissionService;
import com.orion.ops.module.infra.service.SystemRoleMenuService;
import lombok.extern.slf4j.Slf4j;
@@ -52,7 +52,7 @@ public class SystemRoleMenuServiceImpl implements SystemRoleMenuService {
@Override
@Transactional(rollbackFor = Exception.class)
public Integer bindRoleMenu(SystemRoleBindMenuRequest request) {
public Integer grantRoleMenu(SystemRoleGrantMenuRequest request) {
Long roleId = request.getRoleId();
List<Long> menuIdList = request.getMenuIdList();
// 检查角色是否存在

View File

@@ -20,7 +20,7 @@ INSERT INTO `system_menu` VALUES (20, 10, '创建角色', 'infra:system-role:cre
INSERT INTO `system_menu` VALUES (21, 10, '修改角色', 'infra:system-role:update', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:37:33', '2023-08-15 16:42:08', '1', '1', 0);
INSERT INTO `system_menu` VALUES (22, 10, '更新状态', 'infra:system-role:update-status', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:37:58', '2023-08-15 16:37:58', '1', '1', 0);
INSERT INTO `system_menu` VALUES (23, 10, '查询角色', 'infra:system-role:query', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:38:26', '2023-08-16 16:58:22', '1', '1', 0);
INSERT INTO `system_menu` VALUES (24, 10, '绑定菜单', 'infra:system-role:bind-menu', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:39:41', '2023-08-15 16:39:41', '1', '1', 0);
INSERT INTO `system_menu` VALUES (24, 10, '分配菜单', 'infra:system-role:grant-menu', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:39:41', '2023-08-15 16:39:41', '1', '1', 0);
INSERT INTO `system_menu` VALUES (25, 10, '删除角色', 'infra:system-role:delete', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:40:45', '2023-08-15 16:40:45', '1', '1', 0);
INSERT INTO `system_menu` VALUES (26, 13, '创建菜单', 'infra:system-menu:create', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:41:30', '2023-08-15 16:41:30', '1', '1', 0);
INSERT INTO `system_menu` VALUES (27, 13, '修改菜单', 'infra:system-menu:update', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-15 16:41:55', '2023-08-15 16:41:55', '1', '1', 0);
@@ -34,6 +34,6 @@ INSERT INTO `system_menu` VALUES (51, 48, '查询用户', 'infra:system-user:que
INSERT INTO `system_menu` VALUES (52, 48, '删除用户', 'infra:system-user:delete', 3, 40, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 10:19:24', '2023-08-16 10:19:24', NULL, NULL, 0);
INSERT INTO `system_menu` VALUES (53, 13, '初始化缓存', 'infra:system-menu:init-cache', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 10:29:10', '2023-08-16 10:29:10', '1', '1', 0);
INSERT INTO `system_menu` VALUES (60, 48, '修改用户状态', 'infra:system-user:update-status', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 11:49:04', '2023-08-16 11:49:04', '1', '1', 0);
INSERT INTO `system_menu` VALUES (61, 48, '修改用户角色', 'infra:system-user:update-role', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 11:49:23', '2023-08-16 11:49:23', '1', '1', 0);
INSERT INTO `system_menu` VALUES (61, 48, '分配用户角色', 'infra:system-user:grant-role', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 11:49:23', '2023-08-16 11:49:23', '1', '1', 0);
INSERT INTO `system_menu` VALUES (62, 48, '重置用户密码', 'infra:system-user:reset-password', 3, 10, 1, 1, 1, NULL, NULL, NULL, '2023-08-16 11:49:50', '2023-08-16 11:49:50', '1', '1', 0);