package com.tmerclub.cloud.delivery.feign;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.tmerclub.cloud.api.delivery.feign.SameCityFeignClient;
import com.tmerclub.cloud.api.delivery.vo.SameCityVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.delivery.model.SameCity;
import com.tmerclub.cloud.delivery.service.SameCityService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author lanhai
 */
@DubboService
public class SameCityFeignController implements SameCityFeignClient {

    @Autowired
    private SameCityService sameCityService;

    @Override
    public void clearPositionInfo(Long shopId) {
        SameCity sameCity = new SameCity();
        sameCity.setShopId(shopId);
        sameCity.setPositionInfo("[]");
        sameCityService.updateByShopId(sameCity);
    }

    @Override
    public ServerResponseEntity<SameCityVO> getSameCityByShopId(Long shopId) {
        SameCity sameCity = sameCityService.getSameCityByShopId(shopId);
        SameCityVO sameCityVO = JSONObject.parseObject(JSON.toJSONString(sameCity), SameCityVO.class);
        return ServerResponseEntity.success(sameCityVO);
    }

}
