package com.sqx.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.app.entity.InviteAchievement;
import com.sqx.modules.app.service.InviteAchievementService;
import com.sqx.modules.app.mapper.InviteAchievementMapper;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【invite_achievement】的数据库操作Service实现
* @createDate 2024-12-30 13:26:18
*/
@Service
public class InviteAchievementServiceImpl extends ServiceImpl<InviteAchievementMapper, InviteAchievement>
    implements InviteAchievementService{

    @Override
    public int countByUserId(Long userId) {
        return count(new LambdaQueryWrapper<InviteAchievement>()
                .eq(InviteAchievement::getUserId, userId));
    }

    @Override
    public InviteAchievement getByUserId(Long userId) {
        return getOne(new LambdaQueryWrapper<InviteAchievement>()
                .eq(InviteAchievement::getUserId, userId));
    }

    @Override
    public int incrCount(Integer id, int i) {
        return baseMapper.incrCount(id,i);
    }

    @Override
    public boolean insertNotExists(InviteAchievement inviteAchievement) {
        return baseMapper.insertNotExists(inviteAchievement);
    }

    @Override
    public int countBySourceUserId(Long userId) {
        return count(new LambdaQueryWrapper<InviteAchievement>()
                .eq(InviteAchievement::getState, 1)
                .eq(InviteAchievement::getSourceUserId, userId));
    }

    @Override
    public int countNum(Long userId, Integer signCount) {
        return count(new LambdaQueryWrapper<InviteAchievement>()
                .eq(InviteAchievement::getSourceUserId, userId)
                .ge(InviteAchievement::getCount, signCount));
    }
}
