|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using Dapper;
- using Learun.DataBase.Repository;
- using Learun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
-
- namespace Learun.Application.Base.CodeSchemaModule
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
- /// Copyright (c) 2013-2018 上海力软信息技术有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-03-01 11:09
- /// 描 述:代码模板
- /// </summary>
- public class CodeSchemaService : RepositoryFactory
- {
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- public IEnumerable<LR_Base_CodeSchemaEntity> GetPageList(Pagination pagination, string queryJson)
- {
- try
- {
- var strSql = new StringBuilder();
- strSql.Append("SELECT ");
- strSql.Append(@"
- t.F_Id,
- t.F_Name,
- t.F_Catalog,
- t.F_Type,
- t.F_Description
- ");
- strSql.Append(" FROM LR_Base_CodeSchema t ");
- strSql.Append(" WHERE 1=1 ");
- var queryParam = queryJson.ToJObject();
- // 虚拟参数
- var dp = new DynamicParameters(new { });
- if (!queryParam["F_Name"].IsEmpty())
- {
- dp.Add("F_Name", "%" + queryParam["F_Name"].ToString() + "%", DbType.String);
- strSql.Append(" AND t.F_Name Like @F_Name ");
- }
- if (!queryParam["F_Catalog"].IsEmpty())
- {
- dp.Add("F_Catalog",queryParam["F_Catalog"].ToString(), DbType.String);
- strSql.Append(" AND t.F_Catalog = @F_Catalog ");
- }
- return this.BaseRepository().FindList<LR_Base_CodeSchemaEntity>(strSql.ToString(),dp, pagination);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取LR_Base_CodeSchema表实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public LR_Base_CodeSchemaEntity GetLR_Base_CodeSchemaEntity(string keyValue)
- {
- try
- {
- return this.BaseRepository().FindEntity<LR_Base_CodeSchemaEntity>(keyValue);
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- /// <summary>
- /// 获取树形数据
- /// </summary>
- /// <returns></returns>
- public DataTable GetSqlTree()
- {
- try
- {
- return this.BaseRepository().FindTable(" select * from lr_base_dataitemdetail ");
- }
- catch (Exception ex)
- {
- if (ex is ExceptionEx)
- {
- throw;
- }
- else
- {
- throw ExceptionEx.ThrowServiceException(ex);
- }
- }
- }
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public void DeleteEntity(string keyValue)
- {
- try
- {
- this.BaseRepository().Delete<LR_Base_CodeSchemaEntity>(t=>t.F_Id == 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 SaveEntity(string keyValue, LR_Base_CodeSchemaEntity 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
-
- }
- }
|