package com.fs.wxcid.service.impl;

import com.alibaba.fastjson.TypeReference;
import com.fs.wxcid.ServiceUtils;
import com.fs.wxcid.dto.common.ApiResponseCommon;
import com.fs.wxcid.dto.login.AccountIdParam;
import com.fs.wxcid.dto.login.RequestBaseVo;
import com.fs.wxcid.dto.user.UserProfileData;
import com.fs.wxcid.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    private static final String BASE_URL = "/user/";
    @Autowired
    private ServiceUtils serviceUtils;
    @Override
    public UserProfileData getProfile(AccountIdParam param) {
        try {
            ApiResponseCommon<UserProfileData> response = serviceUtils.sendGet(BASE_URL + "GetProfile", RequestBaseVo.builder().accountId(param.getAccountId()).data(null).build(), new TypeReference<ApiResponseCommon<UserProfileData>>() {});
            return response.getData();
        }catch (Exception e){
            return new UserProfileData();
        }
    }
}
