ABP 開發(一)


 

rh 

 

 

 

 

    最近搞Angular ,使用Abp+Angular建項目,遇到部分問題,記錄一下,以備查:

一、Abp官網: https://aspnetboilerplate.com/

點Get started 轉到生成模塊頁:

選擇Angular 

勾選: Include login ,register,user,role and tenant management pages。

輸入驗證碼。

輸入項目名稱,點擊Create my project! 就可以建立項目模板了

我建的時候,APB版本是:3.9.0

二、解壓文件,得到

 

 angular 就是Angular 前端項目

aspnet-core 就是API 后台項目

 

三、打開aspnet-core 找到解決方案,解決方案的名稱,就是剛開建模塊時輸入的項目名。

四、編譯解決方案,

五、還原數據庫:(注意:數據庫版本:sql 2008不行,因為abp.dll 使用了下面這樣的分頁,2008不支持:

exec sp_executesql N'SELECT [x].[Id], [x].[AccessFailedCount], [x].[AuthenticationSource], [x].[ConcurrencyStamp], [x].[CreationTime], [x].[CreatorUserId], [x].[DeleterUserId], [x].[DeletionTime], [x].[EmailAddress], [x].[EmailConfirmationCode], [x].[IsActive], [x].[IsDeleted], [x].[IsEmailConfirmed], [x].[IsLockoutEnabled], [x].[IsPhoneNumberConfirmed], [x].[IsTwoFactorEnabled], [x].[LastLoginTime], [x].[LastModificationTime], [x].[LastModifierUserId], [x].[LockoutEndDateUtc], [x].[Name], [x].[NormalizedEmailAddress], [x].[NormalizedUserName], [x].[Password], [x].[PasswordResetCode], [x].[PhoneNumber], [x].[SecurityStamp], [x].[Surname], [x].[TenantId], [x].[UserName]
FROM [AbpUsers] AS [x]
WHERE (([x].[IsDeleted] = 0) OR ([x].[IsDeleted] <> @__ef_filter__IsSoftDeleteFilterEnabled_0)) AND ([x].[TenantId] IS NULL OR (CASE
    WHEN [x].[TenantId] IS NULL
    THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
END = @__ef_filter__IsMayHaveTenantFilterEnabled_3))
ORDER BY [x].[UserName], [x].[Id]
OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY',N'@__ef_filter__IsSoftDeleteFilterEnabled_0 bit,@__ef_filter__IsMayHaveTenantFilterEnabled_3 bit,@__p
_0 int,@__p_1 int
',@__ef_filter__IsSoftDeleteFilterEnabled_0=1,@__ef_filter__IsMayHaveTenantFilterEnabled_3=1,@__p_0=1,@__p_1=10

 

我使用的是:sql 2014

(再次說明,必須是項目編譯通過之后,把MyHotelApp.Web.Host設為啟動項目)

在VS打開,程序包管理器控制台,並設:EntityFrameworkCore為默認項目,在命令行,輸入:update-database  ,並回車,

 

 

 

 這里,點運行:等待程序運行,將會在瀏覽器出現下面界面:表示成功,就可以測試各API是否正常:

登錄:admin

密碼:123qwe

 

六、Angular項目使用VSCode打開,並在控制台運行:

npm install 

(還原程序依賴包)

成功后再運行:

npm start

 

 看到以上界面表示啟動Angular成功。

 

這時打開瀏覽器:在地址輸入:localhost:4200

即可看到界面

用戶名:admin

密碼:123qwe

 

至此已完成環境搭建。

 

六、以下說一下配置:

1、Angular

   在 文件夾:angular\src\assets  中有一個appconfig.json, 內容如下:

{
"remoteServiceBaseUrl": "http://localhost:21021",
"appBaseUrl": "http://localhost:4200"
}
 
"remoteServiceBaseUrl": "http://localhost:21021",   這個就是配黑齒這套代碼的:API訪問的地址
 
2、網站:在XXX.Web.Host 配置的參數(開發可以用默),文件名:appsettings.json中
 

{
"ConnectionStrings": {
"Default": "Server=localhost\\sql2014; Database=MyHotelAppDb; Trusted_Connection=True;"
},
"App": {
"ServerRootAddress": "http://localhost:21021/",
"ClientRootAddress": "http://localhost:4200/",
"CorsOrigins": "http://localhost:4200,http://localhost:8080,http://localhost:8081"
},
"Authentication": {
"JwtBearer": {
"IsEnabled": "true",
"SecurityKey": "MyHotelApp_C421AAEE0D114E9C",
"Issuer": "MyHotelApp",
"Audience": "MyHotelApp"
}
}
}

返回有點像這個。

暫時寫這么多

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM