public IActionResult DeleteBackupByFname([FromQuery] string fname) { if (Backup.DeleteBackupByFname(fname)) { AdminSystem.AddLog(GetAdminName(), "删除时间为" + fname + "的备份"); return(Json(new { code = 0, msg = "删除成功!" })); } return(Json(new { code = -1, msg = "删除失败!" })); }
public IActionResult Backups() { if (Backup.Save()) { AdminSystem.AddLog(GetAdminName(), "备份当前数据库"); return(Json(new { code = 0, msg = "备份成功!" })); } return(Json(new { code = -1, msg = "备份失败!" })); }
public IActionResult Restore([FromQuery] string fname) { if (Backup.Load(fname)) { AdminSystem.AddLog(GetAdminName(), "恢复数据库为当前状态"); return(Json(new { code = 0, msg = "恢复成功!" })); } return(Json(new { code = -1, msg = "恢复失败!" })); }
public IActionResult ChangeName([FromBody] Admin admin) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } if (AdminSystem.ChangeName(admin)) { AdminSystem.AddLog(GetAdminName(), "修改用户名"); return(Json(new { code = 0, msg = "用户名修改成功" })); } return(Json(new { code = -1, msg = "用户名修改失败" })); }
public IActionResult Changepwd([FromBody] Admin admin) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } if (AdminSystem.ChangePassword(admin)) { AdminSystem.AddLog(GetAdminName(), "修改管理员" + admin.Username + "的密码"); return(Json(new { code = 0, msg = "密码修改成功" })); } return(Json(new { code = -1, msg = "密码修改失败" })); }
public IActionResult AddAdmin(Admin admin) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } if (AdminSystem.AddAdmin(admin)) { AdminSystem.AddLog(GetAdminName(), "添加新管理员:" + admin.Username); return(Json(new { code = 0, msg = "成功添加新管理员!" })); } return(Json(new { code = -1, msg = "添加管理员失败,请检查您输入的信息!" })); }
public IActionResult Delete([FromQuery] User user) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } if (UserSystem.DeleteUser(user)) { AdminSystem.AddLog(GetAdminName(), "删除用户:" + user.Userid); return(Json(new { code = 0, msg = "删除成功!" })); } return(Json(new { code = -1, msg = "删除失败!" })); }
public IActionResult Changepwd([FromBody] User user) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限修改用户密码!" })); } if (UserSystem.ChangePassword(user)) { AdminSystem.AddLog(GetAdminName(), "修改用户 " + user.Userid + " 的密码"); return(Json(new { code = 0, msg = "密码修改成功" })); } return(Json(new { code = -1, msg = "密码修改失败" })); }
public IActionResult Delete([FromQuery] Admin admin) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } admin = AdminSystem.GetAdminById(admin); if (AdminSystem.DeleteAdmin(admin)) { AdminSystem.AddLog(GetAdminName(), "删除用户:" + admin.Username); return(Json(new { code = 0, msg = "删除成功!" })); } return(Json(new { code = 0, msg = "删除失败!" })); }
public IActionResult Login([FromBody] Admin admin) { MuseumContext _context = new MuseumContext(); IManageAdmin _manage = new ManageAdmin(_context); if (_manage.GetAdminByUsername(admin.Username) == null) { return(Json(new { code = -1, msg = "用户名不存在" })); } if (_manage.CheckPassword(admin.Username, admin.Password)) { admin = _manage.GetAdminByUsername(admin.Username); AdminSystem.AddLog(admin.Username, "登录"); return(Json(new { code = 0, data = new { token = GetToken(admin) }, msg = "登录成功" })); } return(Json(new { code = -1, msg = "用户名或密码错误" })); }
public IActionResult ChangeMute([FromQuery] User user) { if (!JudgeRoles(1)) { return(Json(new { code = -1, msg = "您没有权限进行此操作!" })); } if (UserSystem.ChangeMute(user)) { if (user.Coright == 0) { AdminSystem.AddLog(GetAdminName(), "禁言用户:" + user.Userid); } else { AdminSystem.AddLog(GetAdminName(), "解禁用户:" + user.Userid); } return(Json(new { code = 0, msg = "修改禁言状态成功!" })); } return(Json(new { code = -1, msg = "更改失败!" })); }
public IActionResult Logout() { AdminSystem.AddLog(GetAdminFromAuthorization().Username, "注销"); return(Json(new { code = 0, data = "退出成功" })); }