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

enum Api {
  sysTenantQueryPage = '/sys/tenant/query/page',
  sysTenantDetail = '/sys/tenant/detail',
  sysTenantAdd = '/sys/tenant/add',
  sysTenantEdit = '/sys/tenant/edit',
  sysTenantRemove = '/sys/tenant/removeByIds',
  sysTenantQueryCurrent = '/sys/tenant/query/current',
}

/**
 *
 * @author lf
 * @date  2023/05/04 15:42
 * @description: 根据条件查询租户列表列表,权限 - sys:tenant:query
 * @method: POST
 * @param:
 *       {String}  name  like   租户名称
 *       {String}  type  eq   租户类型
 *       {String}  packageId     租户套餐id
 *       {Boolean}  disable  eq   租户状态
 * @return:
 *       {String}  name  租户名称
 *       {String}  contractUser  租户联系人
 *       {String}  type  租户类型
 *       {String}  contactMobile  租户联系人电话
 *       {String}  tenantUserId  租户所属用户id
 *       {String}  packageId  租户套餐id
 *       {String}  remark  租户备注
 *       {Boolean}  disable  租户状态
 */

export const sysTenantQueryPage = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantQueryPage, params: setParams(params) });
};

export const sysTenantQueryCurrent = () => {
  return defHttp.post({ url: Api.sysTenantQueryCurrent });
};
/**
 *
 * @author lf
 * @date  2023/05/04 15:42
 * @description: 根据id查询租户列表详细信息,权限 - sys:tenant:query
 * @method: GET
 * @param:  id 租户列表主键id
 * @return:
 *       {String}  name  租户名称
 *       {String}  contractUser  租户联系人
 *       {String}  type  租户类型
 *       {String}  contactMobile  租户联系人电话
 *       {String}  tenantUserId  租户所属用户id
 *       {String}  packageId  租户套餐id
 *       {String}  remark  租户备注
 *       {Boolean}  disable  租户状态
 */
export const sysTenantDetail = (id: string) => {
  return defHttp.get({ url: Api.sysTenantDetail + '/' + id });
};

/**
 *
 * @author lf
 * @date  2023/05/04 15:42
 * @description: 添加租户列表,权限 - sys:tenant:add
 * @method: POST
 * @param:
 *       {String}  name  租户名称
 *       {String}  contractUser  租户联系人
 *       {String}  type  租户类型
 *       {String}  contactMobile  租户联系人电话
 *       {String}  tenantUserId  租户所属用户id
 *       {String}  packageId  租户套餐id
 *       {String}  remark  租户备注
 *       {Boolean}  disable  租户状态
 * @return:
 *       0 添加失败
 *       1 添加成功
 */
export const sysTenantAdd = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantAdd, params: params });
};

/**
 *
 * @author lf
 * @date  2023/05/04 15:42
 * @description: 通过主键id编辑租户列表,权限 - sys:tenant:edit
 * @method: POST
 * @param:
 *       {String}  name  租户名称
 *       {String}  contractUser  租户联系人
 *       {String}  type  租户类型
 *       {String}  contactMobile  租户联系人电话
 *       {String}  tenantUserId  租户所属用户id
 *       {String}  packageId  租户套餐id
 *       {String}  remark  租户备注
 *       {Boolean}  disable  租户状态
 * @return:
 *       0 编辑失败
 *       1 编辑成功
 */
export const sysTenantEdit = (params?: object) => {
  return defHttp.post({ url: Api.sysTenantEdit, params: params });
};

/**
 * @description: 删除,权限 - sys:tenant:remove
 * @method: POST
 */
export const sysTenantRemove = (params: Array<string | number>) => {
  return defHttp.post({ url: Api.sysTenantRemove, params: params });
};
