BodeAbp.Frame:abp框架css
BodeAbp.Modules:業務模塊html
BodeAbp.Plugins:插件web
BodeAbp.Samples:示例數據庫
using System.Reflection; using Abp.EntityFramework.Default; using Abp.Localization.Dictionaries; using Abp.Localization.Dictionaries.Xml; using Abp.Modules; using BodeAbp.Product.Providers; namespace BodeAbp.Product { /// <summary> /// 產品模塊 /// </summary> public class BodeAbpProductModule : AbpModule { /// <summary> /// 版本號 /// </summary> public const string CurrentVersion = "0.1.0"; /// <summary> /// 初始化前執行 /// </summary> public override void PreInitialize() { Configuration.Localization.Sources.Add( new DictionaryBasedLocalizationSource( BodeAbpProductConsts.LocalizationSourceName, new XmlEmbeddedFileLocalizationDictionaryProvider( Assembly.GetExecutingAssembly(), "BodeAbp.Product.Localization.Source" ) ) ); Configuration.Settings.Providers.Add<BodeAbpProductSettingProvider>(); Configuration.Navigation.Providers.Add<BodeAbpProductNavigationProvider>(); Configuration.Authorization.Providers.Add<BodeAbpProductAuthorizationProvider>(); DefaultDbContextInitializer.Instance.MapperAssemblies.Add(Assembly.GetExecutingAssembly()); } /// <summary> /// 初始化執行 /// </summary> public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); } /// <summary> /// 初始化後執行 /// </summary> public override void PostInitialize() { base.PostInitialize(); } } }
using Abp.Application.Services; using System.ComponentModel; using Abp.Application.Services.Dto; using BodeAbp.Product.Attributes.Dtos; using System.Collections.Generic; using System.Threading.Tasks; namespace BodeAbp.Product.Attributes { /// <summary> /// 屬性 服務 /// </summary> [Description("屬性接口")] public interface IAttributesAppService : IApplicationService { #region 屬性模版 /// <summary> /// 獲取 屬性模版分頁 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<PagedResultOutput<GetAttributeListOutput>> GetAttributePagedList(QueryListPagedRequestInput input); /// <summary> /// 獲取 屬性模版詳情 /// </summary> /// <param name="id">id</param> /// <returns></returns> Task<GetAttributeOutput> GetAttribute(int id); /// <summary> /// 添加 屬性模版 /// </summary> /// <param name="input"></param> /// <returns></returns> Task CreateAttribute(CreateAttributeInput input); /// <summary> /// 更新 屬性模版 /// </summary> /// <param name="input"></param> /// <returns></returns> Task UpdateAttribute(UpdateAttributeInput input); /// <summary> /// 刪除 屬性模版 /// </summary> /// <param name="input"></param> /// <returns></returns> Task DeleteAttribute(List<IdInput> input); #endregion #region 屬性值 /// <summary> /// 獲取 屬性值分頁 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<PagedResultOutput<GetAttributeOptionListOutput>> GetAttributeOptionPagedList(QueryListPagedRequestInput input); /// <summary> /// 獲取 屬性值詳情 /// </summary> /// <param name="id">id</param> /// <returns></returns> Task<GetAttributeOptionOutput> GetAttributeOption(int id); /// <summary> /// 添加 屬性值 /// </summary> /// <param name="input"></param> /// <returns></returns> Task CreateAttributeOption(CreateAttributeOptionInput input); /// <summary> /// 更新 屬性值 /// </summary> /// <param name="input"></param> /// <returns></returns> Task UpdateAttributeOption(UpdateAttributeOptionInput input); /// <summary> /// 刪除 屬性值 /// </summary> /// <param name="input"></param> /// <returns></returns> Task DeleteAttributeOption(List<IdInput> input); #endregion #region 分類 /// <summary> /// 獲取 分類分頁 /// </summary> /// <param name="input"></param> /// <returns></returns> Task<PagedResultOutput<GetProductClassifyListOutput>> GetClassifyPagedList(QueryListPagedRequestInput input); /// <summary> /// 獲取 分類詳情 /// </summary> /// <param name="id">id</param> /// <returns></returns> Task<GetProductClassifyOutput> GetClassify(int id); /// <summary> /// 添加 分類 /// </summary> /// <param name="input"></param> /// <returns></returns> Task CreateClassify(CreateProductClassifyInput input); /// <summary> /// 更新 分類 /// </summary> /// <param name="input"></param> /// <returns></returns> Task UpdateClassify(UpdateProductClassifyInput input); /// <summary> /// 刪除 分類 /// </summary> /// <param name="classifyId">分類Id</param> /// <returns></returns> Task DeleteClassify(int classifyId); #endregion } }
加載模塊:api
using System.Reflection; using System.Web.Http; using Abp.Application.Services; using Abp.Configuration.Startup; using Abp.Modules; using Abp.WebApi; using Abp.WebApi.Controllers.Dynamic.Builders; using Swashbuckle.Application; using System.Linq; using System.Web.Http.Cors; using BodeAbp.Zero; using System; using WebDemo.WebApi.Swagger; using BodeAbp.Activity; using BodeAbp.Product; namespace WebDemo.WebApi { [DependsOn( typeof(AbpWebApiModule) , typeof(WebDemoCoreModule) , typeof(BodeAbpZeroModule) , typeof(BodeAbpActivityModule) , typeof(BodeAbpProductModule))] public class WebDemoWebApiModule : AbpModule { public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(WebDemoCoreModule).Assembly, "app") .Build(); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(BodeAbpZeroModule).Assembly, "zero") .Build(); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(BodeAbpActivityModule).Assembly, "activity") .Build(); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(BodeAbpProductModule).Assembly, "product") .Build(); Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer")); var cors = new EnableCorsAttribute("*", "*", "*"); GlobalConfiguration.Configuration.EnableCors(cors); ConfigureSwaggerUi(); } private void ConfigureSwaggerUi() { Configuration.Modules.AbpWebApi().HttpConfiguration .EnableSwagger(c => { c.SingleApiVersion("v1", "WebDemo.WebApi"); //c.OperationFilter<AuthorizationOperationFilter>(); c.DocumentFilter<ApplicationDocumentFilter>(); c.IncludeXmlComments(GetXmlCommentsPath(typeof(WebDemoCoreModule))); c.IncludeXmlComments(GetXmlCommentsPath(typeof(BodeAbpZeroModule))); c.IncludeXmlComments(GetXmlCommentsPath(typeof(BodeAbpActivityModule))); c.IncludeXmlComments(GetXmlCommentsPath(typeof(BodeAbpProductModule))); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); }) .EnableSwaggerUi(c => { c.CustomAsset("index", typeof(WebDemoWebApiModule).Assembly, "WebDemo.WebApi.Swagger.index.html"); c.InjectStylesheet(typeof(WebDemoWebApiModule).Assembly, "WebDemo.WebApi.Swagger.theme-flattop.css"); c.InjectJavaScript(typeof(WebDemoWebApiModule).Assembly, "WebDemo.WebApi.Swagger.translator.js"); }); } private static string GetXmlCommentsPath(Type moduleType) { return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, moduleType.Assembly.GetName().Name); } } }
確保webconfig中數據庫鏈接正確,直接運行項目,瀏覽器訪問:http://localhost:61759/swagger/ui/index#/,效果圖以下:瀏覽器