package com.cyksj.mapper.manage.distribute.equipment;

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

/*
 *项目名: netflix
 *文件名: EquipmentUserChanceMapper
 *创建者: JavaZou
 *创建时间:2023/2/23 13:34
 */
public interface EquipmentUserChanceMapper extends BaseMapper<EquipmentUserChance> {
	@Update("update equipment_user_chance set num = num + 1 where user_id = #{userId} and num >= 0")
	void addUserChance(Long userId);

	@Update("update equipment_user_chance set num = num - 1 where user_id = #{userId} and num >= 1")
	Integer subUserChance(Long userId);

	@Update("update equipment_user_chance set num = num - 1 where user_id = #{userId} and num = #{num} and num >= 1")
	Integer subUserChanceNoRepeat(@Param("userId") Long userId, @Param("num") Integer num);
}
