package com.lideeyunji.service.system.mapper;

import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.lideeyunji.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.lideeyunji.service.system.entity.UserRankDO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface UserRankMapper extends BaseMapperX<UserRankDO> {

    default List<UserRankDO> selectListByUserId(Long userId) {
        return selectList(UserRankDO::getUserId, userId);
    }



    default List<UserRankDO> selectListByRankIds(Collection<Long> rankIds) {
        return selectList(UserRankDO::getRankId, rankIds);
    }

    default void deleteByUserId(Long userId) {
        delete(Wrappers.lambdaUpdate(UserRankDO.class).eq(UserRankDO::getUserId, userId));
    }

    default void deleteByUserIdAndRankId(Long userId, Collection<Long> rankIds) {
        delete(new LambdaQueryWrapperX<UserRankDO>()
                .eq(UserRankDO::getUserId, userId)
                .in(UserRankDO::getRankId, rankIds));
    }
}
