package cn.hnthyy.thmz.service.impl.thmz;

import cn.hnthyy.thmz.Utils.HttpUtil;
import cn.hnthyy.thmz.service.thmz.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Slf4j
@Service
/**
 * 企业微信信息服务
 */
public class MessageServiceImpl implements MessageService {
    @Value("${serviceUrl}")
    private String serviceUrl;
    @Override
    public int sendWxMessage(String touser, String content) {
        if (StringUtils.isBlank(touser)){
            return 0;
        }
        if (StringUtils.isBlank(content)){
            return 0;
        }
        try {
            String url = serviceUrl+"?touser="+touser+"&content="+content;
            HttpUtil.sendHttpGet(url, "utf-8");
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
        return 1;
    }

}
