ZrAdminNetCore/ZR.Service/Liveforum/T_UserCertificationsService.cs
2025-11-16 14:06:41 +08:00

105 lines
3.5 KiB
C#

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
{
/// <summary>
/// 认证申请表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IT_UserCertificationsService), ServiceLifetime = LifeTime.Transient)]
public class T_UserCertificationsService : BaseService<T_UserCertifications>, IT_UserCertificationsService
{
/// <summary>
/// 查询认证申请表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_UserCertificationsDto> GetList(T_UserCertificationsQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage<T_UserCertifications, T_UserCertificationsDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public T_UserCertifications GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加认证申请表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public T_UserCertifications AddT_UserCertifications(T_UserCertifications model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改认证申请表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateT_UserCertifications(T_UserCertifications model)
{
return Update(model, true);
}
/// <summary>
/// 导出认证申请表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_UserCertificationsDto> ExportList(T_UserCertificationsQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 100000;
var predicate = QueryExp(parm);
var response = Queryable()
.Where(predicate.ToExpression())
.Select((it) => new T_UserCertificationsDto()
{
CertificationTypeLabel = it.CertificationType.GetConfigValue<Model.System.SysDictData>("liveforum_sk"),
StatusLabel = it.Status.GetConfigValue<Model.System.SysDictData>("liveforum_sk_review"),
}, true)
.ToPage(parm);
return response;
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<T_UserCertifications> QueryExp(T_UserCertificationsQueryDto parm)
{
var predicate = Expressionable.Create<T_UserCertifications>();
predicate = predicate.AndIF(parm.UserId != null, it => it.UserId == parm.UserId);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CertificationType), it => it.CertificationType == parm.CertificationType);
return predicate;
}
}
}