package com.tmerclub.cloud.multishop.feign;

import com.tmerclub.cloud.api.multishop.feign.ShopUserFeignClient;
import com.tmerclub.cloud.api.multishop.vo.ShopUserVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.util.BeanUtil;
import com.tmerclub.cloud.multishop.service.ShopUserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
/**
 * @author lanhai
 */
@DubboService
public class ShopUserFeignController implements ShopUserFeignClient {
    @Autowired
    private ShopUserService shopUserService;


    @Override
    public ServerResponseEntity<ShopUserVO> getByUserId(Long userId) {
        ShopUserVO shopUserVO = BeanUtil.map(shopUserService.getByUserId(userId), ShopUserVO.class);
        return ServerResponseEntity.success(shopUserVO);
    }


    @Override
    public ShopUserVO getSimpleByUserId(Long userId) {
        ShopUserVO shopUserVO = BeanUtil.map(shopUserService.getSimpleByUserId(userId), ShopUserVO.class);
        return shopUserVO;
    }

    @Override
    public List<ShopUserVO> getImShopUserList(List<Long> userIds) {
        return BeanUtil.mapAsList(shopUserService.listShopUserByUserIds(userIds), ShopUserVO.class);
    }

    @Override
    public ServerResponseEntity<Integer> countAccoutByMobile(String mobile) {
        return ServerResponseEntity.success(shopUserService.countAccoutByMobile(mobile));
    }

    @Override
    public ServerResponseEntity<Long> getShopUserIdByShopId(Long shopId) {
        return ServerResponseEntity.success(shopUserService.getUserIdByShopId(shopId));
    }
}
