package com.yeejoin.amos.boot.biz.common.utils;

import com.alibaba.fastjson.JSON;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;

import java.util.Map;

/**
 * @Author: xl
 * @Description:
 * @Date: 2021/11/12 18:37
 */
public class RuleUtils {

    public static String instedParams(String content, Object msgObj) {
        Map<String, Object> strengthMap = JSON.parseObject(JSON.toJSONString(msgObj), Map.class);
        for (String key : strengthMap.keySet())
            content = content.replaceAll("\\$\\{" + key + "}", String.valueOf(ValidationUtil.isEmpty(strengthMap.get(key)) ? "" : strengthMap.get(key)));
        return content;
    }
}
