|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- 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
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.07.11
- /// 描 述:日程管理
- /// </summary>
- public class ScheduleService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<ScheduleEntity> 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<ScheduleEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取列表
- /// </summary>
- /// <returns>返回列表</returns>
- public IEnumerable<ScheduleEntity> GetList()
- {
- try
- {
- return this.BaseRepository().FindList<ScheduleEntity>();
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- throw;
- else
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- /// <summary>
- /// 获取实体
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- public ScheduleEntity GetEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository().FindEntity<ScheduleEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- throw;
- else
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void RemoveForm(string keyValue)
- {
- try
- {
- //this.BaseRepository().Delete(keyValue);
- this.BaseRepository().Delete<ScheduleEntity>(x => x.F_ScheduleId == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- throw;
- else
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- /// <summary>
- /// 保存表单(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <param name="entity">实体对象</param>
- /// <returns></returns>
- 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
- }
- }
|