刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 1 | package com.pt5.pthouduan.mapper; |
| 2 | |
| 3 | import com.pt5.pthouduan.entity.Invites; |
| 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 5 | import com.pt5.pthouduan.entity.User; |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 6 | import org.apache.ibatis.annotations.Mapper; |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 7 | import org.apache.ibatis.annotations.Param; |
| 8 | import org.apache.ibatis.annotations.Select; |
| 9 | import org.apache.ibatis.annotations.Update; |
| 10 | import org.springframework.stereotype.Repository; |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 11 | |
21301050 | e4db6a9 | 2025-06-08 23:42:43 +0800 | [diff] [blame] | 12 | import java.util.List; |
| 13 | import java.util.Map; |
| 14 | |
| 15 | /** |
| 16 | * <p> |
| 17 | * Mapper 接口 |
| 18 | * </p> |
| 19 | * |
| 20 | * @author ljx |
| 21 | * @since 2025-04-14 |
| 22 | */ |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 23 | @Repository |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 24 | public interface InvitesMapper extends BaseMapper<Invites> { |
| 25 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 26 | @Select("SELECT * FROM invite WHERE code = #{code}") |
21301050 | e4db6a9 | 2025-06-08 23:42:43 +0800 | [diff] [blame] | 27 | Map<String, Object> selectByCode(String code); |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 28 | |
| 29 | @Update("UPDATE invite SET isUsed = 1, username = #{username} WHERE code = #{code}") |
| 30 | int updateInviteByCode(@Param("code") String code, @Param("username") String username); |
| 31 | |
21301050 | e4db6a9 | 2025-06-08 23:42:43 +0800 | [diff] [blame] | 32 | @Select("SELECT * FROM invite WHERE (buyername = '' OR buyername IS NULL) LIMIT 1") |
| 33 | Map<String, Object> selectFirstEmptyBuyername(); |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 34 | |
| 35 | @Update("UPDATE invite SET buyername = #{buyername} WHERE code = #{code}") |
| 36 | int updatebuyer(@Param("code") String code, @Param("buyername") String buyername); |
21301050 | e4db6a9 | 2025-06-08 23:42:43 +0800 | [diff] [blame] | 37 | |
| 38 | @Select("SELECT * FROM invite WHERE buyername = #{username}") |
| 39 | List<Map<String, Object>> selectInvitesByUsername(@Param("username") String username); |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 40 | } |