import { post } from '../../http'
import { BasicService } from '../basic'

export type GroupUser = {
  groupId: any
  id: any
  remark: string
  userId: any
  userName: string
  userTypeCode: any
  userTypeValue: string
}

interface UserId {
  remark?: string
  userId: any
  userTypeCode: string
}

export interface GroupData {
  groupId: any
  userIds: UserId[]
}

class GroupService extends BasicService {
  async addUsers(data: GroupData) {
    return await post<any>('/org/group/addUsers', data)
  }

  async removeUser(ids: any) {
    ids = this.getIdsList(ids)
    return await post<any>('/org/group/removeUser', ids)
  }

  async updateUser(user: GroupUser) {
    return await post<any>('/org/group/updateUser', user)
  }

  protected findPageUrl(): string {
    return '/org/group/list'
  }

  protected removeUrl(): string {
    return '/org/group/delete'
  }

  protected saveOrUpdateUrl(): string {
    return '/org/group/saveOrUpdate'
  }
}

export const groupService = new GroupService()
