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 ResetUserMimController : Controller { Competition.Mysql.BLL.admin_user user_bll = new Competition.Mysql.BLL.admin_user(); public ResetUserMimController() { } /// /// 重置所有考生密码接口 /// /// [Authorize] [HttpGet] public ActionResult Index() { try { var list = user_bll.GetModelList("role_id='2' "); var password = user_bll.CreateRandomPassword(); var pwd = EncryptionAndDecryption.EncryptByLgzn(EncryptionAndDecryption.EncryptByLgzn(password)); if (user_bll.BatchUpdateUser(list, pwd) > 0) { 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, "发生错误,请联系管理员。")); } } } }