diff --git a/Infrastructure/CustomException/ResultCode.cs b/Infrastructure/CustomException/ResultCode.cs
index 58739e4c80369701fd295ad73f8cc8215780664e..6f1c9c897f90099b758a913828ac9703b3132db8 100644
--- a/Infrastructure/CustomException/ResultCode.cs
+++ b/Infrastructure/CustomException/ResultCode.cs
@@ -34,6 +34,9 @@ namespace Infrastructure
[Description("授权失败")]
OAUTH_FAIL = 201,
+ [Description("请先绑定手机号")]
+ PHONE_BIND = 202,
+
[Description("未授权")]
DENY = 401,
diff --git a/ZR.ServiceCore/ProteryConstant.cs b/Infrastructure/ProteryConstant.cs
similarity index 100%
rename from ZR.ServiceCore/ProteryConstant.cs
rename to Infrastructure/ProteryConstant.cs
diff --git a/ZR.Admin.WebApi/Controllers/Article/ArticleCategoryController.cs b/ZR.Admin.WebApi/Controllers/Article/ArticleCategoryController.cs
index ffa2ac7eb8e11a0221531107d3faf1c0c79dbba4..bb9a8186db7b4ac18600eb72a91a4b56f9585841 100644
--- a/ZR.Admin.WebApi/Controllers/Article/ArticleCategoryController.cs
+++ b/ZR.Admin.WebApi/Controllers/Article/ArticleCategoryController.cs
@@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
+using ZR.Model.Content;
using ZR.Model.Dto;
-using ZR.Model.System;
+using ZR.Service.Content.IService;
namespace ZR.Admin.WebApi.Controllers
{
@@ -28,7 +29,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("list")]
- //[ActionPermissionFilter(Permission = "articlecategory:list")]
+ [AllowAnonymous]
public IActionResult QueryArticleCategory([FromQuery] ArticleCategoryQueryDto parm)
{
var response = _ArticleCategoryService.GetList(parm);
@@ -41,7 +42,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("treeList")]
- //[ActionPermissionFilter(Permission = "articlecategory:list")]
+ [AllowAnonymous]
public IActionResult QueryTreeArticleCategory([FromQuery] ArticleCategoryQueryDto parm)
{
var response = _ArticleCategoryService.GetTreeList(parm);
@@ -54,6 +55,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("{CategoryId}")]
+ [AllowAnonymous]
//[ActionPermissionFilter(Permission = "articlecategory:query")]
public IActionResult GetArticleCategory(int CategoryId)
{
@@ -62,6 +64,20 @@ namespace ZR.Admin.WebApi.Controllers
return SUCCESS(response);
}
+ ///
+ /// 查询目录分类
+ ///
+ ///
+ ///
+ [HttpGet("type{categoryType}")]
+ //[ActionPermissionFilter(Permission = "articlecategory:query")]
+ public IActionResult GetArticleCategoryByType(int categoryType)
+ {
+ var response = _ArticleCategoryService.GetFirst(x => x.CategoryType == categoryType);
+
+ return SUCCESS(response);
+ }
+
///
/// 添加文章目录
///
diff --git a/ZR.Admin.WebApi/Controllers/Article/ArticleController.cs b/ZR.Admin.WebApi/Controllers/Article/ArticleController.cs
index 4056968f89a4a8c949eb3ef5af76a963f37432d2..c8475fc4ec3f94ef50b2cee4df52b54494d9e5a5 100644
--- a/ZR.Admin.WebApi/Controllers/Article/ArticleController.cs
+++ b/ZR.Admin.WebApi/Controllers/Article/ArticleController.cs
@@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Mvc;
-using SqlSugar;
using ZR.Admin.WebApi.Filters;
-using ZR.Model.System;
-using ZR.Model.System.Dto;
-using ZR.ServiceCore.Model.Enums;
+using ZR.Model.Content;
+using ZR.Model.Dto;
+using ZR.Service.Content.IService;
namespace ZR.Admin.WebApi.Controllers
{
@@ -21,10 +20,13 @@ namespace ZR.Admin.WebApi.Controllers
private readonly IArticleService _ArticleService;
private readonly IArticleCategoryService _ArticleCategoryService;
- public ArticleController(IArticleService ArticleService, IArticleCategoryService articleCategoryService)
+ public ArticleController(
+ IArticleService ArticleService,
+ IArticleCategoryService articleCategoryService)
{
_ArticleService = ArticleService;
_ArticleCategoryService = articleCategoryService;
+ _ArticleService = ArticleService;
}
///
@@ -53,83 +55,36 @@ namespace ZR.Admin.WebApi.Controllers
return SUCCESS(response);
}
- ///
- /// 前台查询文章列表
- ///
- ///
- [HttpGet("hotList")]
- [AllowAnonymous]
- public IActionResult QueryHot([FromQuery] ArticleQueryDto parm)
- {
- var response = _ArticleService.GetHotList(parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 查询最新文章列表
- ///
- ///
- [HttpGet("newList")]
- [AllowAnonymous]
- public IActionResult QueryNew()
- {
- var predicate = Expressionable.Create();
- predicate = predicate.And(m => m.Status == "1");
- predicate = predicate.And(m => m.IsPublic == 1);
-
- var response = _ArticleService.Queryable()
- .Where(predicate.ToExpression())
- .Includes(x => x.ArticleCategoryNav) //填充子对象
- .Take(10)
- .OrderBy(f => f.UpdateTime, OrderByType.Desc).ToList();
-
- return SUCCESS(response);
- }
-
///
/// 查询文章详情
///
///
///
[HttpGet("{id}")]
- [AllowAnonymous]
public IActionResult Get(int id)
{
long userId = HttpContext.GetUId();
- var response = _ArticleService.GetId(id);
- var model = response.Adapt();
- if (model == null) return ToResponse(ResultCode.FAIL, "文章不存在");
- if (model.IsPublic == 0 && userId != model.UserId)
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, "访问失败");
- }
- if (model != null)
- {
- model.ArticleCategoryNav = _ArticleCategoryService.GetById(model.CategoryId);
- model.TagList = model.Tags?.Split(',', StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty();
- }
- var CK = "ARTICLE_DETAILS_" + userId + HttpContextExtension.GetClientUserIp(HttpContext);
- if (!CacheHelper.Exists(CK))
- {
- _ArticleService.UpdateArticleHit(id);
- }
- CacheHelper.SetCache(CK, 1, 10);
- return SUCCESS(model);
+ var model = _ArticleService.GetArticle(id, userId);
+
+ ApiResult apiResult = ApiResult.Success(model);
+
+ return ToResponse(apiResult);
}
///
- /// 添加文章
+ /// 发布文章
///
///
[HttpPost("add")]
[ActionPermissionFilter(Permission = "system:article:add")]
- [Log(Title = "发布文章", BusinessType = BusinessType.INSERT)]
+ //[Log(Title = "发布文章", BusinessType = BusinessType.INSERT)]
public IActionResult Create([FromBody] ArticleDto parm)
{
var addModel = parm.Adapt().ToCreate(context: HttpContext);
addModel.AuthorName = HttpContext.GetName();
addModel.UserId = HttpContext.GetUId();
+ addModel.UserIP = HttpContext.GetClientUserIp();
+ addModel.Location = HttpContextExtension.GetIpInfo(addModel.UserIP);
return SUCCESS(_ArticleService.InsertReturnIdentity(addModel));
}
@@ -140,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers
///
[HttpPut("edit")]
[ActionPermissionFilter(Permission = "system:article:update")]
- [Log(Title = "文章修改", BusinessType = BusinessType.UPDATE)]
+ //[Log(Title = "文章修改", BusinessType = BusinessType.UPDATE)]
public IActionResult Update([FromBody] ArticleDto parm)
{
parm.AuthorName = HttpContext.GetName();
@@ -190,6 +145,5 @@ namespace ZR.Admin.WebApi.Controllers
var response = _ArticleService.Delete(id);
return SUCCESS(response);
}
-
}
}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/Controllers/Article/ArticleTopicController.cs b/ZR.Admin.WebApi/Controllers/Article/ArticleTopicController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..300c10266d5bec959cdba6c685ef0fcc46157cdd
--- /dev/null
+++ b/ZR.Admin.WebApi/Controllers/Article/ArticleTopicController.cs
@@ -0,0 +1,122 @@
+using Microsoft.AspNetCore.Mvc;
+using ZR.Admin.WebApi.Filters;
+using ZR.Model.Content;
+using ZR.Model.Dto;
+using ZR.Service.Content.IService;
+
+//创建时间:2024-04-29
+namespace ZR.Admin.WebApi.Controllers
+{
+ ///
+ /// 文章话题
+ ///
+ [Verify]
+ [ApiExplorerSettings(GroupName = "article")]
+ [Route("article/ArticleTopic")]
+ public class ArticleTopicController : BaseController
+ {
+ ///
+ /// 文章话题接口
+ ///
+ private readonly IArticleTopicService _ArticleTopicService;
+
+ public ArticleTopicController(IArticleTopicService ArticleTopicService)
+ {
+ _ArticleTopicService = ArticleTopicService;
+ }
+
+ ///
+ /// 查询文章话题列表
+ ///
+ ///
+ ///
+ [HttpGet("list")]
+ [ActionPermissionFilter(Permission = "articletopic:list")]
+ public IActionResult QueryArticleTopic([FromQuery] ArticleTopicQueryDto parm)
+ {
+ var response = _ArticleTopicService.GetList(parm);
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 查询文章话题详情
+ ///
+ ///
+ ///
+ [HttpGet("{TopicId}")]
+ [ActionPermissionFilter(Permission = "articletopic:query")]
+ public IActionResult GetArticleTopic(long TopicId)
+ {
+ var response = _ArticleTopicService.GetInfo(TopicId);
+
+ var info = response.Adapt();
+ return SUCCESS(info);
+ }
+
+ ///
+ /// 添加文章话题
+ ///
+ ///
+ [HttpPost]
+ [ActionPermissionFilter(Permission = "articletopic:add")]
+ [Log(Title = "文章话题", BusinessType = BusinessType.INSERT)]
+ public IActionResult AddArticleTopic([FromBody] ArticleTopicDto parm)
+ {
+ var modal = parm.Adapt().ToCreate(HttpContext);
+
+ var response = _ArticleTopicService.AddArticleTopic(modal);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 更新文章话题
+ ///
+ ///
+ [HttpPut]
+ [ActionPermissionFilter(Permission = "articletopic:edit")]
+ [Log(Title = "文章话题", BusinessType = BusinessType.UPDATE)]
+ public IActionResult UpdateArticleTopic([FromBody] ArticleTopicDto parm)
+ {
+ var modal = parm.Adapt().ToUpdate(HttpContext);
+ var response = _ArticleTopicService.UpdateArticleTopic(modal);
+
+ return ToResponse(response);
+ }
+
+ ///
+ /// 删除文章话题
+ ///
+ ///
+ [HttpDelete("delete/{ids}")]
+ [ActionPermissionFilter(Permission = "articletopic:delete")]
+ [Log(Title = "文章话题", BusinessType = BusinessType.DELETE)]
+ public IActionResult DeleteArticleTopic([FromRoute] string ids)
+ {
+ var idArr = Tools.SplitAndConvert(ids);
+
+ return ToResponse(_ArticleTopicService.Delete(idArr));
+ }
+
+ ///
+ /// 导出文章话题
+ ///
+ ///
+ [Log(Title = "文章话题", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
+ [HttpGet("export")]
+ [ActionPermissionFilter(Permission = "articletopic:export")]
+ public IActionResult Export([FromQuery] ArticleTopicQueryDto parm)
+ {
+ parm.PageNum = 1;
+ parm.PageSize = 100000;
+ var list = _ArticleTopicService.ExportList(parm).Result;
+ if (list == null || list.Count <= 0)
+ {
+ return ToResponse(ResultCode.FAIL, "没有要导出的数据");
+ }
+ var result = ExportExcelMini(list, "文章话题", "文章话题");
+ return ExportExcel(result.Item2, result.Item1);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/Controllers/Article/FrontArticleController.cs b/ZR.Admin.WebApi/Controllers/Article/FrontArticleController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..34a3276ad1d251541656cfc1c6580453eba05e92
--- /dev/null
+++ b/ZR.Admin.WebApi/Controllers/Article/FrontArticleController.cs
@@ -0,0 +1,205 @@
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using ZR.Admin.WebApi.Filters;
+using ZR.Model.Content;
+using ZR.Model.Dto;
+using ZR.Model.System.Dto;
+using ZR.Service.Content.IService;
+
+namespace ZR.Admin.WebApi.Controllers
+{
+ ///
+ /// 内容管理前端接口
+ ///
+ [Route("front/article")]
+ [ApiExplorerSettings(GroupName = "article")]
+ [Verify]
+ public class FrontArticleController : BaseController
+ {
+ ///
+ /// 文章接口
+ ///
+ private readonly IArticleService _ArticleService;
+ private readonly IArticleCategoryService _ArticleCategoryService;
+ private readonly IArticlePraiseService _ArticlePraiseService;
+ private readonly ISysUserService _SysUserService;
+ private readonly IArticleTopicService _ArticleTopicService;
+
+ public FrontArticleController(
+ IArticleService ArticleService,
+ IArticleCategoryService articleCategoryService,
+ IArticlePraiseService articlePraiseService,
+ ISysUserService sysUserService,
+ IArticleTopicService articleTopicService)
+ {
+ _ArticleService = ArticleService;
+ _ArticleCategoryService = articleCategoryService;
+ _ArticleService = ArticleService;
+ _ArticlePraiseService = articlePraiseService;
+ _SysUserService = sysUserService;
+ _ArticleTopicService = articleTopicService;
+ }
+
+ ///
+ /// 前台查询文章列表
+ ///
+ ///
+ [HttpGet("homeList")]
+ [AllowAnonymous]
+ public IActionResult QueryHomeList([FromQuery] ArticleQueryDto parm)
+ {
+ parm.UserId = HttpContext.GetUId();
+ var response = _ArticleService.GetArticleList(parm);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 查询最新文章列表
+ ///
+ ///
+ [HttpGet("newList")]
+ [AllowAnonymous]
+ public IActionResult QueryNew()
+ {
+ var predicate = Expressionable.Create();
+ predicate = predicate.And(m => m.Status == "1");
+ predicate = predicate.And(m => m.IsPublic == 1);
+ predicate = predicate.And(m => m.ArticleType == 0);
+
+ var response = _ArticleService.Queryable()
+ .Where(predicate.ToExpression())
+ .Includes(x => x.ArticleCategoryNav) //填充子对象
+ .Take(10)
+ .OrderBy(f => f.UpdateTime, OrderByType.Desc).ToList();
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 点赞
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("praise/{id}")]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult Praise(int id = 0, long authorId = 0)
+ {
+ ArticlePraise addModel = new()
+ {
+ UserId = HttpContext.GetUId(),
+ UserIP = HttpContext.GetClientUserIp(),
+ ArticleId = id,
+ ToUserId = authorId
+ };
+ addModel.Location = HttpContextExtension.GetIpInfo(addModel.UserIP);
+
+ return SUCCESS(_ArticlePraiseService.Praise(addModel));
+ }
+
+ ///
+ /// 置顶
+ ///
+ ///
+ [HttpPut("top")]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult Top([FromBody] Article parm)
+ {
+ var response = _ArticleService.TopArticle(parm);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 修改可见范围
+ ///
+ ///
+ [HttpPut("changePublic")]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult ChangePublic([FromBody] Article parm)
+ {
+ if (parm == null) { return ToResponse(ResultCode.CUSTOM_ERROR); }
+ var userId = HttpContext.GetUId();
+ if (userId != parm.UserId)
+ {
+ return ToResponse(ResultCode.CUSTOM_ERROR, "操作失败");
+ }
+ var response = _ArticleService.ChangeArticlePublic(parm);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpDelete("del/{id}")]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult Delete(int id = 0)
+ {
+ var userId = HttpContext.GetUId();
+ var info = _ArticleService.GetId(id);
+ if (info == null || info.UserId != userId)
+ {
+ return ToResponse(ResultCode.CUSTOM_ERROR, "删除失败(-1)");
+ }
+ var response = _ArticleService.Delete(id);
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 查询文章详情
+ ///
+ ///
+ ///
+ [HttpGet("{id}")]
+ [AllowAnonymous]
+ public IActionResult Get(int id)
+ {
+ long userId = HttpContext.GetUId();
+ var model = _ArticleService.GetArticle(id, userId);
+ var user = _SysUserService.GetById(model.UserId);
+ ApiResult apiResult = ApiResult.Success(model);
+ model.User = new ArticleUser()
+ {
+ Avatar = user.Avatar,
+ NickName = user.NickName,
+ Sex = user.Sex,
+ };
+ //apiResult.Put("user", user.Adapt());
+ return ToResponse(apiResult);
+ }
+
+ ///
+ /// 前台查询话题
+ ///
+ ///
+ ///
+ [HttpGet("topicList")]
+ [AllowAnonymous]
+ public IActionResult QueryTopicList([FromQuery] ArticleTopicQueryDto parm)
+ {
+ var response = _ArticleTopicService.GetTopicList(parm);
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 查询文章话题详情
+ ///
+ ///
+ ///
+ [HttpGet("topic/{TopicId}")]
+ [AllowAnonymous]
+ public IActionResult GetArticleTopic(long TopicId)
+ {
+ var response = _ArticleTopicService.GetInfo(TopicId);
+
+ _ArticleTopicService.Update(w => w.TopicId == TopicId, it => new ArticleTopic() { ViewNum = it.ViewNum + 1 });
+
+ var info = response.Adapt();
+ return SUCCESS(info);
+ }
+ }
+}
diff --git a/ZR.Admin.WebApi/Controllers/Article/FrontCommentController.cs b/ZR.Admin.WebApi/Controllers/Article/FrontCommentController.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d1a028f342e47c09e9231f35c378e3f63a2742ba
--- /dev/null
+++ b/ZR.Admin.WebApi/Controllers/Article/FrontCommentController.cs
@@ -0,0 +1,115 @@
+using Microsoft.AspNetCore.Mvc;
+using ZR.Admin.WebApi.Filters;
+using ZR.Model;
+using ZR.Model.Content;
+using ZR.Model.Dto;
+using ZR.Service.Content.IService;
+
+namespace ZR.Admin.WebApi.Controllers
+{
+ ///
+ /// 评论
+ ///
+ [Route("front/comment")]
+ [ApiExplorerSettings(GroupName = "article")]
+ [ApiController]
+ public class FrontCommentController : BaseController
+ {
+ private readonly IArticleCommentService messageService;
+
+ ///
+ ///
+ ///
+ ///
+ public FrontCommentController(IArticleCommentService messageService)
+ {
+ this.messageService = messageService;
+ }
+
+ ///
+ /// 查询评论列表
+ ///
+ ///
+ ///
+ [HttpGet("list")]
+ public IActionResult QueryList([FromQuery] MessageQueryDto parm)
+ {
+ parm.PageSize = 10;
+ PagedInfo? response;
+ //查询二级评论
+ if (parm.CommentId > 0)
+ {
+ response = messageService.GetReplyComments(parm.CommentId, parm);
+ }
+ else
+ {
+ response = messageService.GetMessageList(parm);
+ }
+
+ return SUCCESS(response);
+ }
+
+ ///
+ /// 评论
+ ///
+ ///
+ [HttpPost("add")]
+ [Verify]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult Create([FromBody] ArticleCommentDto parm)
+ {
+ var uid = HttpContextExtension.GetUId(HttpContext);
+ if (uid <= 0) { return ToResponse(ResultCode.DENY); }
+
+ var addModel = parm.Adapt().ToCreate(context: HttpContext);
+ addModel.UserIP = HttpContextExtension.GetClientUserIp(HttpContext);
+ addModel.UserId = uid;
+ return SUCCESS(messageService.AddMessage(addModel).Adapt());
+ }
+
+ ///
+ /// 评论点赞
+ ///
+ ///
+ ///
+ [HttpPost("praise")]
+ [ActionPermissionFilter(Permission = "common")]
+ [Verify]
+ public IActionResult Praise([FromBody] ArticleCommentDto dto)
+ {
+ if (dto == null || dto.CommentId <= 0) return ToResponse(ResultCode.PARAM_ERROR);
+ //var uid = HttpContextExtension.GetUId(HttpContext);
+
+ return SUCCESS(messageService.PraiseMessage(dto.CommentId));
+ }
+
+ ///
+ /// 评论删除
+ ///
+ ///
+ ///
+ [HttpDelete("delete/{mid}")]
+ [ActionPermissionFilter(Permission = "common")]
+ [Verify]
+ public IActionResult Delete(long mid)
+ {
+ var uid = HttpContextExtension.GetUId(HttpContext);
+ if (uid <= 0) { return ToResponse(ResultCode.DENY); }
+ return SUCCESS(messageService.DeleteMessage(mid.ParseToLong(), uid));
+ }
+
+ ///
+ /// 查询我的评论列表
+ ///
+ ///
+ ///
+ [HttpGet("mylist")]
+ [Verify]
+ public IActionResult QueryMyCommentList([FromQuery] MessageQueryDto parm)
+ {
+ PagedInfo response = messageService.GetMyMessageList(parm);
+
+ return SUCCESS(response);
+ }
+ }
+}
diff --git a/ZR.Admin.WebApi/Controllers/Article/MonentController.cs b/ZR.Admin.WebApi/Controllers/Article/MomentsController.cs
similarity index 38%
rename from ZR.Admin.WebApi/Controllers/Article/MonentController.cs
rename to ZR.Admin.WebApi/Controllers/Article/MomentsController.cs
index 7ea92ccf8c5b48f235457c8418fc6473c2c6bb00..d1647c47625d733c78da923a46ea2b13881b5ec4 100644
--- a/ZR.Admin.WebApi/Controllers/Article/MonentController.cs
+++ b/ZR.Admin.WebApi/Controllers/Article/MomentsController.cs
@@ -1,25 +1,30 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
-using ZR.Model.System;
-using ZR.Model.System.Dto;
-using ZR.ServiceCore.Model.Enums;
+using ZR.Model.Content;
+using ZR.Model.Dto;
+using ZR.Model.Enum;
+using ZR.Service.Content.IService;
namespace ZR.Admin.WebApi.Controllers
{
[Verify]
- [Route("monent")]
- public class MonentController : BaseController
+ [Route("moment")]
+ [ApiExplorerSettings(GroupName = "article")]
+ public class MomentsController : BaseController
{
///
/// 动态接口
///
private readonly IArticleService _ArticleService;
- private readonly IArticleCategoryService _ArticleCategoryService;
- public MonentController(IArticleService ArticleService, IArticleCategoryService articleCategoryService)
+ ///
+ ///
+ ///
+ ///
+ public MomentsController(
+ IArticleService ArticleService)
{
_ArticleService = ArticleService;
- _ArticleCategoryService = articleCategoryService;
}
///
@@ -40,96 +45,39 @@ namespace ZR.Admin.WebApi.Controllers
/// 查询动态列表
///
///
- [HttpGet("monentList")]
+ [HttpGet("momentList")]
[AllowAnonymous]
public IActionResult QueryMonentList([FromQuery] ArticleQueryDto parm)
{
parm.UserId = HttpContext.GetUId();
parm.ArticleType = 2;
- var response = _ArticleService.GetArticleList(parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 置顶
- ///
- ///
- [HttpPut("top")]
- [Log(Title = "置顶动态", BusinessType = BusinessType.UPDATE)]
- public IActionResult Top([FromBody] Article parm)
- {
- var response = _ArticleService.TopArticle(parm);
-
- return SUCCESS(response);
- }
-
- ///
- /// 修改可见范围
- ///
- ///
- [HttpPut("changePublic")]
- [Log(Title = "是否公开", BusinessType = BusinessType.UPDATE)]
- public IActionResult ChangePublic([FromBody] Article parm)
- {
- var response = _ArticleService.ChangeArticlePublic(parm);
-
- return SUCCESS(response);
+ if (parm.TabId == 100)
+ {
+ return SUCCESS(_ArticleService.GetFollowMonentList(parm));
+ }
+ return SUCCESS(_ArticleService.GetMonentList(parm));
}
///
/// 动态发布
///
///
- [HttpPost("publishMonent")]
- [Log(Title = "动态发布", BusinessType = BusinessType.INSERT)]
- public IActionResult PublishMonent([FromBody] ArticleDto parm)
+ [HttpPost("publishMoment")]
+ [ActionPermissionFilter(Permission = "common")]
+ public IActionResult PublishMoment([FromBody] ArticleDto parm)
{
+ if (parm == null) { return ToResponse(ResultCode.PARAM_ERROR); }
var addModel = parm.Adapt().ToCreate(context: HttpContext);
- addModel.AuthorName = HttpContext.GetName();
- addModel.UserId = HttpContext.GetUId();
- addModel.ArticleType = ArticleTypeEnum.Monent;
- addModel.UserIP = HttpContext.GetClientUserIp();
+ addModel.Tags = parm.TopicName;
- string location = HttpContextExtension.GetIpInfo(addModel.UserIP);
- addModel.Location = location;
- return SUCCESS(_ArticleService.InsertReturnIdentity(addModel));
- }
-
- ///
- /// 删除动态
- ///
- ///
- [HttpDelete("del/{id}")]
- [Log(Title = "动态删除", BusinessType = BusinessType.DELETE)]
- public IActionResult DeleteMonents(int id = 0)
- {
- var userId = HttpContext.GetUId();
- var info = _ArticleService.GetId(id);
- if (info == null || info.UserId != userId)
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, "删除失败(-1)");
- }
- var response = _ArticleService.Delete(id);
- return SUCCESS(response);
- }
-
- ///
- /// 点赞动态
- ///
- ///
- [HttpPost("praise/{id}")]
- public IActionResult PraiseMonents(int id = 0)
- {
- var response = _ArticleService.PraiseArticle(id);
- return SUCCESS(response);
+ return SUCCESS(_ArticleService.PublishMonent(addModel));
}
///
/// 动态信息
///
///
- [HttpDelete("getInfo")]
+ [HttpGet("getInfo")]
public IActionResult GetInfo()
{
var userId = HttpContext.GetUId();
diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
index 3fdd901f7b83f0adea5a60f1bea284e6b3e54ffe..5ea32ff89e6ec47179d889f24267a52d4a1f3fe2 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
@@ -43,7 +43,6 @@ namespace ZR.Admin.WebApi.Controllers.System
roleService = sysRoleService;
}
-
///
/// 登录
///
@@ -261,37 +260,49 @@ namespace ZR.Admin.WebApi.Controllers.System
///
///
///
- [HttpPost("checkMobile")]
+ [HttpPost("/checkMobile")]
[Log(Title = "发送短息", BusinessType = BusinessType.INSERT)]
public IActionResult CheckMobile([FromBody] PhoneLoginDto dto)
{
dto.LoginIP = HttpContextExtension.GetClientUserIp(HttpContext);
-
- SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
- if (sysConfig?.ConfigValue != "off" && !SecurityCodeHelper.Validate(dto.Uuid, dto.Code, false))
+ var uid = HttpContext.GetUId();
+ //SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
+ //if (!SecurityCodeHelper.Validate(dto.Uuid, dto.Code, false))
+ //{
+ // return ToResponse(ResultCode.CUSTOM_ERROR, "验证码错误");
+ //}
+ if (dto.SendType == 0)
+ {
+ var info = sysUserService.GetFirst(f => f.Phonenumber == dto.PhoneNum) ?? throw new CustomException(ResultCode.CUSTOM_ERROR, "该手机号不存在", false);
+ uid = info.UserId;
+ }
+ if (dto.SendType == 1)
{
- return ToResponse(ResultCode.CUSTOM_ERROR, "验证码错误");
+ if (sysUserService.CheckPhoneBind(dto.PhoneNum).Count > 0)
+ {
+ return ToResponse(ResultCode.CUSTOM_ERROR, "手机号已绑定其他账号");
+ }
}
+
string location = HttpContextExtension.GetIpInfo(dto.LoginIP);
- var info = sysUserService.GetFirst(f => f.Phonenumber == dto.PhoneNum) ?? throw new CustomException(ResultCode.CUSTOM_ERROR, "该手机号不存在", false);
var smsCode = RandomHelper.GenerateNum(6);
- var smsContent = $"验证码{smsCode}(随机验证码),有效期10分钟。";
+ var smsContent = $"验证码{smsCode},有效期10分钟。";
//TODO 发送短息验证码,1分钟内允许一次
smsCodeLogService.AddSmscodeLog(new ServiceCore.Model.SmsCodeLog()
{
- Userid = info.UserId,
+ Userid = uid,
PhoneNum = dto.PhoneNum.ParseToLong(),
- AddTime = DateTime.Now,
- SendType = 1,
+ SendType = dto.SendType,
SmsCode = smsCode,
SmsContent = smsContent,
UserIP = dto.LoginIP,
Location = location,
});
+
CacheService.SetPhoneCode(dto.PhoneNum, smsCode);
- return SUCCESS(new { smsCode });
+ return SUCCESS(1);
}
///
@@ -324,5 +335,27 @@ namespace ZR.Admin.WebApi.Controllers.System
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + user.UserId, permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser)));
}
+
+ ///
+ /// 手机号绑定
+ ///
+ ///
+ ///
+ [Route("/PhoneBind")]
+ [HttpPost]
+ [Log(Title = "手机号绑定")]
+ public IActionResult PhoneBind([FromBody] PhoneLoginDto loginBody)
+ {
+ if (loginBody == null) { throw new CustomException("请求参数错误"); }
+ loginBody.LoginIP = HttpContextExtension.GetClientUserIp(HttpContext);
+ var uid = HttpContext.GetUId();
+ if (!CacheService.CheckPhoneCode(loginBody.PhoneNum, loginBody.PhoneCode))
+ {
+ return ToResponse(ResultCode.CUSTOM_ERROR, "短信验证码错误");
+ }
+ var result = sysUserService.ChangePhoneNum(uid, loginBody.PhoneNum);
+
+ return SUCCESS(result);
+ }
}
}
diff --git a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
index 22349dec2a22e22802e69307266ba97b8e65443a..097124addf87cfe1aa1a7b5e34336766bcecf5b0 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
@@ -185,6 +185,20 @@ namespace ZR.Admin.WebApi.Controllers.System
return ToResponse(result);
}
+ ///
+ /// 菜单删除
+ ///
+ ///
+ ///
+ [HttpDelete("deleteAll/{menuId}")]
+ [Log(Title = "菜单管理", BusinessType = BusinessType.DELETE)]
+ [ActionPermissionFilter(Permission = "system:menu:remove")]
+ public IActionResult RemoveAll(int menuId = 0)
+ {
+ int result = sysMenuService.DeleteAllMenuById(menuId);
+
+ return ToResponse(result);
+ }
///
/// 保存排序
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/UserOnlineLogController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/UserOnlineLogController.cs
index 1a0bce424df6e9d7fed0240d7e4e496c3d7cead9..49962e6786d88b4b70616a0eed549c2f0fd50038 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/UserOnlineLogController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/UserOnlineLogController.cs
@@ -10,6 +10,7 @@ namespace ZR.Admin.WebApi.Controllers
/// 用户在线时长
///
[Verify]
+ [ApiExplorerSettings(GroupName = "sys")]
[Route("monitor/UserOnlineLog")]
public class UserOnlineLogController : BaseController
{
diff --git a/ZR.Admin.WebApi/iprate.json b/ZR.Admin.WebApi/iprate.json
index 7269065d863c76655469205dbacaacb70608b7c3..ce41fb9e8faff4bbad52e26dfd9620bc205166fb 100644
--- a/ZR.Admin.WebApi/iprate.json
+++ b/ZR.Admin.WebApi/iprate.json
@@ -20,6 +20,12 @@
"Period": "3s",
"Limit": 5
},
+ {
+ "Endpoint": "*:/checkMobile",
+ //时间段,格式:{数字}{单位};可使用单位:s, m, h, d
+ "Period": "60s",
+ "Limit": 1
+ },
{
"Endpoint": "((post)|(put)):*",
"Period": "3s",
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
index 30f869c275bdae229a12c85c8fe71a7690ded2a0..93217fcd9adb0d33badf760f98d2f83ab5b7047e 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/api.txt
@@ -60,19 +60,4 @@ export function del${genTable.BusinessName}(pid) {
method: 'delete'
})
}
-$end
-$if(replaceDto.ShowBtnTruncate)
-// 清空${genTable.functionName}
-export function clear${genTable.BusinessName}() {
- return request({
- url: '/${genTable.ModuleName}/${genTable.BusinessName}/clean',
- method: 'delete'
- })
-}
-$end
-$if(replaceDto.ShowBtnExport)
-// 导出${genTable.functionName}
-export async function export${genTable.BusinessName}(query) {
- await downFile('/${genTable.ModuleName}/${genTable.BusinessName}/export', { ...query })
-}
$end
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt
index 429ae1525fd50fe8d65c56f2648d484b49089f30..da88a3c96a7d885bc89948a8ee83d3c03957071f 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/app/form.txt
@@ -1,5 +1,6 @@
-
+
+
$foreach(column in genTable.Columns)
$set(columnName = column.CsharpFieldFl)
@@ -67,7 +68,8 @@ $end
$end
$end
-
+
+
[SugarTable("email_log")]
+ [Tenant("0")]
public class EmailLog
{
[JsonConverter(typeof(ValueToStringConverter))]
diff --git a/ZR.ServiceCore/Model/EmailTpl.cs b/ZR.ServiceCore/Model/EmailTpl.cs
index aa0f3c93ea939b59dbc407bb35fdeccef6d066c5..4d590723ca44097525745f12beb1d46ea1389e27 100644
--- a/ZR.ServiceCore/Model/EmailTpl.cs
+++ b/ZR.ServiceCore/Model/EmailTpl.cs
@@ -6,6 +6,7 @@ namespace ZR.ServiceCore.Model
/// 邮件发送模板
///
[SugarTable("emailTpl")]
+ [Tenant("0")]
public class EmailTpl : SysBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
diff --git a/ZR.ServiceCore/Model/SmsCodeLog.cs b/ZR.ServiceCore/Model/SmsCodeLog.cs
index 5c15b7d56b5716b52ca54eb18c3a304714df006f..2424b05e6a37d9cdd45b8ca46490440936ffd350 100644
--- a/ZR.ServiceCore/Model/SmsCodeLog.cs
+++ b/ZR.ServiceCore/Model/SmsCodeLog.cs
@@ -4,6 +4,7 @@
/// 短信验证码记录
///
[SugarTable("smsCode_log")]
+ [Tenant("0")]
public class SmsCodeLog
{
[JsonConverter(typeof(ValueToStringConverter))]
@@ -28,6 +29,7 @@
///
/// 发送时间
///
+ [SugarColumn(InsertServerTime = true)]
public DateTime AddTime { get; set; }
///
/// 用户IP
diff --git a/ZR.ServiceCore/Model/SysDictType.cs b/ZR.ServiceCore/Model/SysDictType.cs
index c323a636d9d8081af987e3e0e730be9feaaa8fa7..9d4a9ec83f50e6080eb3c5e9344d4dc8ea2c8721 100644
--- a/ZR.ServiceCore/Model/SysDictType.cs
+++ b/ZR.ServiceCore/Model/SysDictType.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// 字典类型表
diff --git a/ZR.ServiceCore/Model/SysFile.cs b/ZR.ServiceCore/Model/SysFile.cs
index cc8eb1df717b289970d425191932fb1ebef0a540..53bacc888cedb041119af84f576b268c64612d23 100644
--- a/ZR.ServiceCore/Model/SysFile.cs
+++ b/ZR.ServiceCore/Model/SysFile.cs
@@ -1,8 +1,4 @@
-using Newtonsoft.Json;
-using SqlSugar;
-using System;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
[Tenant("0")]
[SugarTable("sys_file", "文件存储表")]
diff --git a/ZR.ServiceCore/Model/SysLogininfor.cs b/ZR.ServiceCore/Model/SysLogininfor.cs
index 79b979cdefe71d40042c7f1488ee903c93190d9d..9bd54942b7e8f976e9b9d282b1da223b9fb5f7dd 100644
--- a/ZR.ServiceCore/Model/SysLogininfor.cs
+++ b/ZR.ServiceCore/Model/SysLogininfor.cs
@@ -1,7 +1,4 @@
-using SqlSugar;
-using System;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// sys_logininfor 表
diff --git a/ZR.ServiceCore/Model/SysMenu.cs b/ZR.ServiceCore/Model/SysMenu.cs
index 6e1e1e2878b46f4b6013dcf79352316ac85f2904..eb547d15a6c4af3193aed1f8bc47ae2263b1a6d4 100644
--- a/ZR.ServiceCore/Model/SysMenu.cs
+++ b/ZR.ServiceCore/Model/SysMenu.cs
@@ -1,7 +1,4 @@
-using SqlSugar;
-using System.Collections.Generic;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// Sys_menu表
diff --git a/ZR.ServiceCore/Model/SysNotice.cs b/ZR.ServiceCore/Model/SysNotice.cs
index ff00e3422016c8601b3d4194a33a96057c80f7c8..e794c6fa4c5b22b032fdfb697c184b5b4cff3cad 100644
--- a/ZR.ServiceCore/Model/SysNotice.cs
+++ b/ZR.ServiceCore/Model/SysNotice.cs
@@ -1,5 +1,3 @@
-using SqlSugar;
-
namespace ZR.Model.System
{
///
diff --git a/ZR.ServiceCore/Model/SysPost.cs b/ZR.ServiceCore/Model/SysPost.cs
index 26edfcfe80a42244cc8961fe529e5559bfa978d9..a9116e19ee155c6f2c99d76e71b6ee5c611762f0 100644
--- a/ZR.ServiceCore/Model/SysPost.cs
+++ b/ZR.ServiceCore/Model/SysPost.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
[SugarTable("sys_post", "岗位表")]
[Tenant("0")]
diff --git a/ZR.ServiceCore/Model/SysRole.cs b/ZR.ServiceCore/Model/SysRole.cs
index 3f48946631d45e0ca0d6259709184d99a40785f9..8bc83bc449e7caf4f086a5d0ae9a8e667617eb48 100644
--- a/ZR.ServiceCore/Model/SysRole.cs
+++ b/ZR.ServiceCore/Model/SysRole.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// 角色表 sys_role
diff --git a/ZR.ServiceCore/Model/SysRoleDept.cs b/ZR.ServiceCore/Model/SysRoleDept.cs
index 14abb4b40799ad3471560d0080f7cbc02d46e005..43152b135e2db6604e9dc256622b0a060ebd9fb0 100644
--- a/ZR.ServiceCore/Model/SysRoleDept.cs
+++ b/ZR.ServiceCore/Model/SysRoleDept.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
[SugarTable("sys_role_dept", "角色部门")]
[Tenant(0)]
diff --git a/ZR.ServiceCore/Model/SysRoleMenu.cs b/ZR.ServiceCore/Model/SysRoleMenu.cs
index 9a037a41c21c0a01d131a802605a912a8f21ed6b..ed5c59fa8bdb27f4d76899bfdfcab837815d50e7 100644
--- a/ZR.ServiceCore/Model/SysRoleMenu.cs
+++ b/ZR.ServiceCore/Model/SysRoleMenu.cs
@@ -1,7 +1,4 @@
-using Newtonsoft.Json;
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// 角色菜单
diff --git a/ZR.ServiceCore/Model/SysTasks.cs b/ZR.ServiceCore/Model/SysTasks.cs
index b1a413cf4c16bbddb31813660f73e2ae8b1f5db4..0eadae4e51612f807f75b1b3e763eb9bdfbcb500 100644
--- a/ZR.ServiceCore/Model/SysTasks.cs
+++ b/ZR.ServiceCore/Model/SysTasks.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-using System;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
namespace ZR.Model.System
{
diff --git a/ZR.ServiceCore/Model/SysTasksLog.cs b/ZR.ServiceCore/Model/SysTasksLog.cs
index 88fbcfc8a7228053673c934039209daddcee4037..98bf859187f18e10060aa6179e56c7390176cd7f 100644
--- a/ZR.ServiceCore/Model/SysTasksLog.cs
+++ b/ZR.ServiceCore/Model/SysTasksLog.cs
@@ -1,7 +1,4 @@
-using SqlSugar;
-using System;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// 任务日志
diff --git a/ZR.ServiceCore/Model/SysUserPost.cs b/ZR.ServiceCore/Model/SysUserPost.cs
index 7eadfd0dcc1306929a72887e1dc260ab210d317b..c01bab0a44a5595977a6b3e6155d2b29bd96f613 100644
--- a/ZR.ServiceCore/Model/SysUserPost.cs
+++ b/ZR.ServiceCore/Model/SysUserPost.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace ZR.Model.System
+namespace ZR.Model.System
{
///
/// 用户岗位
diff --git a/ZR.ServiceCore/Services/IService/ISysMenuService.cs b/ZR.ServiceCore/Services/IService/ISysMenuService.cs
index ad5ca63c6fcf45e169cf1b6d2f89d78dc90592f8..21138c5150dcd333f679000eea41815c4a95582e 100644
--- a/ZR.ServiceCore/Services/IService/ISysMenuService.cs
+++ b/ZR.ServiceCore/Services/IService/ISysMenuService.cs
@@ -19,6 +19,7 @@ namespace ZR.ServiceCore.Services
long EditMenu(SysMenu menu);
int DeleteMenuById(int menuId);
+ int DeleteAllMenuById(int menuId);
string CheckMenuNameUnique(SysMenu menu);
diff --git a/ZR.ServiceCore/Services/IService/ISysUserService.cs b/ZR.ServiceCore/Services/IService/ISysUserService.cs
index 411983b0880aaf8c447ecdb1f80605087872aaaf..0cfa99ee27e8969e3af1c46c9f851cbccc1d14ff 100644
--- a/ZR.ServiceCore/Services/IService/ISysUserService.cs
+++ b/ZR.ServiceCore/Services/IService/ISysUserService.cs
@@ -37,6 +37,13 @@ namespace ZR.ServiceCore.Services
public int UpdateUser(SysUser user);
public int ChangeUser(SysUser user);
+ ///
+ ///
+ ///
+ ///
+ ///
+ List CheckPhoneBind(string phoneNum);
+ int ChangePhoneNum(long userid, string phoneNum);
///
/// 重置密码
diff --git a/ZR.ServiceCore/Services/SeedDataService.cs b/ZR.ServiceCore/Services/SeedDataService.cs
index 70fb6331ca86b86f86039a954772e379ca2e0533..b1460becbc3b630dc2ef0c5649906b22168685cd 100644
--- a/ZR.ServiceCore/Services/SeedDataService.cs
+++ b/ZR.ServiceCore/Services/SeedDataService.cs
@@ -1,7 +1,9 @@
using MiniExcelLibs;
using SqlSugar.IOC;
using ZR.Common;
+using ZR.Model.Content;
using ZR.Model.System;
+using ZR.ServiceCore.Model;
namespace ZR.ServiceCore.Services
{
@@ -25,7 +27,7 @@ namespace ZR.ServiceCore.Services
db.Ado.BeginTran();
//db.Ado.ExecuteCommand("SET IDENTITY_INSERT sys_user ON");
var x = db.Storageable(data)
- .SplitInsert(it => it.NotAny())
+ .SplitInsert(it => it.NotAny())//表示如果有where条件根据条件判断是否存在数据,不存在插入,存在不操作
.SplitError(x => x.Item.UserName.IsEmpty(), "用户名不能为空")
.SplitError(x => !Tools.CheckUserName(x.Item.UserName), "用户名不符合规范")
.WhereColumns(it => it.UserId)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
@@ -174,9 +176,7 @@ namespace ZR.ServiceCore.Services
{
var db = DbScoped.SugarScope;
var x = db.Storageable(data)
- //.SplitInsert(it => it.NotAny())
- //.SplitUpdate(it => !it.Any())
- //.WhereColumns(it => new { it.DictType })
+ .WhereColumns(it => new { it.DictType, it.DictValue })
.ToStorage();
x.AsInsertable.ExecuteCommand();
x.AsUpdateable.ExecuteCommand();
@@ -194,12 +194,29 @@ namespace ZR.ServiceCore.Services
{
var db = DbScoped.SugarScope;
var x = db.Storageable(data)
- .SplitInsert(it => it.NotAny())
+ //.SplitInsert(it => it.NotAny())
.WhereColumns(it => it.Name)
.ToStorage();
- var result = x.AsInsertable.ExecuteCommand();
+ x.AsInsertable.ExecuteCommand();
+ x.AsUpdateable.ExecuteCommand();
+ string msg = $"[文章目录] 插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误{x.ErrorList.Count} 总共{x.TotalList.Count}";
+ return (msg, x.ErrorList, x.IgnoreList);
+ }
- string msg = $"[字典数据] 插入{x.InsertList.Count} 错误{x.ErrorList.Count} 总共{x.TotalList.Count}";
+ ///
+ /// 文章话题
+ ///
+ ///
+ ///
+ public (string, object, object) InitArticleTopicData(List data)
+ {
+ var db = DbScoped.SugarScope;
+ var x = db.Storageable(data)
+ .WhereColumns(it => it.TopicName)
+ .ToStorage();
+ x.AsInsertable.ExecuteCommand();
+ x.AsUpdateable.ExecuteCommand();
+ string msg = $"[文章话题] 插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误{x.ErrorList.Count} 总共{x.TotalList.Count}";
return (msg, x.ErrorList, x.IgnoreList);
}
@@ -308,6 +325,10 @@ namespace ZR.ServiceCore.Services
var result11 = InitArticleCategoryData(sysArticleCategory);
result.Add(result11.Item1);
+ var sysArticleTopic = MiniExcel.Query(path, sheetName: "article_topic").ToList();
+ var result13 = InitArticleTopicData(sysArticleTopic);
+ result.Add(result13.Item1);
+
var sysNotice = MiniExcel.Query(path, sheetName: "notice").ToList();
var result12 = InitNoticeData(sysNotice);
result.Add(result12.Item1);
diff --git a/ZR.ServiceCore/Services/SysMenuService.cs b/ZR.ServiceCore/Services/SysMenuService.cs
index 499007c9009242b4fb679bd737c5d40a9c908eee..7ae01df8e7368778c2a34e135fe5d6f4d6816247 100644
--- a/ZR.ServiceCore/Services/SysMenuService.cs
+++ b/ZR.ServiceCore/Services/SysMenuService.cs
@@ -1,6 +1,4 @@
using Infrastructure.Attribute;
-using JinianNet.JNTemplate.Caching;
-using System.ComponentModel;
using ZR.Common;
using ZR.Model.System;
using ZR.Model.System.Dto;
@@ -125,6 +123,22 @@ namespace ZR.ServiceCore.Services
return Delete(menuId);
}
+ ///
+ /// 删除所有菜单
+ ///
+ ///
+ ///
+ public int DeleteAllMenuById(int menuId)
+ {
+ var childMenu = Queryable().ToChildList(x => x.ParentId, menuId).Select(x => x.MenuId);
+ var result = UseTran(() =>
+ {
+ Delete(childMenu.ToArray(), "删除菜单");
+ Context.Deleteable().Where(f => childMenu.Contains(f.Menu_id)).ExecuteCommand();
+ });
+ return result.IsSuccess ? 1 : 0;
+ }
+
///
/// 校验菜单名称是否唯一
///
@@ -317,26 +331,6 @@ namespace ZR.ServiceCore.Services
}
#region 方法
- /////
- ///// 根据父节点的ID获取所有子节点
- /////
- ///// 分类表
- ///// 传入的父节点ID
- /////
- //public List GetChildPerms(List list, int parentId)
- //{
- // List returnList = new List();
- // var data = list.FindAll(f => f.parentId == parentId);
-
- // foreach (var item in data)
- // {
- // RecursionFn(list, item);
-
- // returnList.Add(item);
- // }
- // return returnList;
- //}
-
///
/// 递归列表
///
diff --git a/ZR.ServiceCore/Services/SysUserService.cs b/ZR.ServiceCore/Services/SysUserService.cs
index ab05f7483bcfa8890dfec0d16f58c1cc513a559f..27fc48afac1e6d9c1d9501d95b1281a124da0f18 100644
--- a/ZR.ServiceCore/Services/SysUserService.cs
+++ b/ZR.ServiceCore/Services/SysUserService.cs
@@ -95,6 +95,29 @@ namespace ZR.ServiceCore.Services
return UserConstants.UNIQUE;
}
+ ///
+ /// 校验手机号是否绑定
+ ///
+ ///
+ ///
+ public List CheckPhoneBind(string phoneNum)
+ {
+ var list = GetList(it => it.Phonenumber == phoneNum);
+ var temp = list.Select(x => x.UserId).ToList();
+ return list.Count > 0 ? temp : new List();
+ }
+
+ ///
+ /// 绑定手机号
+ ///
+ ///
+ ///
+ ///
+ public int ChangePhoneNum(long userid, string phoneNum)
+ {
+ return Update(new SysUser() { Phonenumber = phoneNum }, it => new { it.Phonenumber }, f => f.UserId == userid);
+ }
+
///
/// 新增保存用户信息
///
diff --git a/ZR.ServiceCore/SqlSugar/InitTable.cs b/ZR.ServiceCore/SqlSugar/InitTable.cs
index 3ffa359813c04d1f42bc52e17f7606bcc8c72ef9..2cb318dc81bb0bb26954aeda0451d76502e948b9 100644
--- a/ZR.ServiceCore/SqlSugar/InitTable.cs
+++ b/ZR.ServiceCore/SqlSugar/InitTable.cs
@@ -1,4 +1,5 @@
using SqlSugar.IOC;
+using ZR.Model.Content;
using ZR.Model.Models;
using ZR.Model.System;
using ZR.Model.System.Generate;
@@ -14,16 +15,17 @@ namespace ZR.ServiceCore.SqlSugar
///
/// 创建db、表
///
- public static void InitDb()
+ public static void InitDb(bool init)
{
var db = DbScoped.SugarScope;
+ //TODO 可在此处单独更新某个表的结构
+ //例如:db.CodeFirst.InitTables(typeof(EmailLog));
+
+
+ if (!init) return;
//建库:如果不存在创建数据库存在不会重复创建
db.DbMaintenance.CreateDatabase();// 注意 :Oracle和个别国产库需不支持该方法,需要手动建库
- //var baseType = typeof(SysBase);
- //var entityes = AssemblyUtils.GetAllTypes().Where(p => !p.IsAbstract && p != baseType && p.GetCustomAttribute() != null).ToArray();
- //db.CodeFirst.InitTables(entityes);
-
//27个表,建议先使用下面方法初始化表,方便排查问题
db.CodeFirst.InitTables(typeof(SysUser));
db.CodeFirst.InitTables(typeof(SysRole));
@@ -44,14 +46,18 @@ namespace ZR.ServiceCore.SqlSugar
db.CodeFirst.InitTables(typeof(CommonLang));
db.CodeFirst.InitTables(typeof(GenTable));
db.CodeFirst.InitTables(typeof(GenTableColumn));
- db.CodeFirst.InitTables(typeof(Article));
- db.CodeFirst.InitTables(typeof(ArticleCategory));
db.CodeFirst.InitTables(typeof(SysDictData));
db.CodeFirst.InitTables(typeof(SysDictType));
db.CodeFirst.InitTables(typeof(SqlDiffLog));
db.CodeFirst.InitTables(typeof(EmailTpl));
db.CodeFirst.InitTables(typeof(SmsCodeLog));
db.CodeFirst.InitTables(typeof(EmailLog));
+ db.CodeFirst.InitTables(typeof(Article));
+ db.CodeFirst.InitTables(typeof(ArticleCategory));
+ db.CodeFirst.InitTables(typeof(ArticleBrowsingLog));
+ db.CodeFirst.InitTables(typeof(ArticlePraise));
+ db.CodeFirst.InitTables(typeof(ArticleComment));
+ db.CodeFirst.InitTables(typeof(ArticleTopic));
//db.CodeFirst.InitTables(typeof(UserOnlineLog));
}
public static void InitNewTb()
diff --git a/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs b/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs
index 53abaff1bdba7f8a2e58346c7d9bbcc53f499877..5cc1783223e3b27d840e3da7f777bd99e120d1e4 100644
--- a/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs
+++ b/ZR.ServiceCore/SqlSugar/SqlsugarSetup.cs
@@ -54,10 +54,8 @@ namespace ZR.ServiceCore.SqlSugar
if (environment.IsDevelopment())
{
- if (options.InitDb)
- {
- InitTable.InitDb();
- }
+ InitTable.InitDb(options.InitDb);
+
InitTable.InitNewTb();
}
}
diff --git a/ZR.Vue/src/views/monitor/operlog/index.vue b/ZR.Vue/src/views/monitor/operlog/index.vue
index b1856fb1d6187e73e1f77bb1f9d43661de525bcd..1966c1997f406046213bdcdce9313441ecaadcc2 100644
--- a/ZR.Vue/src/views/monitor/operlog/index.vue
+++ b/ZR.Vue/src/views/monitor/operlog/index.vue
@@ -9,12 +9,12 @@
-
+
-
+
@@ -55,7 +55,7 @@
-
+
@@ -64,7 +64,7 @@
-
+
@@ -108,7 +108,7 @@
-
+
@@ -121,7 +121,7 @@
-
+
@@ -161,9 +161,9 @@ export default {
// 是否显示弹出层
open: false,
// 类型数据字典
- statusOptions: [],
+ sys_common_status: [],
// 业务类型(0其它 1新增 2修改 3删除)选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
- businessTypeOptions: [],
+ sys_oper_type: [],
// 日期范围
dateRange: [],
// 表单参数
@@ -181,13 +181,10 @@ export default {
},
created() {
this.getList()
- var dictParams = [
- { dictType: 'sys_oper_type', columnName: 'businessTypeOptions' },
- { dictType: 'sys_common_status', columnName: 'statusOptions' },
- ]
+ var dictParams = [{ dictType: 'sys_oper_type' }, { dictType: 'sys_common_status' }]
this.getDicts(dictParams).then((response) => {
response.data.forEach((element) => {
- this[element.columnName] = element.list
+ this[element.dictType] = element.list
})
})
},
@@ -206,10 +203,6 @@ export default {
}
})
},
- // 操作日志状态字典翻译
- statusFormat(row, column) {
- return this.selectDictLabel(this.statusOptions, row.status)
- },
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1