|
- 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.TwoDevelopment.EducationalAdministration
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-07-08 17:19
- /// 描 述:教师注册功能开关控制
- /// </summary>
- public class TeachSwitchService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<TeachSwitchEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var data = this.BaseRepository().FindList<TeachSwitchEntity>();
- if (!data.Any(a => a.type == "js"))
- {
- var jsEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "js"
- };
- jsEntity.Create();
- this.BaseRepository().Insert(jsEntity);
- }
- if (!data.Any(a => a.type == "fx"))
- {
- var fxEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "fx"
- };
- fxEntity.Create();
- this.BaseRepository().Insert(fxEntity);
- }
- //网上办事大厅
- if (!data.Any(a => a.type == "ssosystem"))
- {
- var jsEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "ssosystem"
- };
- jsEntity.Create();
- this.BaseRepository().Insert(jsEntity);
- }
- //微信快捷登录
- if (!data.Any(a => a.type == "wxloginforpc"))
- {
- var jsEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "wxloginforpc"
- };
- jsEntity.Create();
- this.BaseRepository().Insert(jsEntity);
- }
- if (!data.Any(a => a.type == "modifypwdfirstday"))
- {
- var jsEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "modifypwdfirstday"
- };
- jsEntity.Create();
- this.BaseRepository().Insert(jsEntity);
- }
- if (!data.Any(a => a.type == "modifypwdtip"))
- {
- var jsEntity = new TeachSwitchEntity()
- {
- status = "0",
- type = "modifypwdtip"
- };
- jsEntity.Create();
- this.BaseRepository().Insert(jsEntity);
- }
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.ID,
- t.status,
- t.type
- ");
- strSql.Append(" FROM TeachSwitch t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- return this.BaseRepository().FindList<TeachSwitchEntity>(strSql.ToString(), dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取TeachSwitch表实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public TeachSwitchEntity GetTeachSwitchEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository().FindEntity<TeachSwitchEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- internal bool FindFirst(string type)
- {
- try
- {
- var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
- if (result != null)
- {
- return result.status == "1" ? true : false;
- }
- else
- {
- return false;
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- internal TeachSwitchEntity GetFirst(string type)
- {
- try
- {
- var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
- if (result == null)
- {
- result = new TeachSwitchEntity { status = "0", type = type };
- result.Create();
- this.BaseRepository().Insert(result);
- }
- return result;
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository().Delete<TeachSwitchEntity>(t => t.ID == keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- public void SaveEntity(string keyValue, TeachSwitchEntity 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
-
- }
- }
|