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.
 
 

146 lines
4.7 KiB

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.Pages;
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 CertificationController : AreaApiController<CertificationEntity, CertificationOutput,
CertificationOutput, ICertificationService, long>
{
private readonly ICertificationService _certificationService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="certificationService"></param>
public CertificationController(ICertificationService certificationService) : base(
certificationService)
{
_certificationService = certificationService;
}
/// <summary>
/// 新增前处理数据
/// </summary>
/// <param name="info"></param>
protected override void OnBeforeInsert(CertificationEntity 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(CertificationEntity info)
{
info.ModifiedUserId = CurrentUser.UserId;
info.ModifiedTime = DateTime.Now;
}
/// <summary>
/// 在软删除数据前对数据的修改操作
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
protected override void OnBeforeSoftDelete(CertificationEntity info)
{
info.IsDeleted = true;
}
/// <summary>
/// 异步分页查询
/// </summary>
/// <param name="search"></param>
/// <returns></returns>
[HttpPost("FindWithPagerSearchAsync")]
[FunctionAuthorize("List")]
public async Task<IActionResult> FindWithPagerSearchAsync(SearchUserModel search)
{
CommonResult<PageResult<CertificationOutput>> result = new CommonResult<PageResult<CertificationOutput>>
{
ErrCode = ErrCode.successCode,
ErrMsg = ErrCode.err0,
ResData = await _certificationService.FindWithPagerSearchAsync(search)
};
return ToJsonContent(result);
}
/// <summary>
/// 实名认证审核成功
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPut("AuditSuccessAsync")]
[FunctionAuthorize("")]
public async Task<IActionResult> AuditSuccessAsync(long id)
{
CommonResult result = new CommonResult();
CertificationEntity info = new CertificationEntity
{
Id = id
};
OnBeforeUpdate(info);
bool bl = await _certificationService.AuditSuccessAsync(info);
if (bl)
{
result.ErrCode = ErrCode.successCode;
result.ErrMsg = ErrCode.err0;
}
else
{
result.ErrMsg = ErrCode.err43002;
result.ErrCode = "43002";
}
return ToJsonContent(result);
}
/// <summary>
/// 实名认证审核失败
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPut("AuditFailAsync")]
[FunctionAuthorize("")]
public async Task<IActionResult> AuditFailAsync(long id)
{
CommonResult result = new CommonResult();
CertificationEntity info = new CertificationEntity
{
Id = id
};
OnBeforeUpdate(info);
bool bl = await _certificationService.AuditFailAsync(info);
if (bl)
{
result.ErrCode = ErrCode.successCode;
result.ErrMsg = ErrCode.err0;
}
else
{
result.ErrMsg = ErrCode.err43002;
result.ErrCode = "43002";
}
return ToJsonContent(result);
}
}
}