using FlexJobApi.Core;
|
using Furion.DatabaseAccessor;
|
using Furion.FriendlyException;
|
using Mapster;
|
using MediatR;
|
using Microsoft.EntityFrameworkCore;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace FlexJobApi.UserServer.Application
|
{
|
/// <summary>
|
/// 灵工命令处理器
|
/// </summary>
|
public class EnterpriseEmployeesCommandHandler(
|
IRepository<EnterpriseEmployee> rep
|
) :
|
IRequestHandler<ImportEnterpriseEmployeesCommand, int>,
|
IRequestHandler<EditEnterpriseEmployeeCommand, Guid>
|
{
|
private readonly IRepository<EnterpriseEmployee> rep = rep;
|
|
public Task<int> Handle(ImportEnterpriseEmployeesCommand request, CancellationToken cancellationToken)
|
{
|
throw new NotImplementedException();
|
}
|
|
/// <summary>
|
/// 编辑灵工信息
|
/// </summary>
|
/// <param name="request"></param>
|
/// <param name="cancellationToken"></param>
|
/// <returns></returns>
|
public Task<Guid> Handle(EditEnterpriseEmployeeCommand request, CancellationToken cancellationToken)
|
{
|
return request.SaveData<EnterpriseEmployee, EditEnterpriseEmployeeCommand>(
|
null,
|
null,
|
(entity) =>
|
{
|
if (request.Id.HasValue && entity.UserId.HasValue)
|
{
|
throw Oops.Oh(EnumErrorCodeType.s510, "该灵工已报名无法修改信息");
|
}
|
request.Adapt(entity);
|
},
|
cancellationToken);
|
}
|
}
|
}
|