using learun.iapplication; using learun.util; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2020.04.07 /// 描 述:App首页图片管理 /// public class DTImgService : ServiceBase { #region 构造函数和属性 private readonly string fieldSql; /// /// /// public DTImgService() { fieldSql = @" t.F_Id, t.F_Des, t.F_FileName, t.F_EnabledMark, t.F_SortCode "; } #endregion 构造函数和属性 #region 获取数据 /// /// 获取列表数据 /// /// public Task> GetList() { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(fieldSql); strSql.Append(" FROM LR_App_DTImg t WHERE t.F_EnabledMark = 1 Order by t.F_SortCode "); return this.BaseRepository().FindList(strSql.ToString()); } /// /// 获取列表分页数据 /// /// 分页参数 /// 查询参数 /// public Task> GetPageList(Pagination pagination, string queryJson) { var queryParam = queryJson.ToJObject(); var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(fieldSql); strSql.Append(" FROM LR_App_DTImg t where 1=1 "); // 关键字 string keyword = ""; if (!queryParam["keyword"].IsEmpty()) { keyword = "%" + queryParam["keyword"].ToString() + "%"; strSql.Append(" AND t.F_Des like @keyword "); } return this.BaseRepository().FindList(strSql.ToString(), new { keyword }, pagination); } /// /// 获取实体数据 /// /// 主键 /// public Task GetEntity(string keyValue) { return this.BaseRepository().FindEntityByKey(keyValue); } #endregion 获取数据 #region 提交数据 /// /// 删除实体数据 /// /// 主键 /// public async Task DeleteEntity(string keyValue) { await this.BaseRepository().DeleteAny(new { F_Id = keyValue }); } /// /// 保存实体数据(新增、修改) /// /// 主键 /// 实体 /// public async Task SaveEntity(string keyValue, DTImgEntity entity) { if (!string.IsNullOrEmpty(keyValue)) { entity.F_Id = keyValue; await this.BaseRepository().Update(entity); } else { entity.F_Id = Guid.NewGuid().ToString(); entity.F_EnabledMark = 1; await this.BaseRepository().Insert(entity); } } #endregion 提交数据 } }