diff --git a/Infrastructure/Model/SendEmailDto.cs b/Infrastructure/Model/SendEmailDto.cs
index 7408dcf..6674ec4 100644
--- a/Infrastructure/Model/SendEmailDto.cs
+++ b/Infrastructure/Model/SendEmailDto.cs
@@ -1,15 +1,20 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.ComponentModel.DataAnnotations;
namespace Infrastructure.Model
{
public class SendEmailDto
{
+ ///
+ /// 文件地址
+ ///
public string FileUrl { get; set; } = "";
+ ///
+ /// 主题
+ ///
+ [Required(ErrorMessage = "主题不能为空")]
public string Subject { get; set; }
+ [Required(ErrorMessage = "发送人不能为空")]
public string ToUser { get; set; }
public string Content { get; set; } = "";
public string HtmlContent { get; set; }
diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
index 08fef47..75fd135 100644
--- a/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/ArticleCategoryController.cs
@@ -16,7 +16,6 @@ namespace ZR.Admin.WebApi.Controllers
///
/// 文章目录Controller
///
- [Verify]
[Route("article/ArticleCategory")]
public class ArticleCategoryController : BaseController
{
@@ -36,7 +35,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("list")]
- [ActionPermissionFilter(Permission = "articlecategory:list")]
+ //[ActionPermissionFilter(Permission = "articlecategory:list")]
public IActionResult QueryArticleCategory([FromQuery] ArticleCategoryQueryDto parm)
{
var response = _ArticleCategoryService.GetList(parm);
@@ -49,7 +48,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("treeList")]
- [ActionPermissionFilter(Permission = "articlecategory:list")]
+ //[ActionPermissionFilter(Permission = "articlecategory:list")]
public IActionResult QueryTreeArticleCategory([FromQuery] ArticleCategoryQueryDto parm)
{
var response = _ArticleCategoryService.GetTreeList(parm);
@@ -62,7 +61,7 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpGet("{CategoryId}")]
- [ActionPermissionFilter(Permission = "articlecategory:query")]
+ //[ActionPermissionFilter(Permission = "articlecategory:query")]
public IActionResult GetArticleCategory(int CategoryId)
{
var response = _ArticleCategoryService.GetFirst(x => x.CategoryId == CategoryId);
@@ -75,17 +74,12 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpPost]
+ [Verify]
[ActionPermissionFilter(Permission = "articlecategory:add")]
[Log(Title = "文章目录", BusinessType = BusinessType.INSERT)]
public IActionResult AddArticleCategory([FromBody] ArticleCategoryDto parm)
{
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
- //从 Dto 映射到 实体
var modal = parm.Adapt().ToCreate(HttpContext);
-
var response = _ArticleCategoryService.AddArticleCategory(modal);
return ToResponse(response);
@@ -96,16 +90,12 @@ namespace ZR.Admin.WebApi.Controllers
///
///
[HttpPut]
+ [Verify]
[ActionPermissionFilter(Permission = "articlecategory:edit")]
[Log(Title = "文章目录", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateArticleCategory([FromBody] ArticleCategoryDto parm)
{
- if (parm == null)
- {
- throw new CustomException("请求实体不能为空");
- }
var modal = parm.Adapt().ToUpdate(HttpContext);
-
var response = _ArticleCategoryService.Update(w => w.CategoryId == modal.CategoryId, it => new ArticleCategory()
{
Name = modal.Name,
diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
index 26496de..4317af1 100644
--- a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs
@@ -1,7 +1,5 @@
-using Infrastructure;
-using Infrastructure.Attribute;
+using Infrastructure.Attribute;
using Infrastructure.Enums;
-using Infrastructure.Model;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -79,7 +77,7 @@ namespace ZR.Admin.WebApi.Controllers
if (model != null)
{
model.ArticleCategoryNav = _ArticleCategoryService.GetById(model.CategoryId);
- model.TagList = model.Tags.Split(',', StringSplitOptions.RemoveEmptyEntries);
+ model.TagList = model.Tags?.Split(',', StringSplitOptions.RemoveEmptyEntries);
}
return SUCCESS(model);
}
@@ -90,13 +88,9 @@ namespace ZR.Admin.WebApi.Controllers
///
[HttpPost("add")]
[ActionPermissionFilter(Permission = "system:article:add")]
- [Log(Title = "文章添加", BusinessType = BusinessType.INSERT)]
+ [Log(Title = "添加文章", BusinessType = BusinessType.INSERT)]
public IActionResult Create([FromBody] ArticleDto parm)
{
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
var addModel = parm.Adapt().ToCreate(context: HttpContext);
addModel.AuthorName = HttpContext.GetName();
@@ -112,13 +106,8 @@ namespace ZR.Admin.WebApi.Controllers
[Log(Title = "文章修改", BusinessType = BusinessType.UPDATE)]
public IActionResult Update([FromBody] ArticleDto parm)
{
- if (parm == null)
- {
- throw new CustomException("请求参数错误");
- }
parm.AuthorName = HttpContext.GetName();
var modal = parm.Adapt().ToUpdate(HttpContext);
-
var response = _ArticleService.UpdateArticle(modal);
return SUCCESS(response);
@@ -133,16 +122,8 @@ namespace ZR.Admin.WebApi.Controllers
[Log(Title = "文章删除", BusinessType = BusinessType.DELETE)]
public IActionResult Delete(int id = 0)
{
- if (id <= 0)
- {
- return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
- }
-
- // 删除文章
var response = _ArticleService.Delete(id);
-
return SUCCESS(response);
}
-
}
}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/NLog.config b/ZR.Admin.WebApi/NLog.config
index db70656..9936650 100644
--- a/ZR.Admin.WebApi/NLog.config
+++ b/ZR.Admin.WebApi/NLog.config
@@ -82,7 +82,7 @@
-
+
diff --git a/ZR.Model/System/Dto/ArticleDto.cs b/ZR.Model/System/Dto/ArticleDto.cs
index d12aaf6..959bda2 100644
--- a/ZR.Model/System/Dto/ArticleDto.cs
+++ b/ZR.Model/System/Dto/ArticleDto.cs
@@ -19,9 +19,9 @@ namespace ZR.Model.System.Dto
{
[Required(ErrorMessage = "Cid不能为空")]
public int Cid { get; set; }
-
+ [Required(ErrorMessage = "文章标题不能为空")]
public string Title { get; set; }
-
+ [Required(ErrorMessage = "文章内容不能为空")]
public string Content { get; set; }
public long? UserId { get; set; }
diff --git a/ZR.Service/System/SysLoginService.cs b/ZR.Service/System/SysLoginService.cs
index ca3f5b9..90a5612 100644
--- a/ZR.Service/System/SysLoginService.cs
+++ b/ZR.Service/System/SysLoginService.cs
@@ -69,16 +69,18 @@ namespace ZR.Service.System
///
public PagedInfo GetLoginLog(SysLogininfor logininfoDto, PagerInfo pager)
{
- logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
- logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
+ //logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
+ //logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
var exp = Expressionable.Create();
- exp.And(it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
+
+ exp.AndIF(logininfoDto.BeginTime == null, it => it.LoginTime >= DateTime.Now.ToShortDateString().ParseToDateTime());
+ exp.AndIF(logininfoDto.BeginTime != null, it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
exp.AndIF(logininfoDto.Ipaddr.IfNotEmpty(), f => f.Ipaddr == logininfoDto.Ipaddr);
exp.AndIF(logininfoDto.UserName.IfNotEmpty(), f => f.UserName.Contains(logininfoDto.UserName));
exp.AndIF(logininfoDto.Status.IfNotEmpty(), f => f.Status == logininfoDto.Status);
var query = Queryable().Where(exp.ToExpression())
- .OrderBy(it => it.InfoId, OrderByType.Desc);
+ .OrderBy(it => it.InfoId, OrderByType.Desc);
return query.ToPage(pager);
}