package org.dromara.system.dubbo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.system.api.RemoteProjectService;
import org.dromara.system.api.domain.vo.RemoteProjectVo;
import org.dromara.system.domain.BusProject;
import org.dromara.system.domain.BusUserProjectRelevancy;
import org.dromara.system.service.IBusProjectService;
import org.dromara.system.service.IBusUserProjectRelevancyService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author lilemy
 * @date 2025-09-11 18:33
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteProjectServiceImpl implements RemoteProjectService {

    private final IBusProjectService projectService;

    /**
     * 通过项目ID查询项目名称
     *
     * @param projectId 项目ID
     * @return 项目名称
     */
    @Override
    public String selectProjectNameById(Long projectId) {
        return projectService.getProjectNameById(projectId);
    }

    @Override
    public void validAuth(Long projectId, Long userId) {
        projectService.validAuth(projectId, userId);
    }

    @Override
    public RemoteProjectVo getById(Long projectId) {
        BusProject byId = projectService.getById(projectId);
        RemoteProjectVo remoteProjectVo = new RemoteProjectVo();
        BeanUtils.copyProperties(byId, remoteProjectVo);
        return remoteProjectVo;
    }

    @Override
    public void validAuth(List<Long> projectIdList, Long userId) {
        projectService.validAuth(projectIdList, userId);
    }
}
