package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.entity.UserProfile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户扩展信息Mapper
 */
@Mapper
public interface UserProfileMapper extends BaseMapper<UserProfile> {
    
    /**
     * 根据用户ID查询扩展信息
     */
    @Select("SELECT * FROM user_profile WHERE user_id = #{userId} LIMIT 1")
    UserProfile selectByUserId(@Param("userId") Long userId);
    
    /**
     * 强制更新用户扩展信息（包括设置为NULL的字段）
     */
    @Update("UPDATE user_profile SET " +
            "gender = #{gender}, " +
            "birth_date = #{birthDate}, " +
            "house = #{house}, " +
            "car = #{car}, " +
            "height = #{height}, " +
            "weight = #{weight}, " +
            "star = #{star}, " +
            "animal = #{animal}, " +
            "real_name = #{realName}, " +
            "id_card = #{idCard}, " +
            "education_level = #{educationLevel}, " +
            "hobby = #{hobby}, " +
            "school_name = #{schoolName}, " +
            "company = #{company}, " +
            "salary_range = #{salaryRange}, " +
            "job_title = #{jobTitle}, " +
            "marital_status = #{maritalStatus}, " +
            "is_real_name_verified = #{isRealNameVerified}, " +
            "is_education_verified = #{isEducationVerified}, " +
            "is_work_verified = #{isWorkVerified}, " +
            "is_marital_verified = #{isMaritalVerified}, " +
            "verified_at = #{verifiedAt}, " +
            "province_id = #{provinceId}, " +
            "city_id = #{cityId}, " +
            "area_id = #{areaId}, " +
            "privacy_salary = #{privacySalary}, " +
            "privacy_phone = #{privacyPhone}, " +
            "authenticity_score = #{authenticityScore} " +
            "WHERE profile_id = #{profileId}")
    int forceUpdateById(UserProfile userProfile);
}
