
package com.wechat.common.utils;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wechat.common.Constants;

/**
 * @version 1.0
 * @author ma.jinchang
 * @createDate 2012-9-7
 * @modifyBy ma.jinchang
 * @modifyDate 2012-9-7
 */
public class BaseUtils {
    /**
     * 日志工具
     */
    protected static final Log log = LogFactory.getLog(BaseUtils.class);
    
	/**
	 * 生成分享用的职位id
	 * @param createDate
	 * @param jobId
	 * @return
	 */
	public static String getShareJob(Date createDate,int jobId) {
		return String.valueOf((createDate.getTime())/1000)+String.valueOf(jobId);
	}
	
	
	/**
	 * 获取分享用-用户code
	 * Aes加密
	 * @param request
	 * @return
	 */
	public static String getShareCodeAes(String userCode, Date creatTime) {
		String shareCode = AESUtil.encrypt(userCode+Constants.UNDER_LINE+String.valueOf(creatTime.getTime()), Constants.AES_PASSWORD);
        return shareCode;
    }
	
	/**
	 * 获取分享用-用户code
	 * Aes解密
	 * @param request
	 * @return
	 */
	public static String[] getUserCodeAes(String shareCode) {
		String shareCodeStr = AESUtil.decryptStr(shareCode, Constants.AES_PASSWORD);
        return shareCodeStr.split(Constants.UNDER_LINE);
    }
}
