public Result Add([FromForm] string name, [FromForm] string password) { if (!User.Super) { return(Fail("添加用户失败,你没有权限操作")); } try { if (_repository.Exists(n => n.Name == name)) { return(Fail("用户名称已存在!")); } UserInfo user = new UserInfo { Name = name, Password = UserUtility.EncryptPassword(password) }; if (_repository.Insert(user) <= 0) { return(Fail("添加用户失败!")); } user.Password = password; return(Success(user, "添加成功!")); } catch (Exception ex) { _logger.LogError(ex.Message + ex.StackTrace); return(Fail("系统错误")); } }