package com.sf.mapper;


import com.sf.entity.User;
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 UserMapper
 * @description
 * @create 2025/11/9
 */
public interface UserMapper {

    /**
     * 查询用户信息（User），带有用户详细信息（UserProfile）
     * @return
     */
    @Select("SELECT u.* FROM `user` u")
    @Results({
            @Result(column = "user_id",property = "userId"),
            @Result(column = "username",property = "username"),
            @Result(column = "email",property = "email"),
            @Result(column = "password_hash",property = "passwordHash"),
            @Result(column = "created_at",property = "createdAt"),
            @Result(
                    column = "user_id",
                    property = "userProfile",
                    javaType = com.sf.entity.UserProfile.class,
                    one=@One(select = "com.sf.mapper.UserProfileMapper.selectByUserId")
            )
    })
    List<User> selectAll();
}
