package com.sunyard.chsm.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunyard.chsm.model.entity.AppService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * @author liulu
 * @since 2024/10/29
 */
@Mapper
public interface AppServiceMapper extends BaseMapper<AppService> {

    default List<AppService> selectByAppIds(List<Long> appIds) {
        if (CollectionUtils.isEmpty(appIds)) {
            return Collections.emptyList();
        }
        return selectList(
                new LambdaQueryWrapper<AppService>()
                        .in(AppService::getApplicationId, appIds)
        );
    }


    default void deleteByAppId(Long appId) {
        delete(
                new LambdaQueryWrapper<AppService>()
                        .eq(AppService::getApplicationId, appId)
        );

    }
}
