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.
191 lines
6.0 KiB
191 lines
6.0 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.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
|
|
ApplyJobController : AreaApiController<ApplyJobEntity, ApplyJobOutputDto, ApplyJobInputDto, IApplyJobService,
|
|
long>
|
|
{
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="_service"></param>
|
|
public ApplyJobController(IApplyJobService _service) : base(_service)
|
|
{
|
|
_service = _service;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增前处理数据
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
protected override void OnBeforeInsert(ApplyJobEntity 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(ApplyJobEntity info)
|
|
{
|
|
info.ModifiedUserId = CurrentUser.UserId;
|
|
info.ModifiedTime = DateTime.Now;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在软删除数据前对数据的修改操作
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
protected override void OnBeforeSoftDelete(ApplyJobEntity info)
|
|
{
|
|
info.IsDeleted = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异步新增数据
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("InsertAsync")]
|
|
[FunctionAuthorize("Add")]
|
|
public new async Task<IActionResult> InsertAsync(ApplyJobInputDto input)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
ApplyJobEntity applyJob = input.MapTo<ApplyJobEntity>();
|
|
OnBeforeInsert(applyJob);
|
|
result = await _service.InsertAsync(applyJob);
|
|
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="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("UpdateAsync")]
|
|
[FunctionAuthorize("Edit")]
|
|
public async Task<IActionResult> UpdateAsync(ApplyJobInputDto input)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
ApplyJobEntity applyJob = input.MapTo<ApplyJobEntity>();
|
|
OnBeforeUpdate(applyJob);
|
|
result = await _service.UpdateAsync(applyJob);
|
|
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="search"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("FindWithPagerSearchAsync")]
|
|
[FunctionAuthorize("List")]
|
|
[AllowAnonymous]
|
|
public async Task<IActionResult> FindWithPagerSearchAsync(SearchCloudcarModel search)
|
|
{
|
|
CommonResult<PageResult<ApplyJobOutputDto>> result = new CommonResult<PageResult<ApplyJobOutputDto>>
|
|
{
|
|
ResData = await _service.FindWithPagerSearchAsync(search),
|
|
ErrCode = ErrCode.successCode
|
|
};
|
|
return ToJsonContent(result);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据主键Id获取一个对象信息
|
|
/// </summary>
|
|
/// <param name="id">主键Id</param>
|
|
/// <returns></returns>
|
|
[HttpGet("GetById")]
|
|
[AllowAnonymous]
|
|
public async Task<CommonResult<ApplyJobOutputDto>> GetById(long id)
|
|
{
|
|
CommonResult<ApplyJobOutputDto> result = new CommonResult<ApplyJobOutputDto>();
|
|
ApplyJobOutputDto info = await _service.GetById(id);
|
|
if (info != null)
|
|
{
|
|
result.ErrCode = ErrCode.successCode;
|
|
result.ResData = info;
|
|
}
|
|
else
|
|
{
|
|
result.ErrMsg = ErrCode.err50001;
|
|
result.ErrCode = "50001";
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下架求职信息
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("RevocationAsync")]
|
|
[FunctionAuthorize("Edit")]
|
|
public async Task<IActionResult> RevocationAsync(long id)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
result = await _service.RevocationAsync(id, CurrentUser.UserId);
|
|
if (result.Success)
|
|
{
|
|
result.ErrCode = ErrCode.successCode;
|
|
result.ErrMsg = ErrCode.err0;
|
|
}
|
|
else
|
|
{
|
|
result.ErrMsg = ErrCode.err43002;
|
|
result.ErrCode = "43002";
|
|
}
|
|
|
|
return ToJsonContent(result);
|
|
}
|
|
}
|
|
}
|