From b5b9e66ba12aa34a08abff36633b182ee4df347e Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Fri, 23 Sep 2022 20:10:26 +0800 Subject: [PATCH 1/7] Changing the workbench layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 变更工作台组件. * 工作台加入天气, 需要适配天气api接口. * 将 withAcceptLanguage 加入axios中, 用户自行决定是否加入头. * Platform模块新增用户收藏菜单接口,使用前需要切换目录 PlatformManagement.HttpApi.Host,运行命令行 **dotnet ef database update** 或 **dotnet ef migrations script**执行迁移 --- apps/vue/src/api/weather/index.ts | 75 ++ apps/vue/src/api/weather/model/index.ts | 101 +++ .../Form/src/components/ApiTree.vue | 6 +- .../header/components/lock/LockModal.vue | 86 +- .../src/locales/lang/en/routes/dashboard.ts | 21 +- .../locales/lang/zh-CN/routes/dashboard.ts | 21 +- .../src/router/routes/modules/dashboard.ts | 2 +- apps/vue/src/store/modules/weather.ts | 36 + apps/vue/src/utils/http/axios/index.ts | 11 +- .../workbench/components/MenuCard.vue | 76 ++ .../workbench/components/MenuReference.vue | 86 ++ .../workbench/components/ProjectCard.vue | 2 +- .../workbench/components/WorkbenchHeader.vue | 84 +- .../src/views/dashboard/workbench/index.vue | 47 +- apps/vue/types/axios.d.ts | 2 + apps/vue/vite.config.ts | 22 +- .../VueVbenAdminStandardMenuConverter.cs | 28 + .../Localization/ApplicationContracts/en.json | 3 +- .../ApplicationContracts/zh-Hans.json | 3 +- .../Platform/Menus/Dto/UserFavoriteMenuDto.cs | 21 + .../Menus/Dto/UserFavoriteMenuGetListInput.cs | 9 + .../Menus/Dto/UserFavoriteMenuSetInput.cs | 11 + .../LINGYUN/Platform/Menus/IMenuAppService.cs | 8 + .../PlatformPermissionDefinitionProvider.cs | 3 +- .../Permissions/PlatformPermissions.cs | 4 +- .../LINGYUN/Platform/Menus/MenuAppService.cs | 73 ++ .../PlatformApplicationMappingProfile.cs | 1 + .../LINGYUN.Platform.Domain.Shared.csproj | 4 - .../LINGYUN/Platform/Layouts/LayoutEto.cs | 10 + .../LINGYUN/Platform/Menus/MenuEto.cs | 11 + .../LINGYUN/Platform/Menus/RoleMenuEto.cs | 14 + .../LINGYUN/Platform/Menus/UserMenuEto.cs | 14 + .../LINGYUN/Platform/Routes/RoleRouteEto.cs | 12 - .../LINGYUN/Platform/Routes/RouteEto.cs | 2 +- .../Platform/Routes/UserFavoriteMenuConsts.cs | 5 + .../LINGYUN/Platform/Routes/UserRouteEto.cs | 12 - .../Platform/Datas/DataItemMappingOptions.cs | 27 +- .../Menus/DefaultStandardMenuConverter.cs | 20 + .../LINGYUN/Platform/Menus/IMenuRepository.cs | 3 + .../Platform/Menus/IStandardMenuConverter.cs | 6 + .../Menus/IUserFavoriteMenuRepository.cs | 20 + .../Platform/Menus/MenuChangeHandler.cs | 71 ++ .../LINGYUN/Platform/Menus/StandardMenu.cs | 10 + .../Platform/Menus/UserFavoriteMenu.cs | 47 ++ .../Platform/PlatformDomainMappingProfile.cs | 8 +- .../LINGYUN/Platform/PlatformDomainModule.cs | 10 +- ...PlatformDbContextModelBuilderExtensions.cs | 28 + .../Platform/Menus/EfCoreMenuRepository.cs | 9 + .../Menus/EfCoreUserFavoriteMenuRepository.cs | 44 ++ .../LINGYUN/Platform/Menus/MenuController.cs | 28 + ...3113938_Add-User-Favorite-Menu.Designer.cs | 740 ++++++++++++++++++ .../20220923113938_Add-User-Favorite-Menu.cs | 53 ++ ...ApiHostMigrationsDbContextModelSnapshot.cs | 69 +- ...rmManagementHttpApiHostModule.Configure.cs | 11 +- .../appsettings.Development.json | 1 + 55 files changed, 2000 insertions(+), 131 deletions(-) create mode 100644 apps/vue/src/api/weather/index.ts create mode 100644 apps/vue/src/api/weather/model/index.ts create mode 100644 apps/vue/src/store/modules/weather.ts create mode 100644 apps/vue/src/views/dashboard/workbench/components/MenuCard.vue create mode 100644 apps/vue/src/views/dashboard/workbench/components/MenuReference.vue create mode 100644 aspnet-core/modules/platform/LINGYUN.Abp.UI.Navigation.VueVbenAdmin/LINGYUN/Abp/UI/Navigation/VueVbenAdmin/VueVbenAdminStandardMenuConverter.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/UserFavoriteMenuGetListInput.cs create 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.Domain.Shared/LINGYUN/Platform/Layouts/LayoutEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/MenuEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/RoleMenuEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Menus/UserMenuEto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserFavoriteMenuConsts.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserRouteEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/DefaultStandardMenuConverter.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IStandardMenuConverter.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserFavoriteMenuRepository.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuChangeHandler.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/StandardMenu.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserFavoriteMenu.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserFavoriteMenuRepository.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220923113938_Add-User-Favorite-Menu.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20220923113938_Add-User-Favorite-Menu.cs diff --git a/apps/vue/src/api/weather/index.ts b/apps/vue/src/api/weather/index.ts new file mode 100644 index 000000000..7e8976bb1 --- /dev/null +++ b/apps/vue/src/api/weather/index.ts @@ -0,0 +1,75 @@ +/* + 天气接口 + 数据来源: http://www.nmc.cn (中央气象台) +*/ +import { defHttp } from '/@/utils/http/axios'; +import { Position, Province, WeatherResult } from './model'; +import { format } from '/@/utils/strings'; + +//const Host = 'http://www.nmc.cn'; +const Api = { + GetProvinces: '/wapi/rest/province/all', + GetPosition: '/wapi/rest/position', + GetCitys: '/wapi/rest/province/{province}', + GetWeather: '/wapi/rest/weather?stationid={code}', +}; + +export const getProvinces = () => { + return defHttp.get({ + url: Api.GetProvinces, + //baseURL: Host, + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }, { + apiUrl: '', + joinTime: false, + withToken: false, + withAcceptLanguage: false, + }); +}; + +export const getPosition = () => { + return defHttp.get({ + url: Api.GetPosition, + //baseURL: Host, + headers: { + 'X-Requested-With': 'XMLHttpRequest', + } + }, { + apiUrl: '', + joinTime: false, + withToken: false, + withAcceptLanguage: false, + }); +} + +export const getCitys = (provinceCode: string) => { + return defHttp.get({ + url: format(Api.GetCitys, {province: provinceCode}), + //baseURL: Host, + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }, { + apiUrl: '', + joinTime: false, + withToken: false, + withAcceptLanguage: false, + }); +} + +export const getWeather = (cityCode: string) => { + return defHttp.get({ + url: format(Api.GetWeather, {code: cityCode}), + //baseURL: Host, + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }, { + apiUrl: '', + joinTime: false, + withToken: false, + withAcceptLanguage: false, + }); +} diff --git a/apps/vue/src/api/weather/model/index.ts b/apps/vue/src/api/weather/model/index.ts new file mode 100644 index 000000000..dc3553b9d --- /dev/null +++ b/apps/vue/src/api/weather/model/index.ts @@ -0,0 +1,101 @@ +/* + 天气数据模型 + 数据来源: http://www.nmc.cn (中央气象台) +*/ + +/** + * 定位 + */ +export interface Position { + /** 城市 */ + city: string; + /** 代码 */ + code: string; + /** 省份 */ + province: string; + /** 专用页面 */ + url: string; +} + +/** + * 省份 + */ +export interface Province { + /** 代码 */ + code: string; + /** 名称 */ + name: string; + /** 专用页面 */ + url: string; +} + +export interface Air { + aq: number; + aqi: number; + aqiCode: string; + forecasttime: Date; + text: string; +} + +export interface Weather { + airpressure: number; + feelst: number; + humidity: number; + icomfort: number; + img: string; + info: string; + rain: number; + rcomfort: number; + temperature: number; + temperatureDiff: number; +} + +export interface Wind { + degree: number; + direct: string; + power: string; + speed: number; +} + +export interface PredictDetail { + date: Date; + pt: Date; + day: { weather: Weather; wind: Wind }; + night: { weather: Weather; wind: Wind }; +} + +export interface Predict { + detail: PredictDetail[]; + publish_time: Date; + station: Position; +} + +export interface Real { + publish_time: Date; + station: Position; + weather: Weather; + wind: Wind; +} + +export interface Tempchart { + day_img: string; + day_text: string; + max_temp: number; + min_temp: number; + night_img: string; + night_text: string; + time: Date; +} + +export interface WeatherInfo { + air: Air; + predict: Predict; + real: Real; + tempchart: Tempchart; +} + +export interface WeatherResult { + code: number; + msg: string; + data: WeatherInfo; +} diff --git a/apps/vue/src/components/Form/src/components/ApiTree.vue b/apps/vue/src/components/Form/src/components/ApiTree.vue index 0ec6917dd..44d6b5a2c 100644 --- a/apps/vue/src/components/Form/src/components/ApiTree.vue +++ b/apps/vue/src/components/Form/src/components/ApiTree.vue @@ -1,12 +1,12 @@ diff --git a/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue b/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue new file mode 100644 index 000000000..a325098df --- /dev/null +++ b/apps/vue/src/views/dashboard/workbench/components/MenuReference.vue @@ -0,0 +1,86 @@ + + + + + \ No newline at end of file diff --git a/apps/vue/src/views/dashboard/workbench/components/ProjectCard.vue b/apps/vue/src/views/dashboard/workbench/components/ProjectCard.vue index 0c4990bf2..f990e802d 100644 --- a/apps/vue/src/views/dashboard/workbench/components/ProjectCard.vue +++ b/apps/vue/src/views/dashboard/workbench/components/ProjectCard.vue @@ -4,7 +4,7 @@ 更多 - + {{ item.title }} diff --git a/apps/vue/src/views/dashboard/workbench/components/WorkbenchHeader.vue b/apps/vue/src/views/dashboard/workbench/components/WorkbenchHeader.vue index ef4d90d79..089b7fe38 100644 --- a/apps/vue/src/views/dashboard/workbench/components/WorkbenchHeader.vue +++ b/apps/vue/src/views/dashboard/workbench/components/WorkbenchHeader.vue @@ -2,32 +2,88 @@
-

早安, {{ userinfo.realName }}, 开始您一天的工作吧!

- 今日晴,20℃ - 32℃! +

{{ getWelcomeTitle }}

+ {{ getWeatherInfo }}
-
- 待办 - 2/10 -
- -
- 项目 - 8 -
- 团队 - 300 + {{ t('routes.dashboard.workbench.header.notifier.title') }} + {{ t('routes.dashboard.workbench.header.notifier.count', [unReadNotiferCount]) }}
diff --git a/apps/vue/src/views/dashboard/workbench/index.vue b/apps/vue/src/views/dashboard/workbench/index.vue index 5ee292e22..7858089f3 100644 --- a/apps/vue/src/views/dashboard/workbench/index.vue +++ b/apps/vue/src/views/dashboard/workbench/index.vue @@ -3,30 +3,59 @@
- - +
- + - +
- \ 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) From 06f574cf03c4edc04eb00108c1685f28dc94ba81 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:40:23 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformManagementHttpApiHostModule.Configure.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e5d30c08d..e42f914cc 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) From d739be3a551a7c0d429a9c09e2c11a90ae555569 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:55:16 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=B6=E8=97=8F?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=93=8D=E5=BA=94=E4=BA=8B=E4=BB=B6.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/vue/src/api/model/baseModel.ts | 4 + .../api/platform/user-favorites-menu/index.ts | 114 ++++++++++++++++++ .../user-favorites-menu/model/index.ts | 28 +++++ .../src/locales/lang/en/routes/dashboard.ts | 6 +- .../locales/lang/zh-CN/routes/dashboard.ts | 8 +- .../workbench/components/MenuCard.vue | 71 ++++++++--- .../workbench/components/MenuReference.vue | 75 ++++++------ .../workbench/components/menuProps.ts | 49 ++++++++ .../src/views/dashboard/workbench/index.vue | 93 ++++++++------ 9 files changed, 353 insertions(+), 95 deletions(-) create mode 100644 apps/vue/src/api/platform/user-favorites-menu/index.ts create mode 100644 apps/vue/src/api/platform/user-favorites-menu/model/index.ts create mode 100644 apps/vue/src/views/dashboard/workbench/components/menuProps.ts diff --git a/apps/vue/src/api/model/baseModel.ts b/apps/vue/src/api/model/baseModel.ts index 978b638e6..6a411e534 100644 --- a/apps/vue/src/api/model/baseModel.ts +++ b/apps/vue/src/api/model/baseModel.ts @@ -51,6 +51,10 @@ export class CreationAuditedEntityDto implements IMayHaveCreator { creationTime!: Date; } +export class EntityDto { + id!: TKey; +} + /** 实体审计对象 */ export class AuditedEntityDto implements CreationAuditedEntityDto, IModificationAuditedObject { lastModifierId: string | undefined; diff --git a/apps/vue/src/api/platform/user-favorites-menu/index.ts b/apps/vue/src/api/platform/user-favorites-menu/index.ts new file mode 100644 index 000000000..6162bce68 --- /dev/null +++ b/apps/vue/src/api/platform/user-favorites-menu/index.ts @@ -0,0 +1,114 @@ +import { defAbpHttp } from '/@/utils/http/abp'; +import { UserFavoriteMenuDto, UserFavoriteMenuCreateDto, UserFavoriteMenuUpdateDto } from './model'; + +const remoteService = { + name: 'Platform', + controller: 'UserFavoriteMenu', + replace: { + framework: 'Vue Vben Admin', + } +}; + +export const create = (userId: string, input: UserFavoriteMenuCreateDto) => { + input.framework = remoteService.replace.framework; + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'CreateAsync', + params: { + userId: userId, + }, + data: { + input: input, + }, + }); +}; + +export const createMyFavoriteMenu = (input: UserFavoriteMenuCreateDto) => { + input.framework = remoteService.replace.framework; + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'CreateMyFavoriteMenuAsync', + data: { + input: input, + }, + }); +}; + +export const del = (userId: string, menuId: string) => { + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'DeleteAsync', + params: { + userId: userId, + }, + data: { + input: { + menuId: menuId, + }, + }, + }); +}; + +export const delMyFavoriteMenu = (menuId: string) => { + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'DeleteMyFavoriteMenuAsync', + data: { + input: { + menuId: menuId, + }, + }, + }); +}; + +export const update = (userId: string, input: UserFavoriteMenuUpdateDto) => { + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'UpdateAsync', + params: { + userId: userId, + }, + data: { + input: input, + }, + }); +}; + +export const updateMyFavoriteMenu = (input: UserFavoriteMenuUpdateDto) => { + return defAbpHttp.request({ + service: remoteService.name, + controller: remoteService.controller, + action: 'UpdateMyFavoriteMenuAsync', + data: { + input: input, + }, + }); +}; + +export const getList = (userId: string) => { + return defAbpHttp.listRequest({ + service: remoteService.name, + controller: remoteService.controller, + action: 'GetListAsync', + params: { + userId: userId, + framework: remoteService.replace.framework, + }, + }); +}; + +export const getMyFavoriteMenuList = () => { + return defAbpHttp.listRequest({ + service: remoteService.name, + controller: remoteService.controller, + action: 'GetMyFavoriteMenuListAsync', + params: { + framework: remoteService.replace.framework, + }, + }); +}; diff --git a/apps/vue/src/api/platform/user-favorites-menu/model/index.ts b/apps/vue/src/api/platform/user-favorites-menu/model/index.ts new file mode 100644 index 000000000..5173e035c --- /dev/null +++ b/apps/vue/src/api/platform/user-favorites-menu/model/index.ts @@ -0,0 +1,28 @@ +import { AuditedEntityDto, EntityDto, IHasConcurrencyStamp } from '/@/api/model/baseModel'; + +export interface UserFavoriteMenuDto extends AuditedEntityDto, EntityDto { + menuId: string; + userId: string; + aliasName?: string; + color?: string; + framework: string; + name: string; + displayName: string; + path?: string; + icon?: string; +} + +interface UserFavoriteMenuCreateOrUpdateDto { + menuId: string; + color?: string; + aliasName?: string; + icon?: string; +} + +export interface UserFavoriteMenuCreateDto extends UserFavoriteMenuCreateOrUpdateDto { + framework: string; +} + +export interface UserFavoriteMenuUpdateDto extends UserFavoriteMenuCreateOrUpdateDto, IHasConcurrencyStamp { +} + diff --git a/apps/vue/src/locales/lang/en/routes/dashboard.ts b/apps/vue/src/locales/lang/en/routes/dashboard.ts index 99906a368..4f6a27bbe 100644 --- a/apps/vue/src/locales/lang/en/routes/dashboard.ts +++ b/apps/vue/src/locales/lang/en/routes/dashboard.ts @@ -15,11 +15,15 @@ export default { } }, menus: { + favoriteMenu: '常用', more: 'More', addMenu: 'Add new menu', manager: 'Manage menu', selectMenu: 'Select menu', - selectColor: 'Select color' + selectColor: 'Select color', + deleteMenu: 'Delete menu', + defineAliasName: 'Alias name', + defineIcon: 'Icon' } }, 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 962fb1a57..06eb18197 100644 --- a/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts +++ b/apps/vue/src/locales/lang/zh-CN/routes/dashboard.ts @@ -1,5 +1,5 @@ export default { - dashboard: 'Dashboard', + dashboard: '仪表盘', about: '关于', workbench: { title: '工作台', @@ -15,11 +15,15 @@ export default { } }, menus: { + favoriteMenu: '常用', more: '更多', addMenu: '添加菜单', manager: '管理菜单', selectMenu: '选择菜单', - selectColor: '选择颜色' + selectColor: '选择颜色', + deleteMenu: '移除菜单', + defineAliasName: '自定义别名', + defineIcon: '自定义图标' } }, analysis: '分析页', diff --git a/apps/vue/src/views/dashboard/workbench/components/MenuCard.vue b/apps/vue/src/views/dashboard/workbench/components/MenuCard.vue index 9cd713b1c..c760c8ab3 100644 --- a/apps/vue/src/views/dashboard/workbench/components/MenuCard.vue +++ b/apps/vue/src/views/dashboard/workbench/components/MenuCard.vue @@ -1,10 +1,16 @@