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


import com.xunhong.erp.turbo.api.rbac.dto.qry.RoleListQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.RoleVO;
import com.xunhong.erp.turbo.rbac.app.assembler.RoleAssembler;
import com.xunhong.erp.turbo.rbac.domain.entity.Role;
import com.xunhong.erp.turbo.rbac.domain.gateway.RoleGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class RoleListQryExe {
	private final RoleGateway roleGateway;
	private final RoleAssembler roleAssembler;

	public List<RoleVO> execute(RoleListQry roleListQry) {
		List<Role> roleList = roleGateway.list(roleListQry);
		return roleList.stream().map(roleAssembler::toRoleVO).toList();
	}
}
