package com.gic.haoban.manage.web.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;

@Component
public class ClerkUtils {

    private static ClerkService clerkService;

    @Autowired
    public void setClerkService(ClerkService clerkService) {
        ClerkUtils.clerkService = clerkService;
    }

    public static String getClerkStore(ClerkDTO clerk, String clerkId) {
        if (null == clerk) {
            clerk = clerkService.getclerkById(clerkId);
        }
        if (null == clerk) {
            return null;
        }
        if (clerk.getClerkType() != 0 && clerk.getClerkType() != 1) {
            return null;
        }
        return clerk.getStoreId();
    }
    
    public static String getClerkStore(ClerkDTO clerk , String clerkId , String selectedStoreId) {
        String storeId = getClerkStore(clerk, clerkId) ;
        if(StringUtils.isNotBlank(storeId)) {
            selectedStoreId = storeId ;
        }
        return selectedStoreId ;
    }

}
