diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/en.json b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/en.json
index 79262759c..3e509e876 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/en.json
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/en.json
@@ -36,6 +36,7 @@
"Permission:ManageComments": "Manage Comments",
"Permission:SmsMessage": "Sms Message",
"Permission:EmailMessage": "Email Message",
- "Permission:SendMessage": "Send Message"
+ "Permission:SendMessage": "Send Message",
+ "Permission:Enterprise": "Enterprise"
}
}
\ No newline at end of file
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/zh-Hans.json b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/zh-Hans.json
index 4be53a1a5..675bc1ce9 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/zh-Hans.json
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Localization/ApplicationContracts/zh-Hans.json
@@ -36,6 +36,7 @@
"Permission:ManageComments": "评论管理",
"Permission:SmsMessage": "短信消息",
"Permission:EmailMessage": "邮件消息",
- "Permission:SendMessage": "发送消息"
+ "Permission:SendMessage": "发送消息",
+ "Permission:Enterprise": "企业关联"
}
}
\ No newline at end of file
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 0ad088bce..2139070c1 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
@@ -1,6 +1,7 @@
using LINGYUN.Platform.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
+using Volo.Abp.MultiTenancy;
namespace LINGYUN.Platform.Permissions;
@@ -43,6 +44,11 @@ public class PlatformPermissionDefinitionProvider : PermissionDefinitionProvider
feedback.AddChild(PlatformPermissions.Feedback.ManageAttachments, L("Permission:ManageAttachments"));
feedback.AddChild(PlatformPermissions.Feedback.ManageComments, L("Permission:ManageComments"));
+ var enterprise = platform.AddPermission(PlatformPermissions.Enterprise.Default, L("Permission:Enterprise"));
+ enterprise.AddChild(PlatformPermissions.Enterprise.Create, L("Permission:Create"), MultiTenancySides.Host);
+ enterprise.AddChild(PlatformPermissions.Enterprise.Update, L("Permission:Update"), MultiTenancySides.Host);
+ enterprise.AddChild(PlatformPermissions.Enterprise.Delete, L("Permission:Delete"), MultiTenancySides.Host);
+
var emailMessage = platform.AddPermission(PlatformPermissions.EmailMessage.Default, L("Permission:EmailMessage"));
emailMessage.AddChild(PlatformPermissions.EmailMessage.SendMessage, L("Permission:SendMessage"));
emailMessage.AddChild(PlatformPermissions.EmailMessage.Delete, L("Permission:Delete"));
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs
index 781c30822..6c48dca93 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs
@@ -6,7 +6,7 @@ public static class PlatformPermissions
{
public const string GroupName = "Platform";
- public class DataDictionary
+ public static class DataDictionary
{
public const string Default = GroupName + ".DataDictionary";
@@ -21,7 +21,7 @@ public static class PlatformPermissions
public const string ManageItems = Default + ".ManageItems";
}
- public class Layout
+ public static class Layout
{
public const string Default = GroupName + ".Layout";
@@ -32,7 +32,7 @@ public static class PlatformPermissions
public const string Delete = Default + ".Delete";
}
- public class Menu
+ public static class Menu
{
public const string Default = GroupName + ".Menu";
@@ -53,7 +53,7 @@ public static class PlatformPermissions
///
/// 文件系统
///
- public class FileSystem
+ public static class FileSystem
{
public const string Default = GroupName + ".FileSystem";
@@ -67,7 +67,7 @@ public static class PlatformPermissions
public const string Move = Default + ".Move";
- public class FileManager
+ public static class FileManager
{
public const string Default = FileSystem.Default + ".FileManager";
@@ -85,7 +85,7 @@ public static class PlatformPermissions
}
}
- public class Package
+ public static class Package
{
public const string Default = GroupName + ".Package";
@@ -98,7 +98,7 @@ public static class PlatformPermissions
public const string ManageBlobs = Default + ".ManageBlobs";
}
- public class Feedback
+ public static class Feedback
{
public const string Default = GroupName + ".Feedback";
@@ -113,7 +113,18 @@ public static class PlatformPermissions
public const string ManageAttachments = Default + ".ManageAttachments";
}
- public class EmailMessage
+ public static class Enterprise
+ {
+ public const string Default = GroupName + ".Enterprise";
+
+ public const string Create = Default + ".Create";
+
+ public const string Delete = Default + ".Delete";
+
+ public const string Update = Default + ".Update";
+ }
+
+ public static class EmailMessage
{
public const string Default = GroupName + ".EmailMessage";
@@ -122,7 +133,7 @@ public static class PlatformPermissions
public const string SendMessage = Default + ".SendMessage";
}
- public class SmsMessage
+ public static class SmsMessage
{
public const string Default = GroupName + ".SmsMessage";
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateDto.cs
new file mode 100644
index 000000000..f2e2fa198
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateDto.cs
@@ -0,0 +1,14 @@
+using System.ComponentModel.DataAnnotations;
+using Volo.Abp.Validation;
+
+namespace LINGYUN.Platform.Portal;
+
+public class EnterpriseCreateDto : EnterpriseCreateOrUpdateDto
+{
+ ///
+ /// 名称
+ ///
+ [Required]
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxNameLength))]
+ public string Name { get; set; }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateOrUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateOrUpdateDto.cs
new file mode 100644
index 000000000..777776f85
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseCreateOrUpdateDto.cs
@@ -0,0 +1,55 @@
+using System;
+using Volo.Abp.Validation;
+
+namespace LINGYUN.Platform.Portal;
+
+public abstract class EnterpriseCreateOrUpdateDto
+{
+ ///
+ /// 关联租户
+ ///
+ public Guid? TenantId { get; set; }
+ ///
+ /// 英文名称
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxEnglishNameLength))]
+ public string EnglishName { get; set; }
+ ///
+ /// Logo
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxLogoLength))]
+ public string Logo { get; set; }
+ ///
+ /// 地址
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxAddressLength))]
+ public string Address { get; set; }
+ ///
+ /// 法人代表
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxLegalManLength))]
+ public string LegalMan { get; set; }
+ ///
+ /// 税务登记号
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxTaxCodeLength))]
+ public string TaxCode { get; set; }
+ ///
+ /// 组织机构代码
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxOrganizationCodeLength))]
+ public string OrganizationCode { get; set; }
+ ///
+ /// 注册代码
+ ///
+ [DynamicStringLength(typeof(EnterpriseConsts), nameof(EnterpriseConsts.MaxRegistrationCodeLength))]
+ public string RegistrationCode { get; set; }
+ ///
+ /// 注册日期
+ ///
+ public DateTime? RegistrationDate { get; set; }
+ ///
+ /// 过期日期
+ ///
+ public DateTime? ExpirationDate { get; set; }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseDto.cs
new file mode 100644
index 000000000..1072e502e
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseDto.cs
@@ -0,0 +1,21 @@
+using System;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.Platform.Portal;
+
+public class EnterpriseDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp
+{
+ public Guid? TenantId { get; set; }
+ public string Name { get; set; }
+ public string EnglishName { get; set; }
+ public string Logo { get; set; }
+ public string Address { get; set; }
+ public string LegalMan { get; set; }
+ public string TaxCode { get; set; }
+ public string OrganizationCode { get; set; }
+ public string RegistrationCode { get; set; }
+ public DateTime? RegistrationDate { get; set; }
+ public DateTime? ExpirationDate { get; set; }
+ public string ConcurrencyStamp { get; set; }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseGetListInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseGetListInput.cs
new file mode 100644
index 000000000..ecbea0869
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseGetListInput.cs
@@ -0,0 +1,17 @@
+using System;
+using Volo.Abp.Application.Dtos;
+
+namespace LINGYUN.Platform.Portal;
+
+public class EnterpriseGetListInput : PagedAndSortedResultRequestDto
+{
+ public string Filter { get; set; }
+
+ public DateTime? BeginRegistrationDate { get; set; }
+
+ public DateTime? EndRegistrationDate { get; set; }
+
+ public DateTime? BeginExpirationDate { get; set; }
+
+ public DateTime? EndExpirationDate { get; set; }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseUpdateDto.cs
new file mode 100644
index 000000000..fa74414bb
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/Dto/EnterpriseUpdateDto.cs
@@ -0,0 +1,8 @@
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.Platform.Portal;
+
+public class EnterpriseUpdateDto : EnterpriseCreateOrUpdateDto, IHasConcurrencyStamp
+{
+ public string ConcurrencyStamp { get; set; }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/IEnterpriseAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/IEnterpriseAppService.cs
new file mode 100644
index 000000000..6e7c04e46
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Portal/IEnterpriseAppService.cs
@@ -0,0 +1,14 @@
+using System;
+using Volo.Abp.Application.Services;
+
+namespace LINGYUN.Platform.Portal;
+
+public interface IEnterpriseAppService :
+ ICrudAppService<
+ EnterpriseDto,
+ Guid,
+ EnterpriseGetListInput,
+ EnterpriseCreateDto,
+ EnterpriseUpdateDto>
+{
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationCurdAppServiceBase.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationCurdAppServiceBase.cs
new file mode 100644
index 000000000..1dd6d2d61
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationCurdAppServiceBase.cs
@@ -0,0 +1,18 @@
+using LINGYUN.Platform.Localization;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Entities;
+using Volo.Abp.Domain.Repositories;
+
+namespace LINGYUN.Platform;
+
+public abstract class PlatformApplicationCurdAppServiceBase :
+ CrudAppService
+ where TEntity : class, IEntity
+{
+ protected PlatformApplicationCurdAppServiceBase(
+ IRepository repository) : base(repository)
+ {
+ LocalizationResource = typeof(PlatformResource);
+ ObjectMapperContext = typeof(PlatformApplicationModule);
+ }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs
index 7cf94cc13..6c18a4a22 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs
@@ -5,6 +5,7 @@ using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus;
using LINGYUN.Platform.Messages;
using LINGYUN.Platform.Packages;
+using LINGYUN.Platform.Portal;
namespace LINGYUN.Platform;
@@ -32,5 +33,7 @@ public class PlatformApplicationMappingProfile : Profile
CreateMap();
CreateMap();
CreateMap();
+
+ CreateMap();
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs
index ee12a2150..2bd462842 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs
@@ -17,7 +17,7 @@ public class PlatformApplicationModule : AbpModule
Configure(options =>
{
- options.AddProfile(validate: true);
+ options.AddMaps(validate: true);
});
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs
index b3961579f..c453a01b5 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs
@@ -1,4 +1,5 @@
-using Volo.Abp.Application.Services;
+using LINGYUN.Platform.Localization;
+using Volo.Abp.Application.Services;
namespace LINGYUN.Platform;
@@ -6,6 +7,7 @@ public abstract class PlatformApplicationServiceBase : ApplicationService
{
protected PlatformApplicationServiceBase()
{
-
+ LocalizationResource = typeof(PlatformResource);
+ ObjectMapperContext = typeof(PlatformApplicationModule);
}
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Portal/EnterpriseAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Portal/EnterpriseAppService.cs
new file mode 100644
index 000000000..970349e8d
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Portal/EnterpriseAppService.cs
@@ -0,0 +1,147 @@
+using LINGYUN.Platform.Permissions;
+using Microsoft.AspNetCore.Authorization;
+using System;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Data;
+
+namespace LINGYUN.Platform.Portal;
+
+[Authorize(PlatformPermissions.Enterprise.Default)]
+public class EnterpriseAppService :
+ PlatformApplicationCurdAppServiceBase<
+ Enterprise,
+ EnterpriseDto,
+ Guid,
+ EnterpriseGetListInput,
+ EnterpriseCreateDto,
+ EnterpriseUpdateDto>,
+ IEnterpriseAppService
+{
+ protected IEnterpriseRepository EnterpriseRepository { get; }
+
+ public EnterpriseAppService(IEnterpriseRepository repository)
+ : base(repository)
+ {
+ EnterpriseRepository = repository;
+
+ CreatePolicyName = PlatformPermissions.Enterprise.Create;
+ UpdatePolicyName = PlatformPermissions.Enterprise.Update;
+ DeletePolicyName = PlatformPermissions.Enterprise.Delete;
+ GetListPolicyName = PlatformPermissions.Enterprise.Default;
+ GetPolicyName = PlatformPermissions.Enterprise.Default;
+ }
+
+ protected async override Task MapToEntityAsync(EnterpriseCreateDto createInput)
+ {
+ if (await EnterpriseRepository.FindByNameAsync(createInput.Name) != null)
+ {
+ throw new BusinessException(PlatformErrorCodes.DuplicateEnterpriseName)
+ .WithData("Name", createInput.Name);
+ }
+
+ if (!createInput.EnglishName.IsNullOrWhiteSpace())
+ {
+ if (await EnterpriseRepository.FindByNameAsync(createInput.EnglishName) != null)
+ {
+ throw new BusinessException(PlatformErrorCodes.DuplicateEnterpriseName)
+ .WithData("Name", createInput.EnglishName);
+ }
+ }
+
+ var enterprise = new Enterprise(
+ GuidGenerator.Create(),
+ createInput.Name,
+ createInput.Address,
+ createInput.TaxCode,
+ createInput.OrganizationCode,
+ createInput.RegistrationCode,
+ createInput.RegistrationDate,
+ createInput.ExpirationDate,
+ createInput.TenantId);
+
+ UpdateByInput(enterprise, createInput);
+
+ return enterprise;
+ }
+
+ protected async override Task MapToEntityAsync(EnterpriseUpdateDto updateInput, Enterprise entity)
+ {
+ if (!string.Equals(entity.EnglishName, updateInput.EnglishName, StringComparison.InvariantCultureIgnoreCase))
+ {
+ if (await EnterpriseRepository.FindByNameAsync(updateInput.EnglishName) != null)
+ {
+ throw new BusinessException(PlatformErrorCodes.DuplicateEnterpriseName)
+ .WithData("Name", updateInput.EnglishName);
+ }
+ }
+
+ UpdateByInput(entity, updateInput);
+
+ entity.SetConcurrencyStampIfNotNull(updateInput.ConcurrencyStamp);
+ }
+
+ protected override void TryToSetTenantId(Enterprise entity)
+ {
+ // ignore tenant
+ }
+
+ protected async override Task DeleteByIdAsync(Guid id)
+ {
+ var enterprise = await Repository.GetAsync(id);
+
+ await Repository.DeleteAsync(enterprise);
+ }
+
+ protected virtual void UpdateByInput(Enterprise enterprise, EnterpriseCreateOrUpdateDto input)
+ {
+ if (!string.Equals(enterprise.EnglishName, input.EnglishName, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.EnglishName = input.EnglishName;
+ }
+ if (!string.Equals(enterprise.Logo, input.Logo, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.Logo = input.Logo;
+ }
+ if (!string.Equals(enterprise.Address, input.Address, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.Address = input.Address;
+ }
+ if (!string.Equals(enterprise.LegalMan, input.LegalMan, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.LegalMan = input.LegalMan;
+ }
+ if (!string.Equals(enterprise.TaxCode, input.TaxCode, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.TaxCode = input.TaxCode;
+ }
+ if (!string.Equals(enterprise.OrganizationCode, input.OrganizationCode, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.SetOrganization(input.OrganizationCode);
+ }
+ if (!string.Equals(enterprise.RegistrationCode, input.RegistrationCode, StringComparison.InvariantCultureIgnoreCase))
+ {
+ enterprise.SetRegistration(input.RegistrationCode, input.RegistrationDate, input.ExpirationDate);
+ }
+ }
+
+ protected async override Task> CreateFilteredQueryAsync(EnterpriseGetListInput input)
+ {
+ var filteredQuery = await base.CreateFilteredQueryAsync(input);
+
+ Expression> expression = _ => true;
+
+ expression = expression.AndIf(!input.Filter.IsNullOrWhiteSpace(), x => x.Name.Contains(input.Filter) ||
+ x.EnglishName.Contains(input.Filter) || x.Address.Contains(input.Filter) || x.LegalMan.Contains(input.Filter) ||
+ x.TaxCode.Contains(input.Filter)|| x.OrganizationCode.Contains(input.Filter) || x.RegistrationCode.Contains(input.Filter));
+
+ expression = expression.AndIf(input.BeginRegistrationDate.HasValue, x => x.RegistrationDate >= input.BeginRegistrationDate);
+ expression = expression.AndIf(input.EndRegistrationDate.HasValue, x => x.RegistrationDate <= input.EndRegistrationDate);
+ expression = expression.AndIf(input.BeginExpirationDate.HasValue, x => x.ExpirationDate >= input.BeginExpirationDate);
+ expression = expression.AndIf(input.EndExpirationDate.HasValue, x => x.ExpirationDate <= input.EndExpirationDate);
+
+ return filteredQuery.Where(expression);
+ }
+}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
index f307df6f9..2ace5ac72 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json
@@ -16,6 +16,7 @@
"Platform:05104": "Attachment {Name} is invalid, please upload again!",
"Platform:06101": "Duplicate headers cannot be added {Key}!",
"Platform:06102": "Duplicate attachments cannot be added {Name}!",
+ "Platform:07101": "The enterprise named {Name} already exists!",
"UploadFileSizeBeyondLimit": "Upload file size cannot exceed {0} MB!",
"NotAllowedFileExtensionName": "Not allowed file extension: {0}!",
"DisplayName:VersionFileLimitLength": "File limit size",
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
index f008eab3f..b35fa0ad7 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json
@@ -16,6 +16,7 @@
"Platform:05104": "附件 {Name} 已失效, 请重新上传!",
"Platform:06101": "不能添加重复的标头 {Key}!",
"Platform:06102": "不能添加重复的附件 {Name}!",
+ "Platform:07101": "已经存在名为 {Name} 的企业信息!",
"UploadFileSizeBeyondLimit": "上传文件大小不能超过 {0} MB!",
"NotAllowedFileExtensionName": "不被允许的文件扩展名: {0}!",
"DisplayName:VersionFileLimitLength": "文件限制大小",
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 91843acef..114d044c9 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
@@ -61,4 +61,8 @@ public static class PlatformErrorCodes
/// 不能添加重复的附件 {Name}!
///
public const string DuplicateEmailMessageAttachment = Namespace + ":06102";
+ ///
+ /// 已经存在名为 {Name} 的企业信息!
+ ///
+ public const string DuplicateEnterpriseName = Namespace + ":07101";
}
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs
index 890c4bdd8..57be08633 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/Enterprise.cs
@@ -10,7 +10,7 @@ namespace LINGYUN.Platform.Portal;
public class Enterprise : FullAuditedAggregateRoot
{
///
- /// 租户标识
+ /// 关联租户
///
public virtual Guid? TenantId { get; protected set; }
///
@@ -60,6 +60,7 @@ public class Enterprise : FullAuditedAggregateRoot
}
public Enterprise(
+ Guid id,
string name,
string address,
string taxCode,
@@ -68,6 +69,7 @@ public class Enterprise : FullAuditedAggregateRoot
DateTime? registrationDate = null,
DateTime? expirationDate = null,
Guid? tenantId = null)
+ : base(id)
{
Address = Check.Length(address, nameof(address), EnterpriseConsts.MaxAddressLength);
TaxCode = Check.Length(taxCode, nameof(taxCode), EnterpriseConsts.MaxTaxCodeLength);
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs
index c816564d4..4a5a6b583 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Portal/IEnterpriseRepository.cs
@@ -5,8 +5,12 @@ using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Platform.Portal;
-public interface IEnterpriseRepository : IBasicRepository
+public interface IEnterpriseRepository : IRepository
{
+ Task FindByNameAsync(
+ string name,
+ CancellationToken cancellationToken = default);
+
Task> GetEnterprisesInTenantListAsync(
int maxResultCount = 10,
CancellationToken cancellationToken = default);
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs
index 035d8eaeb..abf2ff9cc 100644
--- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Portal/EfCoreEnterpriseRepository.cs
@@ -17,6 +17,15 @@ public class EfCoreEnterpriseRepository : EfCoreRepository FindByNameAsync(
+ string name,
+ CancellationToken cancellationToken = default)
+ {
+ return await (await GetDbSetAsync())
+ .Where(x => x.Name == name || x.EnglishName == name)
+ .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
+ }
+
public async virtual Task GetEnterpriseInTenantAsync(
Guid id,
CancellationToken cancellationToken = default)
diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Portal/EnterpriseController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Portal/EnterpriseController.cs
new file mode 100644
index 000000000..c4a5f0fab
--- /dev/null
+++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Portal/EnterpriseController.cs
@@ -0,0 +1,59 @@
+using LINGYUN.Platform.Permissions;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Application.Dtos;
+using Volo.Abp.AspNetCore.Mvc;
+
+namespace LINGYUN.Platform.Portal;
+
+[Area("platform")]
+[Authorize(PlatformPermissions.Enterprise.Default)]
+[RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)]
+[Route($"api/{PlatformRemoteServiceConsts.ModuleName}/enterprise")]
+public class EnterpriseController : AbpControllerBase, IEnterpriseAppService
+{
+ private readonly IEnterpriseAppService _service;
+ public EnterpriseController(IEnterpriseAppService service)
+ {
+ _service = service;
+ }
+
+ [HttpPost]
+ [Authorize(PlatformPermissions.Enterprise.Create)]
+ public virtual Task CreateAsync(EnterpriseCreateDto input)
+ {
+ return _service.CreateAsync(input);
+ }
+
+ [HttpDelete]
+ [Route("{id}")]
+ [Authorize(PlatformPermissions.Enterprise.Delete)]
+ public virtual Task DeleteAsync(Guid id)
+ {
+ return _service.DeleteAsync(id);
+ }
+
+ [HttpGet]
+ [Route("{id}")]
+ public virtual Task GetAsync(Guid id)
+ {
+ return _service.GetAsync(id);
+ }
+
+ [HttpGet]
+ public virtual Task> GetListAsync(EnterpriseGetListInput input)
+ {
+ return _service.GetListAsync(input);
+ }
+
+ [HttpPut]
+ [Route("{id}")]
+ [Authorize(PlatformPermissions.Enterprise.Delete)]
+ public virtual Task UpdateAsync(Guid id, EnterpriseUpdateDto input)
+ {
+ return _service.UpdateAsync(id, input);
+ }
+}