using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Repository;
using ZR.Service.Liveforum.ILiveforumService;
namespace ZR.Service.Liveforum
{
///
/// 等级配置Service业务层处理
///
[AppService(ServiceType = typeof(IT_UserLevelsService), ServiceLifetime = LifeTime.Transient)]
public class T_UserLevelsService : BaseService, IT_UserLevelsService
{
///
/// 查询等级配置列表
///
///
///
public PagedInfo GetList(T_UserLevelsQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id asc")
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public T_UserLevels GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加等级配置
///
///
///
public T_UserLevels AddT_UserLevels(T_UserLevels model)
{
return Insertable(model).ExecuteReturnEntity();
}
///
/// 修改等级配置
///
///
///
public int UpdateT_UserLevels(T_UserLevels model)
{
return Update(model, true);
}
///
/// 导出等级配置
///
///
///
public PagedInfo ExportList(T_UserLevelsQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 100000;
var predicate = QueryExp(parm);
var response = Queryable()
.Where(predicate.ToExpression())
.Select((it) => new T_UserLevelsDto()
{
IsActiveLabel = it.IsActive.GetConfigValue("sys_common_status_bool"),
}, true)
.ToPage(parm);
return response;
}
///
/// 查询导出表达式
///
///
///
private static Expressionable QueryExp(T_UserLevelsQueryDto parm)
{
var predicate = Expressionable.Create();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LevelName), it => it.LevelName.Contains(parm.LevelName));
return predicate;
}
}
}