
package com.tmerclub.cloud.product.feign;

import com.tmerclub.cloud.api.product.feign.CategoryFeignClient;
import com.tmerclub.cloud.common.product.vo.CategoryVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.product.service.CategoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Set;

/**
 * @author lhd
 * @date 2020/12/23
 */
@DubboService
public class CategoryFeignController implements CategoryFeignClient {

    @Autowired
    private CategoryService categoryService;

    @Override
    public ServerResponseEntity<CategoryVO> getByCategoryId(Long categoryId) {
        try {
            return ServerResponseEntity.success(categoryService.getById(categoryId));
        } catch (Exception e) {
            return ServerResponseEntity.showFailMsg(e.getMessage());
        }
    }

    @Override
    public ServerResponseEntity<List<CategoryVO>> getByCategoryIds(Set<Long> categoryIds) {
        return ServerResponseEntity.success(categoryService.listByCategoryIds(categoryIds));
    }
}
