package com.ematou.wxservice.common.xml.builder;

import com.ematou.wxservice.mp.message.WeChatMpXmlOutMessage;

/**
 * 构建消息基类
 * @author lhm
 * @version 1.0
 * 2021-05-11 15:01
 */
public abstract class BaseBuilder<BuilderType, ValueType> {

    protected String toUserName;

    protected String fromUserName;

    @SuppressWarnings("unchecked")
    public BuilderType toUser(String touser) {
        this.toUserName = touser;
        return (BuilderType) this;
    }

    @SuppressWarnings("unchecked")
    public BuilderType fromUser(String fromusername) {
        this.fromUserName = fromusername;
        return (BuilderType) this;
    }

    public abstract ValueType build();

    public void setCommon(WeChatMpXmlOutMessage m) {
        m.setToUserName(this.toUserName);
        m.setFromUserName(this.fromUserName);
        m.setCreateTime(System.currentTimeMillis() / 1000L);
    }



}
