├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── TsBlog.sln
├── document
└── scripts
│ └── mysql
│ ├── tsblog_v1.2.sql
│ ├── v1.8
│ └── tb_user.sql
│ └── v1.9
│ └── tsblog.sql
└── src
├── Libraries
├── TsBlog.AutoMapperConfig
│ ├── AutoMapperConfiguration.cs
│ ├── AutoMapperStartupTask.cs
│ ├── MappingExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TsBlog.AutoMapperConfig.csproj
│ └── packages.config
├── TsBlog.Core
│ ├── HtmlHelper.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Security
│ │ └── Encryptor.cs
│ ├── StringHelper.cs
│ └── TsBlog.Core.csproj
├── TsBlog.Domain
│ ├── Entities
│ │ ├── Post.cs
│ │ └── User.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TsBlog.Domain.csproj
│ └── packages.config
├── TsBlog.Repositories
│ ├── Config.cs
│ ├── DataConverter.cs
│ ├── DbFactory.cs
│ ├── GenericRepository.cs
│ ├── IDependency.cs
│ ├── IPagedList.cs
│ ├── IPostRepository.cs
│ ├── IRepository.cs
│ ├── IUserRepository.cs
│ ├── MySqlHelper.cs
│ ├── PagedList.cs
│ ├── PostRepository.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TsBlog.Repositories.csproj
│ ├── UserRepository.cs
│ ├── app.config
│ ├── lib
│ │ ├── MySql.Data.dll
│ │ └── MySqlSugar.dll
│ └── packages.config
├── TsBlog.Services
│ ├── GenericService.cs
│ ├── IPostService.cs
│ ├── IService.cs
│ ├── IUserService.cs
│ ├── PostService.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TsBlog.Services.csproj
│ ├── UserService.cs
│ └── app.config
└── TsBlog.ViewModel
│ ├── Post
│ └── PostViewModel.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── TsBlog.ViewModel.csproj
│ └── User
│ ├── LoginViewModel.cs
│ ├── RegisterViewModel.cs
│ └── UserViewModel.cs
└── Presentation
└── TsBlog.Frontend
├── App_Start
├── BundleConfig.cs
├── FilterConfig.cs
├── RouteConfig.cs
└── WebApiConfig.cs
├── Content
├── PagedList.css
├── Site.css
├── bootstrap-theme.css
├── bootstrap-theme.css.map
├── bootstrap-theme.min.css
├── bootstrap-theme.min.css.map
├── bootstrap.css
├── bootstrap.css.map
├── bootstrap.min.css
└── bootstrap.min.css.map
├── Controllers
├── AccountController.cs
├── Api
│ └── UserController.cs
├── HomeController.cs
└── PostController.cs
├── Extensions
└── PostExtension.cs
├── Global.asax
├── Global.asax.cs
├── Properties
└── AssemblyInfo.cs
├── Scripts
├── bootstrap.js
├── bootstrap.min.js
├── jquery-3.4.1.intellisense.js
├── jquery-3.4.1.js
└── jquery-3.4.1.min.js
├── TsBlog.Frontend.csproj
├── Views
├── Account
│ ├── login.cshtml
│ └── register.cshtml
├── Home
│ ├── Index.cshtml
│ └── Post.cshtml
├── Post
│ └── Details.cshtml
├── Shared
│ ├── Error.cshtml
│ ├── _Layout.cshtml
│ └── _NavBar.cshtml
└── Web.config
├── Web.Debug.config
├── Web.Release.config
├── Web.config
├── favicon.ico
├── fonts
├── glyphicons-halflings-regular.eot
├── glyphicons-halflings-regular.svg
├── glyphicons-halflings-regular.ttf
├── glyphicons-halflings-regular.woff
└── glyphicons-halflings-regular.woff2
├── index.html
├── packages.config
└── resources
└── css
└── site.css
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | *.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
65 | Scripts/* linguist-vendored
66 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
262 | /TsBlog.Frontend/Properties/PublishProfiles
263 |
264 | /Scripts/
265 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TsBlog
2 | **TsBlog**是一个基于ASP.NET MVC 5+Repository+Autofac+AutoMapper+SqlSugar的系列教程。旨在帮助.NET开发者快速地提升ASP.NET MVC项目的开发效率和开发技巧。
3 |
4 | 本项目由基础到框架,通过实战项目中的设计,封装以及重构,让.NET开发者们可以直观地感受ASP.NET MVC 5+Repository+Autofac+AutoMapper+SqlSugar的整个开流程和细节。
5 |
6 | 本项目有专门的专题教程,详情请见:[一步一步创建ASP.NET MVC5程序\[Repository+Autofac+Automapper+SqlSugar\]][1]
7 |
8 | 如果你在学习或者查看源码时遇到什么问题,或有意见/建议,欢迎加入我们的QQ交流群:483350228
9 |
10 | [1]: https://codedefault.com/t/EdVp8xCk
11 |
--------------------------------------------------------------------------------
/TsBlog.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2010
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2.Persentation", "2.Persentation", "{FA8E85B0-9A67-4C64-B336-7DAD8D6833D0}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1.Libraries", "1.Libraries", "{EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.Domain", "src\Libraries\TsBlog.Domain\TsBlog.Domain.csproj", "{E415AB82-2704-4984-9576-A9BC8F3DED30}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.Repositories", "src\Libraries\TsBlog.Repositories\TsBlog.Repositories.csproj", "{0B3D004F-250E-439F-B0AB-9268C33D3DEB}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.Frontend", "src\Presentation\TsBlog.Frontend\TsBlog.Frontend.csproj", "{5CC238A7-ED1E-475D-B8F0-43E94CF5A24E}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.Services", "src\Libraries\TsBlog.Services\TsBlog.Services.csproj", "{6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.AutoMapperConfig", "src\Libraries\TsBlog.AutoMapperConfig\TsBlog.AutoMapperConfig.csproj", "{2866A0EC-8F66-4CB5-BC70-568EC3397EFB}"
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.ViewModel", "src\Libraries\TsBlog.ViewModel\TsBlog.ViewModel.csproj", "{459E7C49-DE30-4FFD-8912-FF9ED8069DEB}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TsBlog.Core", "src\Libraries\TsBlog.Core\TsBlog.Core.csproj", "{0A171809-BF68-4AD5-A3D2-D4638149E95C}"
23 | EndProject
24 | Global
25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
26 | Debug|Any CPU = Debug|Any CPU
27 | Release|Any CPU = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
30 | {E415AB82-2704-4984-9576-A9BC8F3DED30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {E415AB82-2704-4984-9576-A9BC8F3DED30}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {E415AB82-2704-4984-9576-A9BC8F3DED30}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {E415AB82-2704-4984-9576-A9BC8F3DED30}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {0B3D004F-250E-439F-B0AB-9268C33D3DEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {0B3D004F-250E-439F-B0AB-9268C33D3DEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {0B3D004F-250E-439F-B0AB-9268C33D3DEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {0B3D004F-250E-439F-B0AB-9268C33D3DEB}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {5CC238A7-ED1E-475D-B8F0-43E94CF5A24E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {5CC238A7-ED1E-475D-B8F0-43E94CF5A24E}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {5CC238A7-ED1E-475D-B8F0-43E94CF5A24E}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {5CC238A7-ED1E-475D-B8F0-43E94CF5A24E}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {0A171809-BF68-4AD5-A3D2-D4638149E95C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {0A171809-BF68-4AD5-A3D2-D4638149E95C}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {0A171809-BF68-4AD5-A3D2-D4638149E95C}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {0A171809-BF68-4AD5-A3D2-D4638149E95C}.Release|Any CPU.Build.0 = Release|Any CPU
58 | EndGlobalSection
59 | GlobalSection(SolutionProperties) = preSolution
60 | HideSolutionNode = FALSE
61 | EndGlobalSection
62 | GlobalSection(NestedProjects) = preSolution
63 | {E415AB82-2704-4984-9576-A9BC8F3DED30} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
64 | {0B3D004F-250E-439F-B0AB-9268C33D3DEB} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
65 | {5CC238A7-ED1E-475D-B8F0-43E94CF5A24E} = {FA8E85B0-9A67-4C64-B336-7DAD8D6833D0}
66 | {6BCFD47C-B93A-4E6C-8E27-3EF8CCB49D74} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
67 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
68 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
69 | {0A171809-BF68-4AD5-A3D2-D4638149E95C} = {EC3F3ECF-1C39-46B1-9379-13CE519A2BE9}
70 | EndGlobalSection
71 | GlobalSection(ExtensibilityGlobals) = postSolution
72 | SolutionGuid = {C238B374-A804-4D90-9C62-E56EC977BA8B}
73 | EndGlobalSection
74 | EndGlobal
75 |
--------------------------------------------------------------------------------
/document/scripts/mysql/tsblog_v1.2.sql:
--------------------------------------------------------------------------------
1 | /*
2 | SQLyog Enterprise v12.4.1 (64 bit)
3 | MySQL - 5.7.17-log : Database - tsblog
4 | *********************************************************************
5 | */
6 |
7 | /*!40101 SET NAMES utf8 */;
8 |
9 | /*!40101 SET SQL_MODE=''*/;
10 |
11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`tsblog` /*!40100 DEFAULT CHARACTER SET utf8 */;
16 |
17 | USE `tsblog`;
18 |
19 | /*Table structure for table `tb_post` */
20 |
21 | DROP TABLE IF EXISTS `tb_post`;
22 |
23 | CREATE TABLE `tb_post` (
24 | `Id` int(12) NOT NULL AUTO_INCREMENT,
25 | `Title` varchar(255) DEFAULT '' COMMENT '标题',
26 | `Content` text COMMENT '内容',
27 | `AuthorId` int(6) DEFAULT '0' COMMENT '作者ID',
28 | `AuthorName` varchar(50) DEFAULT '' COMMENT '作者姓名',
29 | `CreatedAt` datetime DEFAULT NULL COMMENT '创建时间',
30 | `PublishedAt` datetime DEFAULT NULL COMMENT '发布时间',
31 | `IsDeleted` bit(1) DEFAULT b'0' COMMENT '是否标识已删除[0:否,1:是],默认值:0',
32 | `AllowShow` bit(1) DEFAULT b'1' COMMENT '是否允许展示[0:否,1:是],默认值:1',
33 | `ViewCount` int(10) DEFAULT '0' COMMENT '浏览量',
34 | PRIMARY KEY (`Id`)
35 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
36 |
37 | /*Data for the table `tb_post` */
38 |
39 | insert into `tb_post`(`Id`,`Title`,`Content`,`AuthorId`,`AuthorName`,`CreatedAt`,`PublishedAt`,`IsDeleted`,`AllowShow`,`ViewCount`) values
40 | (1,'Title','Clean content',0,'',NULL,NULL,'\0','',0);
41 |
42 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
43 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
44 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
45 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
46 |
--------------------------------------------------------------------------------
/document/scripts/mysql/v1.8/tb_user.sql:
--------------------------------------------------------------------------------
1 | SET FOREIGN_KEY_CHECKS = 0;
2 |
3 | -- ----------------------------
4 | -- Table structure for ts_user
5 | -- ----------------------------
6 | DROP TABLE IF EXISTS `tb_user`;
7 | CREATE TABLE `tb_user` (
8 | `Id` int(10) NOT NULL AUTO_INCREMENT,
9 | `LoginName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '登录名',
10 | `Password` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '密码',
11 | `DisplayName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '显示名称',
12 | `RealName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '真实姓名',
13 | `EmailAddress` varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '电子邮箱',
14 | `Avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户头像',
15 | `Status` int(2) NOT NULL DEFAULT 1 COMMENT '用户的状态,0:禁用,1:正常',
16 | `Telephone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '手机号码',
17 | `Qq` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '',
18 | `WebsiteUrl` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '',
19 | `CreatedOn` datetime(0) NULL DEFAULT NULL COMMENT '用户创建时间',
20 | `CreatedIp` varchar(24) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建用户时的IP地址',
21 | `LoginCount` int(8) NULL DEFAULT 0 COMMENT '登录次数累加器',
22 | `LatestLoginDate` datetime(0) NULL DEFAULT NULL COMMENT '最近一次登录时间',
23 | `LatestLoginIp` varchar(24) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '最近一次登录时的IP地址',
24 | `ModifiedOn` datetime(0) NULL DEFAULT NULL COMMENT '最近修改时间',
25 | `Type` int(2) NULL DEFAULT 0 COMMENT '用户类型[-1:超级管理员,0:一般用户]',
26 | PRIMARY KEY (`Id`) USING BTREE,
27 | UNIQUE INDEX `IX_LoginName`(`LoginName`) USING BTREE,
28 | UNIQUE INDEX `IX_EmailAddress`(`EmailAddress`) USING BTREE,
29 | INDEX `IX_CreatedOn`(`CreatedOn`) USING BTREE
30 | ) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
31 |
32 | SET FOREIGN_KEY_CHECKS = 1;
33 |
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/AutoMapperConfiguration.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using TsBlog.Domain.Entities;
3 | using TsBlog.ViewModel.Post;
4 | using TsBlog.ViewModel.User;
5 |
6 | namespace TsBlog.AutoMapperConfig
7 | {
8 | ///
9 | /// AutoMapper的全局实体映射配置静态类
10 | ///
11 | public static class AutoMapperConfiguration
12 | {
13 | public static void Init()
14 | {
15 | MapperConfiguration = new MapperConfiguration(cfg =>
16 | {
17 |
18 | #region Post
19 | //将领域实体映射到视图实体
20 | cfg.CreateMap()
21 | .ForMember(d => d.IsDeleted, d => d.MapFrom(s => s.IsDeleted ? "是" : "否")) //将布尔类型映射成字符串类型的是/否
22 | ;
23 | //将视图实体映射到领域实体
24 | cfg.CreateMap();
25 | #endregion
26 |
27 | #region User
28 |
29 | cfg.CreateMap();
30 | cfg.CreateMap();
31 | #endregion
32 | });
33 |
34 | Mapper = MapperConfiguration.CreateMapper();
35 | }
36 |
37 | public static IMapper Mapper { get; private set; }
38 |
39 | public static MapperConfiguration MapperConfiguration { get; private set; }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/AutoMapperStartupTask.cs:
--------------------------------------------------------------------------------
1 | namespace TsBlog.AutoMapperConfig
2 | {
3 | ///
4 | /// AutoMapper初始化类
5 | ///
6 | public class AutoMapperStartupTask
7 | {
8 | public void Execute()
9 | {
10 | AutoMapperConfiguration.Init();
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/MappingExtensions.cs:
--------------------------------------------------------------------------------
1 | using TsBlog.Domain.Entities;
2 | using TsBlog.ViewModel.Post;
3 | using TsBlog.ViewModel.User;
4 |
5 | namespace TsBlog.AutoMapperConfig
6 | {
7 | ///
8 | /// 数据库表-实体映射静态扩展类
9 | ///
10 | public static class MappingExtensions
11 | {
12 | public static TDestination MapTo(this TSource source)
13 | {
14 | return AutoMapperConfiguration.Mapper.Map(source);
15 | }
16 |
17 | public static TDestination MapTo(this TSource source, TDestination destination)
18 | {
19 | return AutoMapperConfiguration.Mapper.Map(source, destination);
20 | }
21 |
22 | #region Post
23 | public static PostViewModel ToModel(this Post entity)
24 | {
25 | return entity.MapTo();
26 | }
27 |
28 | public static Post ToEntity(this PostViewModel model)
29 | {
30 | return model.MapTo();
31 | }
32 |
33 | #endregion
34 |
35 | #region User
36 | public static UserViewModel ToModel(this User entity)
37 | {
38 | return entity.MapTo();
39 | }
40 |
41 | public static User ToEntity(this UserViewModel model)
42 | {
43 | return model.MapTo();
44 | }
45 |
46 | #endregion
47 |
48 | }
49 | }
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TsBlog.AutoMapperConfig")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TsBlog.AutoMapperConfig")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2866a0ec-8f66-4cb5-bc70-568ec3397efb")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/TsBlog.AutoMapperConfig.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2866A0EC-8F66-4CB5-BC70-568EC3397EFB}
8 | Library
9 | Properties
10 | TsBlog.AutoMapperConfig
11 | TsBlog.AutoMapperConfig
12 | v4.6.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\..\..\packages\AutoMapper.8.0.0\lib\net461\AutoMapper.dll
35 |
36 |
37 |
38 |
39 |
40 | ..\..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {e415ab82-2704-4984-9576-a9bc8f3ded30}
58 | TsBlog.Domain
59 |
60 |
61 | {459E7C49-DE30-4FFD-8912-FF9ED8069DEB}
62 | TsBlog.ViewModel
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.AutoMapperConfig/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/Libraries/TsBlog.Core/HtmlHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 |
3 | namespace TsBlog.Core
4 | {
5 | public static class HtmlHelper
6 | {
7 | #region 去掉HTML中的所有标签,只留下纯文本
8 | ///
9 | /// 去掉HTML中的所有标签,只留下纯文本
10 | ///
11 | ///
12 | ///
13 | public static string CleanHtml(this string strHtml)
14 | {
15 | if (string.IsNullOrEmpty(strHtml)) return strHtml;
16 | //删除脚本
17 | strHtml = Regex.Replace(strHtml, "(\\
74 |
75 |
76 |
77 |