package shop.alien.dining.service.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import shop.alien.dining.feign.AlienStoreFeign;
import shop.alien.dining.service.DiningCollectService;
import shop.alien.entity.result.R;
import shop.alien.entity.store.LifeCollect;

/**
 * 点餐模块-收藏服务实现（透传 Feign 调 store）
 *
 * @author ssk
 * @version 1.0
 * @date 2025/01/XX
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DiningCollectServiceImpl implements DiningCollectService {

    private final AlienStoreFeign alienStoreFeign;

    @Override
    public R<Boolean> addCollect(LifeCollect lifeCollect) {
        log.info("DiningCollectService.addCollect lifeCollect={}", lifeCollect);
        try {
            R<Boolean> result = alienStoreFeign.addCollect(lifeCollect);
            if (result == null) {
                return R.fail("添加收藏失败");
            }
            return result;
        } catch (Exception e) {
            log.error("DiningCollectService.addCollect ERROR Msg={}", e.getMessage());
            return R.fail("添加收藏失败");
        }
    }
}
