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

import com.xunhong.erp.turbo.api.rbac.dto.qry.PermissionListQry;
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;

import java.util.List;

@Component
@RequiredArgsConstructor
public class PermissionListQryExe {
	private final PermissionGateway permissionGateway;
	private final PermissionAssembler permissionAssembler;

	public List<PermissionVO> execute(PermissionListQry permissionListQry) {
		List<Permission> permissionList = permissionGateway.list(permissionListQry);
		return permissionList.stream().map(permissionAssembler::toPermissionVO).toList();
	}
}
