
package com.tmerclub.cloud.user.feign;

import com.tmerclub.cloud.api.user.feign.UserAddrFeignClient;
import com.tmerclub.cloud.common.handler.ExcelMergeHandler;
import com.tmerclub.cloud.common.order.vo.UserAddrVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.user.service.UserAddrService;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户地址feign连接
 *
 * @author tmerclub
 * @date 2020/12/07
 */
@DubboService
public class UserAddrFeignController implements UserAddrFeignClient {
    private static final Logger log = LoggerFactory.getLogger(ExcelMergeHandler.class);

    @Autowired
    private UserAddrService userAddrService;

    @Override
    public ServerResponseEntity<UserAddrVO> getUserAddrByAddrId(Long addrId) {
        log.info("UserAddrFeignController.getUserAddrByAddrId -- 用户id: {}", AuthUserContext.get().getUserId());
        UserAddrVO userAddrByUserId = userAddrService.getUserAddrByUserId(addrId, AuthUserContext.get().getUserId());
        log.info("UserAddrFeignController.getUserAddrByAddrId -- 用户地址信息: {}", userAddrByUserId);
        return ServerResponseEntity.success(userAddrByUserId);
    }

    @Override
    public ServerResponseEntity<UserAddrVO> getUserAddrByUserId(Long userId) {
        return ServerResponseEntity.success(userAddrService.getUserAddrByUserId(0L, userId));
    }

    @Override
    public ServerResponseEntity<UserAddrVO> cueGetUserAddrByAddrId(Long addrId, Long userId) {
        return ServerResponseEntity.success(userAddrService.getUserAddrByUserId(addrId, userId));
    }
}
