You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.1 KiB
129 lines
3.1 KiB
using learun.iapplication;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace learun.application
|
|
{
|
|
/// <summary>
|
|
/// 版 本 EasyCode EC管理后台
|
|
/// Copyright (c) 2019-present EC管理有限公司
|
|
/// 创建人:tobin
|
|
/// 日 期:2019.10.31
|
|
/// 描 述:桌面统计数据配置
|
|
/// </summary>
|
|
public class DTTargetService : ServiceBase
|
|
{
|
|
#region 构造函数和属性
|
|
|
|
private readonly string fieldSql;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public DTTargetService()
|
|
{
|
|
fieldSql = @"
|
|
t.F_Id,
|
|
t.F_Name,
|
|
t.F_Icon,
|
|
t.F_CreateUserId,
|
|
t.F_CreateUserName,
|
|
t.F_CreateDate,
|
|
t.F_Description,
|
|
t.F_Url,
|
|
t.F_Sort,
|
|
t.F_DataSourceId,
|
|
t.F_Sql
|
|
";
|
|
}
|
|
|
|
#endregion 构造函数和属性
|
|
|
|
#region 获取数据
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Task<IEnumerable<DTTargetEntity>> GetList()
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(fieldSql);
|
|
strSql.Append(" FROM LR_DT_Target t Order by t.F_Sort ");
|
|
return this.BaseRepository().FindList<DTTargetEntity>(strSql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="keyword">关键字</param>
|
|
/// <returns></returns>
|
|
public Task<IEnumerable<DTTargetEntity>> GetList(string keyword)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(fieldSql);
|
|
strSql.Append(" FROM LR_DT_Target t where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
keyword = "%" + keyword + "%";
|
|
strSql.Append(" t.F_Name like @keyword ");
|
|
}
|
|
|
|
strSql.Append(" Order by t.F_Sort ");
|
|
|
|
return this.BaseRepository().FindList<DTTargetEntity>(strSql.ToString(), new { keyword });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取实体数据
|
|
/// </summary>
|
|
/// <param name="keyValue">主键</param>
|
|
/// <returns></returns>
|
|
public Task<DTTargetEntity> GetEntity(string keyValue)
|
|
{
|
|
return this.BaseRepository().FindEntityByKey<DTTargetEntity>(keyValue);
|
|
}
|
|
|
|
#endregion 获取数据
|
|
|
|
#region 提交数据
|
|
|
|
/// <summary>
|
|
/// 删除实体数据
|
|
/// </summary>
|
|
/// <param name="keyValue">主键</param>
|
|
/// <returns></returns>
|
|
public async Task DeleteEntity(string keyValue)
|
|
{
|
|
await this.BaseRepository().DeleteAny<DTTargetEntity>(new { F_Id = keyValue });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存实体数据(新增、修改)
|
|
/// </summary>
|
|
/// <param name="keyValue">主键</param>
|
|
/// <param name="entity">实体</param>
|
|
/// <returns></returns>
|
|
public async Task SaveEntity(string keyValue, DTTargetEntity entity)
|
|
{
|
|
if (!string.IsNullOrEmpty(keyValue))
|
|
{
|
|
entity.F_Id = keyValue;
|
|
await this.BaseRepository().Update(entity);
|
|
}
|
|
else
|
|
{
|
|
entity.F_Id = Guid.NewGuid().ToString();
|
|
entity.F_CreateDate = DateTime.Now;
|
|
await this.BaseRepository().Insert(entity);
|
|
}
|
|
}
|
|
|
|
#endregion 提交数据
|
|
}
|
|
}
|