using System; using Lottomat.Application.Entity.PublicInfoManage; using Lottomat.Application.IService.PublicInfoManage; using Lottomat.Data.Repository; using Lottomat.Util; using Lottomat.Util.Extension; using Lottomat.Util.WebControl; using System.Collections.Generic; using System.Linq.Expressions; using Newtonsoft.Json.Linq; namespace Lottomat.Application.Service.PublicInfoManage { /// /// 版 本 1.0 /// Copyright (c) 2016-2017 /// 创建人:赵轶 /// 日 期:2015.12.7 16:40 /// 描 述:新闻中心 /// public class NewsService : RepositoryFactory, INewsService { #region 获取数据 /// /// 新闻列表 /// /// 分页 /// 查询参数 /// public IEnumerable GetPageList(Pagination pagination, string queryJson) { var expression = LinqExtensions.True(); JObject queryParam = queryJson.ToJObject(); if (queryParam != null) { if (!queryParam["FullHead"].IsEmpty()) { string FullHead = queryParam["FullHead"].ToString(); expression = expression.And(t => t.FullHead.Contains(FullHead)); } if (!queryParam["Category"].IsEmpty()) { string Category = queryParam["Category"].ToString(); expression = expression.And(t => t.Category == Category); } if (!queryParam["CategoryId"].IsEmpty()) { string CategoryId = queryParam["CategoryId"].ToString(); expression = expression.And(t => t.CategoryId == CategoryId); } } expression = expression.And(t => t.TypeId == 1 && t.IsDelete == false); return this.BaseRepository().FindList(expression, pagination); } /// /// /// /// /// /// public IEnumerable GetPageList(Expression> condition, Pagination pagination) { //var expression = LinqExtensions.True(); //expression = expression.And(t => t.TypeId == 1 && t.IsDelete == false); //expression = expression.And(condition); return this.BaseRepository().FindList(condition, pagination); } /// /// 新闻实体 /// /// 主键值 /// public NewsEntity GetEntity(string keyValue) { return this.BaseRepository().FindEntity(keyValue); } public NewsEntity GetEntity(Expression> condition) { return this.BaseRepository().FindEntity(condition); } /// /// 获取所有数据 /// /// /// public IEnumerable GetList(Expression> condition) { return this.BaseRepository().FindList(condition); } /// /// 批量修改 /// /// 要修改的列及修改后列的值集合 /// 修改的条件 /// 修改列的名称的集合 /// 返回受影响行数 public int Modify(NewsEntity modelModifyProps, Expression> where, params string[] paramModifyStrings) { return this.BaseRepository().Modify(modelModifyProps, where, paramModifyStrings); } public IEnumerable FindList(Expression> condition, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class, new() { return this.BaseRepository().FindList(condition, orderField, isAsc, pageSize, pageIndex, out total); } #endregion #region 提交数据 /// /// 删除新闻 /// /// 主键 public void RemoveForm(string keyValue) { this.BaseRepository().Delete(keyValue); } /// /// 保存新闻表单(新增、修改) /// /// 主键值 /// 新闻实体 /// public void SaveForm(string keyValue, NewsEntity newsEntity) { if (!string.IsNullOrEmpty(keyValue)) { newsEntity.Modify(keyValue); newsEntity.TypeId = 1; this.BaseRepository().Update(newsEntity); } else { newsEntity.Create(); newsEntity.TypeId = 1; this.BaseRepository().Insert(newsEntity); } } /// /// 修改 /// /// 新闻实体 /// public void UpdateForm(NewsEntity newsEntity) { newsEntity.TypeId = 1; this.BaseRepository().Update(newsEntity); } #endregion } }