package com.xunhong.erp.turbo.rbac.app.executor.query;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xunhong.erp.turbo.api.rbac.dto.qry.PermissionPageQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.PermissionVO;
import com.xunhong.erp.turbo.rbac.app.assembler.PermissionAssembler;
import com.xunhong.erp.turbo.rbac.domain.entity.Permission;
import com.xunhong.erp.turbo.rbac.domain.gateway.PermissionGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PermissionPageQryExe {
	private final PermissionGateway privilegeGateway;
	private final PermissionAssembler permissionAssembler;

	public IPage<PermissionVO> execute(PermissionPageQry permissionPageQry) {
		IPage<Permission> page = privilegeGateway.page(permissionPageQry);
		return page.convert(permissionAssembler::toPermissionVO);
	}
}
