diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..1f8aa4c94c5419cce66aee255f20409f6aef056f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+bin
+debug
+obj
+.vscode
+.vs
+node_modules
+dist
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/.gitignore b/CMSBackend/Admin3000.Backend/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..34aa044d6fa4a8ff68d98f8af2854e20fb8aa27b
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/.gitignore
@@ -0,0 +1,4 @@
+.vscode
+.vs
+bin
+obj
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/00520a8a2c8b421faf15cc872805fac0.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/00520a8a2c8b421faf15cc872805fac0.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..731bef6f642968f3303d95bd98e9a939d6a6dd36
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/00520a8a2c8b421faf15cc872805fac0.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/0c36057bfca44c96b9ba1270c08690b3.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/0c36057bfca44c96b9ba1270c08690b3.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a756b21ba3def70dcfb49acfd70799797dcf058d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/0c36057bfca44c96b9ba1270c08690b3.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2c9a0bd6122244fe8dc81cc2261b2a51.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2c9a0bd6122244fe8dc81cc2261b2a51.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..03db0d1ec3f6fdb0fba4b46bf7ac18574b9d568d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2c9a0bd6122244fe8dc81cc2261b2a51.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2d3215cc8f4748899faa9297c0512a3c.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2d3215cc8f4748899faa9297c0512a3c.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..731bef6f642968f3303d95bd98e9a939d6a6dd36
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/2d3215cc8f4748899faa9297c0512a3c.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/3858fc8199a8406699ccb46b822f2193.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/3858fc8199a8406699ccb46b822f2193.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..03db0d1ec3f6fdb0fba4b46bf7ac18574b9d568d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/3858fc8199a8406699ccb46b822f2193.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/46c24bb0c9f94a76bb75080a7f8097a6.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/46c24bb0c9f94a76bb75080a7f8097a6.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a756b21ba3def70dcfb49acfd70799797dcf058d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/46c24bb0c9f94a76bb75080a7f8097a6.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/6d340ae34e4749a4b7db33ccf71b7184.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/6d340ae34e4749a4b7db33ccf71b7184.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..38e4a3121eb91d238f276f7ea80bed9ce60423e6
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/6d340ae34e4749a4b7db33ccf71b7184.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/7e1ab3cc370c4c6abc43174799b756f1.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/7e1ab3cc370c4c6abc43174799b756f1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a756b21ba3def70dcfb49acfd70799797dcf058d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/7e1ab3cc370c4c6abc43174799b756f1.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/80a3f0dd83bb41f68b9f6715c7efba11.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/80a3f0dd83bb41f68b9f6715c7efba11.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..03db0d1ec3f6fdb0fba4b46bf7ac18574b9d568d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/80a3f0dd83bb41f68b9f6715c7efba11.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/834e2677d5144702b2a065c98f86f8b6.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/834e2677d5144702b2a065c98f86f8b6.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..ff4067e79789122cc49efb85df92698b55cb88a3
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/834e2677d5144702b2a065c98f86f8b6.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/877150b5157141a88fb4921bfddc65e6.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/877150b5157141a88fb4921bfddc65e6.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a756b21ba3def70dcfb49acfd70799797dcf058d
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/877150b5157141a88fb4921bfddc65e6.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/8813b7baf76d43d0ab9b1d849731562f.jpg b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/8813b7baf76d43d0ab9b1d849731562f.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..e26ba85a6bfb677becbca7a4f556271d3222d3bb
Binary files /dev/null and b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/8813b7baf76d43d0ab9b1d849731562f.jpg differ
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Admin3000.Backend.Api.csproj b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Admin3000.Backend.Api.csproj
new file mode 100644
index 0000000000000000000000000000000000000000..a75379581b75e3ce3909431fe8d8b3af669d456c
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Admin3000.Backend.Api.csproj
@@ -0,0 +1,18 @@
+
+
+
+ netcoreapp3.1
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticleCommentsController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticleCommentsController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..f30334df1548d787bc36f65c0c5da7e182c94a56
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticleCommentsController.cs
@@ -0,0 +1,168 @@
+
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class ArticleCommentsController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _articlecommentsRepository;
+ private IRepository _usercommentRepository;
+
+ private IRepository _articlesRepository;
+
+ private IRepository _commentsRepository;
+
+ private IRepository _usersRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public ArticleCommentsController(
+ IConfiguration configuration,
+ IRepository articlecommentsRepository,
+ IRepository commentsRepository,
+ IRepository usercommentRepository,
+ IRepository usersRepository
+ )
+ {
+ _configuration = configuration;
+ _articlecommentsRepository = articlecommentsRepository;
+ _commentsRepository = commentsRepository;
+ _usercommentRepository = usercommentRepository;
+ _usersRepository = usersRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+
+ // //通过文章id获取评论id
+ // [HttpPost,Route("acticleid")]
+ // public dynamic POST(CreateArticleComments createarticlecomments)
+ // {
+ // var acticleid=createarticlecomments.ArticleId;
+ // var articlecomment=_articlecommentsRepository.Table.Where(x=>x.ArticleId==acticleid).ToList();
+
+ // return new{
+ // Code=1000,
+ // Data=articlecomment,
+ // Msg="查询指定用户Id成功"
+ // };
+ // }
+
+ //通过文章id获取评论id
+ // [HttpGet("articleid/{articleid}"),Route("articleid")]
+ // public dynamic Get(int articleid)
+ // {
+ // var acticlecomment=_articlecommentsRepository.Table.Where(x=>x.ArticleId==articleid).ToList();
+
+ // return new{
+ // Code=1000,
+ // Data=acticlecomment,
+ // Msg="查询指定用户Id成功"
+ // };
+
+ // }
+
+
+
+
+ //列出文章评论列表
+ [HttpGet]
+ public dynamic Get()
+ {
+ var articlecomment = _articlecommentsRepository.Table.ToList();
+
+ {
+
+ }
+ // var kescc = query.
+
+ var articlecomments = new
+ {
+ Code = 1000,
+ Data = new { Data = articlecomment },
+ Msg = "列出文章评论列表成功"
+ };
+
+ return articlecomments;
+ }
+
+ //通过文章id查询文章评论表
+ [HttpGet("articleid/{articleid}"), Route("articleid")]
+ public dynamic Get(int articleid)
+ {
+ var acticlecomment = _articlecommentsRepository.Table.Where(x => x.ArticleId == articleid).ToList();
+ var comments = _commentsRepository.Table.ToList();
+ var usercomment = _usercommentRepository.Table.ToList();
+ var user = _usersRepository.Table.ToList();
+ var query = from a in acticlecomment
+ join b in comments on a.CommentId equals b.Id
+ join c in usercomment on b.Id equals c.CommentId
+ join d in user on c.UserId equals d.Id
+ select new
+ {
+ ArticleId = a.ArticleId,
+ CommentId = a.CommentId,
+ CommentText = b.CommentText,
+ UserId = c.UserId,
+ Username = d.Username
+ };
+ return new
+ {
+ Code = 1000,
+ Data = new { Data = query },
+ Msg = "查询指定用户Id成功"
+ };
+
+ }
+
+
+
+
+ //增加文章评论 文章Id 评论Id
+ [HttpPost]
+ public dynamic Post(CreateArticleComments newArticleComments)
+ {
+ var articlecomments = new ArticleComments
+ {
+ ArticleId = newArticleComments.ArticleId,
+ CommentId = newArticleComments.CommentId
+ };
+ _articlecommentsRepository.Insert(articlecomments);
+ return new
+ {
+ Code = 1000,
+ Data = articlecomments,
+ Msg = "增加文章评论成功"
+ };
+ }
+
+
+ //删除对应Id文章评论
+ [HttpDelete("{id}")]
+ public dynamic Delete(int id)
+ {
+ _articlecommentsRepository.Delete(id);
+
+ return new { Code = 1000, Data = "", Msg = "删除文章评论成功" };
+
+ }
+
+
+
+
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticlesController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticlesController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d145020039d562ccfda9628afe4fe3ddc8e57e03
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/ArticlesController.cs
@@ -0,0 +1,199 @@
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class ArticlesController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _articlesRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public ArticlesController(
+ IConfiguration configuration,
+ IRepository articlesRepository
+ )
+ {
+ _configuration = configuration;
+ _articlesRepository = articlesRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+ //id搜索
+ [HttpGet("{id}")]
+ public dynamic Get(int id)
+ {
+ var article = _articlesRepository.GetById(id);
+ article.NumReadings+=1;
+ return JsonHelper.Serialize ( new
+ {
+ Code = 1000,
+ Data = article,
+ Msg = "获取成功"
+ });
+ }
+ //列出文章列表
+ public dynamic Ger()
+ {
+ var article=_articlesRepository.Table.ToList();
+
+
+ return new{
+ Code=1000,
+ Data=new{Data=article},
+ Msg="列出文章列表成功"
+ };
+ }
+
+
+ [HttpGet("numReadings"),Route("numReadings")]
+ //搜索阅读排行榜前5条
+ public dynamic Getread()
+ {
+ var article=_articlesRepository.Table.ToList()
+ .OrderByDescending(s => s.NumReadings).Take(5);
+ return new{
+ Code=1000,
+ Data=new{Data=article},
+ Msg="列出阅读列表成功"
+ };
+
+ }
+
+ [HttpGet("latest"),Route("latest")]
+ //搜索最新5条
+ public dynamic latest()
+ {
+ var article=_articlesRepository.Table.ToList()
+ .OrderByDescending(s => s.Id).Take(5);
+ return new{
+ Code=1000,
+ Data=new{Data=article},
+ Msg="列出最新列表成功"
+ };
+ }
+ [HttpGet("addLikes/{id}"),Route("addLikes")]
+ public dynamic addLikes(int id)
+ {
+ var article = _articlesRepository.GetById(id);
+ article.Likes += 1;
+ return JsonHelper.Serialize ( new
+ {
+ Code = 1000,
+ Data = article,
+ Msg = "获取成功"
+ });
+ }
+ [HttpGet("cancleLikes/{id}"),Route("cancleLikes")]
+ public dynamic cancleLikes(int id)
+ {
+ var article = _articlesRepository.GetById(id);
+ article.Likes -= 1;
+ return JsonHelper.Serialize ( new
+ {
+ Code = 1000,
+ Data = article,
+ Msg = "获取成功"
+ });
+ }
+
+
+
+ //新增文章 标题、内容、点赞数、阅读数
+ [HttpPost]
+ public dynamic Post( CreateArticle newArticles)
+ {
+ var title=newArticles.Title;
+ var context=newArticles.Context;
+ var Avatar=newArticles.Avatar;
+ var Author=newArticles.Author;
+ var likes=newArticles.Likes==0;
+ var numreadings=newArticles.NumReadings==0;
+
+
+ var articles = new Articles{
+ Title = newArticles.Title,
+ Context = newArticles.Context,
+ Likes=newArticles.Likes,
+ NumReadings=newArticles.NumReadings,
+ Avatar=newArticles.Avatar,
+ Author=newArticles.Author
+
+ };
+ _articlesRepository.Insert(articles);
+ return new{
+ Code = 1000,
+ Data=articles,
+ Msg = "新增文章成功"
+ };
+ }
+
+
+ //删除对应Id文章
+ [HttpDelete("{id}")]
+ public dynamic Delete(int id)
+ {
+ _articlesRepository.Delete(id);
+ return new { Code = 1000, Data = "", Msg = "删除文章成功^_^" };
+ }
+
+ //获取文章数量
+ [HttpGet("homepage"),Route("homepage")]
+ public dynamic homepage()
+ {
+ var arictles = _articlesRepository.Table.ToList();
+ var res = new
+ {
+ Code = 1000,
+ Data = new { Data = arictles },
+ Msg = "获取文章列表成功^_^"
+ };
+
+ return JsonHelper.Serialize(res);
+ }
+
+ //更新阅读数量
+ [HttpPut("{id}")]
+ public dynamic Post(int id,CreateArticle createarticle )
+ {
+ var article=_articlesRepository.GetById(id);
+
+ article.NumReadings=createarticle.NumReadings;
+
+ _articlesRepository.Update(article);
+
+ return new {
+ Code=1000,
+ Data=article,
+ Msg="更新成功"
+ };
+ }
+ [HttpGet("Likes"),Route("Likes")]
+ //搜索阅读排行榜前5条
+ public dynamic GetLikes()
+ {
+ var article=_articlesRepository.Table.ToList()
+ .OrderByDescending(s => s.Likes).Take(5);
+ return new{
+ Code=1000,
+ Data=new{Data=article},
+ Msg="列出阅读列表成功"
+ };
+ }
+
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/CommentsController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/CommentsController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..9a348df8e23e901be0f2698db58a398f1a7fc5a3
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/CommentsController.cs
@@ -0,0 +1,124 @@
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class CommentsController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _commentsRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public CommentsController(
+ IConfiguration configuration,
+ IRepository commentsRepository
+ )
+ {
+ _configuration = configuration;
+ _commentsRepository = commentsRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+
+
+ //列出评论列表
+ [HttpGet]
+ public dynamic Get()
+ {
+ var comments = _commentsRepository.Table.ToList();
+ var res = new
+ {
+ Code = 1000,
+ Data = new { Data = comments },
+ Msg = "获取评论列表成功^_^"
+ };
+
+ return JsonHelper.Serialize(res);
+ }
+
+ //按评论Id搜索
+ [HttpGet("{id}")]
+ public dynamic Get(int id)
+ {
+ var comments = _commentsRepository.GetById(id);
+
+ return new
+ {
+ Code = 1000,
+ Data = comments,
+ Msg = "获取成功"
+ };
+ }
+
+
+ //增加评论 评论内容
+ [HttpPost]
+ public dynamic Post(CreateComments newComments)
+ {
+ // commenttext = newComments.CommentText.Trim();
+ var Comments = new Comments
+ {
+ CommentText = newComments.CommentText,
+ };
+ _commentsRepository.Insert(Comments);
+ return new
+ {
+ Code = 1000,
+ Data = Comments,
+ Msg = "增加评论成功"
+ };
+ }
+
+
+ //删除对应Id评论
+ [HttpDelete("{id}")]
+ public dynamic Delete(int id)
+ {
+ _commentsRepository.Delete(id);
+ return new { Code = 1000, Data = "", Mig = "删除评论成功" };
+ }
+
+ //获取评论数量
+ [HttpGet("homepage"), Route("homepage")]
+ public dynamic homepage()
+ {
+ var arictles = _commentsRepository.Table.ToList();
+ var res = new
+ {
+ Code = 1000,
+ Data = new { Data = arictles },
+ Msg = "获取评论列表成功^_^"
+ };
+
+ return JsonHelper.Serialize(res);
+ }
+ //查询评论id
+ // [HttpGet("{id}")]
+ // public dynamic Get(int id)
+ // {
+ // var comments = _commentsRepository.GetById(id);
+
+ // return new
+ // {
+ // Code = 1000,
+ // Data = comments,
+ // Msg = "获取成功"
+ // };
+
+ // }
+ }
+ }
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/FilesControllers.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/FilesControllers.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2284673e78a23de56408a6366980a3c45d23ebbb
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/FilesControllers.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class FilesController : ControllerBase
+ {
+ private readonly IConfiguration _configuration;
+
+ public FilesController(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ }
+
+ ///
+ /// 文件上传接口
+ ///
+ ///
+ ///
+ [HttpPost, Route("uploadfiles")]
+ public string UploadFiles(IFormCollection model)
+ {
+ // 获得当前应用所在的完整路径(绝对地址)
+ var filePath = Directory.GetCurrentDirectory();
+
+ // 通过配置文件获得存放文件的相对路径
+ string path = _configuration["UploadFilesPath"];
+
+ // 最终存放文件的完整路径
+ var preFullPath = Path.Combine(filePath, path);
+ // 如果路径不存在,则创建
+ if (!Directory.Exists(preFullPath))
+ {
+ Directory.CreateDirectory(preFullPath);
+ }
+
+ var resultPath = new List();
+ foreach (IFormFile file in model.Files)
+ {
+ if (file.Length > 0)
+ {
+ var fileName = file.FileName;
+ var extName = fileName.Substring(fileName.LastIndexOf("."));//extName包含了“.”
+ var tempPath = Path.Combine(path, Guid.NewGuid().ToString("N") + extName);
+ using (var stream = new FileStream(Path.Combine(filePath, tempPath), FileMode.CreateNew))//Path.Combine(_env.WebRootPath, fileName)
+ {
+ file.CopyTo(stream);
+ }
+
+ // 此处地址可能带有两个反斜杠,虽然也能用,比较奇怪,统一转换成斜杠,这样在任何平台都有一样的表现
+ resultPath.Add(tempPath.Replace("\\", "/"));
+ }
+ }
+
+ var res = new
+ {
+ Code = 1000,
+ Data = resultPath,
+ Msg = "上传成功"
+ };
+
+ return JsonHelper.Serialize(res);
+ }
+
+ [AllowAnonymous]
+ [Route("{prePath}")]
+ [HttpGet]
+ public FileContentResult Get(string prePath)
+ {
+ prePath =prePath;
+
+ var currentPath = Directory.GetCurrentDirectory();
+ var fullPath = Path.Combine(currentPath, prePath);
+ using (var sw = new FileStream(fullPath, FileMode.Open))
+ {
+ var fileType = GetFileTypeWithFileName(fullPath);
+ var bytes = new byte[sw.Length];
+ sw.Read(bytes, 0, bytes.Length);
+ sw.Close();
+ return new FileContentResult(bytes, fileType);
+ };
+
+ }
+
+ ///
+ /// 注册表获取文件类型
+ ///
+ ///
+ ///
+ private string GetFileTypeWithFileName(string fileName)
+ {
+ //获取文件后缀
+ string ext = Path.GetExtension(fileName);
+ using (Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext))
+ {
+ if (registryKey == null)
+ return null;
+ var value = registryKey.GetValue("Content Type");
+ return value?.ToString();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/LogControllers.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/LogControllers.cs
new file mode 100644
index 0000000000000000000000000000000000000000..c7d2f7699c8c149708696e2e07b5d3f341e527c8
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/LogControllers.cs
@@ -0,0 +1,67 @@
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class LogsController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _auditInfoRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public LogsController(
+ IConfiguration configuration,
+ IRepository auditRepository
+ )
+ {
+ _configuration = configuration;
+ _auditInfoRepository = auditRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+ [HttpGet]
+ public string Get([FromQuery]Pager pager)
+ {
+ // get请求默认从url中获取参数,如果需要使用实体接收参数,需要FromQuery特性
+ var pageIndex=pager.PageIndex;
+ var pageSize=pager.PageSize;
+ var users = _auditInfoRepository.Table;
+ var u=users.Skip((pageIndex-1)*pageSize).Take(pageSize).ToList();
+ var res=new {
+ Code = 1000,
+ Data = new {Data = u,Pager =new {pageIndex,pageSize,rowsTotal=users.Count()}},
+ Msg = "获取用户列表成功^_^"
+ };
+ return JsonHelper.Serialize(res);
+ }
+
+ [HttpGet("{id}")]
+ public dynamic Get(int id)
+ {
+ var user = _auditInfoRepository.GetById(id);
+ return new {
+ Code = 1000,
+ Data = user,
+ Msg = "获取指定用户成功^_^"
+ };
+ }
+
+
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UserCommentsController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UserCommentsController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..ed65b363420faf0440a2652f27e446017c32b91f
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UserCommentsController.cs
@@ -0,0 +1,80 @@
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class UserCommentsController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _usercommentRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public UserCommentsController(
+ IConfiguration configuration,
+ IRepository usercommentRepository
+ )
+ {
+ _configuration = configuration;
+ _usercommentRepository = usercommentRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+
+ //列出用户评论列表
+ [HttpGet]
+ public dynamic Get()
+ {
+ var usercomment=_usercommentRepository.Table.ToList();
+
+ return new{
+ Code=1000,
+ Data=new{Data=usercomment},
+ Msg="列出用户评论列表成功"
+ };
+ }
+
+
+ //新增用户评论 用户Id、评论Id
+ [HttpPost]
+ [Route("usercommemtID")]
+ public dynamic Post(CreateUserComments newUserComments)
+ {
+ var userid=newUserComments.UserId;
+ var commentid=newUserComments.CommentId;
+
+
+ var usercomments = new UserComment{
+ UserId=newUserComments.UserId,
+ CommentId=newUserComments.CommentId
+ };
+ _usercommentRepository.Insert(usercomments);
+ return new{
+ Code = 1000,
+ Data=usercomments,
+ Msg = "新增用户评论成功"
+ };
+ }
+ //删除对应Id用户评论
+ [HttpDelete("{id}")]
+ public dynamic Delete(int id)
+ {
+ _usercommentRepository.Delete(id);
+ return new { Code = 1000, Data = "", Msg = "删除用户评论成功^_^" };
+ }
+
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UsersController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UsersController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..321c61f8f4c4251d903bc9c98895e424b2b7da7e
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/UsersController.cs
@@ -0,0 +1,245 @@
+using System.Linq;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Params;
+using Admin3000.Backend.Api.Repository;
+using Admin3000.Backend.Api.Utils;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ // [Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ public class UsersController : ControllerBase
+ {
+ private IConfiguration _configuration;
+
+ private IRepository _usersRepository;
+
+ private TokenParameter _tokenParameter;
+
+ public UsersController(
+ IConfiguration configuration,
+ IRepository usersRepository
+ )
+ {
+ _configuration = configuration;
+ _usersRepository = usersRepository;
+ _tokenParameter =
+ _configuration
+ .GetSection("TokenParameter")
+ .Get();
+ }
+
+
+ //列出用户列表
+ [HttpGet]
+ public string Get([FromQuery] QueryWithPager query)
+ {
+ // get请求默认从url中获取参数,如果需要使用实体接收参数,需要FromQuery特性
+ var pageIndex = query.Pager.PageIndex;
+ var pageSize = query.Pager.PageSize;
+ var keyword = string.IsNullOrEmpty(query.Keyword) ? "" : query.Keyword.Trim();
+ var users = _usersRepository.Table
+ .Where(x => x.IsDeleted == false);
+ // 如果keyword不为空,则再去查询用户名
+ if (!string.IsNullOrEmpty(keyword))
+ {
+ users = users.Where(x => x.Username.Contains(keyword));
+ }
+
+ var u = users.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
+ var res = new
+ {
+ Code = 1000,
+ Data = new { Data = u, Pager = new { pageIndex, pageSize, rowsTotal = users.Count() } },
+ Msg = "获取用户列表成功^_^"
+ };
+ return JsonHelper.Serialize(res);
+ }
+
+
+ //获取用户数量
+ [HttpGet("homepage"), Route("homepage")]
+ public dynamic homepage()
+ {
+ var users = _usersRepository.Table.ToList();
+ var res = new
+ {
+ Code = 1000,
+ Data = new { Data = users },
+ Msg = "获取用户列表成功^_^"
+ };
+
+ return JsonHelper.Serialize(res);
+ }
+
+ //查询对应Id用户
+ [HttpGet("{id}")]
+ public dynamic Get(int id)
+ {
+ var user = _usersRepository.GetById(id);
+
+ if (user == null)
+ {
+ return new
+ {
+ Code = 104,
+ Data = "",
+ Msg = "你要查询的用户不存在!"
+ };
+ }
+ return JsonHelper.Serialize(new
+ {
+ Code = 1000,
+ Data = user,
+ Msg = "获取指定用户成功"
+ });
+
+ }
+
+
+ //新增用户
+ [HttpPost]
+ public dynamic Post([FromBody] CreateUser newUser)
+ {
+ var username = newUser.Username.Trim();
+ var password = newUser.Password == null ? "113" : newUser.Password.Trim();
+
+ if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)
+ )
+ {
+ return JsonHelper.Serialize(new { Code = 104, Data = " ", Msg = "用户名或密码不能为空" });
+ }
+
+ var user =
+ new Users
+ {
+ Username = newUser.Username,
+ Password = newUser.Password,
+ Remarks = newUser.remarks
+ };
+
+ _usersRepository.Insert(user);
+ return JsonHelper.Serialize(new { Code = 1000, Data = user, Msg = "创建用户成功^_^" });
+ }
+
+
+ //修改对应Id用户
+ [HttpPut("{id}")]
+ public string Put(int id, CreateUser updateUser)
+ {
+ var username = updateUser.Username.Trim();
+ var password = updateUser.Password.Trim();
+
+ if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)
+ )
+ {
+ return JsonHelper.Serialize(new
+ {
+ Code = 104,
+ Data = "",
+ Msg = "用户名或密码不能为空=_="
+ });
+ }
+
+ var user = _usersRepository.GetById(id);
+
+ if (user == null)
+ {
+ return JsonHelper.Serialize(new
+ {
+ Code = 104,
+ Data = "",
+ Msg = "要更新的用户不存在,请确认后重试=_="
+ });
+ }
+
+ user.Username = updateUser.Username;
+ user.Password = updateUser.Password;
+ user.Remarks = updateUser.remarks;
+
+ _usersRepository.Update(user);
+
+ return JsonHelper.Serialize(new { Code = 1000, Data = user, Msg = "更新成功" });
+ }
+
+
+
+
+
+ //删除对应Id用户
+ [HttpDelete("{id}")]
+ public dynamic Delete(int id)
+ {
+ _usersRepository.Delete(id);
+ return new { Code = 1000, Data = "", Msg = "删除用户成功^_^" };
+ }
+
+
+
+
+ //登录验证 获取token
+ [AllowAnonymous]
+ [HttpPost, Route("token")]
+ public dynamic GetToken(CreateUser newUser)
+ {
+ var username = newUser.Username.Trim();
+ var password = newUser.Password.Trim();
+
+ var user =
+ _usersRepository
+ .Table
+ .Where(x =>
+ x.Username == username && x.Password == password)
+ .FirstOrDefault();
+
+ if (user == null)
+ {
+ return new
+ {
+ Code = 104,
+ Data = "",
+ Msg = "用户名或密码不正确,请确认后重试"
+ };
+ }
+
+ var token =
+ TokenHelper.GenerateToekn(_tokenParameter, user.Username);
+ var refreshToken = "112358";
+
+ return new
+ {
+ Code = 1000,
+ Data = new { Token = token, refreshToken = refreshToken, user.Username, user.Password, user.Id },
+ Msg = "用户登录成功^_^"
+ };
+ }
+
+
+ //刷新frfreshtoken
+ [AllowAnonymous]
+ [HttpPost, Route("refreshtoken")]
+ public dynamic RefreshToken(RefreshTokenDTO refresh)
+ {
+ var username = TokenHelper.ValidateToken(_tokenParameter, refresh);
+
+ if (string.IsNullOrEmpty(username))
+ {
+ return new { Code = 1002, Data = "", Msg = "token验证失败" };
+ }
+
+ var token = TokenHelper.GenerateToekn(_tokenParameter, username);
+ var refreshToken = "112358";
+
+ return new
+ {
+ Code = 1000,
+ Data = new { Token = token, refreshToken = refreshToken },
+ Msg = "刷新token成功^_^"
+ };
+ }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/WeatherForecastController.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..e9e5f359a2ac8a2eb4641c5a243e10e98cc89eab
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Controllers/WeatherForecastController.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace Admin3000.Backend.Api.Controllers
+{
+ [ApiController]
+ [Route("[controller]")]
+ public class WeatherForecastController : ControllerBase
+ {
+ private static readonly string[] Summaries = new[]
+ {
+ "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
+ };
+
+ private readonly ILogger _logger;
+
+ public WeatherForecastController(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ [HttpGet]
+ public IEnumerable Get()
+ {
+ var rng = new Random();
+ return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+ {
+ Date = DateTime.Now.AddDays(index),
+ TemperatureC = rng.Next(-20, 55),
+ Summary = Summaries[rng.Next(Summaries.Length)]
+ })
+ .ToArray();
+ }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Database/Admin3000Db.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Database/Admin3000Db.cs
new file mode 100644
index 0000000000000000000000000000000000000000..1501fe23d4d7e74c85227010f7157882f1842cd0
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Database/Admin3000Db.cs
@@ -0,0 +1,32 @@
+using Microsoft.EntityFrameworkCore;
+using Admin3000.Backend.Api.Entity;
+
+namespace Admin3000.Backend.Api.Database
+{
+ ///
+ /// 数据库上下文,这里定义这些实体对应的数据表、及连接参数
+ ///
+ public class Admin3000Db : DbContext
+ {
+ ///
+ /// 采用依赖注入的方式的时,必须提供其构造函数,并且调用其父类构造函数
+ ///
+ ///
+ ///
+ public Admin3000Db(DbContextOptions options) : base(options)
+ {
+
+ }
+ public DbSet Users { get; set; }
+ public DbSet Articles { get; set; }
+ public DbSet Comments { get; set; }
+ public DbSet AuditInfo { get; set; }
+ public DbSet ArticleComments{get;set;}
+ public DbSet UserComments{get;set;}
+
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ {
+ options.UseSqlServer(@"server=.;database=Admin3000Db;uid=sa;pwd=123456");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/ArticleComments.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/ArticleComments.cs
new file mode 100644
index 0000000000000000000000000000000000000000..74b5628d06c63d02469fe6db84e7c232a1871248
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/ArticleComments.cs
@@ -0,0 +1,10 @@
+namespace Admin3000.Backend.Api.Entity
+{
+ public class ArticleComments : BaseEntity
+ {
+ public int ArticleId{get;set;}
+ public int CommentId{get;set;}
+ public virtual Articles Article {get;set;}
+ public virtual Comments Comment {get;set;}
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Articles.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Articles.cs
new file mode 100644
index 0000000000000000000000000000000000000000..a52d7828ac80be83bff8c819d3c0492115ee0b59
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Articles.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+
+namespace Admin3000.Backend.Api.Entity
+{
+ public class Articles : BaseEntity
+ {
+
+
+ //标
+ public string Title { get; set; }
+
+ //内容
+ public string Context { get; set; }
+
+ //图片
+ public string Avatar { get; set; }
+ //作者
+ public string Author { get; set; }
+
+
+
+ //点赞
+ public int Likes { get; set; }
+
+ //阅读数量
+ public int NumReadings { get; set; }
+
+ public virtual IEnumerable ArticleComments { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/AuditInfo.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/AuditInfo.cs
new file mode 100644
index 0000000000000000000000000000000000000000..22001398b37a9e80c2f88ba6ede0f4c033be366d
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/AuditInfo.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+
+namespace Admin3000.Backend.Api.Entity
+{
+ ///
+ /// 角色实体
+ ///
+ public class AuditInfo : BaseEntity
+ {
+ ///
+ /// 调用参数
+ ///
+ public string Parameters { get; set; }
+
+ ///
+ /// 浏览器信息
+ ///
+ public string BrowserInfo { get; set; }
+
+ ///
+ /// 客户端信息
+ ///
+ public string ClientName { get; set; }
+
+ ///
+ /// 客户端IP地址
+ ///
+ public string ClientIpAddress { get; set; }
+
+ ///
+ /// 执行耗时
+ ///
+ public int ExecutionDuration { get; set; }
+
+ ///
+ /// 执行时间
+ ///
+ public DateTime ExecutionTime { get; set; }
+
+ ///
+ /// 返回内容
+ ///
+ public string ReturnValue { get; set; }
+
+ ///
+ /// 异常对象
+ ///
+ public string Exception { get; set; }
+
+ ///
+ /// 方法名
+ ///
+ public string MethodName { get; set; }
+
+ ///
+ /// 服务名
+ ///
+ public string ServiceName { get; set; }
+
+ ///
+ /// 调用者信息
+ ///
+ public string UserInfo { get; set; }
+
+ ///
+ /// 自定义数据
+ ///
+ public string CustomData { get; set; }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/BaseEntity.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/BaseEntity.cs
new file mode 100644
index 0000000000000000000000000000000000000000..69f2e01856205450fa66ab2ccc5f2891af1a2fc7
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/BaseEntity.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace Admin3000.Backend.Api.Entity
+{
+ ///
+ /// 基础实体类型
+ ///
+ public abstract class BaseEntity
+ {
+ public int Id { get; set; }
+ public bool IsActived { get; set; }
+ public bool IsDeleted { get; set; }
+ public DateTime CreatedTime { get; set; }
+ public DateTime UpdatedTime { get; set; }
+ public int DisplayOrder { get; set; }
+ public string Remarks { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Comments.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Comments.cs
new file mode 100644
index 0000000000000000000000000000000000000000..72e0203f74da1a85b2005ca22b6e223759b8d981
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Comments.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace Admin3000.Backend.Api.Entity
+{
+ public class Comments : BaseEntity
+ {
+ //评论内容
+ public string CommentText { get; set; }
+ public virtual IEnumerable UserComment { get; set; }
+ public virtual IEnumerable ArticleComments { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/UserComment.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/UserComment.cs
new file mode 100644
index 0000000000000000000000000000000000000000..e92283b65cfe9327b4912843c5089501efc15bcb
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/UserComment.cs
@@ -0,0 +1,10 @@
+namespace Admin3000.Backend.Api.Entity
+{
+ public class UserComment : BaseEntity
+ {
+ public int UserId{get;set;}
+ public int CommentId{get;set;}
+ public virtual Users User{get;set;}
+ public virtual Comments Comment{get;set;}
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Users.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Users.cs
new file mode 100644
index 0000000000000000000000000000000000000000..3e5b812d9a921978260d54cd3cb06b10d35efc68
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Entity/Users.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+
+namespace Admin3000.Backend.Api.Entity
+{
+ public class Users : BaseEntity
+ {
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public virtual IEnumerable UserComment { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Filters/AuditLogActionFilter.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Filters/AuditLogActionFilter.cs
new file mode 100644
index 0000000000000000000000000000000000000000..dd2046d46e0089719232a62356d386a48dbdd79b
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Filters/AuditLogActionFilter.cs
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Admin3000.Backend.Api.Entity;
+using Admin3000.Backend.Api.Repository;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+
+namespace Admin3000.Backend.Api.Filters
+{
+ public class AuditLogActionFilter : IAsyncActionFilter
+ {
+ ///
+ /// 登录用户
+ ///
+ // private readonly ISession _Session;
+ ///
+ /// 日志记录
+ ///
+ private readonly ILogger _logger;
+
+ private readonly IRepository _auditLogService;
+
+ public AuditLogActionFilter(// ISession Session,
+
+ ILogger logger,
+ IRepository auditLogService
+ )
+ {
+ // _Session = Session;
+ _logger = logger;
+ _auditLogService = auditLogService;
+ }
+
+ public async Task
+ OnActionExecutionAsync(
+ ActionExecutingContext context,
+ ActionExecutionDelegate next
+ )
+ {
+ // 判断是否写日志
+ if (!ShouldSaveAudit(context))
+ {
+ await next();
+ return;
+ }
+
+ //接口Type
+ var type =
+ (context.ActionDescriptor as ControllerActionDescriptor)
+ .ControllerTypeInfo
+ .AsType();
+
+ //方法信息
+ var method =
+ (context.ActionDescriptor as ControllerActionDescriptor)
+ .MethodInfo;
+
+ //方法参数
+ var arguments = context.ActionArguments;
+
+ //开始计时
+ var stopwatch = Stopwatch.StartNew();
+ var auditInfo =
+ new AuditInfo {
+ // UserInfo = _Session?.Id,
+ UserInfo = 1.ToString(),
+ ServiceName = type != null ? type.FullName : "",
+ MethodName = method.Name,
+ ////请求参数转Json
+ Parameters = JsonConvert.SerializeObject(arguments),
+ ExecutionTime = DateTime.Now,
+ BrowserInfo =
+ context
+ .HttpContext
+ .Request
+ .Headers["User-Agent"]
+ .ToString(),
+ ClientIpAddress =
+ context
+ .HttpContext
+ .Connection
+ .RemoteIpAddress
+ .ToString()
+ //ClientName = _clientInfoProvider.ComputerName.TruncateWithPostfix(EntityDefault.FieldsLength100),
+ // Id = Guid.NewGuid().ToString()
+ };
+
+ ActionExecutedContext result = null;
+ try
+ {
+ result = await next();
+ if (result.Exception != null && !result.ExceptionHandled)
+ {
+ auditInfo.Exception = result.Exception.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ auditInfo.Exception = ex.ToString();
+ throw;
+ }
+ finally
+ {
+ stopwatch.Stop();
+ auditInfo.ExecutionDuration =
+ Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds);
+
+ if (result != null)
+ {
+ switch (result.Result)
+ {
+ case ObjectResult objectResult:
+ auditInfo.ReturnValue =
+ JsonConvert.SerializeObject(objectResult.Value);
+ break;
+ case JsonResult jsonResult:
+ auditInfo.ReturnValue =
+ JsonConvert.SerializeObject(jsonResult.Value);
+ break;
+ case ContentResult contentResult:
+ auditInfo.ReturnValue = contentResult.Content;
+ break;
+ }
+ }
+ Console.WriteLine(auditInfo.ToString());
+
+ //保存审计日志
+ await _auditLogService.InsertAsync(auditInfo);
+ }
+ }
+
+ ///
+ /// 是否需要记录审计
+ ///
+ ///
+ ///
+ private bool ShouldSaveAudit(ActionExecutingContext context)
+ {
+ if (!(context.ActionDescriptor is ControllerActionDescriptor))
+ return false;
+ var methodInfo =
+ (context.ActionDescriptor as ControllerActionDescriptor)
+ .MethodInfo;
+
+ if (methodInfo == null)
+ {
+ return false;
+ }
+
+ if (!methodInfo.IsPublic)
+ {
+ return false;
+ }
+
+ // if (methodInfo.GetCustomAttribute() != null)
+ // {
+ // return true;
+ // }
+ // if (methodInfo.GetCustomAttribute() != null)
+ // {
+ // return false;
+ // }
+ // var classType = methodInfo.DeclaringType;
+ // if (classType != null)
+ // {
+ // if (classType.GetTypeInfo().GetCustomAttribute() != null)
+ // {
+ // return true;
+ // }
+ // if (classType.GetTypeInfo().GetCustomAttribute() != null)
+ // {
+ // return false;
+ // }
+ // }
+ return true;
+ }
+ }
+}
diff --git "a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.Designer.cs" "b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.Designer.cs"
new file mode 100644
index 0000000000000000000000000000000000000000..a7a3cd79aedb58a32f38d968a78569ae65c40bc1
--- /dev/null
+++ "b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.Designer.cs"
@@ -0,0 +1,344 @@
+//
+using System;
+using Admin3000.Backend.Api.Database;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Admin3000.Backend.Api.Migrations
+{
+ [DbContext(typeof(Admin3000Db))]
+ [Migration("20210805013044_数据迁移")]
+ partial class 数据迁移
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.7")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.ArticleComments", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ArticleId")
+ .HasColumnType("int");
+
+ b.Property("CommentId")
+ .HasColumnType("int");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ArticleId");
+
+ b.HasIndex("CommentId");
+
+ b.ToTable("ArticleComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Articles", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Author")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Avatar")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Context")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Likes")
+ .HasColumnType("int");
+
+ b.Property("NumReadings")
+ .HasColumnType("int");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Title")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.ToTable("Articles");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.AuditInfo", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("BrowserInfo")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClientIpAddress")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClientName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CustomData")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("Exception")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExecutionDuration")
+ .HasColumnType("int");
+
+ b.Property("ExecutionTime")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("MethodName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Parameters")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ReturnValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ServiceName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UserInfo")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("AuditInfo");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Comments", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CommentText")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.ToTable("Comments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.UserComment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CommentId")
+ .HasColumnType("int");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CommentId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("UserComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Users", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Password")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("Username")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.ArticleComments", b =>
+ {
+ b.HasOne("Admin3000.Backend.Api.Entity.Articles", "Article")
+ .WithMany("ArticleComments")
+ .HasForeignKey("ArticleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Admin3000.Backend.Api.Entity.Comments", "Comment")
+ .WithMany("ArticleComments")
+ .HasForeignKey("CommentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Article");
+
+ b.Navigation("Comment");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.UserComment", b =>
+ {
+ b.HasOne("Admin3000.Backend.Api.Entity.Comments", "Comment")
+ .WithMany("UserComment")
+ .HasForeignKey("CommentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Admin3000.Backend.Api.Entity.Users", "User")
+ .WithMany("UserComment")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Comment");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Articles", b =>
+ {
+ b.Navigation("ArticleComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Comments", b =>
+ {
+ b.Navigation("ArticleComments");
+
+ b.Navigation("UserComment");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Users", b =>
+ {
+ b.Navigation("UserComment");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git "a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.cs" "b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.cs"
new file mode 100644
index 0000000000000000000000000000000000000000..5688e7949464154bfefbe30d3966a25a73b38796
--- /dev/null
+++ "b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/20210805013044_\346\225\260\346\215\256\350\277\201\347\247\273.cs"
@@ -0,0 +1,209 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Admin3000.Backend.Api.Migrations
+{
+ public partial class 数据迁移 : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Articles",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Title = table.Column(type: "nvarchar(max)", nullable: true),
+ Context = table.Column(type: "nvarchar(max)", nullable: true),
+ Avatar = table.Column(type: "nvarchar(max)", nullable: true),
+ Author = table.Column(type: "nvarchar(max)", nullable: true),
+ Likes = table.Column(type: "int", nullable: false),
+ NumReadings = table.Column(type: "int", nullable: false),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Articles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AuditInfo",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Parameters = table.Column(type: "nvarchar(max)", nullable: true),
+ BrowserInfo = table.Column(type: "nvarchar(max)", nullable: true),
+ ClientName = table.Column(type: "nvarchar(max)", nullable: true),
+ ClientIpAddress = table.Column(type: "nvarchar(max)", nullable: true),
+ ExecutionDuration = table.Column(type: "int", nullable: false),
+ ExecutionTime = table.Column(type: "datetime2", nullable: false),
+ ReturnValue = table.Column(type: "nvarchar(max)", nullable: true),
+ Exception = table.Column(type: "nvarchar(max)", nullable: true),
+ MethodName = table.Column(type: "nvarchar(max)", nullable: true),
+ ServiceName = table.Column(type: "nvarchar(max)", nullable: true),
+ UserInfo = table.Column(type: "nvarchar(max)", nullable: true),
+ CustomData = table.Column(type: "nvarchar(max)", nullable: true),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AuditInfo", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Comments",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ CommentText = table.Column(type: "nvarchar(max)", nullable: true),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Comments", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Username = table.Column(type: "nvarchar(max)", nullable: true),
+ Password = table.Column(type: "nvarchar(max)", nullable: true),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ArticleComments",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ArticleId = table.Column(type: "int", nullable: false),
+ CommentId = table.Column(type: "int", nullable: false),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ArticleComments", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ArticleComments_Articles_ArticleId",
+ column: x => x.ArticleId,
+ principalTable: "Articles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ArticleComments_Comments_CommentId",
+ column: x => x.CommentId,
+ principalTable: "Comments",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "UserComments",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ UserId = table.Column(type: "int", nullable: false),
+ CommentId = table.Column(type: "int", nullable: false),
+ IsActived = table.Column(type: "bit", nullable: false),
+ IsDeleted = table.Column(type: "bit", nullable: false),
+ CreatedTime = table.Column(type: "datetime2", nullable: false),
+ UpdatedTime = table.Column(type: "datetime2", nullable: false),
+ DisplayOrder = table.Column(type: "int", nullable: false),
+ Remarks = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_UserComments", x => x.Id);
+ table.ForeignKey(
+ name: "FK_UserComments_Comments_CommentId",
+ column: x => x.CommentId,
+ principalTable: "Comments",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_UserComments_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ArticleComments_ArticleId",
+ table: "ArticleComments",
+ column: "ArticleId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ArticleComments_CommentId",
+ table: "ArticleComments",
+ column: "CommentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UserComments_CommentId",
+ table: "UserComments",
+ column: "CommentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_UserComments_UserId",
+ table: "UserComments",
+ column: "UserId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ArticleComments");
+
+ migrationBuilder.DropTable(
+ name: "AuditInfo");
+
+ migrationBuilder.DropTable(
+ name: "UserComments");
+
+ migrationBuilder.DropTable(
+ name: "Articles");
+
+ migrationBuilder.DropTable(
+ name: "Comments");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+ }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/Admin3000DbModelSnapshot.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/Admin3000DbModelSnapshot.cs
new file mode 100644
index 0000000000000000000000000000000000000000..ce1dd5384e81592537a49ca6ff5cfaf884d6385e
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Migrations/Admin3000DbModelSnapshot.cs
@@ -0,0 +1,342 @@
+//
+using System;
+using Admin3000.Backend.Api.Database;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Admin3000.Backend.Api.Migrations
+{
+ [DbContext(typeof(Admin3000Db))]
+ partial class Admin3000DbModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.7")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.ArticleComments", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ArticleId")
+ .HasColumnType("int");
+
+ b.Property("CommentId")
+ .HasColumnType("int");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ArticleId");
+
+ b.HasIndex("CommentId");
+
+ b.ToTable("ArticleComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Articles", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Author")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Avatar")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Context")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Likes")
+ .HasColumnType("int");
+
+ b.Property("NumReadings")
+ .HasColumnType("int");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Title")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.ToTable("Articles");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.AuditInfo", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("BrowserInfo")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClientIpAddress")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClientName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("CustomData")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("Exception")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExecutionDuration")
+ .HasColumnType("int");
+
+ b.Property("ExecutionTime")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("MethodName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Parameters")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ReturnValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ServiceName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UserInfo")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("AuditInfo");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Comments", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CommentText")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.HasKey("Id");
+
+ b.ToTable("Comments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.UserComment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CommentId")
+ .HasColumnType("int");
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("UserId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CommentId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("UserComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Users", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("CreatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("DisplayOrder")
+ .HasColumnType("int");
+
+ b.Property("IsActived")
+ .HasColumnType("bit");
+
+ b.Property("IsDeleted")
+ .HasColumnType("bit");
+
+ b.Property("Password")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Remarks")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UpdatedTime")
+ .HasColumnType("datetime2");
+
+ b.Property("Username")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.ArticleComments", b =>
+ {
+ b.HasOne("Admin3000.Backend.Api.Entity.Articles", "Article")
+ .WithMany("ArticleComments")
+ .HasForeignKey("ArticleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Admin3000.Backend.Api.Entity.Comments", "Comment")
+ .WithMany("ArticleComments")
+ .HasForeignKey("CommentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Article");
+
+ b.Navigation("Comment");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.UserComment", b =>
+ {
+ b.HasOne("Admin3000.Backend.Api.Entity.Comments", "Comment")
+ .WithMany("UserComment")
+ .HasForeignKey("CommentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Admin3000.Backend.Api.Entity.Users", "User")
+ .WithMany("UserComment")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Comment");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Articles", b =>
+ {
+ b.Navigation("ArticleComments");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Comments", b =>
+ {
+ b.Navigation("ArticleComments");
+
+ b.Navigation("UserComment");
+ });
+
+ modelBuilder.Entity("Admin3000.Backend.Api.Entity.Users", b =>
+ {
+ b.Navigation("UserComment");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticleComments.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticleComments.cs
new file mode 100644
index 0000000000000000000000000000000000000000..200c214257bdfa7ace11c40cfcd3964fcf40df34
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticleComments.cs
@@ -0,0 +1,9 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class CreateArticleComments
+ {
+ //评论内容
+ public int ArticleId{get;set;}
+ public int CommentId{get;set;}
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticles.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticles.cs
new file mode 100644
index 0000000000000000000000000000000000000000..8754dc2df341996e51dcaf6a65758e6c524ed47d
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateArticles.cs
@@ -0,0 +1,25 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class CreateArticle
+ {
+
+
+ //标题
+ public string Title { get; set; }
+
+ //内容
+ public string Context { get; set; }
+ //作者
+ public string Author { get; set; }
+
+ //点赞
+
+ public int Likes { get; set; }
+ //图片
+ public string Avatar { get; set; }
+
+ //阅读数量
+ public int NumReadings { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateComments.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateComments.cs
new file mode 100644
index 0000000000000000000000000000000000000000..69b515f67dcca1fefd9de81270daacf230d754f1
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateComments.cs
@@ -0,0 +1,8 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class CreateComments
+ {
+ //评论内容
+ public string CommentText { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUser.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUser.cs
new file mode 100644
index 0000000000000000000000000000000000000000..2c017ebefa6ee38a35d1a83bfcefe02732a08b9f
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUser.cs
@@ -0,0 +1,9 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class CreateUser
+ {
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public string remarks {get;set;}
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUserComments.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUserComments.cs
new file mode 100644
index 0000000000000000000000000000000000000000..be72a90d24d19692c2dca1d95a85f7d707555e1e
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/CreateUserComments.cs
@@ -0,0 +1,9 @@
+namespace Admin3000.Backend.Api.Entity
+{
+ public class CreateUserComments
+ {
+ public int UserId{get;set;}
+ public int CommentId{get;set;}
+
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/Pager.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/Pager.cs
new file mode 100644
index 0000000000000000000000000000000000000000..f5655d08c692d568a57caa7d3bcf7cb93d7b4ecf
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/Pager.cs
@@ -0,0 +1,49 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class Pager
+ {
+ private int _pageIndex;
+ private int _pageSize;
+ public Pager()
+ {
+ _pageSize=1;
+ _pageSize=10;
+ }
+ // 页码(当前第几页)
+ public int PageIndex
+ {
+ get
+ {
+ if (_pageIndex < 1)
+ {
+ _pageIndex = 1;
+ }
+ return _pageIndex;
+ }
+ set
+ {
+ _pageIndex = value;
+ }
+ }
+
+ // 页大小(一页里面行的数量)
+ public int PageSize
+ {
+ get
+ {
+ if (_pageSize < 10)
+ {
+ _pageSize = 10;
+ }
+ return _pageSize;
+ }
+ set
+ {
+ _pageSize = value;
+ }
+ }
+
+ // 总记录数量
+ public int RowsTotal { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/QueryWithPager.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/QueryWithPager.cs
new file mode 100644
index 0000000000000000000000000000000000000000..688aa6dfc5346a28cdfa88c7c9025851bfff8c39
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/QueryWithPager.cs
@@ -0,0 +1,11 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class QueryWithPager
+ {
+ public QueryWithPager(){
+ Pager=new Pager();
+ }
+ public string Keyword { get; set; }
+ public Pager Pager { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/RefreshToken.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/RefreshToken.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d5e9d53e0f15243a8d0a0e77816cfe3919f72685
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/RefreshToken.cs
@@ -0,0 +1,8 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class RefreshTokenDTO
+ {
+ public string Token { get; set; }
+ public string refreshToken { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/TokenParameter.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/TokenParameter.cs
new file mode 100644
index 0000000000000000000000000000000000000000..217f1ebe3f31c8194e2f1e8f7f53fee7047d4a02
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Params/TokenParameter.cs
@@ -0,0 +1,17 @@
+namespace Admin3000.Backend.Api.Params
+{
+ public class TokenParameter
+ {
+ //生成token的所需要的密钥,一定不能泄漏
+ public string Secret { get; set; }
+
+ // 发行token的发行人(可以是个人或者组织)
+ public string Issuer { get; set; }
+
+ // token的有效分钟数
+ public int AccessExpiration { get; set; }
+
+ // RefreshExpiration的有效分钟数
+ public int RefreshExpiration { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Program.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Program.cs
new file mode 100644
index 0000000000000000000000000000000000000000..f16341afe16f12e63e665a348a67127d75345e72
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Program.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace Admin3000.Backend.Api
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ });
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Properties/launchSettings.json b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Properties/launchSettings.json
new file mode 100644
index 0000000000000000000000000000000000000000..30ef2588b75cbe93a1b881034ab435493a8cca79
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Properties/launchSettings.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:56858",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "weatherforecast",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "Admin3000.Backend.Api": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "weatherforecast",
+ "applicationUrl": "http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Repository/EfRepository.cs b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Repository/EfRepository.cs
new file mode 100644
index 0000000000000000000000000000000000000000..e9e5c79dc1842bdb1c0173fdaef519f82fdb3b1e
--- /dev/null
+++ b/CMSBackend/Admin3000.Backend/Admin3000.Backend.Api/Repository/EfRepository.cs
@@ -0,0 +1,155 @@
+using Admin3000.Backend.Api.Entity;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Admin3000.Backend.Api.Database;
+using Microsoft.EntityFrameworkCore;
+using System;
+
+namespace Admin3000.Backend.Api.Repository
+{
+ public class EfRepository : IRepository where T : BaseEntity
+ {
+ private Admin3000Db _db;
+
+ public EfRepository(Admin3000Db db)
+ {
+ _db = db;
+ }
+
+ private DbSet _entity;
+
+ protected DbSet Entity
+ {
+ get
+ {
+ if (_entity == null)
+ {
+ _entity = _db.Set();
+ }
+ return _entity;
+ }
+ }
+
+ public IQueryable