import logging
import allure
from dulizhan.library.Dlizhan_interface import DlzhanInterface

obj_log = logging.getLogger("logger")


class UserProfile(DlzhanInterface):
    def __init__(self):
        super().__init__()

    @allure.step("获得登录用户信息")
    def kw_joyhub_user_profile_get_get(self):
        """
        获得登录用户信息业务关键字
        :return: 响应结果
        """
        obj_log.info("获得登录用户信息")
        
        resp = self.kw_in_joyhub_user_profile_get_get()
        obj_log.info(f"获得登录用户信息响应: {resp}")
        
        return resp

    @allure.step("修改用户个人信息")
    def kw_joyhub_user_profile_update_put(self, nickname="", email="", mobile="", sex=None, avatar=""):
        """
        修改用户个人信息业务关键字
        :param nickname: 用户昵称
        :param email: 用户邮箱
        :param mobile: 手机号码
        :param sex: 用户性别
        :param avatar: 用户头像
        :return: 响应结果
        """
        obj_log.info(f"修改用户个人信息 - nickname: {nickname}, email: {email}, mobile: {mobile}, sex: {sex}")
        
        params = {}
        
        if nickname:
            params["nickname"] = nickname
        if email:
            params["email"] = email
        if mobile:
            params["mobile"] = mobile
        if sex is not None:
            params["sex"] = sex
        if avatar:
            params["avatar"] = avatar
        
        resp = self.kw_in_joyhub_user_profile_update_put(**params)
        obj_log.info(f"修改用户个人信息响应: {resp}")
        
        return resp

    @allure.step("修改用户个人密码")
    def kw_joyhub_user_profile_update_password_put(self, old_password, new_password):
        """
        修改用户个人密码业务关键字
        :param old_password: 旧密码
        :param new_password: 新密码
        :return: 响应结果
        """
        obj_log.info(f"修改用户个人密码 - oldPassword: {old_password}, newPassword: {new_password}")
        
        params = {
            "oldPassword": old_password,
            "newPassword": new_password
        }
        
        resp = self.kw_in_joyhub_user_profile_update_password_put(**params)
        obj_log.info(f"修改用户个人密码响应: {resp}")
        
        return resp
