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

import com.xunhong.erp.turbo.api.rbac.dto.qry.UserRoleListQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.UserRoleVO;
import com.xunhong.erp.turbo.rbac.app.assembler.UserRoleAssembler;
import com.xunhong.erp.turbo.rbac.domain.entity.UserRole;
import com.xunhong.erp.turbo.rbac.domain.gateway.UserRoleGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class UserRoleListQryExe {
	private final UserRoleGateway userRoleGateway;
	private final UserRoleAssembler userRoleAssembler;

	public List<UserRoleVO> execute(UserRoleListQry userRoleListQry) {
		List<UserRole> userRoleList = userRoleGateway.list(userRoleListQry);
		return userRoleList.stream().map(userRoleAssembler::toUserRoleVO).toList();
	}
}
