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
4.0 KiB
129 lines
4.0 KiB
2 years ago
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using System;
|
||
|
using System.Threading.Tasks;
|
||
|
using Znyc.Recruitment.Admin.AspNetCore.Controllers;
|
||
|
using Znyc.Recruitment.Admin.AspNetCore.Entitys;
|
||
|
using Znyc.Recruitment.Admin.AspNetCore.Mvc;
|
||
|
using Znyc.Recruitment.Admin.Commons.Entitys;
|
||
|
using Znyc.Recruitment.Admin.Commons.Mapping;
|
||
|
using Znyc.Recruitment.Admin.Security.Dtos;
|
||
|
using Znyc.Recruitment.Admin.Security.Entitys;
|
||
|
using Znyc.Recruitment.Admin.Security.IServices;
|
||
|
|
||
|
namespace Znyc.Recruitment.Admin.WebApi.Controllers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 审核
|
||
|
/// </summary>
|
||
|
[ApiController]
|
||
|
[Route("api/Security/[controller]")]
|
||
|
public class AuditController : AreaApiController<AuditEntity, AuditOutputDto, AuditInputDto,
|
||
|
IAuditService, long>
|
||
|
{
|
||
|
private readonly IAuditService _productAuditService;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 构造函数
|
||
|
/// </summary>
|
||
|
public AuditController(
|
||
|
IAuditService productAuditService,
|
||
|
IUserService userService
|
||
|
) : base(productAuditService)
|
||
|
{
|
||
|
_productAuditService = productAuditService;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 新增前处理数据
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
protected override void OnBeforeInsert(AuditEntity info)
|
||
|
{
|
||
|
info.Id = 0;
|
||
|
info.CreatedTime = DateTime.Now;
|
||
|
info.CreatedUserId = CurrentUser.UserId;
|
||
|
info.IsDeleted = false;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 在更新数据前对数据的修改操作
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns></returns>
|
||
|
protected override void OnBeforeUpdate(AuditEntity info)
|
||
|
{
|
||
|
info.AuditUserId = CurrentUser.UserId;
|
||
|
info.ModifiedUserId = CurrentUser.UserId;
|
||
|
info.ModifiedTime = DateTime.Now;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 在软删除数据前对数据的修改操作
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns></returns>
|
||
|
protected override void OnBeforeSoftDelete(AuditEntity info)
|
||
|
{
|
||
|
info.IsDeleted = true;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 审核通过
|
||
|
/// </summary>
|
||
|
/// <param name="pid"></param>
|
||
|
/// <param name="productType"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPut("AuditSuccessAsync")]
|
||
|
[FunctionAuthorize("")]
|
||
|
public async Task<IActionResult> AuditSuccessAsync(long pid, int productType)
|
||
|
{
|
||
|
CommonResult result = new CommonResult();
|
||
|
AuditEntity info = new AuditEntity
|
||
|
{
|
||
|
ProductId = pid,
|
||
|
ProductType = productType
|
||
|
};
|
||
|
OnBeforeInsert(info);
|
||
|
result = await _productAuditService.AuditSuccessAsync(info);
|
||
|
if (result.Success)
|
||
|
{
|
||
|
result.ErrCode = ErrCode.successCode;
|
||
|
result.ErrMsg = ErrCode.err0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
result.ErrMsg = ErrCode.err43002;
|
||
|
result.ErrCode = "43002";
|
||
|
}
|
||
|
|
||
|
return ToJsonContent(result);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 审核失败
|
||
|
/// </summary>
|
||
|
/// <param name="productAuditInput"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPut("AuditFailAsync")]
|
||
|
[FunctionAuthorize("")]
|
||
|
public async Task<IActionResult> AuditFailAsync(AuditInputDto productAuditInput)
|
||
|
{
|
||
|
CommonResult result = new CommonResult();
|
||
|
AuditEntity info = productAuditInput.MapTo<AuditEntity>();
|
||
|
OnBeforeInsert(info);
|
||
|
result = await _productAuditService.AuditFailAsync(info);
|
||
|
if (result.Success)
|
||
|
{
|
||
|
result.ErrCode = ErrCode.successCode;
|
||
|
result.ErrMsg = ErrCode.err0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
result.ErrMsg = ErrCode.err43002;
|
||
|
result.ErrCode = "43002";
|
||
|
}
|
||
|
|
||
|
return ToJsonContent(result);
|
||
|
}
|
||
|
}
|
||
|
}
|