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_UsersService), ServiceLifetime = LifeTime.Transient)]
public class T_UsersService : BaseService, IT_UsersService
{
///
/// 查询用户表,存储用户基本信息(移除登录相关字段)列表
///
///
///
public PagedInfo GetList(T_UsersQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public T_Users GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加用户表,存储用户基本信息(移除登录相关字段)
///
///
///
public T_Users AddT_Users(T_Users model)
{
return Insertable(model).ExecuteReturnEntity();
}
///
/// 修改用户表,存储用户基本信息(移除登录相关字段)
///
///
///
public int UpdateT_Users(T_Users model)
{
return Update(model, true, "修改用户表,存储用户基本信息(移除登录相关字段)");
}
///
/// 导出用户表,存储用户基本信息(移除登录相关字段)
///
///
///
public PagedInfo ExportList(T_UsersQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 100000;
var predicate = QueryExp(parm);
var response = Queryable()
.Where(predicate.ToExpression())
.Select((it) => new T_UsersDto()
{
GenderLabel = it.Gender.GetConfigValue("liveforum_user_gender"),
CertifiedTypeLabel = it.CertifiedType.GetConfigValue("liveforum_sk"),
StatusLabel = it.Status.GetConfigValue("liveforum_user_status"),
}, true)
.ToPage(parm);
return response;
}
///
/// 查询导出表达式
///
///
///
private static Expressionable QueryExp(T_UsersQueryDto parm)
{
var predicate = Expressionable.Create();
predicate = predicate.AndIF(parm.Id != null, it => it.Id == parm.Id);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NickName), it => it.NickName.Contains(parm.NickName));
return predicate;
}
}
}