package dao

import "youngee_b_api/app/entity"

type UserDao struct{}

func (d UserDao) GetPhoneByUserId(userId int64) (string, error) {
	var user entity.User
	err := Db.Model(&entity.User{}).Where("id = ?", userId).Select("phone").First(&user).Error
	if err != nil {
		return "", err
	}
	return user.Phone, nil
}

func (d UserDao) GetNameByUserId(userId int64) (string, error) {
	var user entity.User
	err := Db.Model(&entity.User{}).Where("id = ?", userId).Select("username").First(&user).Error
	if err != nil {
		return "", err
	}
	return user.Username, nil
}
