import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { request } from "../../utils/index.js";
//#region src/plus/saasRole/serve.ts
/**
* 获取扩展表单列表
* @returns
*/
const getExtensionFormList = function() {
	var _ref = _asyncToGenerator(function* (params) {
		return (yield request.getRequest().get("/shop/form", params, { isShopApi: true })).data || {
			list: [],
			count: 0
		};
	});
	return function getExtensionFormList(_x) {
		return _ref.apply(this, arguments);
	};
}();
/**
* 获取角色列表
* GET: /tenant/role
* Query: with_count[]=tenant_account
*/
const getRoles = function() {
	var _ref2 = _asyncToGenerator(function* () {
		return (yield request.getRequest().get("/tenant/role", { "with_count[]": "tenant_account" })).data || [];
	});
	return function getRoles() {
		return _ref2.apply(this, arguments);
	};
}();
(function() {
	var _ref3 = _asyncToGenerator(function* (id) {
		return (yield request.getRequest().get(`/tenant/role/${id}`, {})).data;
	});
	return function getRoleDetail(_x2) {
		return _ref3.apply(this, arguments);
	};
})();
/**
* 创建角色
* POST: /tenant/role
*/
const createRole = function() {
	var _ref4 = _asyncToGenerator(function* (role) {
		return (yield request.getRequest().post("/tenant/role", role)).data;
	});
	return function createRole(_x3) {
		return _ref4.apply(this, arguments);
	};
}();
/**
* 更新角色
* POST: /tenant/role/{id}
*/
const updateRole = function() {
	var _ref5 = _asyncToGenerator(function* (id, updates) {
		return (yield request.getRequest().put(`/tenant/role/${id}`, updates)).data;
	});
	return function updateRole(_x4, _x5) {
		return _ref5.apply(this, arguments);
	};
}();
/**
* 删除角色
* DELETE: /tenant/role/{id}
*/
const deleteRole = function() {
	var _ref6 = _asyncToGenerator(function* (id) {
		yield request.getRequest().remove(`/tenant/role/${id}`);
	});
	return function deleteRole(_x6) {
		return _ref6.apply(this, arguments);
	};
}();
/**
* 获取角色成员列表 (通过筛选租户账户列表实现)
* GET: /tenant/account
* Query: tenant_role_ids[]={roleId}, with[]=account, with[]=roles
*/
const getRoleMembers = function() {
	var _ref7 = _asyncToGenerator(function* (params) {
		return (yield request.getRequest().get("/tenant/account", params)).data || {
			list: [],
			count: 0
		};
	});
	return function getRoleMembers(_x7) {
		return _ref7.apply(this, arguments);
	};
}();
/**
* 获取角色permission
*/
const getRolePermission = function() {
	var _ref8 = _asyncToGenerator(function* () {
		return (yield request.getRequest().get(`/tenant/role/permissions`, {})).data || {};
	});
	return function getRolePermission() {
		return _ref8.apply(this, arguments);
	};
}();
/**
* 更新角色成员列表
* @param memberId
* @param roleIds
*/
const updateRoleMembers = function() {
	var _ref9 = _asyncToGenerator(function* (roleId, accountIds) {
		yield request.getRequest().post(`/tenant/role/${roleId}/accounts`, { tenant_account_ids: accountIds });
	});
	return function updateRoleMembers(_x8, _x9) {
		return _ref9.apply(this, arguments);
	};
}();
/**
* 移除角色成员
* DELETE: /tenant/role/{roleId}/accounts
* Query: tenant_account_ids={tenantAccountId}
*/
const removeRoleMember = function() {
	var _ref10 = _asyncToGenerator(function* (roleId, tenantAccountId) {
		yield request.getRequest().remove(`/tenant/role/${roleId}/account/${tenantAccountId}`, {});
	});
	return function removeRoleMember(_x10, _x11) {
		return _ref10.apply(this, arguments);
	};
}();
/**
* 获取所有成员列表 (用于选择添加)
* GET: /tenant/account
*/
const getAllMembers = function() {
	var _ref11 = _asyncToGenerator(function* (params = {}) {
		return (yield request.getRequest().get("/tenant/account", _objectSpread2({ "with[]": ["roles"] }, params))).data;
	});
	return function getAllMembers() {
		return _ref11.apply(this, arguments);
	};
}();
//#endregion
export { createRole, deleteRole, getAllMembers, getExtensionFormList, getRoleMembers, getRolePermission, getRoles, removeRoleMember, updateRole, updateRoleMembers };
