|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Text;
-
- namespace Learun.Application.Base.SystemModule
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.03.08
- /// 描 述:数据字典管理服务类
- /// </summary>
- public class DataItemService : RepositoryFactory
- {
- #region 属性 构造函数
- private string fieldSql;
- private string detailFieldSql;
- public DataItemService()
- {
- fieldSql = @"
- t.F_ItemId,
- t.F_ParentId,
- t.F_ItemCode,
- t.F_ItemName,
- t.F_IsTree,
- t.F_IsNav,
- t.F_SortCode,
- t.F_DeleteMark,
- t.F_EnabledMark,
- t.F_Description,
- t.F_CreateDate,
- t.F_CreateUserId,
- t.F_CreateUserName,
- t.F_ModifyDate,
- t.F_ModifyUserId,
- t.F_ModifyUserName
- ";
- detailFieldSql = @"
- t.F_ItemDetailId,
- t.F_ItemId,
- t.F_ParentId,
- t.F_ItemCode,
- t.F_ItemName,
- t.F_ItemValue,
- t.F_QuickQuery,
- t.F_SimpleSpelling,
- t.F_IsDefault,
- t.F_SortCode,
- t.F_DeleteMark,
- t.F_EnabledMark,
- t.F_Description,
- t.F_CreateDate,
- t.F_CreateUserId,
- t.F_CreateUserName,
- t.F_ModifyDate,
- t.F_ModifyUserId,
- t.F_ModifyUserName,
- t.F_Type,t.F_Length,t.F_Constraint,t.F_ValueSpace,t.F_Explain,t.F_ReferenceNum
- ";
- }
- #endregion
-
- #region 数据字典分类管理
- /// <summary>
- /// 分类列表
- /// </summary>
- /// <returns></returns>
- public IEnumerable<DataItemEntity> GetClassifyList()
- {
- try
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT " + fieldSql + " FROM LR_Base_DataItem t WHERE t.F_DeleteMark = 0 Order By t.F_ParentId,t.F_SortCode ");
- return this.BaseRepository().FindList<DataItemEntity>(strSql.ToString());
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 虚拟删除分类数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void VirtualDeleteClassify(string keyValue)
- {
- try
- {
- DataItemEntity entity = new DataItemEntity()
- {
- F_ItemId = keyValue,
- F_DeleteMark = 1
- };
- this.BaseRepository().Update(entity);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 保存分类数据实体
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- public void SaveClassifyEntity(string keyValue, DataItemEntity entity) {
- try
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- entity.Create();
- this.BaseRepository().Insert(entity);
- }
- else {
- entity.Modify(keyValue);
- this.BaseRepository().Update(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- #endregion
-
- #region 数据字典明细
- /// <summary>
- /// 获取数据字典明显根据分类编号
- /// </summary>
- /// <param name="itemCode">分类编号</param>
- /// <returns></returns>
- public IEnumerable<DataItemDetailEntity> GetDetailList(string itemCode)
- {
- try
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT " + detailFieldSql + @" FROM LR_Base_DataItemDetail t
- INNER JOIN LR_Base_DataItem t2 ON t.F_ItemId = t2.F_ItemId
- WHERE t2.F_ItemCode = @itemCode AND t.F_DeleteMark = 0 Order By t.F_SortCode
- ");
- return this.BaseRepository().FindList<DataItemDetailEntity>(strSql.ToString(), new { itemCode = itemCode });
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 获取数据字典明细实体类
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public DataItemDetailEntity GetDetailEntity(string keyValue) {
- try
- {
- return this.BaseRepository().FindEntity<DataItemDetailEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 虚拟删除明细数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void VirtualDeleteDetail(string keyValue)
- {
- try
- {
- DataItemDetailEntity entity = new DataItemDetailEntity()
- {
- F_ItemDetailId = keyValue,
- F_DeleteMark = 1
- };
- this.BaseRepository().Update(entity);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- /// <summary>
- /// 保存明细数据实体
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- public void SaveDetailEntity(string keyValue, DataItemDetailEntity entity)
- {
- try
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- entity.Create();
- this.BaseRepository().Insert(entity);
- }
- else
- {
- entity.Modify(keyValue);
- this.BaseRepository().Update(entity);
- }
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
- #endregion
- }
- }
|