package com.sf.mapper;


import com.sf.entity.Card;
import com.sf.entity.Person;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title CardMapper
 * @description
 * @create 2025/11/9
 */
public interface CardMapper {
    /**
     * 查询所有身份证信息
     * @return
     */
    @Select("SELECT * FROM card")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "number", property = "number"),
            @Result(
                    column = "pid", //被包含对象的关于数据库映射的表字段，需要根据查询出来的card表的pid查询person表
                    property = "person",    //被包含对象的变量
                    javaType = Person.class,    //被包含对象的实际数据类型
                    //一对一，调用被包含对象Mapper的查询方法
                    one = @One(select = "com.sf.mapper.PersonMapper.selectById")
            )
    })
    List<Card> selectAll();
}
