From b9903e936463b721ebbcf8656a86a3a9702728b3 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:38:13 +0800 Subject: [PATCH] add color and alias name with UserFavoriteMenu --- apps/vue/package.json | 1 + .../src/locales/lang/en/routes/dashboard.ts | 3 +- .../locales/lang/zh-CN/routes/dashboard.ts | 3 +- apps/vue/src/main.ts | 2 +- .../workbench/components/MenuReference.vue | 26 +- .../Menus/Dto/UserFavoriteMenuCreateDto.cs | 13 + .../Dto/UserFavoriteMenuCreateOrUpdateDto.cs | 20 + .../Platform/Menus/Dto/UserFavoriteMenuDto.cs | 4 + .../Menus/Dto/UserFavoriteMenuRemoveInput.cs | 9 + .../Menus/Dto/UserFavoriteMenuSetInput.cs | 11 - .../Menus/Dto/UserFavoriteMenuUpdateDto.cs | 9 + .../LINGYUN/Platform/Menus/IMenuAppService.cs | 8 - .../Menus/IUserFavoriteMenuAppService.cs | 25 + .../PlatformPermissionDefinitionProvider.cs | 18 - .../LINGYUN/Platform/Menus/MenuAppService.cs | 73 -- .../Menus/UserFavoriteMenuAppService.cs | 172 ++++ .../Platform/Menus/UserFavoriteMenuConsts.cs | 9 + .../LINGYUN/Platform/PlatformErrorCodes.cs | 8 + .../Platform/Routes/UserFavoriteMenuConsts.cs | 5 - .../Menus/IUserFavoriteMenuRepository.cs | 17 +- .../Platform/Menus/UserFavoriteMenu.cs | 22 +- ...PlatformDbContextModelBuilderExtensions.cs | 10 +- .../Menus/EfCoreUserFavoriteMenuRepository.cs | 22 + .../LINGYUN/Platform/Menus/MenuController.cs | 28 - .../Menus/UserFavoriteMenuController.cs | 78 ++ ...liasName-With-UserFavoriteMenu.Designer.cs | 751 ++++++++++++++++++ ...lor-And-AliasName-With-UserFavoriteMenu.cs | 71 ++ ...ApiHostMigrationsDbContextModelSnapshot.cs | 11 + ...rmManagementHttpApiHostModule.Configure.cs | 2 +- 29 files changed, 1269 insertions(+), 162 deletions(-) create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateOrUpdateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuRemoveInput.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuSetInput.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuUpdateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IUserFavoriteMenuAppService.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/UserFavoriteMenuAppService.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/UserFavoriteMenuConsts.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserFavoriteMenuConsts.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/UserFavoriteMenuController.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.cs diff --git a/apps/vue/package.json b/apps/vue/package.json index fc116b104..49842c7c6 100644 --- a/apps/vue/package.json +++ b/apps/vue/package.json @@ -75,6 +75,7 @@ "vue-json-pretty": "^2.0.6", "vue-router": "^4.0.14", "vue-types": "^4.1.1", + "vue3-colorpicker": "^2.0.4", "xlsx": "^0.18.5" }, "devDependencies": { diff --git a/apps/vue/src/locales/lang/en/routes/dashboard.ts b/apps/vue/src/locales/lang/en/routes/dashboard.ts index 0a6f098f4..99906a368 100644 --- a/apps/vue/src/locales/lang/en/routes/dashboard.ts +++ b/apps/vue/src/locales/lang/en/routes/dashboard.ts @@ -18,7 +18,8 @@ export default { more: 'More', addMenu: 'Add new menu', manager: 'Manage menu', - selectMenu: '选择菜单' + selectMenu: 'Select menu', + selectColor: 'Select color' } }, analysis: 'Analysis', diff --git a/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts b/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts index f23b9bf4e..962fb1a57 100644 --- a/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts +++ b/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts @@ -18,7 +18,8 @@ export default { more: '更多', addMenu: '添加菜单', manager: '管理菜单', - selectMenu: '选择菜单' + selectMenu: '选择菜单', + selectColor: '选择颜色' } }, analysis: '分析页', diff --git a/apps/vue/src/main.ts b/apps/vue/src/main.ts index 844d144f4..aad76baf8 100644 --- a/apps/vue/src/main.ts +++ b/apps/vue/src/main.ts @@ -6,7 +6,7 @@ import 'virtual:windi-utilities.css'; import 'virtual:svg-icons-register'; import App from './App.vue'; import Antd from 'ant-design-vue'; -import VueCookies from 'vue-cookies' +import VueCookies from 'vue-cookies'; import { createApp } from 'vue'; import { initAppConfigStore, initAbpConfigStore } from '/@/logics/initAppConfig'; import { setupErrorHandle } from '/@/logics/error-handle'; diff --git a/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue b/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue index a325098df..24ed43e9b 100644 --- a/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue +++ b/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue @@ -7,10 +7,15 @@ @ok="handleSubmit" >
+ + + ({{ formModel.color }}) + - + @check="handleMenuCheck" + > + +
@@ -28,15 +38,20 @@ import { reactive, ref, unref } from 'vue'; import { useI18n } from '/@/hooks/web/useI18n'; import { Form, Tree } from 'ant-design-vue'; + import { ColorPicker } from "vue3-colorpicker"; + import { Icon } from '/@/components/Icon'; import { BasicModal, useModalInner } from '/@/components/Modal'; import { getMenuList } from '/@/api/sys/menu'; import { listToTree } from '/@/utils/helper/treeHelper'; - const ATree = Tree; + const VTree = Tree; + const VColorPicker = ColorPicker; + const VIcon = Icon; const emits = defineEmits(['change', 'change:keys', 'register']); const { t } = useI18n(); const formModel = reactive({ + color: '#000000', menus: [] as string[], }); const formElRef = ref(null); @@ -50,6 +65,7 @@ }); function init(props) { + formModel.color = '#000000'; formModel.menus = []; checkedMenus.value = []; radio.value = props.radio ?? false; @@ -81,6 +97,6 @@ } - \ No newline at end of file diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateDto.cs new file mode 100644 index 000000000..7326d0268 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateDto.cs @@ -0,0 +1,13 @@ +using LINGYUN.Platform.Routes; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Menus; + +public class UserFavoriteMenuCreateDto : UserFavoriteMenuCreateOrUpdateDto +{ + [Required] + [DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))] + + public string Framework { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateOrUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateOrUpdateDto.cs new file mode 100644 index 000000000..3814d0de5 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuCreateOrUpdateDto.cs @@ -0,0 +1,20 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Menus; + +public abstract class UserFavoriteMenuCreateOrUpdateDto +{ + [Required] + public Guid MenuId { get; set; } + + [DynamicStringLength(typeof(UserFavoriteMenuConsts), nameof(UserFavoriteMenuConsts.MaxColorLength))] + public string Color { get; set; } + + [DynamicStringLength(typeof(UserFavoriteMenuConsts), nameof(UserFavoriteMenuConsts.MaxAliasNameLength))] + public string AliasName { get; set; } + + [DynamicStringLength(typeof(UserFavoriteMenuConsts), nameof(UserFavoriteMenuConsts.MaxIconLength))] + public string Icon { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuDto.cs index 9e2df64e8..7087df150 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuDto.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuDto.cs @@ -9,6 +9,10 @@ public class UserFavoriteMenuDto : AuditedEntityDto public Guid UserId { get; set; } + public string AliasName { get; set; } + + public string Color { get; set; } + public string Framework { get; set; } public string Name { get; set; } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuRemoveInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuRemoveInput.cs new file mode 100644 index 000000000..0679ac8e1 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuRemoveInput.cs @@ -0,0 +1,9 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Platform.Menus; +public class UserFavoriteMenuRemoveInput +{ + [Required] + public Guid MenuId { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuSetInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuSetInput.cs deleted file mode 100644 index d5cdea3e5..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuSetInput.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace LINGYUN.Platform.Menus; - -public class UserFavoriteMenuSetInput -{ - public string Framework { get; set; } - - public List MenuIds { get; set; } = new List(); -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuUpdateDto.cs new file mode 100644 index 000000000..90a0e702d --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuUpdateDto.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Domain.Entities; + +namespace LINGYUN.Platform.Menus; + +public class UserFavoriteMenuUpdateDto : UserFavoriteMenuCreateOrUpdateDto, IHasConcurrencyStamp +{ + + public string ConcurrencyStamp { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IMenuAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IMenuAppService.cs index 9a701e54b..4adf49ba8 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IMenuAppService.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IMenuAppService.cs @@ -23,18 +23,10 @@ namespace LINGYUN.Platform.Menus Task SetUserStartupAsync(Guid id, UserMenuStartupInput input); - Task SetUserFavoriteMenusAsync(Guid userId, UserFavoriteMenuSetInput input); - Task SetRoleMenusAsync(RoleMenuInput input); Task SetRoleStartupAsync(Guid id, RoleMenuStartupInput input); Task> GetCurrentUserMenuListAsync(GetMenuInput input); - - Task SetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuSetInput input); - - Task> GetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuGetListInput input); - - Task> GetUserFavoriteMenuListAsync(Guid userId, UserFavoriteMenuGetListInput input); } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IUserFavoriteMenuAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IUserFavoriteMenuAppService.cs new file mode 100644 index 000000000..aa914ca1f --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/IUserFavoriteMenuAppService.cs @@ -0,0 +1,25 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Platform.Menus; + +public interface IUserFavoriteMenuAppService : IApplicationService +{ + Task CreateAsync(Guid userId, UserFavoriteMenuCreateDto input); + + Task CreateMyFavoriteMenuAsync(UserFavoriteMenuCreateDto input); + + Task UpdateAsync(Guid userId, UserFavoriteMenuUpdateDto input); + + Task UpdateMyFavoriteMenuAsync(UserFavoriteMenuUpdateDto input); + + Task DeleteAsync(Guid userId, UserFavoriteMenuRemoveInput input); + + Task DeleteMyFavoriteMenuAsync(UserFavoriteMenuRemoveInput input); + + Task> GetMyFavoriteMenuListAsync(UserFavoriteMenuGetListInput input); + + Task> GetListAsync(Guid userId, UserFavoriteMenuGetListInput input); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs index be0a2b27e..719bf2240 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs @@ -38,24 +38,6 @@ namespace LINGYUN.Platform.Permissions menu.AddChild(PlatformPermissions.Menu.ManageRoles, L("Permission:ManageRoleMenus")); menu.AddChild(PlatformPermissions.Menu.ManageUsers, L("Permission:ManageUserMenus")); menu.AddChild(PlatformPermissions.Menu.ManageUserFavorites, L("Permission:ManageUserFavoriteMenus")); - - - // TODO: 2020-07-27 目前abp不支持对象存储管理(或者属于企业版?)需要创建一个 LINGYUN.Abp.BlobStoring 项目自行实现 - - //var fileSystem = platform.AddPermission(PlatformPermissions.FileSystem.Default, L("Permission:FileSystem")); - //fileSystem.AddChild(PlatformPermissions.FileSystem.Create, L("Permission:CreateFolder")); - //fileSystem.AddChild(PlatformPermissions.FileSystem.Delete, L("Permission:DeleteFolder")); - //fileSystem.AddChild(PlatformPermissions.FileSystem.Rename, L("Permission:RenameFolder")); - //fileSystem.AddChild(PlatformPermissions.FileSystem.Copy, L("Permission:CopyFolder")); - //fileSystem.AddChild(PlatformPermissions.FileSystem.Move, L("Permission:MoveFolder")); - - //var fileManager = fileSystem.AddChild(PlatformPermissions.FileSystem.FileManager.Default, L("Permission:FileManager")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Create, L("Permission:AppendFile")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Update, L("Permission:UpdateFile")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Delete, L("Permission:DeleteFile")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Copy, L("Permission:CopyFile")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Move, L("Permission:MoveFile")); - //fileManager.AddChild(PlatformPermissions.FileSystem.FileManager.Download, L("Permission:DownloadFile")); } private static LocalizableString L(string name) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs index ad51910b0..4db785ea5 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs @@ -17,13 +17,10 @@ namespace LINGYUN.Platform.Menus [Authorize] public class MenuAppService : PlatformApplicationServiceBase, IMenuAppService { - protected IStandardMenuConverter StandardMenuConverter => LazyServiceProvider.LazyGetRequiredService(); - protected DataItemMappingOptions DataItemMapping { get; } protected MenuManager MenuManager { get; } protected IMenuRepository MenuRepository { get; } protected IUserMenuRepository UserMenuRepository { get; } - protected IUserFavoriteMenuRepository UserFavoriteMenuRepository { get; } protected IRoleMenuRepository RoleMenuRepository { get; } protected IDataRepository DataRepository { get; } protected ILayoutRepository LayoutRepository { get; } @@ -35,7 +32,6 @@ namespace LINGYUN.Platform.Menus ILayoutRepository layoutRepository, IUserMenuRepository userMenuRepository, IRoleMenuRepository roleMenuRepository, - IUserFavoriteMenuRepository userFavoriteMenuRepository, IOptions options) { MenuManager = menuManager; @@ -44,7 +40,6 @@ namespace LINGYUN.Platform.Menus LayoutRepository = layoutRepository; UserMenuRepository = userMenuRepository; RoleMenuRepository = roleMenuRepository; - UserFavoriteMenuRepository = userFavoriteMenuRepository; DataItemMapping = options.Value; } @@ -310,73 +305,5 @@ namespace LINGYUN.Platform.Menus return new ListResultDto(menuDtos); } - - [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] - public async virtual Task SetUserFavoriteMenusAsync(Guid userId, UserFavoriteMenuSetInput input) - { - await SetUserFavoriteMenuListAsync(userId, input); - } - - public async virtual Task SetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuSetInput input) - { - await SetUserFavoriteMenuListAsync(CurrentUser.GetId(), input); - } - - [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] - public async virtual Task> GetUserFavoriteMenuListAsync(Guid userId, UserFavoriteMenuGetListInput input) - { - var userFacoriteMenus = await UserFavoriteMenuRepository.GetFavoriteMenusAsync( - userId, input.Framework); - - return new ListResultDto( - ObjectMapper.Map, List>(userFacoriteMenus)); - } - - public async virtual Task> GetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuGetListInput input) - { - var userFacoriteMenus = await UserFavoriteMenuRepository.GetFavoriteMenusAsync( - CurrentUser.GetId(), input.Framework); - - return new ListResultDto( - ObjectMapper.Map, List>(userFacoriteMenus)); - } - - protected async virtual Task SetUserFavoriteMenuListAsync(Guid userId, UserFavoriteMenuSetInput input) - { - var userFacoriteMenus = await UserFavoriteMenuRepository.GetFavoriteMenusAsync( - userId, input.Framework); - - var wellDeleteMenus = userFacoriteMenus.Where(um => !input.MenuIds.Any(id => id == um.MenuId)); - var wellInsertMenus = input.MenuIds.Where(id => !userFacoriteMenus.Any(um => um.MenuId == id)); - - if (wellInsertMenus.Any()) - { - var insertMenus = new List(); - var menus = await MenuRepository.GetListAsync(wellInsertMenus.Select(id => id)); - - foreach (var menu in menus) - { - var standardMenu = StandardMenuConverter.Convert(menu); - - insertMenus.Add( - new UserFavoriteMenu( - GuidGenerator.Create(), - menu.Id, - userId, - menu.Framework, - standardMenu.Name, - standardMenu.DisplayName, - standardMenu.Path, - standardMenu.Icon, - CurrentTenant.Id)); - } - - await UserFavoriteMenuRepository.InsertManyAsync(insertMenus); - } - - await UserFavoriteMenuRepository.DeleteManyAsync(wellDeleteMenus); - - await CurrentUnitOfWork.SaveChangesAsync(); - } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/UserFavoriteMenuAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/UserFavoriteMenuAppService.cs new file mode 100644 index 000000000..2aac9e760 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/UserFavoriteMenuAppService.cs @@ -0,0 +1,172 @@ +using LINGYUN.Platform.Permissions; +using Microsoft.AspNetCore.Authorization; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Users; + +namespace LINGYUN.Platform.Menus; + +[Authorize] +public class UserFavoriteMenuAppService : PlatformApplicationServiceBase, IUserFavoriteMenuAppService +{ + protected IStandardMenuConverter StandardMenuConverter => LazyServiceProvider.LazyGetRequiredService(); + protected IMenuRepository MenuRepository { get; } + protected IUserFavoriteMenuRepository UserFavoriteMenuRepository { get; } + + public UserFavoriteMenuAppService( + IMenuRepository menuRepository, + IUserFavoriteMenuRepository userFavoriteMenuRepository) + { + MenuRepository = menuRepository; + UserFavoriteMenuRepository = userFavoriteMenuRepository; + } + + [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] + public async virtual Task CreateAsync(Guid userId, UserFavoriteMenuCreateDto input) + { + if (!await UserFavoriteMenuRepository.CheckExistsAsync(input.Framework, userId, input.MenuId)) + { + throw new BusinessException(PlatformErrorCodes.UserDuplicateFavoriteMenu); + } + + var menu = await MenuRepository.GetAsync(input.MenuId); + var standardMenu = StandardMenuConverter.Convert(menu); + var userFavoriteMenu = new UserFavoriteMenu( + GuidGenerator.Create(), + input.MenuId, + userId, + input.Framework, + standardMenu.Name, + standardMenu.DisplayName, + standardMenu.Path, + standardMenu.Icon, + input.Color, + input.AliasName, + CurrentTenant.Id); + + userFavoriteMenu = await UserFavoriteMenuRepository.InsertAsync(userFavoriteMenu); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(userFavoriteMenu); + } + + public async virtual Task CreateMyFavoriteMenuAsync(UserFavoriteMenuCreateDto input) + { + var userId = CurrentUser.GetId(); + if (!await UserFavoriteMenuRepository.CheckExistsAsync(input.Framework, userId, input.MenuId)) + { + throw new BusinessException(PlatformErrorCodes.UserDuplicateFavoriteMenu); + } + + var menu = await MenuRepository.GetAsync(input.MenuId); + var standardMenu = StandardMenuConverter.Convert(menu); + var userFavoriteMenu = new UserFavoriteMenu( + GuidGenerator.Create(), + input.MenuId, + userId, + input.Framework, + standardMenu.Name, + standardMenu.DisplayName, + standardMenu.Path, + standardMenu.Icon, + input.Color, + input.AliasName, + CurrentTenant.Id); + + userFavoriteMenu = await UserFavoriteMenuRepository.InsertAsync(userFavoriteMenu); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(userFavoriteMenu); + } + + [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] + public async virtual Task DeleteAsync(Guid userId, UserFavoriteMenuRemoveInput input) + { + var userFavoriteMenu = await GetUserMenuAsync(userId, input.MenuId); + + await UserFavoriteMenuRepository.DeleteAsync(userFavoriteMenu); + } + + public async virtual Task DeleteMyFavoriteMenuAsync(UserFavoriteMenuRemoveInput input) + { + var userFavoriteMenu = await GetUserMenuAsync(CurrentUser.GetId(), input.MenuId); + + await UserFavoriteMenuRepository.DeleteAsync(userFavoriteMenu); + } + + [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] + public async virtual Task> GetListAsync(Guid userId, UserFavoriteMenuGetListInput input) + { + var userFacoriteMenus = await UserFavoriteMenuRepository.GetFavoriteMenusAsync( + userId, input.Framework); + + return new ListResultDto( + ObjectMapper.Map, List>(userFacoriteMenus)); + } + + public async virtual Task> GetMyFavoriteMenuListAsync(UserFavoriteMenuGetListInput input) + { + var userFacoriteMenus = await UserFavoriteMenuRepository.GetFavoriteMenusAsync( + CurrentUser.GetId(), input.Framework); + + return new ListResultDto( + ObjectMapper.Map, List>(userFacoriteMenus)); + } + + [Authorize(PlatformPermissions.Menu.ManageUserFavorites)] + public async virtual Task UpdateAsync(Guid userId, UserFavoriteMenuUpdateDto input) + { + var userFavoriteMenu = await GetUserMenuAsync(userId, input.MenuId); + + UpdateByInput(userFavoriteMenu, input); + + userFavoriteMenu = await UserFavoriteMenuRepository.UpdateAsync(userFavoriteMenu); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(userFavoriteMenu); + } + + public async virtual Task UpdateMyFavoriteMenuAsync(UserFavoriteMenuUpdateDto input) + { + var userFavoriteMenu = await GetUserMenuAsync(CurrentUser.GetId(), input.MenuId); + + UpdateByInput(userFavoriteMenu, input); + + userFavoriteMenu = await UserFavoriteMenuRepository.UpdateAsync(userFavoriteMenu); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(userFavoriteMenu); + } + + protected async virtual Task GetUserMenuAsync(Guid userId, Guid menuId) + { + var userFavoriteMenu = await UserFavoriteMenuRepository.FindByUserMenuAsync(userId, menuId); + + return userFavoriteMenu ?? throw new BusinessException(PlatformErrorCodes.UserFavoriteMenuNotFound); + } + + protected virtual void UpdateByInput(UserFavoriteMenu userFavoriteMenu, UserFavoriteMenuCreateOrUpdateDto input) + { + if (!string.Equals(userFavoriteMenu.Color, input.Color, StringComparison.CurrentCultureIgnoreCase)) + { + userFavoriteMenu.Color = Check.Length(input.Color, nameof(UserFavoriteMenuCreateOrUpdateDto.Color), UserFavoriteMenuConsts.MaxColorLength); + } + + if (!string.Equals(userFavoriteMenu.AliasName, input.AliasName, StringComparison.CurrentCultureIgnoreCase)) + { + userFavoriteMenu.AliasName = Check.Length(input.AliasName, nameof(UserFavoriteMenuCreateOrUpdateDto.AliasName), UserFavoriteMenuConsts.MaxAliasNameLength); + } + + if (!string.Equals(userFavoriteMenu.Icon, input.Icon, StringComparison.CurrentCultureIgnoreCase)) + { + userFavoriteMenu.Icon = Check.Length(input.Icon, nameof(UserFavoriteMenuCreateOrUpdateDto.Icon), UserFavoriteMenuConsts.MaxIconLength); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/UserFavoriteMenuConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/UserFavoriteMenuConsts.cs new file mode 100644 index 000000000..cc109cd05 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/UserFavoriteMenuConsts.cs @@ -0,0 +1,9 @@ +using LINGYUN.Platform.Routes; + +namespace LINGYUN.Platform.Menus; +public class UserFavoriteMenuConsts +{ + public static int MaxIconLength { get; set; } = 512; + public static int MaxColorLength { get; set; } = 30; + public static int MaxAliasNameLength { get; set; } = RouteConsts.MaxDisplayNameLength; +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs index 42468aaf7..3c1e2cb01 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs @@ -25,5 +25,13 @@ /// 元数据格式不匹配 /// public const string MetaFormatMissMatch = Namespace + ":03001"; + /// + /// 用户重复收藏菜单 + /// + public const string UserDuplicateFavoriteMenu = Namespace + ":04400"; + /// + /// 用户收藏菜单未找到 + /// + public const string UserFavoriteMenuNotFound = Namespace + ":04404"; } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserFavoriteMenuConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserFavoriteMenuConsts.cs deleted file mode 100644 index 828d6b491..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserFavoriteMenuConsts.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace LINGYUN.Platform.Routes; -public class UserFavoriteMenuConsts -{ - public static int MaxIconLength { get; set; } = 512; -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserFavoriteMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserFavoriteMenuRepository.cs index d83ee4bce..31bf1d08f 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserFavoriteMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserFavoriteMenuRepository.cs @@ -8,13 +8,24 @@ namespace LINGYUN.Platform.Menus; public interface IUserFavoriteMenuRepository : IBasicRepository { + Task CheckExistsAsync( + string framework, + Guid userId, + Guid menuId, + CancellationToken cancellationToken = default); + + Task FindByUserMenuAsync( + Guid userId, + Guid menuId, + CancellationToken cancellationToken = default); + Task> GetListByMenuIdAsync( Guid menuId, CancellationToken cancellationToken = default); Task> GetFavoriteMenusAsync( - Guid userId, - string framework = null, - Guid? menuId = null, + Guid userId, + string framework = null, + Guid? menuId = null, CancellationToken cancellationToken = default); } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserFavoriteMenu.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserFavoriteMenu.cs index 2adfdbcdf..046345e8a 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserFavoriteMenu.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserFavoriteMenu.cs @@ -1,4 +1,6 @@ -using System; +using LINGYUN.Platform.Routes; +using System; +using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; @@ -12,6 +14,10 @@ public class UserFavoriteMenu : AuditedEntity, IMultiTenant public virtual Guid UserId { get; protected set; } + public virtual string AliasName { get; set; } + + public virtual string Color { get; set; } + public virtual string Framework { get; set; } public virtual string Name { get; set; } @@ -32,16 +38,20 @@ public class UserFavoriteMenu : AuditedEntity, IMultiTenant string displayName, string path, string icon, + string color, + string aliasName = null, Guid? tenantId = null) : base(id) { MenuId = menuId; UserId = userId; - Framework = framework; - Name = name; - DisplayName = displayName; - Path = path; - Icon = icon; + Framework = Check.NotNullOrWhiteSpace(framework, nameof(framework), LayoutConsts.MaxFrameworkLength); + Name = Check.NotNullOrWhiteSpace(name, nameof(name), RouteConsts.MaxNameLength); + DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), RouteConsts.MaxDisplayNameLength); + Path = Check.NotNullOrWhiteSpace(path, nameof(path), RouteConsts.MaxPathLength); + Icon = Check.Length(icon, nameof(icon), UserFavoriteMenuConsts.MaxIconLength); + Color = Check.Length(color, nameof(color), UserFavoriteMenuConsts.MaxColorLength); + AliasName = Check.Length(aliasName, nameof(aliasName), UserFavoriteMenuConsts.MaxAliasNameLength); TenantId = tenantId; } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs index 2b4e3217f..d4de4b1db 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs @@ -100,10 +100,18 @@ namespace LINGYUN.Platform.EntityFrameworkCore .IsRequired(); x.Property(p => p.Path) .HasMaxLength(RouteConsts.MaxPathLength) - .HasColumnName(nameof(Route.Path)); + .HasColumnName(nameof(Route.Path)) + .IsRequired(); + x.Property(p => p.Icon) .HasMaxLength(UserFavoriteMenuConsts.MaxIconLength) .HasColumnName(nameof(UserFavoriteMenu.Icon)); + x.Property(p => p.Color) + .HasMaxLength(UserFavoriteMenuConsts.MaxColorLength) + .HasColumnName(nameof(UserFavoriteMenu.Color)); + x.Property(p => p.AliasName) + .HasMaxLength(UserFavoriteMenuConsts.MaxAliasNameLength) + .HasColumnName(nameof(UserFavoriteMenu.AliasName)); x.ConfigureByConvention(); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserFavoriteMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserFavoriteMenuRepository.cs index 36618e4fd..f43af6609 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserFavoriteMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserFavoriteMenuRepository.cs @@ -41,4 +41,26 @@ public class EfCoreUserFavoriteMenuRepository : .OrderBy(x => x.CreationTime) .ToListAsync(GetCancellationToken(cancellationToken)); } + + public async virtual Task CheckExistsAsync( + string framework, + Guid userId, + Guid menuId, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .AnyAsync(x => + x.Framework == framework && x.UserId == userId && x.MenuId == menuId, + GetCancellationToken(cancellationToken)); + } + + public async virtual Task FindByUserMenuAsync( + Guid userId, + Guid menuId, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.UserId == userId && x.MenuId == menuId) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs index c7f2a6960..ccceef28c 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/MenuController.cs @@ -138,33 +138,5 @@ namespace LINGYUN.Platform.Menus Framework = framework }); } - - [HttpPut] - [Route("favorites/by-user/{userId}")] - public async virtual Task SetUserFavoriteMenusAsync(Guid userId, UserFavoriteMenuSetInput input) - { - await MenuAppService.SetUserFavoriteMenusAsync(userId, input); - } - - [HttpGet] - [Route("favorites/by-user/{userId}")] - public async virtual Task> GetUserFavoriteMenuListAsync(Guid userId, UserFavoriteMenuGetListInput input) - { - return await MenuAppService.GetUserFavoriteMenuListAsync(userId, input); - } - - [HttpPut] - [Route("favorites/by-current-user")] - public async virtual Task SetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuSetInput input) - { - await MenuAppService.SetCurrentUserFavoriteMenuListAsync(input); - } - - [HttpGet] - [Route("favorites/by-current-user")] - public async virtual Task> GetCurrentUserFavoriteMenuListAsync(UserFavoriteMenuGetListInput input) - { - return await MenuAppService.GetCurrentUserFavoriteMenuListAsync(input); - } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/UserFavoriteMenuController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/UserFavoriteMenuController.cs new file mode 100644 index 000000000..a0def9042 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Menus/UserFavoriteMenuController.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Platform.Menus; + +[Authorize] +[RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)] +[Area("platform")] +[Route("api/platform/menus/favorites")] +public class UserFavoriteMenuController : PlatformControllerBase, IUserFavoriteMenuAppService +{ + protected IUserFavoriteMenuAppService Service { get; } + + public UserFavoriteMenuController(IUserFavoriteMenuAppService service) + { + Service = service; + } + + [HttpPost] + [Route("{userId}")] + public virtual Task CreateAsync(Guid userId, UserFavoriteMenuCreateDto input) + { + return Service.CreateAsync(userId, input); + } + + [HttpPost] + [Route("my-favorite-menu")] + public virtual Task CreateMyFavoriteMenuAsync(UserFavoriteMenuCreateDto input) + { + return Service.CreateMyFavoriteMenuAsync(input); + } + + [HttpDelete] + [Route("{userId}/{MenuId}")] + public virtual Task DeleteAsync(Guid userId, UserFavoriteMenuRemoveInput input) + { + return Service.DeleteAsync(userId, input); + } + + [HttpDelete] + [Route("my-favorite-menu/{MenuId}")] + public virtual Task DeleteMyFavoriteMenuAsync(UserFavoriteMenuRemoveInput input) + { + return Service.DeleteMyFavoriteMenuAsync(input); + } + + [HttpGet] + [Route("{userId}")] + public virtual Task> GetListAsync(Guid userId, UserFavoriteMenuGetListInput input) + { + return Service.GetListAsync(userId, input); + } + + [HttpGet] + [Route("my-favorite-menus")] + public virtual Task> GetMyFavoriteMenuListAsync(UserFavoriteMenuGetListInput input) + { + return Service.GetMyFavoriteMenuListAsync(input); + } + + [HttpPut] + [Route("{userId}")] + public virtual Task UpdateAsync(Guid userId, UserFavoriteMenuUpdateDto input) + { + return Service.UpdateAsync(userId, input); + } + + [HttpPut] + [Route("my-favorite-menu")] + public virtual Task UpdateMyFavoriteMenuAsync(UserFavoriteMenuUpdateDto input) + { + return Service.UpdateMyFavoriteMenuAsync(input); + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.Designer.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.Designer.cs new file mode 100644 index 000000000..bb5c5c43e --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.Designer.cs @@ -0,0 +1,751 @@ +// +using System; +using LY.MicroService.PlatformManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.PlatformManagement.Migrations +{ + [DbContext(typeof(PlatformManagementMigrationsDbContext))] + [Migration("20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu")] + partial class AddColorAndAliasNameWithUserFavoriteMenu + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("PlatformType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Title"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Version"); + + b.ToTable("AppPlatformVersion", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AppVersionId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("FileType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("SHA256") + .IsRequired() + .HasMaxLength(65) + .HasColumnType("varchar(65)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("AppVersionId"); + + b.HasIndex("Path", "Name", "Version") + .IsUnique(); + + b.ToTable("AppPlatformVersionFile", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") + .WithMany("Files") + .HasForeignKey("AppVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppVersion"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Navigation("Files"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.cs new file mode 100644 index 000000000..9e1ed10eb --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220926012110_Add-Color-And-AliasName-With-UserFavoriteMenu.cs @@ -0,0 +1,71 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.PlatformManagement.Migrations +{ + public partial class AddColorAndAliasNameWithUserFavoriteMenu : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "AppPlatformUserFavoriteMenus", + keyColumn: "Path", + keyValue: null, + column: "Path", + value: ""); + + migrationBuilder.AlterColumn( + name: "Path", + table: "AppPlatformUserFavoriteMenus", + type: "varchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldMaxLength: 255, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "AliasName", + table: "AppPlatformUserFavoriteMenus", + type: "varchar(128)", + maxLength: 128, + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "Color", + table: "AppPlatformUserFavoriteMenus", + type: "varchar(30)", + maxLength: 30, + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "AliasName", + table: "AppPlatformUserFavoriteMenus"); + + migrationBuilder.DropColumn( + name: "Color", + table: "AppPlatformUserFavoriteMenus"); + + migrationBuilder.AlterColumn( + name: "Path", + table: "AppPlatformUserFavoriteMenus", + type: "varchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldMaxLength: 255) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs index 2c0f59ba3..ceaa9ce46 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs @@ -449,6 +449,16 @@ namespace LY.MicroService.PlatformManagement.Migrations .ValueGeneratedOnAdd() .HasColumnType("char(36)"); + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + b.Property("CreationTime") .HasColumnType("datetime(6)") .HasColumnName("CreationTime"); @@ -492,6 +502,7 @@ namespace LY.MicroService.PlatformManagement.Migrations .HasColumnName("Name"); b.Property("Path") + .IsRequired() .HasMaxLength(255) .HasColumnType("varchar(255)") .HasColumnName("Path"); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs index e42f914cc..e5d30c08d 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs @@ -326,7 +326,7 @@ public partial class PlatformManagementHttpApiHostModule if (isDevelopment) { - // services.AddAlwaysAllowAuthorization(); + services.AddAlwaysAllowAuthorization(); } if (!isDevelopment)