package com.kym.service.admin.impl;

import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.kym.entity.admin.ActivityStation;
import com.kym.entity.admin.Station;
import com.kym.entity.admin.vo.ActivityVo;
import com.kym.mapper.admin.ActivityStationMapper;
import com.kym.service.admin.ActivityStationService;
import com.kym.service.mybatisplus.MyBaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 活动站点关联表 服务实现类
 * </p>
 *
 * @author skyline
 * @since 2023-10-18
 */
@Service
public class ActivityStationServiceImpl extends MyBaseServiceImpl<ActivityStationMapper, ActivityStation> implements ActivityStationService {

    /**
     * 根据活动id查询活动站点关联表
     *
     * @param activityIdList
     * @return
     */
    @Override
    public List<ActivityVo> getActivityVoList(List<Long> activityIdList) {
        if(activityIdList.isEmpty()){
            return null;
        }
        MPJLambdaWrapper<ActivityStation> wrapper = JoinWrappers.lambda(ActivityStation.class)
                .selectCollection(Station.class, ActivityVo::getStationList)
                .selectAs(ActivityStation::getActivityId, ActivityVo::getActivityId)
                .innerJoin(Station.class, on ->
                        on.eq(ActivityStation::getStationId, Station::getStationId))
                .in(ActivityStation::getActivityId, activityIdList);
        return selectJoinList(ActivityVo.class, wrapper);
    }


}
