import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';

enum Api {
  sysTenantPackageQueryPage = '/sys/tenantPackage/query/page',
  sysTenantPackageDetail = '/sys/tenantPackage/detail',
  sysTenantPackageAdd = '/sys/tenantPackage/add',
  sysTenantPackageEdit = '/sys/tenantPackage/edit',
  sysTenantPackageRemove = '/sys/tenantPackage/removeByIds',
  sysPackageAssign = '/sys/tenantPackage/assign',
  sysPackageQueryMenuTree = '/sys/tenantPackage/menu/list',
}

/**
 *
 * @author lf
 * @date  2023/05/04 15:44
 * @description: 根据条件查询租户套餐列表,权限 - sys:tenantPackage:query
 * @method: POST
 * @param:
 *       {String}  packageCode  like   套餐编码
 *       {String}  packageName  like   套餐名称
 *       {String}  type  eq   套餐类型
 *       {Boolean}  disable  eq   启用
 * @return:
 *       {String}  packageCode  套餐编码
 *       {String}  packageName  套餐名称
 *       {String}  remark  套餐备注
 *       {Integer}  sort  排序
 *       {String}  type  套餐类型
 *       {Boolean}  disable  启用
 */

export const sysTenantPackageQueryPage = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantPackageQueryPage, params: setParams(params) });
};
/**
 *
 * @author lf
 * @date  2023/05/04 15:44
 * @description: 根据id查询租户套餐详细信息,权限 - sys:tenantPackage:query
 * @method: GET
 * @param:  id 租户套餐主键id
 * @return:
 *       {String}  packageCode  套餐编码
 *       {String}  packageName  套餐名称
 *       {String}  remark  套餐备注
 *       {Integer}  sort  排序
 *       {String}  type  套餐类型
 *       {Boolean}  disable  启用
 */
export const sysTenantPackageDetail = (id: string) => {
  return defHttp.get({ url: Api.sysTenantPackageDetail + '/' + id });
};

/**
 *
 * @author lf
 * @date  2023/05/04 15:44
 * @description: 添加租户套餐,权限 - sys:tenantPackage:add
 * @method: POST
 * @param:
 *       {String}  packageCode  套餐编码
 *       {String}  packageName  套餐名称
 *       {String}  remark  套餐备注
 *       {Integer}  sort  排序
 *       {Boolean}  disable  启用
 * @return:
 *       0 添加失败
 *       1 添加成功
 */
export const sysTenantPackageAdd = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantPackageAdd, params: params });
};

/**
 *
 * @author lf
 * @date  2023/05/04 15:44
 * @description: 通过主键id编辑租户套餐,权限 - sys:tenantPackage:edit
 * @method: POST
 * @param:
 *       {String}  packageCode  套餐编码
 *       {String}  packageName  套餐名称
 *       {String}  remark  套餐备注
 *       {Integer}  sort  排序
 *       {Boolean}  disable  启用
 * @return:
 *       0 编辑失败
 *       1 编辑成功
 */
export const sysTenantPackageEdit = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantPackageEdit, params: params });
};

/**
 * @description: 删除,权限 - sys:tenantPackage:remove
 * @method: POST
 */
export const sysTenantPackageRemove = (params: Array<string | number>) => {
  return defHttp.post({ url: Api.sysTenantPackageRemove, params: params });
};
/**
 * @description: 分配租户套餐,权限 - sys:tenantPackage:assign
 * @method: POST
 */
export const sysPackageAssign = (params?: object) => {
  return defHttp.post({ url: Api.sysPackageAssign, params: params });
};

/**
 * @description: 查询角色信息列表,权限 - sys:role:query
 * @method: POST
 */
export const sysPackageQueryMenuTree = id => {
  return defHttp.get({ url: Api.sysPackageQueryMenuTree + '/' + id });
};
