187 lines
6.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Learun.Util;
using Learun.Util.SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace Learun.Application.Form
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创建人:研发部
/// 日 期2017.04.01
/// 描 述:表单关联功能
/// </summary>
public class FormRelationService
{
#region
Repository<FormRelationEntity> _formRelationRepository => new Repository<FormRelationEntity>();
#endregion
#region
private string fieldSql;
public FormRelationService()
{
fieldSql = @"
t.F_Id,
t.F_CreateDate,
t.F_CreateUserId,
t.F_CreateUserName,
t.F_ModifyDate,
t.F_ModifyUserId,
t.F_ModifyUserName
";
}
#endregion
#region
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pagination">分页参数</param>
/// <param name="keyword">关键字</param>
/// <returns></returns>
public IEnumerable<FormRelationEntity> GetPageList(Pagination pagination, string keyword)
{
try
{
var strSql = new StringBuilder();
strSql.Append(" SELECT ");
strSql.Append(fieldSql);
strSql.Append(" ,s.F_Name as F_FormId,m.F_FullName as F_ModuleId FROM LR_Form_Relation t ");
strSql.Append(" LEFT JOIN LR_Form_SchemeInfo s ON t.F_FormId = s.F_Id ");
strSql.Append(" LEFT JOIN LR_Base_Module m ON t.F_ModuleId = m.F_ModuleId WHERE 1=1 ");
if (!string.IsNullOrEmpty(keyword))
{
strSql.Append(" AND (s.F_Name like @keyword OR m.F_FullName like @keyword ) ");
keyword = "%" + keyword + "%";
}
//return this.BaseRepository().FindList<FormRelationEntity>(strSql.ToString(), new { keyword = keyword }, pagination);
return SqlSugarHelper.Db.SqlQueryable<FormRelationEntity>(strSql.ToString()).AddParameters(new { keyword = keyword }).ToPageList(pagination.page, pagination.rows);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pagination">分页参数</param>
/// <param name="keyword">关键字</param>
/// <returns></returns>
public IEnumerable<FormRelationEntity> GetList()
{
try
{
var strSql = new StringBuilder();
strSql.Append(" SELECT ");
strSql.Append(fieldSql);
strSql.Append(" ,t.F_FormId,m.F_FullName as F_ModuleId FROM LR_Form_Relation t ");
strSql.Append(" LEFT JOIN LR_Base_Module m ON t.F_ModuleId = m.F_ModuleId WHERE 1=1 ");
//return this.BaseRepository().FindList<FormRelationEntity>(strSql.ToString());
return SqlSugarHelper.Db.SqlQueryable<FormRelationEntity>(strSql.ToString()).ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 获取实体数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
public FormRelationEntity GetEntity(string keyValue)
{
try
{
return _formRelationRepository.GetById(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region
/// <summary>
/// 虚拟删除模板信息
/// </summary>
/// <param name="keyValue">主键</param>
public void DeleteEntity(string keyValue)
{
try
{
_formRelationRepository.Delete(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="formRelationEntity">表单与功能信息</param>
public void SaveEntity(string keyValue, FormRelationEntity formRelationEntity)
{
try
{
if (string.IsNullOrEmpty(keyValue))
{
_formRelationRepository.Insert(formRelationEntity);
}
else
{
formRelationEntity.Modify(keyValue);
_formRelationRepository.Update(formRelationEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}