package com.cyksj.mapper.mini;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyksj.model.entity.MiniPopularizeUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 项目名: yhlxj2
 * 文件名: MiniPopularizeUserMapper
 * 创建者: JavaZou
 * 创建时间:2025/4/10 15:17
 */
public interface MiniPopularizeUserMapper extends BaseMapper<MiniPopularizeUser> {
	@Update("update mini_popularize_user set num = num + #{num} where user_id = #{userId}")
	int incrNum(@Param("userId") Long userId, @Param("num") Integer num);

	@Update("update mini_popularize_user set num = num - #{num} where user_id = #{userId} and num = #{userNum} and num > 0")
	int decrNum(@Param("userId") Long userId, @Param("num") Integer num, @Param("userNum") Integer userNum);

	@Update("update mini_popularize_user set num = num + #{addNum} where user_id = #{userId} and num = #{oriNum}")
	int incrNumSync(@Param("userId") long userId, @Param("oriNum") Integer oriNum, @Param("addNum") Integer addNum);
}
