
package com.tmerclub.cloud.user.feign;

import cn.hutool.core.collection.CollUtil;
import com.tmerclub.cloud.api.user.feign.UserTagFeignClient;
import com.tmerclub.cloud.api.user.vo.UserApiVO;
import com.tmerclub.cloud.api.user.vo.UserTagApiVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.user.service.UserTagService;
import com.tmerclub.cloud.user.service.UserTagUserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collections;
import java.util.List;

/**
 * @author cl
 * @date 2021-05-20 14:14:36
 */
@DubboService
public class UserTagFeignController implements UserTagFeignClient {

    @Autowired
    private UserTagService userTagService;

    @Autowired
    private UserTagUserService userTagUserService;

    @Override
    public ServerResponseEntity<List<UserTagApiVO>> getUserTagList(List<Long> tagIds) {
        if (CollUtil.isEmpty(tagIds)) {
            return ServerResponseEntity.success(Collections.emptyList());
        }
        List<UserTagApiVO> list = userTagService.getUserTagList(tagIds);
        return ServerResponseEntity.success(list);
    }

    @Override
    public ServerResponseEntity<List<UserApiVO>> getUserByTagIds(List<Long> userTagIds) {
        return ServerResponseEntity.success(userTagUserService.getUserByTagIds(userTagIds));
    }
}
