package com.sqx.modules.app.mapper;

import com.sqx.modules.app.entity.InviteAchievement;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
* @author Administrator
* @description 针对表【invite_achievement】的数据库操作Mapper
* @createDate 2024-12-30 13:26:18
* @Entity com.sqx.modules.app.entity.InviteAchievement
*/
@Mapper
public interface InviteAchievementMapper extends BaseMapper<InviteAchievement> {

    @Update("update invite_achievement set count = count + #{i}, update_time=now() where id = #{id}")
    int incrCount(Integer id, int i);

    @Insert("INSERT INTO invite_achievement (user_id, source_user_id, count, state, create_time)\n" +
            "SELECT #{userId}, #{sourceUserId}, #{count}, #{state}, #{createTime} " +
            "WHERE NOT EXISTS ( " +
            "    SELECT 1 FROM invite_achievement WHERE user_id = #{userId} " +
            ");")
    boolean insertNotExists(InviteAchievement inviteAchievement);
}




