package com.ssj.service.conch.utils;

import com.ssj.bean.weixin.user.domain.User;
import com.ssj.framework.core.util.StringUtil;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.weixin.user.service.UserService;


public class ParseUtil {
    public static String[]  Object2String (Object[] array1){
        String[] result = null;
        if (array1 != null && array1.length > 0){
            result = new String[array1.length];
            for (int i = 0; i < array1.length; i++){
                result[i] = array1[i].toString();
            }
        }
        return result;
    }

    /**
     * 如果姓名为空,则取微信名
     * @param name
     * @param userId
     * @return
     */
    public static String getName (String name, String userId){
        if (StringUtil.isEmpty(name)){
            UserService service = (UserService)SystemResourceLocator.getBean(UserService.class);
            User user = service.getById(userId);
            if (user != null){
                name = user.getName();
            }
        }
        return name;
    }

    /**
     * 如果姓名为空,则取微信名
     * @param path
     * @param userId
     * @return
     */
    public static String getPhotoPath (String path, String userId){
        if (StringUtil.isEmpty(path)){
        	UserService service = (UserService)SystemResourceLocator.getBean(UserService.class);
            User user = service.getById(userId);
            if (user != null){
                path = user.getPhoto();
            }
        }
        return path;
    }


}
