⚡优化代码
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
@@ -10,8 +11,10 @@ namespace ZR.Service.System.IService
|
||||
/// @author zr
|
||||
/// @date 2021-12-15
|
||||
/// </summary>
|
||||
public interface ISysNoticeService: IBaseService<SysNotice>
|
||||
public interface ISysNoticeService : IBaseService<SysNotice>
|
||||
{
|
||||
List<SysNotice> GetSysNotices();
|
||||
|
||||
PagedInfo<SysNotice> GetPageList(SysNoticeQueryDto parm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
@@ -24,12 +25,25 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public List<SysNotice> GetSysNotices()
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<SysNotice>();
|
||||
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
predicate = predicate.And(m => m.Status == 0);
|
||||
return GetList(predicate.ToExpression());
|
||||
return Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderByDescending(f => f.Create_time)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PagedInfo<SysNotice> GetPageList(SysNoticeQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<SysNotice>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NoticeTitle), m => m.NoticeTitle.Contains(parm.NoticeTitle));
|
||||
predicate = predicate.AndIF(parm.NoticeType != null, m => m.NoticeType == parm.NoticeType);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CreateBy), m => m.Create_by.Contains(parm.CreateBy) || m.Update_by.Contains(parm.CreateBy));
|
||||
predicate = predicate.AndIF(parm.Status != null, m => m.Status == parm.Status);
|
||||
var response = GetPages(predicate.ToExpression(), parm);
|
||||
return response;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user