package org.springblade.wx.constant;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.tool.utils.StringUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: lianghanqiang
 * @description: 微信消息模板
 * @since: 9/6/21 -- 8:16 PM
 */
@Getter
@AllArgsConstructor
public enum MessageTemplate {

	/**
	 * 商户入驻签约
	 * */
	INVITATION_SIGN("yAtQ6AY8zBHDT1PxXHv7x7gS-qiN1DnSedN4MWLbHwk","" +
		"{\n" +
		" \"phrase1\": {\n" +
		"    \"value\": \"%s\"\n" +
		" },\n" +
		" \"thing2\": {\n" +
		"    \"value\": \"%s\"\n" +
		" }\n" +
		"}");

	String templateId;
	String contentString;

	public String buildRequestBody(String openId, JSONObject content, String page){
		HashMap<String, Object> params = new HashMap<>(3);
		params.put("touser",openId);
//		params.put("miniprogram_state","developer");
		HashMap<String, Object> weappTemplateMsg = new HashMap<>(3);
		weappTemplateMsg.put("template_id",templateId);
		weappTemplateMsg.put("data",content);
		weappTemplateMsg.put("page",page);
		params.put("weapp_template_msg",weappTemplateMsg);
		return JSON.toJSONString(params);
	}

}
