package com.luozhihui.project.mapper;

//引入sql insert方法
import com.luozhihui.project.entity.Phone;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
public interface PhoneMapper {
    //    将得到的手机号以及验证码插入mysql数据库
    @Insert("insert into `phone`(`phone`,`code`) VALUES(#{phone},#{code})")
    @Transactional
    void save(Phone user);
    //通过手机号查询信息
    @Select("select * from `phone` where `phone` = #{phone}")
    boolean findByPhone(String phone);
    //通过手机号删除验证码
    @Delete("delete  from  `phone` where `phone`=#{phone}")
    void deleteCode(String phone);

    // 通过手机号查询验证码
    @Select("select `code` from  `phone` where `phone`=#{phone}")
    List<String> findByCode(@Param("phone") String phone);
}
