fix 添加积分,扣除积分
This commit is contained in:
@@ -3,10 +3,24 @@ package com.tailbet.mapper;
|
||||
import com.tailbet.model.entity.User;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 用户Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
/**
|
||||
* 原子增加积分
|
||||
*/
|
||||
@Update("UPDATE user SET points = points + #{amount} WHERE id = #{id}")
|
||||
int addPoints(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 原子扣除积分(积分不足时返回0)
|
||||
*/
|
||||
@Update("UPDATE user SET points = points - #{amount} WHERE id = #{id} AND points >= #{amount}")
|
||||
int subPoints(@Param("id") Long id, @Param("amount") Long amount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user