using Dapper; using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace Learun.Application.OA.Schedule { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2017.07.11 /// 描 述:日程管理 /// public class ScheduleService : RepositoryFactory { #region 获取数据 /// /// 获取页面显示列表分页数据 /// /// 分页参数 /// 查询参数 /// public IEnumerable GetPageListByUserId(Pagination pagination, string queryJson, string userId) { try { var strSql = new StringBuilder(); strSql.Append("SELECT t.* "); strSql.Append(" FROM LR_OA_Schedule t "); strSql.Append(" WHERE 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); if (!userId.IsEmpty()) { dp.Add("F_CreateUserId", userId, DbType.String); strSql.Append(" AND t.F_CreateUserId = @F_CreateUserId "); } return this.BaseRepository().FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取列表 /// /// 返回列表 public IEnumerable GetList() { try { return this.BaseRepository().FindList(); } catch (Exception ex) { if (ex is ExceptionEx) throw; else throw ExceptionEx.ThrowServiceException(ex); } } /// /// 获取实体 /// /// 主键值 /// public ScheduleEntity GetEntity(string keyValue) { try { return this.BaseRepository().FindEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) throw; else throw ExceptionEx.ThrowServiceException(ex); } } #endregion #region 提交数据 /// /// 删除数据 /// /// 主键 public void RemoveForm(string keyValue) { try { //this.BaseRepository().Delete(keyValue); this.BaseRepository().Delete(x => x.F_ScheduleId == keyValue); } catch (Exception ex) { if (ex is ExceptionEx) throw; else throw ExceptionEx.ThrowServiceException(ex); } } /// /// 保存表单(新增、修改) /// /// 主键值 /// 实体对象 /// public void SaveForm(string keyValue, ScheduleEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) throw; else throw ExceptionEx.ThrowServiceException(ex); } } #endregion } }