Coder Social home page Coder Social logo

eden2f / weixin-mp-saas Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 5.0 532 KB

微信公众号后台服务SaaS, 支持微信公众平台(订阅号、服务号、企业号、小程序). 支持多个微信公众号配置. 动态更新配置.

Home Page: https://github.com/eden2f/weixin-mp-saas

Java 100.00%
weixin mp saas java redis elasticsearch spring-boot wechat

weixin-mp-saas's Introduction

WeixinMPSaaS

介绍

微信公众号后台服务SaaS, 支持微信公众平台(订阅号、服务号、企业号、小程序).

  • 支持多个微信公众号配置
  • 动态更新配置
  • 自建搜索引擎全文检索

本项目仍在不断迭代开发中,遇到问题请提 issues , 谢谢配合.

代码仓库

软件架构

本项目基于 Spring Boot 构建, 对接微信公众号Api.

微信公众号示例

安装教程

  • 创建MySQL数据库
CREATE SCHEMA `weixin_mp_saas` DEFAULT CHARACTER SET utf8mb4;
  • 生成可执行jar包
mvn clean package -Dmaven.test.skip=true
  • 启动服务
java -jar weixin-mp-saas.jar
  • 配置项
    • server.port 服务端口号, 默认是 8080
    • mysql.host 默认是 127.0.0.1:3306
    • mysql.username 默认是 root
    • mysql.password 默认是 toor
    • mysql.database.name 数据库名称, 默认是 : weixin_mp_saas
    • elasticsearch.hostAndPort es服务的 ip + 端口 , 默认是 : 127.0.0.1:9200
    • elasticsearch.username es服务用户名, 默认是 ""
    • elasticsearch.password es服务密码, 默认是 ""
java -jar -Dserver.port=8080 -Dmysql.host=localhost:3306 -Dmysql.username=root -Dmysql.password=toor -Dmysql.database.name=weixin_mp_saas -Delasticsearch.hostAndPort=127.0.0.1:9200 weixin-mp-saas.jar
  • 提前创建好 ElasticSearch 索引及映射文件
    • 创建索引
      curl --location --request PUT 'http://127.0.0.1:9200/weixin_mp_saas_search_content'
    • 创建映射文件
      curl --location --request POST 'http://127.0.0.1:9200/weixin_mp_saas_search_content/_mapping' \
      --header 'Content-Type: application/json' \
      --data-raw '{	
          "properties": {
              "appTag": {
                  "type": "keyword"
              },
              "resourceType": {
                  "type": "keyword"
              },
              "originalId": {
                  "type": "keyword"
              },
              "title": {
                  "type": "text",
                  "analyzer": "ik_max_word",
                  "search_analyzer": "ik_smart"
              },
              "digest": {
                  "type": "text",
                  "analyzer": "ik_max_word",
                  "search_analyzer": "ik_smart"
              },
              "content": {
                  "type": "text",
                  "analyzer": "ik_max_word",
                  "search_analyzer": "ik_smart"
              }
          }
      }'
      

使用说明

注意:需先在微信公众平台完成"IP白名单"设置

新增微信公众号配置

  • 调用Http接口
    • 开发者密码(AppSecret) : "secret"
    • 消息加解密密钥 : "aesKey"
    • 开发者ID(AppID) : "appId"
    • 令牌(Token) : "token"
    • 应用标识 : "appTag"

appTag与微信无关, 是本项目用于标识应用的, 因为本项目可支持多个微信公众号.

appTag 就是用来区别不同公众号的一个配置项.

假设 appTag 设置为 "WeixinMPSaaS", 那么在公众号基本配置页面配置如下 :

服务全局前缀 : /weixin-mp-saas (下面的图还没更新)

功能示例

curl --location --request POST 'http://127.0.0.1:8080/weixin-mp-saas/config/weixin/openapi/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "appTag":"xx",
    "secret":"xx",
    "aesKey":"xx",
    "appId":"xx",
    "token":"xx",
    "verifyValue":"xx",
    "verifyKey":"xx"
}'

更新微信公众号配置

大多数请求参数与"新增微信公众号配置"接口一样,不再赘述.

openapiConfigVerify.secret 用于验证,当其等于原有配置的secret,才允许更新.

curl --location --request POST 'http://127.0.0.1:8080/weixin-mp-saas/config/weixin/openapi/update' \
--header 'Content-Type: application/json' \
--data-raw '{
    "appTag":"xx",
    "secret":"xx",
    "aesKey":"xx",
    "appId":"xx",
    "token":"xx",
    "verifyValue":"",
    "verifyKey":"",
    "openapiConfigVerify":{
        "secret":"xx"
    }
}'

效果演示

微信公众号示例

功能示例

其他配置

nignx 反向代理

server {

	# 极简配置, 需要其他配置项自行补上
	listen 80;

	location /weixin-mp-saas/ {
		proxy_pass http://127.0.0.1:8080/weixin-mp-saas/;
	}
}

关闭跨公众号搜索能力

secret 用于验证,当其等于原有配置的secret,才允许更新.

curl --location --request POST 'http://127.0.0.1:8080/weixin-mp-saas/config/weixin/drainage/enable' \
--header 'Content-Type: application/json' \
--data-raw '{
    "appTag":"test",
    "secret":"testSecret",
    "enable" : "false"
}'

weixin-mp-saas's People

Contributors

eden2f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.