class $Role {
  constructor(AV, name, acl, request, that) {
    this.AV = AV
    this.$http = acl ? new AV.Role(name, acl) : AV.Object
    this.request = request
    this.that = that
    this.Users = null
  }

  getUsers() {
    if (this.Users) this.$http = this.Users
    this.$http.getUsers()
    this.Users = this.$http
    return this
  }

  add(user) {
    if (this.Users) this.$http = this.Users
    this.$http.add(user)
    this.Users = this.$http
    return this
  }

  // 设置对象
  set(jsonObj) {
    if (this.avObject) this.$http = this.Users
    for (const k in jsonObj) {
      this.$http.set(k, jsonObj[k])
    }
    this.Users = this.$http
    return this
  }

  save() {
    const { $http, request, Users, that } = this
    const dispatchRequest = () => (Users ? Users.save() : $http.save())
    return request.call(that, dispatchRequest)
  }

  // 个人定制API
}
export default $Role
