import { BaseController } from '@/api/BaseController';
import { RequestOption } from '@/common/http/types';
import { DictData, DictionaryBase } from '@/common/staticDict/types';
import { ANY_OBJECT } from '@/types/generic';
import { API_CONTEXT } from '../config';

export default class DictionaryController extends BaseController {
  static dictSysRole(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/sysRole/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('角色字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }
  // 全局编码字典
  static dictGlobalDict(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/globalDict/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase(
            '编码字典',
            (res.data || []).map(item => {
              return {
                ...item,
                // 设置已禁用编码字典数据项
                disabled: item.status === 1,
              };
            }),
          );
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictGlobalDictByIds(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/globalDict/listDictByIds', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('编码字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictAllMenu(params: ANY_OBJECT, httpOptions?: RequestOption): Promise<DictionaryBase> {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/sysMenu/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('菜单字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictSysMenu(params: ANY_OBJECT, httpOptions?: RequestOption): Promise<DictionaryBase> {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/sysMenu/listMenuDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('菜单字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictDeptPost(params: ANY_OBJECT, httpOptions?: RequestOption): Promise<ANY_OBJECT[]> {
    return new Promise((resolve, reject) => {
      super.get<ANY_OBJECT[]>(
        API_CONTEXT + '/upms/sysDept/listSysDeptPostWithRelation',
        params,
        httpOptions,
      )
        .then(res => {
          resolve(res.data);
        })
        .catch(err => {
          reject(err);
        });
    });
  }
  static dictSysPost(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/upms/sysPost/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('岗位字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictReportDblink(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/report/reportDblink/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('数据库链接', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }

  static dictReportDict(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>(API_CONTEXT + '/report/reportDict/listDict', params, httpOptions)
        .then(res => {
          const dictData = new DictionaryBase('报表字典', res.data);
          resolve(dictData);
        })
        .catch(err => {
          reject(err);
        });
    });
  }


  static dictSysUser(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/upms/sysUser/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('用户字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictSysDept(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/upms/sysDept/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('部门字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictSysDeptByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/upms/sysDept/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('部门字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictDirectoryInfo(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/directoryInfo/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('门户菜单字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictDirectoryInfoByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/directoryInfo/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('门户菜单字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourUser(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourUser/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('游记用户手机号', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictRestaurantInfo(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/restaurantInfo/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('餐馆列表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictRestaurantType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/restaurantType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('餐馆种类', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictRestaurantFoodType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/restaurantFoodType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('餐馆美食类型', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourCountryCode(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourCountryCode/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('国家地区字典表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourismProject(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourismProjectHH/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('旅游项目字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourHouseAreaMenu(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourHouseAreaMenu/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('房屋区域类型', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourHouseAreaMenuByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourHouseAreaMenu/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('房屋区域类型', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourHouseAdvisorInfo(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourHouseAdvisorInfo/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('房屋顾问字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourHouseDevelopersType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourHouseDevelopersType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('房屋开发商类型', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourVisaType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourVisaType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('签证类型字典表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourVisaCounselor(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourVisaCounselor/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('顾问字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictChinaArea(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/chinaArea/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('中国行政区划信息', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictChinaAreaByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/chinaArea/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('中国行政区划信息', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourCarContractMenu(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourCarContractMenu/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('包车区域字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourCarContractMenuByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourCarContractMenu/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('包车区域字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourVisa(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourVisa/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('签证信息字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourCarModel(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourCarModel/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('包车车辆类型', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourImComplaintType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourImComplaintType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('投诉类型字典', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourImGroup(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourImGroup/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('群聊字典表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourImGroupType(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourImGroupType/listDict', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('聊天群聊类型字典表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
  static dictTourImGroupTypeByParentId(params: ANY_OBJECT, httpOptions?: RequestOption) {
    return new Promise<DictionaryBase>((resolve, reject) => {
      super.get<DictData[]>('/admin/app/tourImGroupType/listDictByParentId', params, httpOptions)
        .then(res => {
          let dictData = new DictionaryBase('聊天群聊类型字典表', res.data);
          resolve(dictData);
        }).catch(err => {
          reject(err);
        });
    });
  }
}
