Commit 6be47d09 by Seniorious

新增照片信息删除接口

parent b363a310
......@@ -8,6 +8,7 @@ using Common.Utility.RabbitMQ;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Models.SqlModel;
using Models.Table;
using Models.ToolsModel;
using Newtonsoft.Json;
using Services;
......@@ -40,6 +41,79 @@ namespace APIs.Controllers
}
/// <summary>
/// 根据人员id删除照片及照片数据库信息
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult> DeletePictureById([FromForm] DelPicReq req)
{
try
{
var police = await _policeService.QueryOne(p => p.id.Equals(req.id));
if(police == null)
{
var error = new ApiResult
{
code = ResultCode.POLICE_ERROR.Code,
msg = ResultCode.POLICE_ERROR.Msg,
};
return error;
}
string delurl = police.picUrl;
if (string.IsNullOrEmpty(delurl))
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "照片信息不存在",
};
return error;
}
//删除数据库照片信息
police.faceInfo = "";
police.picUrl = "";
police.picUpdateTime = DateTime.Now;
bool rs = await _policeService.Update(police);
if (!rs)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "照片信息删除失败",
};
return error;
}
//删除照片
FileInfo mypic = new FileInfo(delurl);
mypic.Delete();
var src = new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg
};
return src;
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 人员照片下载
/// </summary>
/// <returns></returns>
......
namespace APIs.Req
{
public class DelPicReq
{
public string id { get; set; }
}
public class PictureReq
{
public string policeId { get; set; }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论