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

import com.xunhong.erp.turbo.api.user.dto.qry.UserListQry;
import com.xunhong.erp.turbo.api.user.dto.vo.UserVO;
import com.xunhong.erp.turbo.user.app.assembler.UserAssembler;
import com.xunhong.erp.turbo.user.domain.entity.User;
import com.xunhong.erp.turbo.user.domain.gateway.UserGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@RequiredArgsConstructor
public class UserListQryExe {
	private final UserGateway userGateway;
	private final UserAssembler userAssembler;

	public List<UserVO> execute(UserListQry userListQry) {
		List<User> userList = userGateway.list(userListQry);
		return userList.stream().map(userAssembler::toUserVO).toList();
	}
}
