package com.tmerclub.cloud.multishop.feign;

import com.tmerclub.cloud.api.multishop.feign.ShopRenovationFeignClient;
import com.tmerclub.cloud.api.multishop.vo.ShopRenovationVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.util.BeanUtil;
import com.tmerclub.cloud.multishop.model.ShopRenovation;
import com.tmerclub.cloud.multishop.service.ShopRenovationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Objects;

/**
 * @author TRACK
 */
@DubboService
public class ShopRenovationFeignController implements ShopRenovationFeignClient {

    @Autowired
    private ShopRenovationService shopRenovationService;

    @Override
    public ServerResponseEntity<ShopRenovationVO> getbyRenovationId(Long renovationId) {
        ShopRenovation shopRenovation = shopRenovationService.getByRenovationId(renovationId);
        if (Objects.isNull(shopRenovation)) {
            return ServerResponseEntity.success(null);
        }
        ShopRenovationVO shopRenovationVO = BeanUtil.map(shopRenovation, ShopRenovationVO.class);
        return ServerResponseEntity.success(shopRenovationVO);
    }
}
