CompetitionAPI_dotnet/CompetitionAPI/Controllers/back/system/DeleteUserController.cs

55 lines
1.6 KiB
C#

using Competition.Common.Util;
using CompetitionAPI.Util;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CompetitionAPI.Controllers.back.system
{
[Route("api/[controller]")]
[ApiController]
public class DeleteUserController : Controller
{
Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user();
public DeleteUserController()
{
}
/// <summary>
/// 获取单条用户数据接口
/// </summary>
/// <param name="UserId">用户id</param>
/// <returns></returns>
[Authorize]
[HttpGet]
[APIFilter]
public JsonResult Index(string UserId)
{
try
{
if (string.IsNullOrEmpty(UserId))
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "用户id不能为空"));
}
var ret = user_bll.Delete(UserId);
if (ret)
{
return Json(Tool.GetJsonWithCode(APICode.Success, "删除成功"));
}
else
{
return Json(Tool.GetJsonWithCode(APICode.Fail, "删除失败"));
}
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
}
}
}
}