package com.jwipc.sys.client.impl;

import cn.hutool.core.collection.CollUtil;
import com.jwipc.sys.client.UserPurchaseGroupClient;
import com.jwipc.sys.service.IUserPurchaseGroupService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author shenyang.ou
 * @date 2024/3/27 16:25
 * @desc
 */
@Service
@RequiredArgsConstructor
public class UserPurchaseGroupClientImpl implements UserPurchaseGroupClient {
    private final IUserPurchaseGroupService userPurchaseGroupService;

    /**
     * 根据用户id获取优先展示的采购组编码
     * @param userId 用户id
     * @return 采购组编码
     */
    public String getMarkPurchaseGroupCodeByUserId(Long userId){
        return userPurchaseGroupService.getMarkPurchaseGroupCodeByUserId(userId);
    }

    @Override
    public Set<String> getUserPurchaseGroupCode(Long userId) {
        final Set<String> userPurchaseGroupCode = userPurchaseGroupService.getUserPurchaseGroupCode(userId);
        if(CollUtil.isEmpty(userPurchaseGroupCode)){
            userPurchaseGroupCode.add("-1");
        }
        return userPurchaseGroupCode;
    }
}
