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.1 KiB

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Znyc.Cloudcar.Admin.AspNetCore.Controllers;
using Znyc.Cloudcar.Admin.AspNetCore.Entitys;
using Znyc.Cloudcar.Admin.AspNetCore.Mvc;
using Znyc.Cloudcar.Admin.Commons.Entitys;
using Znyc.Cloudcar.Admin.Commons.Mapping;
using Znyc.Cloudcar.Admin.Security.Dtos;
using Znyc.Cloudcar.Admin.Security.Entitys;
using Znyc.Cloudcar.Admin.Security.IServices;
namespace Znyc.Cloudcar.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="equipmentId"></param>
/// <param name="promoteType"></param>
/// <returns></returns>
[HttpPut("AuditSuccessAsync")]
[FunctionAuthorize("")]
public async Task<IActionResult> AuditSuccessAsync(long equipmentId,int promoteType)
{
CommonResult result = new CommonResult();
AuditEntity info = new AuditEntity
{
EquipmentId = equipmentId
};
OnBeforeInsert(info);
result = await _productAuditService.AuditSuccessAsync(info, promoteType);
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);
}
}
}