├── .gitattributes
├── .gitee
└── ISSUE_TEMPLATE.zh-CN.md
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE.md
└── workflows
│ ├── build-test.yml
│ └── deploy-doc.yml
├── .gitignore
├── .npmignore
├── .prettierignore
├── .prettierrc
├── .travis.yml
├── .vscode
└── setting.json
├── LICENSE
├── README.md
├── assets
└── img
│ ├── aliYun.jpg
│ ├── huawei.jpg
│ ├── logo.png
│ ├── tencent.jpg
│ └── tnwx-mind.png
├── docs
├── .gitignore
├── deploy.sh
├── docs
│ ├── .vuepress
│ │ ├── components
│ │ │ └── FloatIframe.vue
│ │ ├── config.js
│ │ ├── enhanceApp.js
│ │ ├── nav
│ │ │ └── zh.js
│ │ ├── public
│ │ │ ├── 1.jpeg
│ │ │ ├── 2.jpeg
│ │ │ ├── 3.jpeg
│ │ │ ├── 4.jpeg
│ │ │ ├── 5.jpeg
│ │ │ ├── chat.png
│ │ │ ├── coffee.jpeg
│ │ │ └── frp.png
│ │ └── styles
│ │ │ ├── index.styl
│ │ │ └── override.styl
│ ├── README.md
│ └── guide
│ │ ├── README.md
│ │ ├── common
│ │ ├── accesstoken.md
│ │ └── init.md
│ │ ├── donate
│ │ └── README.md
│ │ ├── miniprogram
│ │ ├── login.md
│ │ ├── ocr.md
│ │ ├── qrcode.md
│ │ └── subscribemsg.md
│ │ ├── tools
│ │ └── frp.md
│ │ ├── wxcp
│ │ ├── callback.md
│ │ ├── handmsg.md
│ │ ├── media.md
│ │ ├── oauth.md
│ │ └── sendmsg.md
│ │ ├── wxmp
│ │ ├── callback.md
│ │ ├── custom_menu.md
│ │ ├── jssdk.md
│ │ ├── oauth.md
│ │ ├── sendmsg.md
│ │ └── templatemsg.md
│ │ └── wxpay
│ │ ├── README.md
│ │ ├── api-v2.md
│ │ └── api-v3.md
├── package.json
└── yarn.lock
├── jest.config.js
├── lerna.json
├── package.json
├── packages
├── accesstoken
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── AccessToken.ts
│ │ ├── AccessTokenApi.ts
│ │ ├── ApiConfig.ts
│ │ ├── ApiConfigKit.ts
│ │ ├── index.ts
│ │ ├── opencp
│ │ │ ├── OpenCorpAccessTokenApi.ts
│ │ │ └── OpenCpAccessTokenApi.ts
│ │ ├── openmp
│ │ │ ├── OpenAuthorizerAccessTokenApi.ts
│ │ │ └── OpenComponentAccessTokenApi.ts
│ │ └── wxcp
│ │ │ ├── QyAccessTokenApi.ts
│ │ │ └── QyApiConfigKit.ts
│ └── tsconfig.json
├── cache
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── DefaultCache.ts
│ │ ├── ICache.ts
│ │ └── index.ts
│ └── tsconfig.json
├── commons
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── CryptoKit.ts
│ │ ├── Enums.ts
│ │ ├── InMsgParser.ts
│ │ ├── MsgAdapter.ts
│ │ ├── api
│ │ │ ├── ComSubscribeMsgApi.ts
│ │ │ ├── JsTicketApi.ts
│ │ │ ├── QyJsTicketApi.ts
│ │ │ └── UniformMessageApi.ts
│ │ ├── entity
│ │ │ ├── JsTicket.ts
│ │ │ ├── menu
│ │ │ │ └── Menu.ts
│ │ │ ├── msg
│ │ │ │ ├── BaseMsg.ts
│ │ │ │ ├── in
│ │ │ │ │ ├── InAuthEvent.ts
│ │ │ │ │ ├── InAuthMpEvent.ts
│ │ │ │ │ ├── InBatchJobResult.ts
│ │ │ │ │ ├── InComponentVerifyTicket.ts
│ │ │ │ │ ├── InExternalContact.ts
│ │ │ │ │ ├── InImageMsg.ts
│ │ │ │ │ ├── InLinkMsg.ts
│ │ │ │ │ ├── InLocationMsg.ts
│ │ │ │ │ ├── InMsg.ts
│ │ │ │ │ ├── InNotDefinedMsg.ts
│ │ │ │ │ ├── InRegisterCorp.ts
│ │ │ │ │ ├── InShortVideoMsg.ts
│ │ │ │ │ ├── InSpeechRecognitionResults.ts
│ │ │ │ │ ├── InSuiteTicket.ts
│ │ │ │ │ ├── InTextMsg.ts
│ │ │ │ │ ├── InVideoMsg.ts
│ │ │ │ │ ├── InVoiceMsg.ts
│ │ │ │ │ ├── card
│ │ │ │ │ │ ├── InCardMerchantCheckResultEvent.ts
│ │ │ │ │ │ ├── InCardPassCheckEvent.ts
│ │ │ │ │ │ ├── InCardPayOrderEvent.ts
│ │ │ │ │ │ ├── InCardSkuRemindEvent.ts
│ │ │ │ │ │ ├── InMerChantOrderEvent.ts
│ │ │ │ │ │ ├── InUpdateMemberCardEvent.ts
│ │ │ │ │ │ ├── InUserCardEvent.ts
│ │ │ │ │ │ ├── InUserConsumeCardEvent.ts
│ │ │ │ │ │ ├── InUserGetCardEvent.ts
│ │ │ │ │ │ ├── InUserGiftingCardEvent.ts
│ │ │ │ │ │ └── InUserPayFromCardEvent.ts
│ │ │ │ │ └── event
│ │ │ │ │ │ ├── EventInMsg.ts
│ │ │ │ │ │ ├── InBatchJobResultEvent.ts
│ │ │ │ │ │ ├── InCustomEvent.ts
│ │ │ │ │ │ ├── InEnterAgentEvent.ts
│ │ │ │ │ │ ├── InExternalContactEvent.ts
│ │ │ │ │ │ ├── InFollowEvent.ts
│ │ │ │ │ │ ├── InLocationEvent.ts
│ │ │ │ │ │ ├── InMassEvent.ts
│ │ │ │ │ │ ├── InMenuEvent.ts
│ │ │ │ │ │ ├── InNotDefinedEvent.ts
│ │ │ │ │ │ ├── InPoiCheckNotifyEvent.ts
│ │ │ │ │ │ ├── InQrCodeEvent.ts
│ │ │ │ │ │ ├── InShakearoundUserShakeEvent.ts
│ │ │ │ │ │ ├── InTaskEvent.ts
│ │ │ │ │ │ ├── InTemplateMsgEvent.ts
│ │ │ │ │ │ ├── InUpdatePartyEvent.ts
│ │ │ │ │ │ ├── InUpdateTagEvent.ts
│ │ │ │ │ │ ├── InUpdateUserEvent.ts
│ │ │ │ │ │ ├── InVerifyFailEvent.ts
│ │ │ │ │ │ ├── InVerifySuccessEvent.ts
│ │ │ │ │ │ ├── InWifiEvent.ts
│ │ │ │ │ │ ├── InWxVerifyDispatchEvent.ts
│ │ │ │ │ │ └── ScanCodeInfo.ts
│ │ │ │ └── out
│ │ │ │ │ ├── Article.ts
│ │ │ │ │ ├── MenuMsg.ts
│ │ │ │ │ ├── News.ts
│ │ │ │ │ ├── OutCustomMsg.ts
│ │ │ │ │ ├── OutImageMsg.ts
│ │ │ │ │ ├── OutMsg.ts
│ │ │ │ │ ├── OutMusicMsg.ts
│ │ │ │ │ ├── OutNewsMsg.ts
│ │ │ │ │ ├── OutTextMsg.ts
│ │ │ │ │ ├── OutVideoMsg.ts
│ │ │ │ │ ├── OutVoiceMsg.ts
│ │ │ │ │ └── TransInfo.ts
│ │ │ ├── subscribe
│ │ │ │ └── SubscribeMsg.ts
│ │ │ └── template
│ │ │ │ └── TemplateData.ts
│ │ └── index.ts
│ └── tsconfig.json
├── kits
│ ├── README.md
│ ├── __tests__
│ │ ├── HttpKit.spec.ts
│ │ └── Kits.spec.ts
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── AxiosHttpKit.ts
│ │ ├── HttpKit.ts
│ │ ├── Kits.ts
│ │ └── index.ts
│ └── tsconfig.json
├── miniprogram
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── ImgApi.ts
│ │ ├── MiniCustomerMsgApi.ts
│ │ ├── MiniPluginManagerApi.ts
│ │ ├── MiniProgramApi.ts
│ │ ├── MiniSubscribeMsgApi.ts
│ │ ├── NearByPoiApi.ts
│ │ ├── OCRApi.ts
│ │ └── index.ts
│ └── tsconfig.json
├── opencp
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── OpenCpApi.ts
│ │ ├── OpenCpOauthApi.ts
│ │ ├── OpenQrCode.ts
│ │ └── index.ts
│ └── tsconfig.json
├── openmp
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── OpenMpApi.ts
│ │ ├── OpenMpSnsAccessTokenApi.ts
│ │ └── index.ts
│ └── tsconfig.json
├── tnwx
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── index.ts
│ └── tsconfig.json
├── wxcp
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── QyAgentApi.ts
│ │ ├── QyAppChatApi.ts
│ │ ├── QyDepartmentApi.ts
│ │ ├── QyExContact.ts
│ │ ├── QyGroupRobotApi.ts
│ │ ├── QyInvoiceApi.ts
│ │ ├── QyMediaApi.ts
│ │ ├── QyOAApi.ts
│ │ ├── QyOauthApi.ts
│ │ ├── QySendMsgApi.ts
│ │ ├── QySyncApi.ts
│ │ ├── QyTagApi.ts
│ │ ├── QyUserApi.ts
│ │ ├── QyWeChat.ts
│ │ ├── QyWxApi.ts
│ │ ├── entity
│ │ │ ├── QyBaseMsg.ts
│ │ │ ├── QyFileMsg.ts
│ │ │ ├── QyImageMsg.ts
│ │ │ ├── QyMarkDownMsg.ts
│ │ │ ├── QyMiniProgramNoticeMsg.ts
│ │ │ ├── QyMpNewsMsg.ts
│ │ │ ├── QyNewsMsg.ts
│ │ │ ├── QyTaskCardMsg.ts
│ │ │ ├── QyTextCardMsg.ts
│ │ │ ├── QyTextMsg.ts
│ │ │ ├── QyVideoMsg.ts
│ │ │ └── QyVoiceMsg.ts
│ │ └── index.ts
│ └── tsconfig.json
├── wxmp
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ │ ├── WeChat.ts
│ │ ├── api
│ │ │ ├── AutoReplyInfoApi.ts
│ │ │ ├── CallbackApi.ts
│ │ │ ├── CardApi.ts
│ │ │ ├── CustomServiceApi.ts
│ │ │ ├── DatacubeApi.ts
│ │ │ ├── MediaApi.ts
│ │ │ ├── MemberCardApi.ts
│ │ │ ├── MenuApi.ts
│ │ │ ├── MessageApi.ts
│ │ │ ├── PoiApi.ts
│ │ │ ├── QrcodeApi.ts
│ │ │ ├── SemanticApi.ts
│ │ │ ├── ShortUrlApi.ts
│ │ │ ├── SnsAccessTokenApi.ts
│ │ │ ├── SubscribeMsgApi.ts
│ │ │ ├── TagApi.ts
│ │ │ ├── TemplateApi.ts
│ │ │ ├── UserApi.ts
│ │ │ └── shakearound
│ │ │ │ ├── ShakeAroundApi.ts
│ │ │ │ ├── ShakeAroundDeviceApi.ts
│ │ │ │ ├── ShakeAroundPageApi.ts
│ │ │ │ ├── ShakeAroundStatisticsApi.ts
│ │ │ │ └── ShakeAroundUserApi.ts
│ │ └── index.ts
│ └── tsconfig.json
└── wxpay
│ ├── README.md
│ ├── jest.config.js
│ ├── package.json
│ ├── src
│ ├── PayKit.ts
│ ├── RequestMethod.ts
│ ├── TradeType.ts
│ ├── WxApiType.ts
│ ├── WxDomain.ts
│ ├── WxPay.ts
│ ├── WxPayApiConfig.ts
│ ├── WxPayApiConifgKit.ts
│ └── index.ts
│ └── tsconfig.json
├── sample
├── egg
│ ├── .autod.conf.js
│ ├── .eslintignore
│ ├── .eslintrc
│ ├── .gitignore
│ ├── .travis.yml
│ ├── README.md
│ ├── app.ts
│ ├── app
│ │ ├── MenuManager.ts
│ │ ├── controller
│ │ │ ├── home.ts
│ │ │ ├── opencp
│ │ │ │ └── opencpapi.ts
│ │ │ ├── openmp
│ │ │ │ ├── openmpapi.ts
│ │ │ │ └── openmpmsg.ts
│ │ │ ├── wxcp
│ │ │ │ ├── qyapi.ts
│ │ │ │ ├── qyjssdk.ts
│ │ │ │ └── qymsg.ts
│ │ │ ├── wxmp
│ │ │ │ ├── jssdk.ts
│ │ │ │ └── mpmsg.ts
│ │ │ └── wxpay.ts
│ │ ├── handMsgAdapter.ts
│ │ ├── middleware
│ │ │ ├── jssdk.ts
│ │ │ ├── openjssdk.ts
│ │ │ └── qyjssdk.ts
│ │ ├── public
│ │ │ ├── 5478274718.txt
│ │ │ ├── WW_verify_YgLiaOHIivF2XgmR.txt
│ │ │ ├── css
│ │ │ │ ├── qyjssdk.css
│ │ │ │ └── style.css
│ │ │ └── images
│ │ │ │ └── coffee.jpeg
│ │ ├── router.ts
│ │ ├── schedule
│ │ │ └── sendschedule.ts
│ │ ├── service
│ │ │ └── Weather.ts
│ │ └── view
│ │ │ ├── index.html
│ │ │ ├── jssdk.html
│ │ │ ├── openmp.html
│ │ │ ├── pay.html
│ │ │ └── qyjssdk.html
│ ├── appveyor.yml
│ ├── config
│ │ ├── config.default.ts
│ │ ├── config.local.ts
│ │ ├── config.prod.ts
│ │ ├── env
│ │ └── plugin.ts
│ ├── package-lock.json
│ ├── package.json
│ ├── test
│ │ └── app
│ │ │ ├── controller
│ │ │ └── home.test.ts
│ │ │ └── service
│ │ │ └── Test.test.ts
│ ├── tsconfig.json
│ └── typings
│ │ ├── app
│ │ ├── controller
│ │ │ └── index.d.ts
│ │ ├── index.d.ts
│ │ ├── middleware
│ │ │ └── index.d.ts
│ │ └── service
│ │ │ └── index.d.ts
│ │ ├── config
│ │ ├── index.d.ts
│ │ └── plugin.d.ts
│ │ └── index.d.ts
└── express
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ ├── App.ts
│ ├── MenuManager.ts
│ ├── MsgController.ts
│ └── http.ts
│ ├── static
│ ├── WW_verify_iDBWSTNEMIzAbXYN.txt
│ └── index.html
│ ├── tsconfig.json
│ └── yarn.lock
├── tsconfig.json
└── yarn.lock
/.gitattributes:
--------------------------------------------------------------------------------
1 | # All text files should have the "lf" (Unix) line endings
2 | * text eol=lf
3 | # windows cmd shoud have the "crlf" (Win32) line endings
4 | *.cmd eol=crlf
5 |
6 | # Explicitly declare text files you want to always be normalized and converted
7 | # to native line endings on checkout.
8 | *.java text
9 | *.js text
10 | *.css text
11 | *.html text
12 | *.properties text
13 | *.xml text
14 | *.yml text
15 |
16 | # Denote all files that are truly binary and should not be modified.
17 | *.png binary
18 | *.jpg binary
19 | *.jar binary
20 | *.ttf binary
21 |
--------------------------------------------------------------------------------
/.gitee/ISSUE_TEMPLATE.zh-CN.md:
--------------------------------------------------------------------------------
1 |
6 | ### 版本信息
7 | - 当前版本:
8 | - 操作系统:
9 | - 复现操作:
10 |
11 | ### 报错信息 (注意格式化)
12 |
13 | ```
14 | 这里粘贴代码或者、日志
15 | ```
16 |
17 | ### 问题描述(包括回显步骤、截图 )
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: ['https://javen205.github.io/IJPay/guide/donate/','https://github.com/Javen205/donate']
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
7 | ### 版本信息
8 |
9 | - 当前版本:
10 | - 操作系统:
11 | - 复现操作:
12 |
13 | ### 报错信息 (注意格式化)
14 |
15 | ```
16 | 这里粘贴代码或者、日志
17 | ```
18 |
19 | ### 问题描述(包括回显步骤、截图 )
20 |
--------------------------------------------------------------------------------
/.github/workflows/build-test.yml:
--------------------------------------------------------------------------------
1 | name: Build and Test
2 | on:
3 | push:
4 | branches:
5 | - dev
6 | jobs:
7 | build-test:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: checkout
11 | uses: actions/checkout@v1
12 | with:
13 | ref: dev
14 |
15 | - name: install node
16 | uses: actions/setup-node@v1
17 | with:
18 | node-version: 12.x
19 | registry-url: https://registry.npmjs.org/
20 |
21 | - name: npm install, build, test
22 | run: |
23 | npm install -g yarn
24 | yarn
25 | yarn run tsc
26 | yarn run test
27 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-doc.yml:
--------------------------------------------------------------------------------
1 | name: Build and Deploy Doc
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | build-and-deploy:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v1
12 | with:
13 | ref: master
14 |
15 | - name: install node
16 | uses: actions/setup-node@v1
17 | with:
18 | node-version: 12.x
19 | registry-url: https://registry.npmjs.org/
20 |
21 | - name: Duild
22 | run: |
23 | npm install -g yarn
24 | cd docs
25 | yarn
26 | yarn run docs:build
27 | pwd
28 |
29 | - name: Deploy
30 | uses: peaceiris/actions-gh-pages@v3
31 | with:
32 | deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
33 | publish_branch: gh-pages
34 | publish_dir: ./docs/docs/.vuepress/dist
35 | force_orphan: true
36 | commit_message: ':memo: deploy docs'
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | node_modules/
3 | .DS_Store
4 | *.log
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | docs
2 | assets
3 | sample
4 | **/*.ts
5 | *.ts
6 | # configuration
7 | .gitee
8 | .github
9 | .vscode
10 | .prettierrc
11 | .travis.yml
12 | tsconfig.json
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | dist/
2 | docs/
3 | assets/
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "singleQuote": true,
4 | "printWidth": 180
5 | }
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language : node_js
2 | node_js :
3 | - stable
4 | install:
5 | - npm install
6 | script:
7 | - npm test
--------------------------------------------------------------------------------
/.vscode/setting.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules/typescript/lib",
3 | "cSpell.enabledLanguageIds": ["markdown", "plaintext", "text", "yml"],
4 | "[typescript]": {
5 | "editor.defaultFormatter": "esbenp.prettier-vscode"
6 | },
7 | "[javascript]": {
8 | "editor.defaultFormatter": "esbenp.prettier-vscode"
9 | },
10 | "[json]": {
11 | "editor.defaultFormatter": "esbenp.prettier-vscode"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ### 简介
12 |
13 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信、企业微信开发平台。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
14 |
15 |
16 |
17 |
18 |
19 | ### 简易指南
20 |
21 | #### 尝鲜版
22 |
23 | ```bash
24 | $ git clone https://gitee.com/javen205/TNWX.git
25 | $ cd TNWX
26 | $ yarn bootstrap
27 | $ yarn tsc
28 | ```
29 |
30 | #### 运行示例
31 |
32 | ```bash
33 | $ cd sample/express && yarn
34 | $ yarn build
35 | $ yarn dev
36 | ```
37 |
38 | #### 稳定版
39 |
40 | ```bash
41 | $ mkdir TNWX && cd TNWX
42 | $ yarn init -y
43 | $ yarn add tnwx
44 | ```
45 |
46 | ### 文档
47 |
48 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
49 |
50 | ### 交流群
51 |
52 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
53 |
54 | ### 开源推荐
55 |
56 | - `IJPay` 让支付触手可及:https://gitee.com/javen205/IJPay
57 | - SpringBoot 微服务高效开发 `mica` 工具集:https://gitee.com/596392912/mica
58 | - `Avue` 一款基于 vue 可配置化的神奇框架:https://gitee.com/smallweigit/avue
59 | - `pig` 宇宙最强微服务(架构师必备):https://gitee.com/log4j/pig
60 | - `SpringBlade` 完整的线上解决方案(企业开发必备):https://gitee.com/smallc/SpringBlade
61 |
--------------------------------------------------------------------------------
/assets/img/aliYun.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/assets/img/aliYun.jpg
--------------------------------------------------------------------------------
/assets/img/huawei.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/assets/img/huawei.jpg
--------------------------------------------------------------------------------
/assets/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/assets/img/logo.png
--------------------------------------------------------------------------------
/assets/img/tencent.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/assets/img/tencent.jpg
--------------------------------------------------------------------------------
/assets/img/tnwx-mind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/assets/img/tnwx-mind.png
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | dist
--------------------------------------------------------------------------------
/docs/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | # 确保脚本抛出遇到的错误
4 | set -e
5 |
6 | # 生成静态文件
7 | npm run docs:build
8 |
9 | # 进入生成的文件夹
10 | cd docs/.vuepress/dist
11 |
12 | # 如果是发布到自定义域名
13 | # echo 'www.example.com' > CNAME
14 |
15 | git init
16 | git add -A
17 | git commit -m ':memo: deploy docs'
18 |
19 | # 如果发布到 https://.github.io
20 | # git push -f git@github.com:/.github.io.git master
21 |
22 | # 如果发布到 https://.github.io/
23 | # git push -f git@github.com:/.git master:gh-pages
24 |
25 | case "$1" in
26 | 'Github')
27 | git push -f git@github.com:javen205/TNWX.git master:gh-pages
28 | ;;
29 | 'Gitee')
30 | git push -f git@gitee.com:javen205/TNWX.git master:gh-pages
31 | ;;
32 | *)
33 | git push -f git@github.com:javen205/TNWX.git master:gh-pages
34 | esac
35 |
36 | cd -
--------------------------------------------------------------------------------
/docs/docs/.vuepress/components/FloatIframe.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
18 |
19 |
20 |
21 |
22 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/docs/.vuepress/enhanceApp.js:
--------------------------------------------------------------------------------
1 | import Element from "element-ui";
2 | import "element-ui/lib/theme-chalk/index.css";
3 |
4 | export default ({ Vue, isServer }) => {
5 | Vue.use(Element);
6 | if (!isServer) {
7 | import('vue-toasted' /* webpackChunkName: "notification" */).then((module) => {
8 | Vue.use(module.default)
9 | })
10 | }
11 | }
--------------------------------------------------------------------------------
/docs/docs/.vuepress/nav/zh.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | text: '接入指南',
4 | link: '/guide/',
5 | },
6 | {
7 | text: '开源项目',
8 | items: [
9 | {
10 | text: 'IJPay 让支付触手可及',
11 | link: 'https://gitee.com/javen205/IJPay'
12 | },
13 | {
14 | text: 'JPay 简易而不简单的支付 SDK',
15 | link: 'https://gitee.com/javen205/JPay'
16 | },
17 | {
18 | text: 'TNWX 微信系开发脚手架',
19 | link: 'https://gitee.com/javen205/TNWX'
20 | },
21 | {
22 | text: 'weixin_guide 微信公众号开发指南',
23 | link: 'https://gitee.com/javen205/weixin_guide'
24 | },
25 | {
26 | text: '微信小游戏·云开发',
27 | link: 'https://gitee.com/javen205/Sunflower'
28 | },
29 | {
30 | text: 'SpringBoot·SpringCloud 案例',
31 | link: 'https://gitee.com/javen205/SpringBoot_Guide'
32 | },
33 | ]
34 | },
35 | {
36 | text: '赞助',
37 | link: '/guide/donate/',
38 | },
39 | {
40 | text: 'Gitee',
41 | link: 'https://gitee.com/javen205/TNWX',
42 | },
43 | ]
44 |
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/1.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/2.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/3.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/4.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/4.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/5.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/5.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/chat.png
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/coffee.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/coffee.jpeg
--------------------------------------------------------------------------------
/docs/docs/.vuepress/public/frp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/docs/docs/.vuepress/public/frp.png
--------------------------------------------------------------------------------
/docs/docs/.vuepress/styles/index.styl:
--------------------------------------------------------------------------------
1 | // placeholder for test, dont't remove it.
2 |
3 | //.content {
4 | // font-size 30px;
5 | //}
6 |
7 | pre.vue-container
8 | border-left-width: .5rem;
9 | border-left-style: solid;
10 | border-color: #42b983;
11 | border-radius: 0px;
12 | & > code
13 | font-size: 14px !important;
14 | & > p
15 | margin: -5px 0 -20px 0;
16 | code
17 | background-color: #42b983 !important;
18 | padding: 3px 5px;
19 | border-radius: 3px;
20 | color #000
21 | em
22 | color #808080
23 | font-weight light
24 |
--------------------------------------------------------------------------------
/docs/docs/.vuepress/styles/override.styl:
--------------------------------------------------------------------------------
1 | $accentColor = #3eaf7c
2 | $textColor = #2c3e50
3 | $borderColor = #eaecef
4 | $codeBgColor = #FFFFFF
5 |
--------------------------------------------------------------------------------
/docs/docs/guide/donate/README.md:
--------------------------------------------------------------------------------
1 | # 请作者喝一杯咖啡
2 |
3 | 如果你觉得 TNWX 对你有帮助,可以请作者喝一杯咖啡 ^_^
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 其他赞助方式
13 |
14 |
15 | 前往赞助
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/docs/guide/miniprogram/login.md:
--------------------------------------------------------------------------------
1 | # 登录
2 |
3 | ## 获取 code
4 |
5 | ```JavaScript
6 | wx.login({
7 | success: res => {
8 | console.log(res);
9 | }
10 | })
11 | ```
12 |
13 | ## 登录凭证校验
14 |
15 | ```TypeScript
16 | MiniProgramApi.code2Session(ApiConfigKit.getAppId, ApiConfigKit.getApiConfig.getAppScrect, code)
17 | .then((data) => {
18 | res.send(data);
19 | }).catch((error) => console.log(error))
20 | ```
21 |
22 | ## 获取用户信息
23 |
24 | ```JavaScript
25 | wx.getUserInfo({
26 | withCredentials: true,
27 | success: res=>{
28 | console.log(res);
29 | }
30 | })
31 | ```
32 |
33 | 签证签名并解密 encryptedData
34 |
35 | ```TypeScript
36 | signature = 'bc404eedffb75c8d3cf3346acaf92466a7a793a1';
37 | let rawData = '{"nickName":"Javen","gender":1,"language":"zh_CN","city":"Shenzhen","province":"Guangdong","country":"China","avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/icc2nhPAgI52Yx52hWXknQzYC122WeVIAoE1F9Tia3ZFmj8TUEr6M4rY10GDf4qTFT9RvdM3icDibq9BQ7kooYMW5g/132"}';
38 | let session_key = 'syOEZf6faXl3JqAKh9FfvQ==';
39 | let iv = 'wGZm1/t99wRHb4oiwDbybQ==';
40 | let encryptedData = 'r9UTG7Yo3xlXZ1++2atDr/7So5b+GevtC4ZkxXeL+vCjYoMp50YB004IcCuPdbZlzd06Pvx0Yd6B92188ttbvkhCYb2uE8Wa8Nr1a/M72984gHj37TX4dX5f8/IMAXGqSPOMVjx14LZPMg8YDFYY5lUlYtHRvsOLl8zboZ9fR2B5+p3juPsnzyxuZZkUHYclRJ3qQzffZHMrelP7IHdMbUHVmsgpfwJc5Is6zhSpi/DKjHJxdIfHjl0wusP1Dy55WymSfxUfaEi63Fln9m8fUXF0mZprbFGl54sxKdabQuaQIL7aeETpMhNEmWBdtIetTuC3bkfBXLlW1b/JkUjBRdU2ZF4tRKHT24I6LnwfQMmXrEcbHA0JdU2CvU/TeF+iqYud4mgo115THVy76jxIPJXm65zbLuUVG6CvzOUSEOyWVSNQ7nbcwA3qrDiEuL4nYPusyoQpsZCxs+FUTEImmATD12R0/6Q1N557Ica59Wo=';
41 | let key = Buffer.from(session_key, 'base64');
42 | let baseIv = Buffer.from(iv, 'base64');
43 |
44 | let signature2 = Kits.sha1(rawData + session_key);
45 |
46 | if (signature2 === signature) {
47 | let ecrypt = Kits.aes128cbcDecrypt(key, baseIv, encryptedData);
48 | res.send(ecrypt);
49 | } else {
50 | res.send('签名错误');
51 | }
52 |
53 | ```
--------------------------------------------------------------------------------
/docs/docs/guide/miniprogram/ocr.md:
--------------------------------------------------------------------------------
1 | # OCR 识别
2 |
3 | ## 官方文档
4 |
5 | [OCR 识别官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.bankcard.html)
6 |
7 | ## 源码
8 |
9 | [TNWX 中 OCR 识别相关接口源码](https://gitee.com/javen205/TNWX/blob/master/packages/miniprogram/src/OCRApi.ts)
10 |
11 | ## 示例
12 |
13 | ```TypeScript
14 | app.get('/ocr', async (req: any, res: any) => {
15 |
16 | let type: string = req.query.type;
17 |
18 | console.log('to ocr...' + type);
19 |
20 | switch (parseInt(type)) {
21 | case 1:
22 | OCRApi.ocrByUrl(OCRType.IDCARD,'https://up.enterdesk.com/edpic_360_360/28/bc/80/28bc80d62c84ea7797197a6d7cb03394.jpg')
23 | .then((data) => {
24 | res.send(data);
25 | })
26 | .catch((error) => console.log(error))
27 | break;
28 | case 2:
29 | OCRApi.ocrByUrl(OCRType.PRINTEDTEXT,'https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1724603202,554806693&fm=26&gp=0.jpg')
30 | .then((data) => {
31 | res.send(data);
32 | })
33 | .catch((error) => console.log(error))
34 | break;
35 | case 3:
36 | OCRApi.ocrByFile(OCRType.PRINTEDTEXT,'/Users/Javen/Downloads/miniprogram_qrcode2.png')
37 | .then((data) => {
38 | res.send(data);
39 | })
40 | .catch((error) => console.log(error))
41 | break;
42 | default:
43 | break
44 | }
45 |
46 | });
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/docs/guide/miniprogram/qrcode.md:
--------------------------------------------------------------------------------
1 | # 小程序码
2 |
3 | ## 官方文档
4 |
5 | [小程序码文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.createQRCode.html)
6 |
7 | ## 源码
8 |
9 | [TNWX 中小程序码相关接口源码](https://gitee.com/javen205/TNWX/blob/master/packages/miniprogram/src/MiniProgramApi.ts#L180)
10 |
11 |
12 | ## 示例
13 |
14 | ```TypeScript
15 | case 7:
16 | MiniProgramApi.getUnlimited('TNWX','IJPay?author=Javen')
17 | .then((data) => {
18 | //写入文件
19 | fs.writeFile('/Users/Javen/Downloads/miniprogram_qrcode.png', data, function(err){
20 | if(err){
21 | res.send(err);
22 | }else{
23 | res.send('保存成功');
24 | }
25 | });
26 | })
27 | .catch((error) => console.log(error))
28 | break;
29 | case 8:
30 | MiniProgramApi.createQRCode('IJPay?author=Javen')
31 | .then((data) => {
32 | //写入文件
33 | fs.writeFile('/Users/Javen/Downloads/miniprogram_qrcode2.png', data, function(err){
34 | if(err){
35 | res.send(err);
36 | }else{
37 | res.send('保存成功');
38 | }
39 | });
40 | })
41 | .catch((error) => console.log(error))
42 | break;
43 | case 9:
44 | MiniProgramApi.getWxAcode('IJPay?author=Javen')
45 | .then((data) => {
46 | //写入文件
47 | fs.writeFile('/Users/Javen/Downloads/miniprogram_qrcode3.png', data, function(err){
48 | if(err){
49 | res.send(err);
50 | }else{
51 | res.send('保存成功');
52 | }
53 | });
54 | })
55 | .catch((error) => console.log(error))
56 | break;
57 | ```
--------------------------------------------------------------------------------
/docs/docs/guide/wxcp/callback.md:
--------------------------------------------------------------------------------
1 | # 开发者模式
2 |
3 | ## 简介
4 |
5 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
6 |
7 | ## 配置初始化
8 |
9 | [请参考快速入门中的初始化与示例](../common/init)
10 |
11 | ## 开发者模式
12 |
13 | **TNWX** 中验证签名的关键接口如下:
14 |
15 | ```TypeScript
16 | QyWeChat.checkSignature(signature, timestamp,nonce, echostr)
17 | ```
18 |
19 | **Express** 示例如下:
20 |
21 | ```TypeScript
22 | app.get('/qymsg', (req: any, res: any) => {
23 | console.log('get query...', req.query);
24 |
25 | let appId: string = req.query.appId;
26 | let corpId: string = req.query.corpId;
27 | if (appId && corpId) {
28 | QyApiConfigKit.setCurrentAppId(appId,corpId);
29 | }
30 |
31 | let signature = urlencode.decode(req.query.msg_signature)//微信加密签名
32 | let timestamp = urlencode.decode(req.query.timestamp)//时间戳
33 | let nonce = urlencode.decode(req.query.nonce)//随机数
34 | let echostr = urlencode.decode(req.query.echostr)//随机字符串
35 |
36 | res.send(QyWeChat.checkSignature(signature, timestamp,nonce, echostr));
37 | });
38 |
39 | ```
40 |
41 | **特别说明:**
42 |
43 | 1. 开发者URL为:`http/https://域名/qymsg?appId=xxxxx&corpId=xxxx`
44 | 2. 加密模式必须设置为 `true`(`ApiConfig` 第四个参数)
45 |
46 |
47 | ## 本地端口映射工具
48 |
49 | 推荐使用 [FRP](https://github.com/fatedier/frp) 目前Github Start 已超越 3.2w。如有更好的工具欢迎推荐 [issues](https://gitee.com/javen205/TNWX/issues)
50 |
51 |
52 | ## 开源推荐
53 |
54 | - `TNWX` 微信公众号开发脚手架:
55 | - `IJPay` 让支付触手可及:
56 | - SpringBoot 微服务高效开发 `mica` 工具集:
57 | - `Avue` 一款基于 vue 可配置化的神奇框架:
58 | - `pig` 宇宙最强微服务(架构师必备):
59 | - `SpringBlade` 完整的线上解决方案(企业开发必备):
--------------------------------------------------------------------------------
/docs/docs/guide/wxcp/handmsg.md:
--------------------------------------------------------------------------------
1 | # 各种消息交互
2 |
3 | ## 简介
4 |
5 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
6 |
7 |
8 | ## 开启开发者模式
9 |
10 | [如何开启开发者模式](./callback)
11 |
12 |
13 | ## 接收各种消息
14 |
15 | 在 TNWX 中实现企业微信各种消息交互非常简单,步骤如下:
16 |
17 | 1. 接收各种消息
18 | 2. 调用 `QyWeChat.handleMsg(...)` 方法处理分发消息
19 | 3. 实现 `MsgAdapter` 接口,实现业务逻辑以及各种消息回复
20 |
21 | **开发者 URL 的 POST 方法下接收各种消息** 具体实现代码如下
22 |
23 | ## Express 示例
24 |
25 | ```typescript
26 | // 接收微信消息入口
27 | app.post('/qymsg', function (req: any, res: any) {
28 | console.log('post...', req.query);
29 |
30 | let appId: string = req.query.appId;
31 | let corpId: string = req.query.corpId;
32 | if (appId && corpId) {
33 | QyApiConfigKit.setCurrentAppId(appId,corpId);
34 | }
35 | let msgSignature = req.query.msg_signature,
36 | timestamp = req.query.timestamp,
37 | nonce = req.query.nonce;
38 |
39 | //监听 data 事件 用于接收数据
40 | let buffer: Uint8Array[] = [];
41 | req.on('data', function (data: any) {
42 | buffer.push(data);
43 | });
44 |
45 | req.on('end', function () {
46 | let msgXml = Buffer.concat(buffer).toString('utf-8');
47 | console.log(`接收到的消息msgXml:${msgXml}`)
48 |
49 | QyWeChat.handleMsg(msgAdapter, msgXml, msgSignature, timestamp, nonce)
50 | .then(data => {
51 | res.send(data);
52 | })
53 | .catch((error) => console.log(error));
54 | });
55 |
56 | });
57 | ```
58 |
59 | ## 处理响应消息以及事件
60 |
61 | 与微信公众号相关 请参考 [微信公众号各种消息交互](../wxmp/sendmsg)
62 |
63 | ## 开源推荐
64 |
65 | - `TNWX` 微信公众号开发脚手架:
66 | - `IJPay` 让支付触手可及:
67 | - SpringBoot 微服务高效开发 `mica` 工具集:
68 | - `Avue` 一款基于 vue 可配置化的神奇框架:
69 | - `pig` 宇宙最强微服务(架构师必备):
70 | - `SpringBlade` 完整的线上解决方案(企业开发必备):
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/docs/docs/guide/wxcp/media.md:
--------------------------------------------------------------------------------
1 | # 素材管理
2 |
3 | ## 官方文档
4 |
5 | [企业微信素材管理官方文档](https://work.weixin.qq.com/api/doc/90000/90135/91054)
6 |
7 | ## 源码
8 |
9 | [TNWX-QyMediaApi](https://gitee.com/javen205/TNWX/blob/master/packages/wxcp/src/QyMediaApi.ts)
10 |
11 | ## 示例
12 |
13 | ```TypeScript
14 | // 企业微信素材管理
15 | app.get('/qyMediaApi', (req: any, res: any) => {
16 | let type: string = req.query.type;
17 | console.log('type', type);
18 | switch (parseInt(type)) {
19 | // 上传图片
20 | case 0:
21 | QyMediaApi.uploadImg('/Users/Javen/Documents/pic/1.jpeg')
22 | .then(data => {
23 | console.log(data);
24 | res.send(data);
25 | })
26 | .catch((error) => console.log(error));
27 | break;
28 | // 上传临时素材图片 media_id 仅三天内有效
29 | case 1:
30 | QyMediaApi.upload(QyMediaType.IMAGE,'/Users/Javen/Documents/pic/1.jpeg')
31 | .then(data => {
32 | console.log(data);
33 | res.send(data);
34 | })
35 | .catch((error) => console.log(error));
36 | break;
37 | // 上传临时素材文件 media_id 仅三天内有效
38 | case 2:
39 | QyMediaApi.upload(QyMediaType.FILE,'/Users/Javen/Documents/TNW/TNW-Menu.md')
40 | .then(data => {
41 | console.log(data);
42 | res.send(data);
43 | })
44 | .catch((error) => console.log(error));
45 | break;
46 | // 获取临时素材
47 | case 3:
48 | QyMediaApi.get('39Cnt6IuBjBh-z1kWk7iY5EFoYuptkowMvT_r0yRM4Rk')
49 | .then(data => {
50 | console.log(data);
51 | res.send(data);
52 | })
53 | .catch((error) => console.log(error));
54 | break;
55 | default:
56 | break;
57 | }
58 | });
59 | ```
--------------------------------------------------------------------------------
/docs/docs/guide/wxcp/oauth.md:
--------------------------------------------------------------------------------
1 | # 授权登录
2 |
3 | ## 官方文档
4 |
5 | [身份认证官方文档](https://work.weixin.qq.com/api/doc/90000/90135/91020)
6 |
7 | ## 源码
8 |
9 | [TNWX-QyOauthApi](https://gitee.com/javen205/TNWX/blob/master/packages/wxcp/src/QyOauthApi.ts)
10 |
11 | ## 示例
12 |
13 | ```TypeScript
14 | // 构造网页授权链接
15 | app.get('/qyToAuth', (req, res) => {
16 | let url = QyOauthApi.getAuthorizeUrl(QyApiConfigKit.getCorpId,'http://wx.frp.ek208.com/qyAuth','tnwx');
17 | console.log("授权URL:", url);
18 | res.redirect(url);
19 | });
20 | // 构造扫码登录链接
21 | app.get('/getQrConnect', (req, res) => {
22 | let url = QyOauthApi.getQrConnect(QyApiConfigKit.getCorpId,QyApiConfigKit.getAppId,'http://wx.frp.ek208.com/qyAuth','tnwx');
23 | console.log("授权URL:", url);
24 | res.redirect(url);
25 | });
26 | // 根据code获取成员信息
27 | app.get('/qyAuth', (req, res) => {
28 | let code = req.query.code;
29 | let state = req.query.state;
30 | console.log("code:", code, " state:", state);
31 | QyOauthApi.getUserInfo(code)
32 | .then((data) => {
33 | res.send(data);
34 | })
35 | .catch((error) => console.log(error));
36 | });
37 | ```
--------------------------------------------------------------------------------
/docs/docs/guide/wxpay/README.md:
--------------------------------------------------------------------------------
1 | # 让支付触手可及
2 |
3 | ## Node.js 版本
4 |
5 | - 微信支付同时支持 Api-v3 以及 Api-v2 版本接口
6 | - 微信支付同时支持多商户多应用,同时支持国内与境外的普通商户模式和服务商模式
7 | - 微信支付 v2 接口同时支持 MD5 以及 HMAC-SHA256 签名算法
8 | - 不依赖任何 Node.js 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里
9 |
10 |
11 | ## Java 版
12 |
13 | 聚合支付 SDK,[IJPay](https://gitee.com/javen205/IJPay) 让支付触手可及,封装了微信支付、QQ支付、支付宝支付、京东支付、银联支付等常用的支付方式以及各种常用的接口。不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。[https://javen205.gitee.io/ijpay](https://javen205.gitee.io/ijpay)
14 |
15 | - 不依赖任何第三方 MVC 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里
16 | - 微信支付同时支持 Api-v3 以及 Api-v2 版本接口
17 | - 微信支付同时支持多商户多应用,同时支持国内与境外的普通商户模式和服务商模式
18 | - 微信支付 v2 接口同时支持 MD5 以及 HMAC-SHA256 签名算法
19 | - 支付宝支付同时支持普通公钥方式与公钥证书方式
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docs",
3 | "version": "1.0.0",
4 | "description": "docs of tnwx",
5 | "author": "Javen",
6 | "license": "Apache-2.0",
7 | "private": true,
8 | "scripts": {
9 | "docs:dev": "vuepress dev docs",
10 | "docs:build": "vuepress build docs"
11 | },
12 | "devDependencies": {
13 | "@vuepress/plugin-back-to-top": "^1.3.0",
14 | "@vuepress/plugin-google-analytics": "^1.3.0",
15 | "@vuepress/plugin-medium-zoom": "^1.3.0",
16 | "@vuepress/plugin-pwa": "^1.3.0",
17 | "vue-toasted": "^1.1.27",
18 | "vuepress": "^1.3.0"
19 | },
20 | "dependencies": {
21 | "element-ui": "^2.13.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | transform: {
3 | '^.+\\.tsx?$': 'ts-jest'
4 | },
5 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
6 | }
7 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.5.5",
3 | "npmClient": "yarn",
4 | "useWorkspaces": true,
5 | "packages": [
6 | "packages/*"
7 | ],
8 | "command": {
9 | "publish": {
10 | "ignoreChanges": [
11 | "ignored-file",
12 | "*.md"
13 | ]
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "workspaces": [
4 | "packages/*"
5 | ],
6 | "scripts": {
7 | "test": "lerna run test",
8 | "bootstrap": "lerna bootstrap",
9 | "tsc": "lerna run tsc --stream",
10 | "tsc:watch": "lerna run watch --stream",
11 | "pub": "lerna publish --skip-git",
12 | "del": "lerna exec -- rm -rf ./dist"
13 | },
14 | "devDependencies": {
15 | "@types/jest": "^24.0.23",
16 | "jest": "^24.9.0",
17 | "lerna": "^3.17.0",
18 | "prettier": "^1.18.2",
19 | "ts-jest": "^24.2.0",
20 | "typescript": "^3.6.4"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/accesstoken/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/accesstoken
2 |
3 | TNWX 微信系开发脚手架之微信 accesstoken
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/accesstoken/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/accesstoken",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之微信 accesstoken",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "bugs": {
45 | "url": "http://gitee.com/javen205/TNWX/issues"
46 | },
47 | "dependencies": {
48 | "@tnwx/cache": "^2.5.5",
49 | "@tnwx/kits": "^2.5.5"
50 | },
51 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
52 | }
53 |
--------------------------------------------------------------------------------
/packages/accesstoken/src/ApiConfig.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description ApiConfig
5 | */
6 |
7 | export class ApiConfig {
8 | private token: string
9 | // 企业微信为 agentId
10 | private appId: string
11 | // 企业ID
12 | private corpId: string
13 | private appScrect: string
14 | private ticket: string
15 | // 是否加密 企业号必须为 true 微信测试号必须非 false
16 | private encryptMessage: boolean
17 | private encodingAesKey: string
18 |
19 | constructor(appId?: string, appScrect?: string, token?: string, encryptMessage: boolean = false, encodingAesKey?: string, corpId?: string) {
20 | this.appId = appId
21 | this.corpId = corpId
22 | this.appScrect = appScrect
23 | this.encryptMessage = encryptMessage
24 | this.encodingAesKey = encodingAesKey
25 | this.token = token
26 | }
27 |
28 | public get getToken(): string {
29 | return this.token
30 | }
31 |
32 | public set setToken(token: string) {
33 | this.token = token
34 | }
35 |
36 | public get getAppId(): string {
37 | return this.appId
38 | }
39 |
40 | public set setAppId(appId: string) {
41 | this.appId = appId
42 | }
43 |
44 | public get getCorpId(): string {
45 | return this.corpId
46 | }
47 |
48 | public set setCorpId(corpId: string) {
49 | this.corpId = corpId
50 | }
51 |
52 | public get getTicket(): string {
53 | return this.ticket
54 | }
55 |
56 | public set setTicket(ticket: string) {
57 | this.ticket = ticket
58 | }
59 |
60 | public get getAppScrect(): string {
61 | return this.appScrect
62 | }
63 |
64 | public set setAppScrect(appScrect: string) {
65 | this.appScrect = appScrect
66 | }
67 |
68 | public get getEncryptMessage(): boolean {
69 | return this.encryptMessage
70 | }
71 |
72 | public set setEncryptMessage(encryptMessage: boolean) {
73 | this.encryptMessage = encryptMessage
74 | }
75 |
76 | public get getEncodingAesKey(): string {
77 | return this.encodingAesKey
78 | }
79 |
80 | public set setEncodingAesKey(encodingAesKey: string) {
81 | this.encodingAesKey = encodingAesKey
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/packages/accesstoken/src/index.ts:
--------------------------------------------------------------------------------
1 | export { AccessTokenApi } from './AccessTokenApi'
2 | export { AccessToken, AccessTokenType } from './AccessToken'
3 | export { ApiConfig } from './ApiConfig'
4 | export { ApiConfigKit } from './ApiConfigKit'
5 | export { QyApiConfigKit } from './wxcp/QyApiConfigKit'
6 | export { QyAccessTokenApi } from './wxcp/QyAccessTokenApi'
7 | export { OpenCpAccessTokenApi } from './opencp/OpenCpAccessTokenApi'
8 | export { OpenCorpAccessTokenApi } from './opencp/OpenCorpAccessTokenApi'
9 | export { OpenAuthorizerAccessTokenApi } from './openmp/OpenAuthorizerAccessTokenApi'
10 | export { OpenComponentAccessTokenApi } from './openmp/OpenComponentAccessTokenApi'
11 |
--------------------------------------------------------------------------------
/packages/accesstoken/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/cache/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/cache
2 |
3 | TNWX 微信系开发脚手架之缓存
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/cache/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'cache',
5 | displayName: 'cache',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/cache/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/cache",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之缓存",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "jest": {
45 | "testEnvironment": "node"
46 | },
47 | "bugs": {
48 | "url": "http://gitee.com/javen205/TNWX/issues"
49 | },
50 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
51 | }
52 |
--------------------------------------------------------------------------------
/packages/cache/src/DefaultCache.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 默认的缓存策略
5 | */
6 |
7 | import { ICache } from './ICache'
8 |
9 | export class DefaultCache implements ICache {
10 | private map: Map = new Map()
11 |
12 | async get(key: string): Promise {
13 | return this.map.get(key) || ''
14 | }
15 |
16 | async set(key: string, jsonValue: string) {
17 | this.map.set(key, jsonValue)
18 | }
19 |
20 | async remove(key: string) {
21 | this.map.delete(key)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/packages/cache/src/ICache.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description access_token 缓存接口
5 | */
6 |
7 | export interface ICache {
8 | get(key: string): Promise
9 | set(key: string, jsonValue: string): Promise
10 | remove(key: string): Promise
11 | }
12 |
--------------------------------------------------------------------------------
/packages/cache/src/index.ts:
--------------------------------------------------------------------------------
1 | export { DefaultCache } from './DefaultCache'
2 | export { ICache } from './ICache'
3 |
--------------------------------------------------------------------------------
/packages/cache/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/commons/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/commons
2 |
3 | TNWX 微信系开发脚手架之公共模块
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/commons/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'commons',
5 | displayName: 'commons',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/commons/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/commons",
3 | "version": "2.5.5",
4 | "description": "TTNWX 微信系开发脚手架之公共模块",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "jest": {
45 | "testEnvironment": "node"
46 | },
47 | "bugs": {
48 | "url": "http://gitee.com/javen205/TNWX/issues"
49 | },
50 | "dependencies": {
51 | "@tnwx/accesstoken": "^2.5.5",
52 | "@tnwx/cache": "^2.5.5",
53 | "@tnwx/kits": "^2.5.5"
54 | },
55 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
56 | }
57 |
--------------------------------------------------------------------------------
/packages/commons/src/Enums.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 常用枚举
5 | */
6 |
7 | export enum ScopeEnum {
8 | SNSAPI_BASE = 'snsapi_base',
9 | SNSAPI_USERINFO = 'snsapi_userinfo'
10 | }
11 |
12 | export enum Lang {
13 | ZH_CN = 'zh_CN',
14 | ZH_TW = 'zh_TW',
15 | EN = 'en'
16 | }
17 |
18 | export enum JsApiType {
19 | JSAPI = 'jsapi',
20 | WX_CARD = 'wx_card'
21 | }
22 |
23 | export enum QyJsApiType {
24 | CORP = 'corp',
25 | AGENT = 'agent'
26 | }
27 |
--------------------------------------------------------------------------------
/packages/commons/src/api/UniformMessageApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessTokenApi, AccessToken } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 公共 API
8 | */
9 | export class UniformMessageApi {
10 | private static sendUniformMessageUrl: string = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=%s'
11 |
12 | /**
13 | * 下发小程序和公众号统一的服务消息
14 | * @param touser 用户openid
15 | * @param weappTemplateMsg 小程序模板消息相关的信息
16 | * @param mpTemplateMsg 公众号模板消息相关的信息
17 | */
18 | public static async sendUniformMessage(touser: string, mpTemplateMsg: object, weappTemplateMsg?: object) {
19 | let accessToken = await AccessTokenApi.getAccessToken()
20 | let url = util.format(this.sendUniformMessageUrl, (accessToken).getAccessToken)
21 | return HttpKit.getHttpDelegate.httpPost(
22 | url,
23 | JSON.stringify({
24 | touser: touser,
25 | mp_template_msg: mpTemplateMsg,
26 | weapp_template_msg: weappTemplateMsg
27 | })
28 | )
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/JsTicket.ts:
--------------------------------------------------------------------------------
1 | export class JsTicket {
2 | private ticket: string
3 | private expires_in: number
4 | private errcode: number
5 | private errmsg: string
6 |
7 | private expired_time: number
8 | private json: string
9 |
10 | constructor(json: string) {
11 | this.json = json
12 | let ticket = JSON.parse(json)
13 | this.ticket = ticket.ticket
14 | this.expires_in = ticket.expires_in
15 | this.errcode = ticket.errcode
16 | this.errmsg = ticket.errmsg
17 |
18 | if (this.expires_in) {
19 | this.expired_time = new Date().getTime() + (this.expires_in - 9) * 1000
20 | }
21 | // 从缓存读取时还原
22 | if (ticket.expired_time) {
23 | this.expired_time = ticket.expired_time
24 | }
25 | }
26 |
27 | public get getCacheJson(): string {
28 | let temp = JSON.parse(this.json)
29 | temp.expired_time = this.expired_time
30 | return JSON.stringify(temp)
31 | }
32 |
33 | public isAvailable(): boolean {
34 | if (this.expired_time == null) return false
35 | if (this.errcode != null) return false
36 | if (this.expired_time < new Date().getTime()) return false
37 | return this.ticket != null
38 | }
39 |
40 | public get getTicket(): string {
41 | return this.ticket
42 | }
43 |
44 | public set setTicket(ticket: string) {
45 | this.ticket = ticket
46 | }
47 |
48 | public get getExpiresIn(): number {
49 | return this.expires_in
50 | }
51 |
52 | public set setExpiresIn(expires_in: number) {
53 | this.expires_in = expires_in
54 | }
55 |
56 | public get getErrCode(): number {
57 | return this.errcode
58 | }
59 |
60 | public set setErrCode(errcode: number) {
61 | this.errcode = errcode
62 | }
63 |
64 | public get getErrMsg(): string {
65 | return this.errmsg
66 | }
67 |
68 | public set setErrMsg(errmsg: string) {
69 | this.errmsg = errmsg
70 | }
71 |
72 | public get getJson(): string {
73 | return this.json
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/BaseMsg.ts:
--------------------------------------------------------------------------------
1 | export abstract class BaseMsg {}
2 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InAuthEvent.ts:
--------------------------------------------------------------------------------
1 | import { BaseMsg } from '../BaseMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 企业开放平台授权通知事件
7 | */
8 |
9 | export class InAuthEvent extends BaseMsg {
10 | public static CREATE_AUTH: string = 'create_auth'
11 | public static CHANGE_AUTH: string = 'change_auth'
12 | public static CANCEL_AUTH: string = 'cancel_auth'
13 |
14 | private suiteid: string
15 | private authcode: string
16 | private infotype: string
17 | private timestamp: number
18 | private authcorpid: string
19 |
20 | constructor(suiteId: string, infoType: string, timeStamp: number, authCode?: string, authCorpId?: string) {
21 | super()
22 | this.suiteid = suiteId
23 | this.infotype = infoType
24 | this.timestamp = timeStamp
25 | this.authcode = authCode
26 | this.authcorpid = authCorpId
27 | }
28 |
29 | public get suiteId(): string {
30 | return this.suiteid
31 | }
32 |
33 | public set suiteId(suiteId: string) {
34 | this.suiteid = suiteId
35 | }
36 |
37 | public get infoType(): string {
38 | return this.infotype
39 | }
40 |
41 | public set infoType(infoType: string) {
42 | this.infotype = infoType
43 | }
44 |
45 | public get timeStamp(): number {
46 | return this.timestamp
47 | }
48 |
49 | public set timeStamp(timeStamp: number) {
50 | this.timestamp = timeStamp
51 | }
52 |
53 | public get authCode(): string {
54 | return this.authcode
55 | }
56 |
57 | public set authCode(authCode: string) {
58 | this.authcode = authCode
59 | }
60 |
61 | public get authCorpId(): string {
62 | return this.authcorpid
63 | }
64 |
65 | public set authCorpId(authCorpId: string) {
66 | this.authcorpid = authCorpId
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InBatchJobResult.ts:
--------------------------------------------------------------------------------
1 | import { BaseMsg } from '../BaseMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 异步任务回调通知
7 | */
8 |
9 | export class InBatchJobResult extends BaseMsg {
10 | public static INFO_TYPE: string = 'batch_job_result'
11 |
12 | private servicecorpid: string
13 | private infotype: string
14 | private timestamp: number
15 | private authcorpid: string
16 | private jobid: string
17 | private jobtype: string
18 |
19 | constructor(serviceCorpId: string, infoType: string, timeStamp: number, authCorpId: string, jobId: string, jobType: string) {
20 | super()
21 | this.servicecorpid = serviceCorpId
22 | this.infotype = infoType
23 | this.timestamp = timeStamp
24 | this.authcorpid = authCorpId
25 | this.jobid = jobId
26 | this.jobtype = jobType
27 | }
28 |
29 | public get serviceCorpId(): string {
30 | return this.servicecorpid
31 | }
32 |
33 | public set serviceCorpId(serviceCorpId: string) {
34 | this.servicecorpid = serviceCorpId
35 | }
36 |
37 | public get infoType(): string {
38 | return this.infotype
39 | }
40 |
41 | public set infoType(infoType: string) {
42 | this.infotype = infoType
43 | }
44 |
45 | public get timeStamp(): number {
46 | return this.timestamp
47 | }
48 |
49 | public set timeStamp(timeStamp: number) {
50 | this.timestamp = timeStamp
51 | }
52 |
53 | public get authCorpId(): string {
54 | return this.authcorpid
55 | }
56 |
57 | public set authCorpId(authCorpId: string) {
58 | this.authCorpId = authCorpId
59 | }
60 |
61 | public get jobId(): string {
62 | return this.jobid
63 | }
64 |
65 | public set jobId(jobId: string) {
66 | this.jobid = jobId
67 | }
68 |
69 | public get jobType(): string {
70 | return this.jobtype
71 | }
72 |
73 | public set jobType(jobType: string) {
74 | this.jobtype = jobType
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InComponentVerifyTicket.ts:
--------------------------------------------------------------------------------
1 | import { BaseMsg } from '../BaseMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 推送 component_verify_ticket
7 | */
8 |
9 | export class InComponentVerifyTicket extends BaseMsg {
10 | public static INFO_TYPE: string = 'component_verify_ticket'
11 |
12 | private appid: string
13 | private infotype: string
14 | private createtime: number
15 | private ticket: string
16 |
17 | constructor(appId: string, infoType: string, createTime: number, ticket: string) {
18 | super()
19 | this.appid = appId
20 | this.infotype = infoType
21 | this.createtime = createTime
22 | this.ticket = ticket
23 | }
24 |
25 | public get appId(): string {
26 | return this.appid
27 | }
28 |
29 | public set appId(appId: string) {
30 | this.appid = appId
31 | }
32 |
33 | public get infoType(): string {
34 | return this.infotype
35 | }
36 |
37 | public set infoType(infoType: string) {
38 | this.infotype = infoType
39 | }
40 |
41 | public get createTime(): number {
42 | return this.createtime
43 | }
44 |
45 | public set timeStamp(createTime: number) {
46 | this.createtime = createTime
47 | }
48 |
49 | public get getTicket(): string {
50 | return this.ticket
51 | }
52 |
53 | public set setTicket(ticket: string) {
54 | this.ticket = ticket
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InImageMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收图片消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InImageMsg extends InMsg {
9 | private picUrl: string
10 | private mediaId: string
11 | private msgId: string
12 |
13 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
14 | super(toUserName, fromUserName, createTime, msgType)
15 | }
16 |
17 | public get getPicUrl(): string {
18 | return this.picUrl
19 | }
20 |
21 | public set setPicUrl(picUrl: string) {
22 | this.picUrl = picUrl
23 | }
24 |
25 | public get getMediaId(): string {
26 | return this.mediaId
27 | }
28 |
29 | public set setMediaId(mediaId: string) {
30 | this.mediaId = mediaId
31 | }
32 |
33 | public get getMsgId(): string {
34 | return this.msgId
35 | }
36 |
37 | public set setMsgId(msgId: string) {
38 | this.msgId = msgId
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InLinkMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收链接消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InLinkMsg extends InMsg {
9 | private title: string
10 | private description: string
11 | private url: string
12 | private msgId: string
13 |
14 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
15 | super(toUserName, fromUserName, createTime, msgType)
16 | }
17 |
18 | public get getTitle(): string {
19 | return this.title
20 | }
21 |
22 | public set setTitle(title: string) {
23 | this.title = title
24 | }
25 |
26 | public get getDescription(): string {
27 | return this.description
28 | }
29 |
30 | public set setDescription(description: string) {
31 | this.description = description
32 | }
33 |
34 | public get getUrl(): string {
35 | return this.url
36 | }
37 |
38 | public set setUrl(url: string) {
39 | this.url = url
40 | }
41 |
42 | public get getMsgId(): string {
43 | return this.msgId
44 | }
45 |
46 | public set setMsgId(msgId: string) {
47 | this.msgId = msgId
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InLocationMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收地理位置消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InLocationMsg extends InMsg {
9 | private location_X: string
10 | private location_Y: string
11 | private scale: string
12 | private label: string
13 | private msgId: string
14 |
15 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
16 | super(toUserName, fromUserName, createTime, msgType)
17 | }
18 |
19 | public get getLocation_X(): string {
20 | return this.location_X
21 | }
22 |
23 | public set setLocation_X(location_X: string) {
24 | this.location_X = location_X
25 | }
26 |
27 | public get getLocation_Y(): string {
28 | return this.location_Y
29 | }
30 |
31 | public set setLocation_Y(location_Y: string) {
32 | this.location_Y = location_Y
33 | }
34 |
35 | public get getScale(): string {
36 | return this.scale
37 | }
38 |
39 | public set setScale(scale: string) {
40 | this.scale = scale
41 | }
42 |
43 | public get getLabel(): string {
44 | return this.label
45 | }
46 |
47 | public set setLabel(label: string) {
48 | this.label = label
49 | }
50 |
51 | public get getMsgId(): string {
52 | return this.msgId
53 | }
54 |
55 | public set setMsgId(msgId: string) {
56 | this.msgId = msgId
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InMsg.ts:
--------------------------------------------------------------------------------
1 | import { BaseMsg } from '../BaseMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 接收消息抽象类
7 | */
8 |
9 | export abstract class InMsg extends BaseMsg {
10 | protected toUserName: string //开发者微信号
11 | protected fromUserName: string //发送方帐号openId
12 | protected createTime: number //消息创建时间
13 | protected agentId: string // 企业号的应用ID
14 | /**
15 | * 消息类型
16 | * 1:text 文本消息
17 | * 2:image 图片消息
18 | * 3:voice 语音消息
19 | * 4:video 视频消息
20 | * 5:location 地址位置消息
21 | * 6:link 链接消息
22 | * 7:event 事件
23 | */
24 | protected msgType: string //消息类型
25 |
26 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
27 | super()
28 | this.toUserName = toUserName
29 | this.fromUserName = fromUserName
30 | this.createTime = createTime
31 | this.msgType = msgType
32 | }
33 |
34 | public get getToUserName(): string {
35 | return this.toUserName
36 | }
37 |
38 | public set setToUserName(toUserName: string) {
39 | this.toUserName = toUserName
40 | }
41 |
42 | public get getFromUserName(): string {
43 | return this.fromUserName
44 | }
45 |
46 | public set setFromUserName(fromUserName: string) {
47 | this.fromUserName = fromUserName
48 | }
49 |
50 | public get getCreateTime(): number {
51 | return this.createTime
52 | }
53 |
54 | public set setCreateTime(createTime: number) {
55 | this.createTime = createTime
56 | }
57 |
58 | public get getMsgType(): string {
59 | return this.msgType
60 | }
61 |
62 | public set setMsgType(msgType: string) {
63 | this.msgType = msgType
64 | }
65 |
66 | public get getAgentId(): string {
67 | return this.agentId
68 | }
69 |
70 | public set setAgentId(agentId: string) {
71 | this.agentId = agentId
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InNotDefinedMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 未知消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InNotDefinedMsg extends InMsg {
9 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
10 | super(toUserName, fromUserName, createTime, msgType)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InShortVideoMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收视频消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InShortVideoMsg extends InMsg {
9 | private mediaId: string
10 | private thumbMediaId: string
11 | private msgId: string
12 |
13 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
14 | super(toUserName, fromUserName, createTime, msgType)
15 | }
16 |
17 | public get getMediaId(): string {
18 | return this.mediaId
19 | }
20 |
21 | public set setMediaId(mediaId: string) {
22 | this.mediaId = mediaId
23 | }
24 |
25 | public get getThumbMediaId(): string {
26 | return this.thumbMediaId
27 | }
28 |
29 | public set setThumbMediaId(thumbMediaId: string) {
30 | this.thumbMediaId = thumbMediaId
31 | }
32 |
33 | public get getMsgId(): string {
34 | return this.msgId
35 | }
36 |
37 | public set setMsgId(msgId: string) {
38 | this.msgId = msgId
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InSpeechRecognitionResults.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收语音识别结果,与 InVoiceMsg 唯一的不同是多了一个 Recognition 标记
5 | */
6 | import { InVoiceMsg } from './InVoiceMsg'
7 |
8 | export class InSpeechRecognitionResults extends InVoiceMsg {
9 | private recognition: string
10 |
11 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
12 | super(toUserName, fromUserName, createTime, msgType)
13 | }
14 |
15 | public get getRecognition(): string {
16 | return this.recognition
17 | }
18 |
19 | public set setRecognition(recognition: string) {
20 | this.recognition = recognition
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InSuiteTicket.ts:
--------------------------------------------------------------------------------
1 | import { BaseMsg } from '../BaseMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 推送suite_ticket
7 | */
8 |
9 | export class InSuiteTicket extends BaseMsg {
10 | public static INFO_TYPE: string = 'suite_ticket'
11 |
12 | private suiteid: string
13 | private infotype: string
14 | private timestamp: number
15 | private suiteticket: string
16 |
17 | constructor(suiteId: string, infoType: string, timeStamp: number, suiteTicket: string) {
18 | super()
19 | this.suiteid = suiteId
20 | this.infotype = infoType
21 | this.timestamp = timeStamp
22 | this.suiteticket = suiteTicket
23 | }
24 |
25 | public get suiteId(): string {
26 | return this.suiteid
27 | }
28 |
29 | public set suiteId(suiteId: string) {
30 | this.suiteid = suiteId
31 | }
32 |
33 | public get infoType(): string {
34 | return this.infotype
35 | }
36 |
37 | public set infoType(infoType: string) {
38 | this.infotype = infoType
39 | }
40 |
41 | public get timeStamp(): number {
42 | return this.timestamp
43 | }
44 |
45 | public set timeStamp(timeStamp: number) {
46 | this.timestamp = timeStamp
47 | }
48 |
49 | public get suiteTicket(): string {
50 | return this.suiteticket
51 | }
52 |
53 | public set suiteTicket(suiteTicket: string) {
54 | this.suiteticket = suiteTicket
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InTextMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收文本消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InTextMsg extends InMsg {
9 | private content: string
10 | private msgId: string
11 |
12 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
13 | super(toUserName, fromUserName, createTime, msgType)
14 | }
15 |
16 | public get getContent(): string {
17 | return this.content
18 | }
19 |
20 | public set setContent(content: string) {
21 | this.content = content
22 | }
23 |
24 | public get getMsgId(): string {
25 | return this.msgId
26 | }
27 |
28 | public set setMsgId(msgId: string) {
29 | this.msgId = msgId
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InVideoMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收视频消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InVideoMsg extends InMsg {
9 | private mediaId: string
10 | private thumbMediaId: string
11 | private msgId: string
12 |
13 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
14 | super(toUserName, fromUserName, createTime, msgType)
15 | }
16 |
17 | public get getMediaId(): string {
18 | return this.mediaId
19 | }
20 |
21 | public set setMediaId(mediaId: string) {
22 | this.mediaId = mediaId
23 | }
24 |
25 | public get getThumbMediaId(): string {
26 | return this.thumbMediaId
27 | }
28 |
29 | public set setThumbMediaId(thumbMediaId: string) {
30 | this.thumbMediaId = thumbMediaId
31 | }
32 |
33 | public get getMsgId(): string {
34 | return this.msgId
35 | }
36 |
37 | public set setMsgId(msgId: string) {
38 | this.msgId = msgId
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/InVoiceMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 接收语音消息
5 | */
6 | import { InMsg } from './InMsg'
7 |
8 | export class InVoiceMsg extends InMsg {
9 | private mediaId: string
10 | private format: string
11 | private msgId: string
12 |
13 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
14 | super(toUserName, fromUserName, createTime, msgType)
15 | }
16 |
17 | public get getMediaId(): string {
18 | return this.mediaId
19 | }
20 |
21 | public set setMediaId(mediaId: string) {
22 | this.mediaId = mediaId
23 | }
24 |
25 | public get getFormat(): string {
26 | return this.format
27 | }
28 |
29 | public set setFormat(format: string) {
30 | this.format = format
31 | }
32 |
33 | public get getMsgId(): string {
34 | return this.msgId
35 | }
36 |
37 | public set setMsgId(msgId: string) {
38 | this.msgId = msgId
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InCardMerchantCheckResultEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from '../event/EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 子商户审核事件推送
7 | */
8 | export class InCardMerchantCheckResultEvent extends EventInMsg {
9 | public static EVENT: string = 'card_merchant_check_result'
10 |
11 | /**
12 | * 子商户ID
13 | */
14 | private merchantId: string
15 | /**
16 | * 是否通过,为1时审核通过
17 | */
18 | private isPass: number
19 | /**
20 | * 驳回的原因
21 | */
22 | private reason: string
23 |
24 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
25 | super(toUserName, fromUserName, createTime, msgType)
26 | }
27 |
28 | public get getMerchantId(): string {
29 | return this.merchantId
30 | }
31 |
32 | public set setMerchantId(merchantId: string) {
33 | this.merchantId = merchantId
34 | }
35 |
36 | public get getIsPass(): number {
37 | return this.isPass
38 | }
39 |
40 | public set setIsPass(isPass: number) {
41 | this.isPass = isPass
42 | }
43 |
44 | public get geteason(): string {
45 | return this.reason
46 | }
47 |
48 | public set setReason(reason: string) {
49 | this.reason = reason
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InCardPassCheckEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 审核事件推送
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InCardPassCheckEvent extends EventInMsg {
9 | public static EVENT_PASS: string = 'card_pass_check'
10 | public static EVENT_NOT_PASS: string = 'card_not_pass_check'
11 |
12 | /**
13 | * 卡券ID
14 | */
15 | private cardId: string
16 | /**
17 | * 审核不通过原因
18 | */
19 | private refuseReason: string
20 |
21 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
22 | super(toUserName, fromUserName, createTime, msgType)
23 | }
24 |
25 | public get getCardId(): string {
26 | return this.cardId
27 | }
28 |
29 | public set setCardId(cardId: string) {
30 | this.cardId = cardId
31 | }
32 |
33 | public get getRefuseReason(): string {
34 | return this.refuseReason
35 | }
36 |
37 | public set setRefuseReason(refuseReason: string) {
38 | this.refuseReason = refuseReason
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InCardSkuRemindEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 库存报警事件
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InCardSkuRemindEvent extends EventInMsg {
9 | public static EVENT: string = 'card_pay_order'
10 |
11 | private cardId: string //卡券ID
12 | private detail: string //报警详细信息
13 |
14 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
15 | super(toUserName, fromUserName, createTime, msgType)
16 | }
17 |
18 | public get getCardId(): string {
19 | return this.cardId
20 | }
21 | public set setCardId(cardId: string) {
22 | this.cardId = cardId
23 | }
24 | public get getDetail() {
25 | return this.detail
26 | }
27 | public set setDetail(detail: string) {
28 | this.detail = detail
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InMerChantOrderEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信小店订单支付成功接口消息
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InMerChantOrderEvent extends EventInMsg {
9 | public static EVENT: string = 'merchant_order'
10 |
11 | private orderId: string
12 | private orderStatus: number
13 | private productId: string
14 | private skuInfo: string
15 |
16 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
17 | super(toUserName, fromUserName, createTime, msgType)
18 | }
19 |
20 | public get getOrderId(): string {
21 | return this.orderId
22 | }
23 |
24 | public set setOrderId(orderId: string) {
25 | this.orderId = orderId
26 | }
27 |
28 | public get getOrderStatus(): number {
29 | return this.orderStatus
30 | }
31 |
32 | public set setOrderStatus(orderStatus: number) {
33 | this.orderStatus = orderStatus
34 | }
35 |
36 | public get getProductId(): string {
37 | return this.productId
38 | }
39 |
40 | public set setProductId(productId: string) {
41 | this.productId = productId
42 | }
43 |
44 | public get getSkuInfo(): string {
45 | return this.skuInfo
46 | }
47 |
48 | public set setSkuInfo(skuInfo: string) {
49 | this.skuInfo = skuInfo
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InUpdateMemberCardEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信会员卡积分变更
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InUpdateMemberCardEvent extends EventInMsg {
9 | public static EVENT: string = 'update_member_card'
10 |
11 | private cardId: string
12 | private userCardCode: string
13 | private modifyBonus: string
14 | private modifyBalance: string
15 |
16 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
17 | super(toUserName, fromUserName, createTime, msgType)
18 | }
19 |
20 | public get getCardId(): string {
21 | return this.cardId
22 | }
23 |
24 | public set setCardId(cardId: string) {
25 | this.cardId = cardId
26 | }
27 |
28 | public get getUserCardCode(): string {
29 | return this.userCardCode
30 | }
31 |
32 | public set setUserCardCode(userCardCode: string) {
33 | this.userCardCode = userCardCode
34 | }
35 |
36 | public get getModifyBalance(): string {
37 | return this.modifyBalance
38 | }
39 |
40 | public set setModifyBalance(modifyBalance: string) {
41 | this.modifyBalance = modifyBalance
42 | }
43 |
44 | public get getModifyBonus(): string {
45 | return this.modifyBonus
46 | }
47 |
48 | public set setModifyBonus(modifyBonus: string) {
49 | this.modifyBonus = modifyBonus
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InUserCardEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信会员卡卡券
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InUserCardEvent extends EventInMsg {
9 | // 微信会员卡激活接口
10 | public static EVENT_MEMBERCARD: string = 'submit_membercard_user_info'
11 | // 微信会员卡二维码扫描领取接口
12 | public static EVENT_USER_VIEW: string = 'user_view_card'
13 | // 从卡券进入公众号会话事件推送
14 | public static EVENT_USER_ENTER: string = 'user_enter_session_from_card'
15 | // 卡券删除事件推送
16 | public static EVENT_USER_DEL: string = 'user_del_card'
17 |
18 | private cardId: string
19 | private userCardCode: string
20 |
21 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
22 | super(toUserName, fromUserName, createTime, msgType)
23 | }
24 |
25 | public get getCardId(): string {
26 | return this.cardId
27 | }
28 |
29 | public set setCardId(cardId: string) {
30 | this.cardId = cardId
31 | }
32 |
33 | public get getUserCardCode(): string {
34 | return this.userCardCode
35 | }
36 |
37 | public set setUserCardCode(userCardCode: string) {
38 | this.userCardCode = userCardCode
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InUserGiftingCardEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 转赠事件推送
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InUserGiftingCardEvent extends EventInMsg {
9 | public static EVENT: string = 'user_gifting_card'
10 |
11 | private cardId: string
12 | private userCardCode: string
13 | private isReturnBack: string
14 | private friendUserName: string
15 | private isChatRoom: string
16 |
17 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
18 | super(toUserName, fromUserName, createTime, msgType)
19 | }
20 |
21 | public get getCardId(): string {
22 | return this.cardId
23 | }
24 |
25 | public set setCardId(cardId: string) {
26 | this.cardId = cardId
27 | }
28 |
29 | public get getUserCardCode(): string {
30 | return this.userCardCode
31 | }
32 |
33 | public set setUserCardCode(userCardCode: string) {
34 | this.userCardCode = userCardCode
35 | }
36 |
37 | public get getIsReturnBack(): string {
38 | return this.isReturnBack
39 | }
40 |
41 | public set setIsReturnBack(isReturnBack: string) {
42 | this.isReturnBack = isReturnBack
43 | }
44 |
45 | public get getFriendUserName(): string {
46 | return this.friendUserName
47 | }
48 |
49 | public set setFriendUserName(friendUserName: string) {
50 | this.friendUserName = friendUserName
51 | }
52 |
53 | public get getIsChatRoom(): string {
54 | return this.isChatRoom
55 | }
56 |
57 | public set setIsChatRoom(isChatRoom: string) {
58 | this.isChatRoom = isChatRoom
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/card/InUserPayFromCardEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信会员卡快速买单
5 | */
6 | import { EventInMsg } from '../event/EventInMsg'
7 |
8 | export class InUserPayFromCardEvent extends EventInMsg {
9 | public static EVENT: string = 'user_pay_from_pay_cell'
10 |
11 | private cardId: string
12 | private userCardCode: string
13 | private transId: string
14 | private locationId: string
15 | private fee: string
16 | private originalFee: string
17 |
18 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
19 | super(toUserName, fromUserName, createTime, msgType)
20 | }
21 |
22 | public get getCardId(): string {
23 | return this.cardId
24 | }
25 |
26 | public set setCardId(cardId: string) {
27 | this.cardId = cardId
28 | }
29 |
30 | public get getUserCardCode(): string {
31 | return this.userCardCode
32 | }
33 |
34 | public set setUserCardCode(userCardCode: string) {
35 | this.userCardCode = userCardCode
36 | }
37 |
38 | public get getTransId(): string {
39 | return this.transId
40 | }
41 |
42 | public set setTransId(transId: string) {
43 | this.transId = transId
44 | }
45 |
46 | public get getLocationId(): string {
47 | return this.locationId
48 | }
49 |
50 | public set setLocationId(locationId: string) {
51 | this.locationId = locationId
52 | }
53 |
54 | public get getFee(): string {
55 | return this.fee
56 | }
57 |
58 | public set setFee(fee: string) {
59 | this.fee = fee
60 | }
61 |
62 | public get getOriginalFee(): string {
63 | return this.originalFee
64 | }
65 |
66 | public set setOriginalFee(originalFee: string) {
67 | this.originalFee = originalFee
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/EventInMsg.ts:
--------------------------------------------------------------------------------
1 | import { InMsg } from '../InMsg'
2 |
3 | export abstract class EventInMsg extends InMsg {
4 | protected event: string
5 |
6 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
7 | super(toUserName, fromUserName, createTime, 'event')
8 | this.event = event
9 | }
10 |
11 | public get getEvent(): string {
12 | return this.event
13 | }
14 |
15 | public set setEvent(event: string) {
16 | this.event = event
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InBatchJobResultEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 异步任务完成通知
7 | */
8 | export class InBatchJobResultEvent extends EventInMsg {
9 | public static EVENT: string = 'batch_job_result'
10 |
11 | private jobId: string
12 | private jobType: string
13 | private eventCode: number
14 | private eventMsg: string
15 |
16 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
17 | super(toUserName, fromUserName, createTime, event)
18 | }
19 |
20 | public get getJobId(): string {
21 | return this.jobId
22 | }
23 |
24 | public set setJobId(jobId: string) {
25 | this.jobId = jobId
26 | }
27 |
28 | public set setJobType(jobType: string) {
29 | this.jobType = jobType
30 | }
31 |
32 | public get getJobType(): string {
33 | return this.jobType
34 | }
35 |
36 | public set setEventCode(eventCode: number) {
37 | this.eventCode = eventCode
38 | }
39 |
40 | public get getEventCode(): number {
41 | return this.eventCode
42 | }
43 |
44 | public set setEventMsg(eventMsg: string) {
45 | this.eventMsg = eventMsg
46 | }
47 | public get getEventMsg(): string {
48 | return this.eventMsg
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InCustomEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 客服消息事件
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InCustomEvent extends EventInMsg {
9 | // 接入会话:kf_create_session
10 | public static EVENT_INCUSTOM_KF_CREATE_SESSION: string = 'kf_create_session'
11 | // 关闭会话:kf_close_session
12 | public static EVENT_INCUSTOM_KF_CLOSE_SESSION: string = 'kf_close_session'
13 | // 转接会话:kf_switch_session
14 | public static EVENT_INCUSTOM_KF_SWITCH_SESSION: string = 'kf_switch_session'
15 |
16 | private kfAccount: string
17 | private toKfAccount: string
18 |
19 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
20 | super(toUserName, fromUserName, createTime, event)
21 | }
22 |
23 | public get getKfAccount(): string {
24 | return this.kfAccount
25 | }
26 |
27 | public set setKfAccount(kfAccount: string) {
28 | this.kfAccount = kfAccount
29 | }
30 |
31 | public get getToKfAccount(): string {
32 | return this.toKfAccount
33 | }
34 |
35 | public set setToKfAccount(toKfAccount: string) {
36 | this.toKfAccount = toKfAccount
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InEnterAgentEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InEnterAgentEvent extends EventInMsg {
4 | public static EVENT: string = 'enter_agent'
5 |
6 | private eventKey: string
7 |
8 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
9 | super(toUserName, fromUserName, createTime, event)
10 | }
11 |
12 | public get getEventKey(): string {
13 | return this.eventKey
14 | }
15 |
16 | public set setEventKey(eventKey: string) {
17 | this.eventKey = eventKey
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InExternalContactEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 企业客户事件
7 | */
8 |
9 | export class InExternalContactEvent extends EventInMsg {
10 | public static EVENT: string = 'change_external_contact'
11 |
12 | private changetype: string
13 | private userid: string
14 | private externaluserid: string
15 | private state: string
16 | private welcomecode: string
17 |
18 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
19 | super(toUserName, fromUserName, createTime, event)
20 | }
21 |
22 | public get changeType(): string {
23 | return this.changetype
24 | }
25 |
26 | public set changeType(changeType: string) {
27 | this.changetype = changeType
28 | }
29 |
30 | public get userId(): string {
31 | return this.userid
32 | }
33 |
34 | public set userId(userId: string) {
35 | this.userid = userId
36 | }
37 |
38 | public get externalUserId(): string {
39 | return this.externaluserid
40 | }
41 |
42 | public set externalUserId(externalUserId: string) {
43 | this.externaluserid = externalUserId
44 | }
45 |
46 | public get getState(): string {
47 | return this.state
48 | }
49 |
50 | public set setState(state: string) {
51 | this.state = state
52 | }
53 |
54 | public get welcomeCode(): string {
55 | return this.welcomecode
56 | }
57 |
58 | public set welcomeCode(welcomeCode: string) {
59 | this.welcomecode = welcomeCode
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InFollowEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InFollowEvent extends EventInMsg {
4 | // 订阅:subscribe
5 | public static EVENT_INFOLLOW_SUBSCRIBE = 'subscribe'
6 | // 取消订阅:unsubscribe
7 | public static EVENT_INFOLLOW_UNSUBSCRIBE = 'unsubscribe'
8 |
9 | private eventKey: string
10 |
11 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
12 | super(toUserName, fromUserName, createTime, event)
13 | }
14 |
15 | public get getEventKey(): string {
16 | return this.eventKey
17 | }
18 |
19 | public set setEventKey(eventKey: string) {
20 | this.eventKey = eventKey
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InLocationEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InLocationEvent extends EventInMsg {
4 | public static EVENT: string = 'LOCATION'
5 |
6 | private latitude: string
7 | private longitude: string
8 | private precision: string
9 |
10 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
11 | super(toUserName, fromUserName, createTime, event)
12 | }
13 |
14 | public get getLatitude(): string {
15 | return this.latitude
16 | }
17 |
18 | public set setLatitude(latitude: string) {
19 | this.latitude = latitude
20 | }
21 |
22 | public get getLongitude(): string {
23 | return this.longitude
24 | }
25 |
26 | public set setLongitude(longitude: string) {
27 | this.longitude = longitude
28 | }
29 |
30 | public get getPrecision(): string {
31 | return this.precision
32 | }
33 |
34 | public set setPrecision(precision: string) {
35 | this.precision = precision
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InMassEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 群发结果
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InMassEvent extends EventInMsg {
9 | public static EVENT: string = 'MASSSENDJOBFINISH'
10 | //群发成功
11 | public static EVENT_INMASS_STATUS_SENDSUCCESS: string = 'sendsuccess'
12 | //群发失败,其他失败情况是err(num)
13 | public static EVENT_INMASS_STATUS_SENDFAIL: string = 'sendfail'
14 |
15 | private msgId: string
16 | private status: string
17 | private totalCount: string
18 | private filterCount: string
19 | private sentCount: string
20 | private errorCount: string
21 |
22 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
23 | super(toUserName, fromUserName, createTime, event)
24 | }
25 |
26 | public get getMsgId(): string {
27 | return this.msgId
28 | }
29 |
30 | public set setMsgId(msgId: string) {
31 | this.msgId = msgId
32 | }
33 |
34 | public get getStatus(): string {
35 | return this.status
36 | }
37 |
38 | public set setStatus(status: string) {
39 | this.status = status
40 | }
41 |
42 | public get getTotalCount(): string {
43 | return this.totalCount
44 | }
45 |
46 | public set setTotalCount(totalCount: string) {
47 | this.totalCount = totalCount
48 | }
49 |
50 | public get getFilterCount(): string {
51 | return this.filterCount
52 | }
53 |
54 | public set setFilterCount(filterCount: string) {
55 | this.filterCount = filterCount
56 | }
57 |
58 | public get getSentCount(): string {
59 | return this.sentCount
60 | }
61 |
62 | public set setSentCount(sentCount: string) {
63 | this.sentCount = sentCount
64 | }
65 |
66 | public get getErrorCount(): string {
67 | return this.errorCount
68 | }
69 |
70 | public set setErrorCount(errorCount: string) {
71 | this.errorCount = errorCount
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InNotDefinedEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InNotDefinedEvent extends EventInMsg {
4 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
5 | super(toUserName, fromUserName, createTime, event)
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InPoiCheckNotifyEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 门店审核通知事件
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InPoiCheckNotifyEvent extends EventInMsg {
9 | public static EVENT: string = 'poi_check_notify'
10 |
11 | private uniqId: string
12 | private poiId: string
13 | private result: string
14 | private msg: string
15 |
16 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
17 | super(toUserName, fromUserName, createTime, event)
18 | }
19 |
20 | public get getUniqId(): string {
21 | return this.uniqId
22 | }
23 |
24 | public set setUniqId(uniqId: string) {
25 | this.uniqId = uniqId
26 | }
27 |
28 | public get getPoiId(): string {
29 | return this.poiId
30 | }
31 |
32 | public set setPoiId(poiId: string) {
33 | this.poiId = poiId
34 | }
35 |
36 | public get getResult(): string {
37 | return this.result
38 | }
39 |
40 | public set setResult(result: string) {
41 | this.result = result
42 | }
43 |
44 | public get getMsg(): string {
45 | return this.msg
46 | }
47 |
48 | public set setMsg(msg: string) {
49 | this.msg = msg
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InQrCodeEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InQrCodeEvent extends EventInMsg {
4 | // 用户未关注时,进行关注后的事件推送: subscribe
5 | public static EVENT_INQRCODE_SUBSCRIBE = 'subscribe'
6 |
7 | // 用户已关注时的事件推送: SCAN
8 | public static EVENT_INQRCODE_SCAN = 'SCAN'
9 |
10 | private eventKey: string
11 | private ticket: string
12 |
13 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
14 | super(toUserName, fromUserName, createTime, event)
15 | }
16 |
17 | public get getEventKey(): string {
18 | return this.eventKey
19 | }
20 |
21 | public set setEventKey(eventKey: string) {
22 | this.eventKey = eventKey
23 | }
24 |
25 | public get getTicket(): string {
26 | return this.ticket
27 | }
28 |
29 | public set setTicket(ticket: string) {
30 | this.ticket = ticket
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InShakearoundUserShakeEvent.ts:
--------------------------------------------------------------------------------
1 | import { InMsg } from '../InMsg'
2 |
3 | export class InShakearoundUserShakeEvent extends InMsg {
4 | private event: string //事件
5 | private uuid: string
6 | private major: number
7 | private minor: number
8 | private distance: number //设备与用户的距离(浮点数;单位:米)
9 | private aroundBeaconList: AroundBeacon[]
10 |
11 | constructor(toUserName: string, fromUserName: string, createTime: number, msgType: string) {
12 | super(toUserName, fromUserName, createTime, msgType)
13 | }
14 |
15 | public get getEvent(): string {
16 | return this.event
17 | }
18 | public set setEvent(event: string) {
19 | this.event = event
20 | }
21 |
22 | public get getUuid(): string {
23 | return this.uuid
24 | }
25 | public set setUuid(uuid: string) {
26 | this.uuid = uuid
27 | }
28 |
29 | public get getMajor(): number {
30 | return this.major
31 | }
32 | public set setMajor(major: number) {
33 | this.major = major
34 | }
35 |
36 | public get getMinor(): number {
37 | return this.minor
38 | }
39 | public set setMinor(minor: number) {
40 | this.minor = minor
41 | }
42 |
43 | public get getDistance(): number {
44 | return this.distance
45 | }
46 | public set setDistance(distance: number) {
47 | this.distance = distance
48 | }
49 |
50 | public get getAroundBeaconList(): AroundBeacon[] {
51 | return this.aroundBeaconList
52 | }
53 | public set setAroundBeaconList(aroundBeaconList: AroundBeacon[]) {
54 | this.aroundBeaconList = aroundBeaconList
55 | }
56 | }
57 |
58 | export class AroundBeacon {
59 | private uuid: string
60 | private major: number
61 | private minor: number
62 | private distance: number //设备与用户的距离(浮点数;单位:米)
63 |
64 | constructor(uuid: string, major: number, minor: number, distance: number) {
65 | this.uuid = uuid
66 | this.major = major
67 | this.minor = minor
68 | this.distance = distance
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InTaskEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InTaskEvent extends EventInMsg {
4 | public static EVENT: string = 'taskcard_click'
5 |
6 | private eventKey: string
7 | private taskId: string
8 |
9 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
10 | super(toUserName, fromUserName, createTime, event)
11 | }
12 |
13 | public get getEventKey(): string {
14 | return this.eventKey
15 | }
16 |
17 | public set setEventKey(eventKey: string) {
18 | this.eventKey = eventKey
19 | }
20 |
21 | public get getTaskId(): string {
22 | return this.taskId
23 | }
24 |
25 | public set setTaskId(taskId: string) {
26 | this.taskId = taskId
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InTemplateMsgEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | export class InTemplateMsgEvent extends EventInMsg {
4 | public static EVENT: string = 'TEMPLATESENDJOBFINISH'
5 | //"success": 成功
6 | public static EVENT_INTEMPLATEMSG_STATUS_SUCCESS: string = 'success'
7 | //"block": 用户拒绝接收
8 | public static EVENT_INTEMPLATEMSG_STATUS_BLOCK: string = 'block'
9 | //"failed: system failed": 发送失败(非用户拒绝)
10 | public static EVENT_INTEMPLATEMSG_STATUS_FAILED: string = 'failed: system failed'
11 |
12 | private msgId: string
13 | private status: string
14 |
15 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
16 | super(toUserName, fromUserName, createTime, event)
17 | }
18 |
19 | public get getMsgId(): string {
20 | return this.msgId
21 | }
22 |
23 | public set setMsgId(msgId: string) {
24 | this.msgId = msgId
25 | }
26 |
27 | public get getStatus(): string {
28 | return this.status
29 | }
30 |
31 | public set setStatus(status: string) {
32 | this.status = status
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InUpdatePartyEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 部门变更通知
7 | */
8 | export class InUpdatePartyEvent extends EventInMsg {
9 | public static CREATE_PARTY: string = 'create_party'
10 | public static UPDATE_PARTY: string = 'update_party'
11 | public static DELETE_PARTY: string = 'delete_party'
12 |
13 | private changeType: string
14 | private id: number
15 | private name: string
16 | private parentId: string
17 | private order: number
18 |
19 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
20 | super(toUserName, fromUserName, createTime, event)
21 | }
22 |
23 | public get getChangeType(): string {
24 | return this.changeType
25 | }
26 |
27 | public set setChangeType(changeType: string) {
28 | this.changeType = changeType
29 | }
30 |
31 | public get getId(): number {
32 | return this.id
33 | }
34 |
35 | public set setId(id: number) {
36 | this.id = id
37 | }
38 |
39 | public set setName(name: string) {
40 | this.name = name
41 | }
42 |
43 | public get getName(): string {
44 | return this.name
45 | }
46 |
47 | public set setParentId(parentId: string) {
48 | this.parentId = parentId
49 | }
50 |
51 | public get getParentId(): string {
52 | return this.parentId
53 | }
54 |
55 | public set setOrder(order: number) {
56 | this.order = order
57 | }
58 |
59 | public get getOrder(): number {
60 | return this.order
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InUpdateTagEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 标签变更通知
7 | */
8 | export class InUpdateTagEvent extends EventInMsg {
9 | public static CHANGE_TYPE: string = 'update_tag'
10 |
11 | private tagId: number
12 | private addUserItems: string
13 | private delUserItems: string
14 | private addPartyItems: string
15 | private delPartyItems: string
16 |
17 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
18 | super(toUserName, fromUserName, createTime, event)
19 | }
20 |
21 | public get getTagId(): number {
22 | return this.tagId
23 | }
24 |
25 | public set setTagId(tagId: number) {
26 | this.tagId = tagId
27 | }
28 |
29 | public set setAddUserItems(addUserItems: string) {
30 | this.addUserItems = addUserItems
31 | }
32 |
33 | public get getAddUserItems(): string {
34 | return this.addUserItems
35 | }
36 |
37 | public set setDelUserItems(delUserItems: string) {
38 | this.delUserItems = delUserItems
39 | }
40 |
41 | public get getDelUserItems(): string {
42 | return this.delUserItems
43 | }
44 |
45 | public set setAddPartyItems(addPartyItems: string) {
46 | this.addPartyItems = addPartyItems
47 | }
48 |
49 | public get getAddPartyItems(): string {
50 | return this.addPartyItems
51 | }
52 |
53 | public set setDelPartyItems(delPartyItems: string) {
54 | this.delPartyItems = delPartyItems
55 | }
56 |
57 | public get getDelPartyItems(): string {
58 | return this.delPartyItems
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InVerifyFailEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 资质认证失败通知事件
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InVerifyFailEvent extends EventInMsg {
9 | //资质认证失败
10 | public static EVENT_IN_QUALIFICATION_VERIFY_FAIL: string = 'qualification_verify_fail'
11 | //名称认证失败
12 | public static EVENT_IN_NAMING_VERIFY_FAIL: string = 'naming_verify_fail'
13 |
14 | private failTime: string
15 | private failReason: string
16 |
17 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
18 | super(toUserName, fromUserName, createTime, event)
19 | }
20 | public get getFailTime(): string {
21 | return this.failTime
22 | }
23 |
24 | public set setFailTime(failTime: string) {
25 | this.failTime = failTime
26 | }
27 |
28 | public get getFailReason(): string {
29 | return this.failReason
30 | }
31 |
32 | public set setFailReason(failReason: string) {
33 | this.failReason = failReason
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InVerifySuccessEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 资质认证成功通知事件
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InVerifySuccessEvent extends EventInMsg {
9 | //资质认证成功
10 | public static EVENT_IN_QUALIFICATION_VERIFY_SUCCESS: string = 'qualification_verify_success'
11 | //名称认证成功
12 | public static EVENT_IN_NAMING_VERIFY_SUCCESS: string = 'naming_verify_success'
13 | //年审通知
14 | public static EVENT_IN_ANNUAL_RENEW: string = 'annual_renew'
15 | //认证过期失效通知
16 | public static EVENT_IN_VERIFY_EXPIRED: string = 'verify_expired'
17 |
18 | private expiredTime: string
19 |
20 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
21 | super(toUserName, fromUserName, createTime, event)
22 | }
23 |
24 | public get getExpiredTime(): string {
25 | return this.expiredTime
26 | }
27 |
28 | public set setExpiredTime(expiredTime: string) {
29 | this.expiredTime = expiredTime
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InWifiEvent.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description wifi连网后下发消息
5 | */
6 | import { EventInMsg } from './EventInMsg'
7 |
8 | export class InWifiEvent extends EventInMsg {
9 | public static EVENT: string = 'WifiConnected'
10 | private connectTime: string
11 | private expireTime: string
12 | private vendorId: string
13 | private shopId: string
14 | private deviceNo: string
15 |
16 | public get getConnectTime(): string {
17 | return this.connectTime
18 | }
19 |
20 | public set setConnectTime(connectTime: string) {
21 | this.connectTime = connectTime
22 | }
23 |
24 | public get getExpireTime(): string {
25 | return this.expireTime
26 | }
27 |
28 | public set setExpireTime(expireTime: string) {
29 | this.expireTime = expireTime
30 | }
31 |
32 | public get getVendorId(): string {
33 | return this.vendorId
34 | }
35 |
36 | public set setVendorId(vendorId: string) {
37 | this.vendorId = vendorId
38 | }
39 |
40 | public get getShopId(): string {
41 | return this.shopId
42 | }
43 |
44 | public set setShopId(shopId: string) {
45 | this.shopId = shopId
46 | }
47 |
48 | public get getDeviceNo(): string {
49 | return this.deviceNo
50 | }
51 |
52 | public set setDeviceNo(deviceNo: string) {
53 | this.deviceNo = deviceNo
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/InWxVerifyDispatchEvent.ts:
--------------------------------------------------------------------------------
1 | import { EventInMsg } from './EventInMsg'
2 |
3 | /**
4 | * @author Javen
5 | * @copyright javendev@126.com
6 | * @description 微信认证事件
7 | */
8 | export class InWxVerifyDispatchEvent extends EventInMsg {
9 | public static EVENT: string = 'wx_verify_dispatch'
10 |
11 | private provider: string
12 | private contact: string
13 | private dispatchTime: string
14 |
15 | constructor(toUserName: string, fromUserName: string, createTime: number, event: string) {
16 | super(toUserName, fromUserName, createTime, event)
17 | }
18 |
19 | public get getProvider(): string {
20 | return this.provider
21 | }
22 |
23 | public set setProvider(provider: string) {
24 | this.provider = provider
25 | }
26 |
27 | public get getContact(): string {
28 | return this.contact
29 | }
30 |
31 | public set setContact(contact: string) {
32 | this.contact = contact
33 | }
34 |
35 | public get getDispatchTime(): string {
36 | return this.dispatchTime
37 | }
38 |
39 | public set setDispatchTime(dispatchTime: string) {
40 | this.dispatchTime = dispatchTime
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/in/event/ScanCodeInfo.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 菜单二维码扫描的结果
5 | */
6 |
7 | export class ScanCodeInfo {
8 | private ScanType: string
9 | private ScanResult: string
10 |
11 | constructor(scanType: string, scanResult: string) {
12 | this.ScanType = scanType
13 | this.ScanResult = scanResult
14 | }
15 |
16 | public get getScanType(): string {
17 | return this.ScanType
18 | }
19 | public set setScanType(scanType: string) {
20 | this.ScanType = scanType
21 | }
22 | public get getScanResult(): string {
23 | return this.ScanResult
24 | }
25 | public set setScanResult(scanResult: string) {
26 | this.ScanResult = scanResult
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/Article.ts:
--------------------------------------------------------------------------------
1 | export class Article {
2 | private title: string
3 | private description: string
4 | private url: string
5 | private picurl: string
6 |
7 | constructor(title: string, description: string, url: string, picurl: string) {
8 | this.title = title
9 | this.description = description
10 | this.url = url
11 | this.picurl = picurl
12 | }
13 |
14 | public get getTitle(): string {
15 | return this.title
16 | }
17 | public set setTitle(title: string) {
18 | this.title = title
19 | }
20 | public get getDescription(): string {
21 | return this.description
22 | }
23 | public set setDescription(description: string) {
24 | this.description = description
25 | }
26 | public get getUrl(): string {
27 | return this.url
28 | }
29 | public set setUrl(url: string) {
30 | this.url = url
31 | }
32 | public get getPicurl(): string {
33 | return this.picurl
34 | }
35 | public set setPicurl(picurl: string) {
36 | this.picurl = picurl
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/MenuMsg.ts:
--------------------------------------------------------------------------------
1 | export class MenuMsg {
2 | private id: string
3 | private content: string
4 |
5 | constructor(id: string, content: string) {
6 | this.id = id
7 | this.content = content
8 | }
9 |
10 | public get getId(): string {
11 | return this.id
12 | }
13 |
14 | public set setId(id: string) {
15 | this.id = id
16 | }
17 |
18 | public get getContent(): string {
19 | return this.content
20 | }
21 |
22 | public set setContent(content: string) {
23 | this.content = content
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/News.ts:
--------------------------------------------------------------------------------
1 | export class News {
2 | private title: string
3 | private description: string
4 | private picUrl: string
5 | private url: string
6 |
7 | public static getInstantiationNews(title: string, description: string, picUrl: string, url: string): News {
8 | let news = new News()
9 | news.title = title
10 | news.description = description
11 | news.picUrl = picUrl
12 | news.url = url
13 | return news
14 | }
15 |
16 | public get getTitle(): string {
17 | return this.title
18 | }
19 |
20 | public set setTitle(title: string) {
21 | this.title = title
22 | }
23 |
24 | public get getDescription(): string {
25 | return this.description
26 | }
27 |
28 | public set setDescription(description: string) {
29 | this.description = description
30 | }
31 |
32 | public get getPicUrl(): string {
33 | return this.picUrl
34 | }
35 |
36 | public set setPicUrl(picUrl: string) {
37 | this.picUrl = picUrl
38 | }
39 |
40 | public get getUrl(): string {
41 | return this.url
42 | }
43 |
44 | public set setUrl(url: string) {
45 | this.url = url
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutCustomMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 转发多客服消息 或者 转发到指定客服
5 | */
6 | import { OutMsg } from './OutMsg'
7 | import { TransInfo } from './TransInfo'
8 | import { InMsg } from '../in/InMsg'
9 |
10 | export class OutCustomMsg extends OutMsg {
11 | private transInfo: TransInfo
12 |
13 | constructor(inMsg: InMsg) {
14 | super(inMsg)
15 | this.msgType = 'transfer_customer_service'
16 | }
17 |
18 | public toXml(): string {
19 | let str = super.toXml()
20 | if (null != this.transInfo && this.transInfo.getKfAccount) {
21 | str += '\n'
22 | str += '\n'
23 | str += '\n'
24 | }
25 | str += '\n'
26 | return str
27 | }
28 |
29 | public getTransInfo(): TransInfo {
30 | return this.transInfo
31 | }
32 |
33 | public setTransInfo(transInfo: TransInfo) {
34 | this.transInfo = transInfo
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutImageMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { InMsg } from '../in/InMsg'
3 |
4 | export class OutImageMsg extends OutMsg {
5 | private mediaId: string
6 |
7 | constructor(inMsg: InMsg) {
8 | super(inMsg)
9 | this.msgType = 'image'
10 | }
11 |
12 | public toXml(): string {
13 | let str = super.toXml()
14 | if (!this.mediaId) {
15 | throw new Error('mediaId is null')
16 | }
17 | str += '\n\n\n'
18 | return str
19 | }
20 |
21 | public get getMediaId(): string {
22 | return this.mediaId
23 | }
24 |
25 | public set setMediaId(mediaId: string) {
26 | this.mediaId = mediaId
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutMsg.ts:
--------------------------------------------------------------------------------
1 | import { InMsg } from '../in/InMsg'
2 |
3 | export abstract class OutMsg {
4 | // 接收方帐号 openId
5 | protected toUserName: string
6 | // 开发者微信号
7 | protected fromUserName: string
8 | // 消息创建时间
9 | protected createTime: number
10 | /**
11 | * 被动响应消息类型
12 | * 1:text 文本消息
13 | * 2:image 图片消息
14 | * 3:voice 语音消息
15 | * 4:video 视频消息
16 | * 5:music 音乐消息
17 | * 6:news 图文消息
18 | */
19 | protected msgType: string
20 |
21 | constructor(inMsg: InMsg) {
22 | this.toUserName = inMsg.getFromUserName
23 | this.fromUserName = inMsg.getToUserName
24 | this.createTime = this.now()
25 | }
26 |
27 | public toXml(): string {
28 | let xmlContent = '\n\n'
29 | xmlContent += '\n'
30 | xmlContent += '' + this.createTime + '\n'
31 | xmlContent += '\n'
32 | return xmlContent
33 | }
34 |
35 | public now(): number {
36 | return new Date().getTime()
37 | }
38 |
39 | public get getToUserName(): string {
40 | return this.toUserName
41 | }
42 |
43 | public set setToUserName(toUserName: string) {
44 | this.toUserName = toUserName
45 | }
46 |
47 | public get getFromUserName(): string {
48 | return this.fromUserName
49 | }
50 |
51 | public set setFromUserName(fromUserName: string) {
52 | this.fromUserName = fromUserName
53 | }
54 |
55 | public get getCreateTime(): number {
56 | return this.createTime
57 | }
58 |
59 | public set setCreateTime(createTime: number) {
60 | this.createTime = createTime
61 | }
62 |
63 | public get getMsgType(): string {
64 | return this.msgType
65 | }
66 |
67 | public set setMsgType(msgType: string) {
68 | this.msgType = msgType
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutMusicMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { InMsg } from '../in/InMsg'
3 |
4 | export class OutMusicMsg extends OutMsg {
5 | private title: string
6 | private description: string
7 | private musicUrl: string
8 | private hqMusicUrl: string
9 | private funcFlag: string = '0'
10 |
11 | constructor(inMsg: InMsg) {
12 | super(inMsg)
13 | this.msgType = 'music'
14 | }
15 |
16 | public toXml(): string {
17 | let str = super.toXml()
18 | str += '\n'
19 | if (this.title) {
20 | str += '\n'
21 | }
22 | if (this.description) {
23 | str += '\n'
24 | }
25 | if (this.musicUrl) {
26 | str += '\n'
27 | }
28 | if (this.hqMusicUrl) {
29 | str += '\n'
30 | }
31 | str += '\n\n'
32 | str += '\n'
33 | return str
34 | }
35 |
36 | public get getTitle(): string {
37 | return this.title
38 | }
39 |
40 | public set setTitle(title: string) {
41 | this.title = title
42 | }
43 |
44 | public get getDescription(): string {
45 | return this.description
46 | }
47 |
48 | public set setDescription(description: string) {
49 | this.description = description
50 | }
51 |
52 | public get getMusicUrl(): string {
53 | return this.musicUrl
54 | }
55 |
56 | public set setMusicUrl(musicUrl: string) {
57 | this.musicUrl = musicUrl
58 | }
59 |
60 | public get getHqMusicUrl(): string {
61 | return this.hqMusicUrl
62 | }
63 |
64 | public set setHqMusicUrl(hqMusicUrl: string) {
65 | this.hqMusicUrl = hqMusicUrl
66 | }
67 |
68 | public get getFuncFlag(): string {
69 | return this.funcFlag
70 | }
71 | public set setFuncFlag(funcFlag: boolean) {
72 | this.funcFlag = funcFlag ? '1' : '0'
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutNewsMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { News } from './News'
3 | import { InMsg } from '../in/InMsg'
4 |
5 | export class OutNewsMsg extends OutMsg {
6 | private articles: News[] = []
7 |
8 | constructor(inMsg: InMsg) {
9 | super(inMsg)
10 | this.msgType = 'news'
11 | }
12 | public toXml(): string {
13 | let str = super.toXml()
14 | str += '' + this.getArticleCount + '\n\n'
15 | this.articles.forEach(item => {
16 | str += '- \n'
17 | str += '\n'
18 | str += '\n'
19 | str += '\n'
20 | str += '\n'
21 | str += '
\n'
22 | })
23 | str += '\n'
24 | str += '\n'
25 | return str
26 | }
27 |
28 | public get getArticleCount(): number {
29 | return this.articles.length
30 | }
31 |
32 | public get getArticles(): News[] {
33 | return this.articles
34 | }
35 |
36 | public set setArticles(articles: News[]) {
37 | if (articles != null) this.articles = articles
38 | }
39 |
40 | public addNews(articles: News[]): OutNewsMsg {
41 | if (articles != null) this.articles.concat(articles)
42 | return this
43 | }
44 |
45 | public addArticle(title: string, description: string, picUrl: string, url: string): OutNewsMsg {
46 | this.articles.push(News.getInstantiationNews(title, description, picUrl, url))
47 | return this
48 | }
49 |
50 | public addNew(news: News): OutNewsMsg {
51 | this.articles.push(news)
52 | return this
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutTextMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { InMsg } from '../in/InMsg'
3 |
4 | export class OutTextMsg extends OutMsg {
5 | private content: string
6 |
7 | constructor(inMsg: InMsg) {
8 | super(inMsg)
9 | this.msgType = 'text'
10 | }
11 |
12 | public toXml(): string {
13 | let str = super.toXml()
14 | if (!this.content) {
15 | throw new Error('content is null')
16 | }
17 | str += '\n\n'
18 | return str
19 | }
20 |
21 | public get getContent(): string {
22 | return this.content
23 | }
24 |
25 | public setContent(content: string): OutTextMsg {
26 | this.content = content
27 | return this
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutVideoMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { InMsg } from '../in/InMsg'
3 |
4 | export class OutVideoMsg extends OutMsg {
5 | private mediaId: string
6 | private title: string
7 | private description: string
8 |
9 | constructor(inMsg: InMsg) {
10 | super(inMsg)
11 | this.msgType = 'video'
12 | }
13 |
14 | public toXml(): string {
15 | let str = super.toXml()
16 | if (!this.mediaId) {
17 | throw new Error('mediaId is null')
18 | }
19 | str += '\n'
24 | str += '\n'
25 | return str
26 | }
27 |
28 | public get getMediaId(): string {
29 | return this.mediaId
30 | }
31 |
32 | public set setMediaId(mediaId: string) {
33 | this.mediaId = mediaId
34 | }
35 |
36 | public get getTitle(): string {
37 | return this.title
38 | }
39 |
40 | public set setTitle(title: string) {
41 | this.title = title
42 | }
43 |
44 | public get getDescription(): string {
45 | return this.description
46 | }
47 |
48 | public set setDescription(description: string) {
49 | this.description = description
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/OutVoiceMsg.ts:
--------------------------------------------------------------------------------
1 | import { OutMsg } from './OutMsg'
2 | import { InMsg } from '../in/InMsg'
3 |
4 | export class OutVoiceMsg extends OutMsg {
5 | private mediaId: string
6 |
7 | constructor(inMsg: InMsg) {
8 | super(inMsg)
9 | this.msgType = 'voice'
10 | }
11 |
12 | public toXml(): string {
13 | let str = super.toXml()
14 | if (!this.mediaId) {
15 | throw new Error('mediaId is null')
16 | }
17 | str += '\n\n\n\n'
18 | return str
19 | }
20 |
21 | public get getMediaId(): string {
22 | return this.mediaId
23 | }
24 |
25 | public set setMediaId(mediaId: string) {
26 | this.mediaId = mediaId
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/msg/out/TransInfo.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 将消息转发到多客服
5 | */
6 | export class TransInfo {
7 | // 指定会话接入的客服账号
8 | private KfAccount: string
9 |
10 | constructor(KfAccount: string) {
11 | this.KfAccount = KfAccount
12 | }
13 |
14 | public get getKfAccount(): string {
15 | return this.KfAccount
16 | }
17 |
18 | public set setKfAccount(kfAccount: string) {
19 | this.KfAccount = kfAccount
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/packages/commons/src/entity/subscribe/SubscribeMsg.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 订阅消息
5 | */
6 | export class SubscribeMsg {
7 | private touser: string
8 | private template_id: string
9 | private url: string
10 | private miniprogram: MiniProgram
11 | private scene: number
12 | private title: string
13 | private data: Data
14 |
15 | constructor(touser: string, template_id: string, scene: number, title: string, data: Data) {
16 | this.touser = touser
17 | this.template_id = template_id
18 | this.scene = scene
19 | this.title = title
20 | this.data = data
21 | }
22 |
23 | public get getUrl(): string {
24 | return this.url
25 | }
26 |
27 | public set setUrl(url: string) {
28 | this.url = url
29 | }
30 |
31 | public get getMiniProgram(): MiniProgram {
32 | return this.miniprogram
33 | }
34 |
35 | public set setMiniProgram(miniprogram: MiniProgram) {
36 | this.miniprogram = miniprogram
37 | }
38 | }
39 |
40 | export class MiniProgram {
41 | private appid: string
42 | private pagepath: string
43 | constructor(appid: string, pagepath: string) {
44 | this.appid = appid
45 | this.pagepath = pagepath
46 | }
47 | }
48 |
49 | export class Data {
50 | private content: Content
51 |
52 | constructor(content: Content) {
53 | this.content = content
54 | }
55 | }
56 |
57 | export class Content {
58 | private value: string
59 | private color: string
60 |
61 | constructor(value: string, color: string) {
62 | this.value = value
63 | this.color = color
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/packages/commons/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/kits/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/kits
2 |
3 | TNWX 微信系开发脚手架之工具集合
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/kits/__tests__/HttpKit.spec.ts:
--------------------------------------------------------------------------------
1 | import { HttpKit } from './../src/HttpKit'
2 |
3 | test('http get', async () => {
4 | let url = 'https://gitee.com/api/v5/repos/Javen205/TNWX'
5 | let data = await HttpKit.getHttpDelegate.httpGet(url)
6 | return expect(data['stargazers_count']).toBeGreaterThanOrEqual(117)
7 | })
8 |
--------------------------------------------------------------------------------
/packages/kits/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'kits',
5 | displayName: 'kits',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/kits/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/kits",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之工具集合",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "jest": {
45 | "testEnvironment": "node"
46 | },
47 | "bugs": {
48 | "url": "http://gitee.com/javen205/TNWX/issues"
49 | },
50 | "dependencies": {
51 | "axios": "^0.19.0",
52 | "concat-stream": "^2.0.0",
53 | "request": "^2.88.0",
54 | "urlencode": "^1.1.0",
55 | "uuid": "^3.3.3",
56 | "xml2js": "^0.4.22"
57 | },
58 | "devDependencies": {
59 | "@types/concat-stream": "^1.6.0",
60 | "@types/request": "^2.48.3",
61 | "@types/urlencode": "^1.1.1",
62 | "@types/uuid": "^3.4.6",
63 | "@types/xml2js": "^0.4.5"
64 | },
65 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
66 | }
67 |
--------------------------------------------------------------------------------
/packages/kits/src/HttpKit.ts:
--------------------------------------------------------------------------------
1 | import { AxiosHttpKit } from './AxiosHttpKit'
2 | /**
3 | * @author Javen
4 | * @copyright javendev@126.com
5 | * @description 封装网络请求工具
6 | */
7 | export class HttpKit {
8 | private static delegate: HttpDelegate = new AxiosHttpKit()
9 |
10 | public static get getHttpDelegate(): HttpDelegate {
11 | return this.delegate
12 | }
13 |
14 | public static set setHttpDelegate(delegate: HttpDelegate) {
15 | this.delegate = delegate
16 | }
17 | }
18 |
19 | export interface HttpDelegate {
20 | httpGet(url: string, options?: any): Promise
21 | httpGetToResponse(url: string, options?: any): Promise
22 | httpPost(url: string, data: string, options?: any): Promise
23 | httpPostToResponse(url: string, data: string, options?: any): Promise
24 | httpDeleteToResponse(url: string, options?: any): Promise
25 | httpPostWithCert(url: string, data: string, certFileContent: Buffer, passphrase: string): Promise
26 | upload(url: string, filePath: string, params?: string): Promise
27 | uploadToResponse(url: string, filePath: string, data: string, options?: any): Promise
28 | httpPutToResponse(url: string, data: string, options?: any): Promise
29 | }
30 |
--------------------------------------------------------------------------------
/packages/kits/src/index.ts:
--------------------------------------------------------------------------------
1 | export { HttpKit, HttpDelegate } from './HttpKit'
2 | export { AxiosHttpKit } from './AxiosHttpKit'
3 | export { Kits, SIGN_TYPE, SIGN_KEY_TYPE } from './Kits'
4 |
--------------------------------------------------------------------------------
/packages/kits/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/miniprogram/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/miniprogram
2 |
3 | TNWX 微信系开发脚手架之极速开发微信小程序
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/miniprogram/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/miniprogram",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之极速开发微信小程序",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "bugs": {
45 | "url": "http://gitee.com/javen205/TNWX/issues"
46 | },
47 | "dependencies": {
48 | "@tnwx/accesstoken": "^2.5.5"
49 | },
50 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
51 | }
52 |
--------------------------------------------------------------------------------
/packages/miniprogram/src/ImgApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessTokenApi, AccessToken } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 图像处理相关 API
9 | */
10 |
11 | export class ImgApi {
12 | /**
13 | * 图像处理
14 | * @param type 接口URL
15 | * @param imgUrl 图片的URL
16 | */
17 | public static async imgProcessingByUrl(type: ImgProcessingType, imgUrl: string) {
18 | let accessToken = await AccessTokenApi.getAccessToken()
19 | let url = util.format(type, (accessToken).getAccessToken)
20 | return HttpKit.getHttpDelegate.httpGet(url.concat('&img_url=').concat(imgUrl))
21 | }
22 |
23 | /**
24 | * 图像处理
25 | * @param type 接口URL
26 | * @param filePath 图片文件路径
27 | */
28 | public static async imgProcessingByFile(type: ImgProcessingType, filePath: string) {
29 | let accessToken = await AccessTokenApi.getAccessToken()
30 | let url = util.format(type, (accessToken).getAccessToken)
31 | return HttpKit.getHttpDelegate.upload(url, filePath)
32 | }
33 | }
34 |
35 | export enum ImgProcessingType {
36 | // 图片智能裁剪
37 | AICROP = 'https://api.weixin.qq.com/cv/img/aicrop?access_token=%s',
38 | // 条码/二维码识别
39 | QRCODE = 'https://api.weixin.qq.com/cv/img/qrcode?access_token=%s',
40 | // 图片高清化
41 | SUPERRESOLUTION = 'https://api.weixin.qq.com/cv/img/superresolution?access_token=%s'
42 | }
43 |
--------------------------------------------------------------------------------
/packages/miniprogram/src/OCRApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessTokenApi, AccessToken } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description OCR 识别相关 API
9 | */
10 |
11 | export class OCRApi {
12 | /**
13 | * OCR 识别
14 | * @param OcrType 接口URL
15 | * @param imgUrl 图片的URL
16 | */
17 | public static async ocrByUrl(OcrType: OCRType, imgUrl: string) {
18 | let accessToken = await AccessTokenApi.getAccessToken()
19 | let url = util.format(OcrType, (accessToken).getAccessToken)
20 | return HttpKit.getHttpDelegate.httpGet(url.concat('&img_url=').concat(imgUrl))
21 | }
22 |
23 | /**
24 | * OCR 识别
25 | * @param ocrType 接口URL
26 | * @param filePath 图片的文件路径
27 | */
28 | public static async ocrByFile(ocrType: OCRType, filePath: string) {
29 | let accessToken = await AccessTokenApi.getAccessToken()
30 | let url = util.format(ocrType, (accessToken).getAccessToken)
31 | return HttpKit.getHttpDelegate.upload(url, filePath)
32 | }
33 | }
34 |
35 | export enum OCRType {
36 | // 银行卡 OCR 识别
37 | BANKCARD = 'https://api.weixin.qq.com/cv/ocr/bankcard?access_token=%s',
38 | // 营业执照 OCR 识别
39 | BUSINESSLICENSE = 'https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=%s',
40 | // 驾驶证 OCR 识别
41 | DRIVERLICENSE = 'https://api.weixin.qq.com/cv/ocr/drivinglicense?access_token=%s',
42 | // 身份证 OCR 识别
43 | IDCARD = 'https://api.weixin.qq.com/cv/ocr/idcard?access_token=%s',
44 | // 通用印刷体 OCR 识别
45 | PRINTEDTEXT = 'https://api.weixin.qq.com/cv/ocr/comm?access_token=%s',
46 | // 行驶证 OCR 识别
47 | VEHICLELICENSE = 'https://api.weixin.qq.com/cv/ocr/driving?access_token=%s'
48 | }
49 |
--------------------------------------------------------------------------------
/packages/miniprogram/src/index.ts:
--------------------------------------------------------------------------------
1 | export { MiniProgramMediaType, MiniProgramApi } from './MiniProgramApi'
2 | export { MiniSubscribeMsgApi } from './MiniSubscribeMsgApi'
3 | export { OCRApi, OCRType } from './OCRApi'
4 | export { ImgApi, ImgProcessingType } from './ImgApi'
5 | export { MiniCustomerMsgApi, MiniCSRMsgType } from './MiniCustomerMsgApi'
6 | export { NearByPoiApi } from './NearByPoiApi'
7 | export { MiniPluginManagerApi } from './MiniPluginManagerApi'
8 |
--------------------------------------------------------------------------------
/packages/miniprogram/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/opencp/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/opencp
2 |
3 | TNWX 微信系开发脚手架之企业微信开放平台
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/opencp/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'opencp',
5 | displayName: 'opencp',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/opencp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/opencp",
3 | "version": "2.5.5",
4 | "description": "TTNWX 微信系开发脚手架之企业微信开放平台",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "opencp",
13 | "wxcp",
14 | "微信支付",
15 | "微信公众号",
16 | "微信小程序",
17 | "微信小游戏",
18 | "企业微信",
19 | "微信开放平台"
20 | ],
21 | "author": "javen205 ",
22 | "homepage": "http://gitee.com/javen205/TNWX",
23 | "license": "Apache-2.0",
24 | "main": "dist/index.js",
25 | "types": "dist/index.d.ts",
26 | "directories": {
27 | "lib": "dist",
28 | "test": "__tests__"
29 | },
30 | "files": [
31 | "dist"
32 | ],
33 | "publishConfig": {
34 | "access": "public"
35 | },
36 | "repository": {
37 | "type": "git",
38 | "url": "git+http://gitee.com/javen205/TNWX.git"
39 | },
40 | "scripts": {
41 | "tsc": "tsc",
42 | "watch": "tsc --watch",
43 | "prettier": "prettier --check 'src/**/*.ts'",
44 | "test": "jest --passWithNoTests"
45 | },
46 | "jest": {
47 | "testEnvironment": "node"
48 | },
49 | "bugs": {
50 | "url": "http://gitee.com/javen205/TNWX/issues"
51 | },
52 | "dependencies": {
53 | "@tnwx/accesstoken": "^2.5.5"
54 | },
55 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
56 | }
57 |
--------------------------------------------------------------------------------
/packages/opencp/src/index.ts:
--------------------------------------------------------------------------------
1 | export { OpenCpApi } from './OpenCpApi'
2 | export { OpenCpOauthApi } from './OpenCpOauthApi'
3 | export { OpenQrCode } from './OpenQrCode'
4 |
--------------------------------------------------------------------------------
/packages/opencp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/openmp/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/openmp
2 |
3 | TNWX 微信系开发脚手架之微信开放平台
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/openmp/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'openmp',
5 | displayName: 'openmp',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/openmp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/openmp",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之缓存",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "jest": {
45 | "testEnvironment": "node"
46 | },
47 | "bugs": {
48 | "url": "http://gitee.com/javen205/TNWX/issues"
49 | },
50 | "dependencies": {
51 | "@tnwx/commons": "^2.5.5"
52 | },
53 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
54 | }
55 |
--------------------------------------------------------------------------------
/packages/openmp/src/index.ts:
--------------------------------------------------------------------------------
1 | export { OpenMpApi } from './OpenMpApi'
2 | export { OpenMpSnsAccessTokenApi } from './OpenMpSnsAccessTokenApi'
3 |
--------------------------------------------------------------------------------
/packages/openmp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/tnwx/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ### 简介
12 |
13 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信、企业微信开发平台。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
14 |
15 | ### 简易指南
16 |
17 | #### 尝鲜版
18 |
19 | ```bash
20 | $ git clone https://gitee.com/javen205/TNWX.git
21 | $ cd TNWX
22 | $ yarn bootstrap
23 | $ yarn tsc
24 | ```
25 |
26 | #### 运行示例
27 |
28 | ```bash
29 | $ cd sample/express && yarn
30 | $ yarn build
31 | $ yarn dev
32 | ```
33 |
34 | #### 稳定版
35 |
36 | ```bash
37 | $ mkdir TNWX && cd TNWX
38 | $ yarn init -y
39 | $ yarn add tnwx
40 | ```
41 |
42 | ### 文档
43 |
44 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
45 |
46 | ### 交流群
47 |
48 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
49 |
--------------------------------------------------------------------------------
/packages/tnwx/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tnwx",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架 By Javen",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "bugs": {
45 | "url": "http://gitee.com/javen205/TNWX/issues"
46 | },
47 | "dependencies": {
48 | "@tnwx/accesstoken": "^2.5.5",
49 | "@tnwx/cache": "^2.5.5",
50 | "@tnwx/commons": "^2.5.5",
51 | "@tnwx/kits": "^2.5.5",
52 | "@tnwx/miniprogram": "^2.5.5",
53 | "@tnwx/opencp": "^2.5.5",
54 | "@tnwx/openmp": "^2.5.5",
55 | "@tnwx/wxcp": "^2.5.5",
56 | "@tnwx/wxmp": "^2.5.5",
57 | "@tnwx/wxpay": "^2.5.5"
58 | },
59 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
60 | }
61 |
--------------------------------------------------------------------------------
/packages/tnwx/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@tnwx/kits'
2 | export * from '@tnwx/wxpay'
3 | export * from '@tnwx/wxmp'
4 | export * from '@tnwx/accesstoken'
5 | export * from '@tnwx/miniprogram'
6 | export * from '@tnwx/commons'
7 | export * from '@tnwx/wxcp'
8 | export * from '@tnwx/opencp'
9 | export * from '@tnwx/cache'
10 | export * from '@tnwx/openmp'
11 |
--------------------------------------------------------------------------------
/packages/tnwx/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxcp/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/wxcp
2 |
3 | TNWX 微信系开发脚手架之极速开发企业微信/企业号
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/wxcp/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'wxcp',
5 | displayName: 'wxcp',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxcp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/wxcp",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之极速开发企业微信/企业号",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "jest": {
45 | "testEnvironment": "node"
46 | },
47 | "bugs": {
48 | "url": "http://gitee.com/javen205/TNWX/issues"
49 | },
50 | "dependencies": {
51 | "@tnwx/commons": "^2.5.5"
52 | },
53 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
54 | }
55 |
--------------------------------------------------------------------------------
/packages/wxcp/src/QyGroupRobotApi.ts:
--------------------------------------------------------------------------------
1 | import { HttpKit } from '@tnwx/kits'
2 | import { QyTextMsg } from './entity/QyTextMsg'
3 | import { QyMarkDownMsg } from './entity/QyMarkDownMsg'
4 | import { QyImageMsg } from './entity/QyImageMsg'
5 | import { QyArticles, QyNewsMsg } from './entity/QyNewsMsg'
6 | /**
7 | * @author Javen
8 | * @copyright javendev@126.com
9 | * @description 群机器人
10 | */
11 | export class QyGroupRobotApi {
12 | /**
13 | * 往群组推送消息
14 | * @param url webhook url
15 | * @param jsonData 请求数据
16 | */
17 | public static async send(url: string, jsonData: string) {
18 | return HttpKit.getHttpDelegate.httpPost(url, jsonData)
19 | }
20 |
21 | /**
22 | * 发送文本消息
23 | * @param url webhook 地址
24 | * @param text 文本消息对象 QyTextMsg
25 | */
26 | public static async sendTextMsg(url: string, text: QyTextMsg) {
27 | return this.send(url, JSON.stringify(text))
28 | }
29 |
30 | /**
31 | * 发送 markdown 消息
32 | * @param url webhook 地址
33 | * @param markdown markdown 消息对象 QyMarkDownMsg
34 | */
35 | public static async sendMarkDownMsg(url: string, markdown: QyMarkDownMsg) {
36 | return this.send(url, JSON.stringify(markdown))
37 | }
38 |
39 | /**
40 | * 发送图片消息
41 | * @param url webhook 地址
42 | * @param image 图片消息对象 QyImageMsg
43 | */
44 | public static async sendImageMsg(url: string, image: QyImageMsg) {
45 | return this.send(url, JSON.stringify(image))
46 | }
47 |
48 | /**
49 | * 发送图文消息
50 | * @param url webhook 地址
51 | * @param news 图文类型对象 QyNewsMsg
52 | */
53 | public static async sendNewsMsg(url: string, news: QyNewsMsg) {
54 | return this.send(url, JSON.stringify(news))
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/packages/wxcp/src/QyWxApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { HttpKit } from '@tnwx/kits'
3 | import { AccessToken, QyAccessTokenApi } from '@tnwx/accesstoken'
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 企业微信 API 接口
8 | */
9 | export class QyWxApi {
10 | private static updateTaskCardUrl: string = 'https://qyapi.weixin.qq.com/cgi-bin/message/update_taskcard?access_token=%s'
11 | /**
12 | * 更新任务卡片消息状态
13 | * @param userIds 企业的成员ID列表(消息接收者,最多支持1000个)
14 | * @param agentId 应用的 agentId
15 | * @param taskId 发送任务卡片消息时指定的 taskId
16 | * @param clickedKey 设置指定的按钮为选择状态,需要与发送消息时指定的btn:key一致
17 | * @param accessToken AccessToken
18 | */
19 | public static async updateTaskCard(userIds: string, agentId: string, taskId: string, clickedKey: string, accessToken?: AccessToken) {
20 | if (!accessToken) {
21 | accessToken = await QyAccessTokenApi.getAccessToken()
22 | }
23 | let url = util.format(this.updateTaskCardUrl, accessToken.getAccessToken)
24 | return HttpKit.getHttpDelegate.httpPost(
25 | url,
26 | JSON.stringify({
27 | userids: userIds,
28 | agentid: agentId,
29 | task_id: taskId,
30 | clicked_key: clickedKey
31 | })
32 | )
33 | }
34 |
35 | private static getApiDomainIpUrl = 'https://qyapi.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token=%s'
36 |
37 | /**
38 | * 获取企业微信API域名IP段
39 | */
40 | public static async getApiDomainIp(accessToken?: AccessToken) {
41 | if (!accessToken) {
42 | accessToken = await QyAccessTokenApi.getAccessToken()
43 | }
44 | let url = util.format(this.getApiDomainIpUrl, accessToken.getAccessToken)
45 | return HttpKit.getHttpDelegate.httpGet(url)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyFileMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg, QyMediaId } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 文件消息
8 | */
9 | export class QyFileMsg extends QyBaseMsg {
10 | private file: QyMediaId
11 |
12 | constructor(
13 | file: QyMediaId,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.FILE, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.file = file
25 | }
26 |
27 | public get getFile(): QyMediaId {
28 | return this.file
29 | }
30 |
31 | public set setFile(file: QyMediaId) {
32 | this.file = file
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyImageMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg, QyMediaId } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 图片消息
8 | */
9 | export class QyImageMsg extends QyBaseMsg {
10 | private image: QyMediaId | QyImage
11 |
12 | constructor(
13 | image: QyMediaId | QyImage,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.IMAGE, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.image = image
25 | }
26 |
27 | public get getImage(): QyMediaId | QyImage {
28 | return this.image
29 | }
30 |
31 | public set setImage(image: QyMediaId | QyImage) {
32 | this.image = image
33 | }
34 | }
35 |
36 | export class QyImage {
37 | private base64: string
38 | private md5: string
39 |
40 | constructor(base64: string, md5: string) {
41 | this.base64 = base64
42 | this.md5 = md5
43 | }
44 |
45 | public set setBase64(base64: string) {
46 | this.base64 = base64
47 | }
48 |
49 | public get getBase64(): string {
50 | return this.base64
51 | }
52 | public set setMd5(md5: string) {
53 | this.md5 = md5
54 | }
55 |
56 | public get getMd5(): string {
57 | return this.md5
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyMarkDownMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 | import { QyText } from './QyTextMsg'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description markdown 消息
9 | */
10 | export class QyMarkDownMsg extends QyBaseMsg {
11 | private markdown: QyText
12 |
13 | constructor(
14 | markdown: QyText,
15 | agentId?: string,
16 | toUser?: string,
17 | toParty?: string,
18 | toTag?: string,
19 | safe = 0,
20 | enableIdTrans = 0,
21 | enableDuplicateCheck = 0,
22 | duplicateCheckInterval = 1800
23 | ) {
24 | super(QySendMessageType.MARKDOWN, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
25 | this.markdown = markdown
26 | }
27 |
28 | public get markDown(): QyText {
29 | return this.markdown
30 | }
31 |
32 | public set markDown(markdown: QyText) {
33 | this.markdown = markdown
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyTextCardMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 文本卡片消息
8 | */
9 | export class QyTextCardMsg extends QyBaseMsg {
10 | private textcard: QyTextCard
11 |
12 | constructor(
13 | textCard: QyTextCard,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.TEXTCARD, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.textcard = textCard
25 | }
26 |
27 | public get textCard(): QyTextCard {
28 | return this.textcard
29 | }
30 |
31 | public set textCard(textCard: QyTextCard) {
32 | this.textcard = textCard
33 | }
34 | }
35 |
36 | export class QyTextCard {
37 | private title: string
38 | private description: string
39 | private url: string
40 | private btntxt: string
41 |
42 | constructor(title: string, description: string, url: string, btnTxt: string) {
43 | this.title = title
44 | this.description = description
45 | this.url = url
46 | this.btntxt = btnTxt
47 | }
48 |
49 | public set setTitle(title: string) {
50 | this.title = title
51 | }
52 |
53 | public get getTitle(): string {
54 | return this.title
55 | }
56 |
57 | public get getDescription(): string {
58 | return this.description
59 | }
60 |
61 | public set setDescription(description: string) {
62 | this.description = description
63 | }
64 |
65 | public set setUrl(url: string) {
66 | this.url = url
67 | }
68 |
69 | public get getUrl(): string {
70 | return this.url
71 | }
72 |
73 | public set setBtnTxt(btntxt: string) {
74 | this.btntxt = btntxt
75 | }
76 |
77 | public get getBtnTxt(): string {
78 | return this.btntxt
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyTextMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 文本消息
8 | */
9 | export class QyTextMsg extends QyBaseMsg {
10 | private text: QyText
11 |
12 | constructor(
13 | text: QyText,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.TEXT, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.text = text
25 | }
26 |
27 | public get getText(): QyText {
28 | return this.text
29 | }
30 |
31 | public set setText(text: QyText) {
32 | this.text = text
33 | }
34 | }
35 |
36 | export class QyText {
37 | private content: string
38 | private mentioned_list: Array
39 | private mentioned_mobile_list: Array
40 |
41 | constructor(content: string, mentionedList?: Array, mentionedMobileList?: Array) {
42 | this.content = content
43 | this.mentioned_list = mentionedList
44 | this.mentioned_mobile_list = mentionedMobileList
45 | }
46 |
47 | public set setContent(content: string) {
48 | this.content = content
49 | }
50 |
51 | public get getContent(): string {
52 | return this.content
53 | }
54 |
55 | public set mentionedList(mentioned_list: Array) {
56 | this.mentioned_list = mentioned_list
57 | }
58 |
59 | public get mentionedList(): Array {
60 | return this.mentioned_list
61 | }
62 |
63 | public set mentionedMobileList(mentionedMobileList: Array) {
64 | this.mentioned_mobile_list = mentionedMobileList
65 | }
66 |
67 | public get mentionedMobileList(): Array {
68 | return this.mentioned_mobile_list
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyVideoMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg, QyMediaId } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 视频消息
8 | */
9 | export class QyVideoMsg extends QyBaseMsg {
10 | private video: QyVideo
11 |
12 | constructor(
13 | video: QyVideo,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.VIDEO, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.video = video
25 | }
26 |
27 | public get getVideo(): QyVideo {
28 | return this.video
29 | }
30 |
31 | public set setVideo(video: QyVideo) {
32 | this.video = video
33 | }
34 | }
35 |
36 | export class QyVideo extends QyMediaId {
37 | private title: string
38 | private description: string
39 |
40 | constructor(mediaId: string, title: string, description: string) {
41 | super(mediaId)
42 | this.title = title
43 | this.description = description
44 | }
45 |
46 | public set setTitle(title: string) {
47 | this.title = title
48 | }
49 |
50 | public get getTitle(): string {
51 | return this.title
52 | }
53 |
54 | public get getDescription(): string {
55 | return this.description
56 | }
57 |
58 | public set setDescription(description: string) {
59 | this.description = description
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/packages/wxcp/src/entity/QyVoiceMsg.ts:
--------------------------------------------------------------------------------
1 | import { QyBaseMsg, QyMediaId } from './QyBaseMsg'
2 | import { QySendMessageType } from '../QySendMsgApi'
3 |
4 | /**
5 | * @author Javen
6 | * @copyright javendev@126.com
7 | * @description 语音消息
8 | */
9 | export class QyVoiceMsg extends QyBaseMsg {
10 | private voice: QyMediaId
11 |
12 | constructor(
13 | voice: QyMediaId,
14 | agentId?: string,
15 | toUser?: string,
16 | toParty?: string,
17 | toTag?: string,
18 | safe = 0,
19 | enableIdTrans = 0,
20 | enableDuplicateCheck = 0,
21 | duplicateCheckInterval = 1800
22 | ) {
23 | super(QySendMessageType.VOICE, agentId, toUser, toParty, toTag, safe, enableIdTrans, enableDuplicateCheck, duplicateCheckInterval)
24 | this.voice = voice
25 | }
26 |
27 | public get getVoice(): QyMediaId {
28 | return this.voice
29 | }
30 |
31 | public set setVoice(voice: QyMediaId) {
32 | this.voice = voice
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/packages/wxcp/src/index.ts:
--------------------------------------------------------------------------------
1 | export { QyWeChat } from './QyWeChat'
2 | export { QySendMsgApi, QySendMessageType } from './QySendMsgApi'
3 |
4 | export { QyBaseMsg, QyMediaId } from './entity/QyBaseMsg'
5 | export { QyTextMsg, QyText } from './entity/QyTextMsg'
6 | export { QyImageMsg, QyImage } from './entity/QyImageMsg'
7 | export { QyVoiceMsg } from './entity/QyVoiceMsg'
8 | export { QyVideoMsg, QyVideo } from './entity/QyVideoMsg'
9 | export { QyFileMsg } from './entity/QyFileMsg'
10 | export { QyTextCardMsg, QyTextCard } from './entity/QyTextCardMsg'
11 | export { QyNewsMsg, QyNews, QyArticles } from './entity/QyNewsMsg'
12 | export { QyMpNewsMsg, QyMpNews, QyMpNewsArticles } from './entity/QyMpNewsMsg'
13 | export { QyMarkDownMsg } from './entity/QyMarkDownMsg'
14 | export { QyMiniProgramNoticeMsg, QyMiniprogram, QyKv } from './entity/QyMiniProgramNoticeMsg'
15 | export { QyTaskCardMsg, QyTaskCardBtn, QyTaskCard } from './entity/QyTaskCardMsg'
16 |
17 | export { QyWxApi } from './QyWxApi'
18 | export { QyAgentApi } from './QyAgentApi'
19 | export { QyAppChatApi } from './QyAppChatApi'
20 | export { QyMediaApi, QyMediaType } from './QyMediaApi'
21 | export { QyOauthApi } from './QyOauthApi'
22 | export { QyOAApi, Attendees, Reminders } from './QyOAApi'
23 | export { QyUserApi } from './QyUserApi'
24 | export { QyDepartmentApi } from './QyDepartmentApi'
25 | export { QyTagApi } from './QyTagApi'
26 | export { QySyncApi, QySyncCallback } from './QySyncApi'
27 | export { QyGroupRobotApi } from './QyGroupRobotApi'
28 | export { QyExContact } from './QyExContact'
29 |
--------------------------------------------------------------------------------
/packages/wxcp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxmp/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/wxmp
2 |
3 | TNWX 微信系开发脚手架之极速开发微信公众号
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 文档
17 |
18 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx)
19 |
20 | ### 交流群
21 |
22 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
23 |
--------------------------------------------------------------------------------
/packages/wxmp/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'wxmp',
5 | displayName: 'wxmp',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxmp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/wxmp",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之极速开发微信公众号",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "bugs": {
45 | "url": "http://gitee.com/javen205/TNWX/issues"
46 | },
47 | "dependencies": {
48 | "@tnwx/commons": "^2.5.5"
49 | },
50 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
51 | }
52 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/AutoReplyInfoApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessToken, AccessTokenApi } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 获取公众号的自动回复规则
9 | */
10 | export class AutoReplyInfoApi {
11 | private static getCurrentAutoreplyInfoUrl: string = 'https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=%s'
12 |
13 | /**
14 | * 获取公众号的自动回复规则
15 | * @param accessToken
16 | */
17 | public static async get(accessToken?: AccessToken) {
18 | if (!accessToken) {
19 | accessToken = await AccessTokenApi.getAccessToken()
20 | }
21 | let url = util.format(this.getCurrentAutoreplyInfoUrl, accessToken.getAccessToken)
22 | return HttpKit.getHttpDelegate.httpGet(url)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/CallbackApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessToken, AccessTokenApi } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 微信服务器
9 | */
10 | export class CallbackApi {
11 | private static apiUrl: string = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=%s'
12 | /**
13 | * 获取微信服务器IP地址
14 | * @param accessToken
15 | */
16 | public static async getCallbackIp(accessToken?: AccessToken) {
17 | if (!accessToken) {
18 | accessToken = await AccessTokenApi.getAccessToken()
19 | }
20 | let url = util.format(this.apiUrl, accessToken.getAccessToken)
21 | return HttpKit.getHttpDelegate.httpGet(url)
22 | }
23 |
24 | private static checkUrl: string = 'https://api.weixin.qq.com/cgi-bin/callback/check?access_token=%s'
25 | /**
26 | * 网络检测
27 | * @param action 执行的检测动作,允许的值:dns(做域名解析)、ping(做ping检测)、all(dns和ping都做)
28 | * @param operator 指定平台从某个运营商进行检测,允许的值:CHINANET(电信出口)、UNICOM(联通出口)、CAP(腾讯自建出口)、DEFAULT(根据ip来选择运营商)
29 | * @param accessToken
30 | */
31 | public static async check(action: CheckAction = CheckAction.ALL, operator: CheckOperator = CheckOperator.DEFAULT, accessToken?: AccessToken) {
32 | if (!accessToken) {
33 | accessToken = await AccessTokenApi.getAccessToken()
34 | }
35 | let url = util.format(this.checkUrl, accessToken.getAccessToken)
36 | return HttpKit.getHttpDelegate.httpPost(
37 | url,
38 | JSON.stringify({
39 | action: action,
40 | check_operator: operator
41 | })
42 | )
43 | }
44 | }
45 |
46 | export enum CheckAction {
47 | DNS = 'dns',
48 | PING = 'ping',
49 | ALL = 'all'
50 | }
51 |
52 | export enum CheckOperator {
53 | CHINANET = 'CHINANET',
54 | UNICOM = 'UNICOM',
55 | CAP = 'CAP',
56 | DEFAULT = 'DEFAULT'
57 | }
58 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/SemanticApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessToken, AccessTokenApi } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 语义理解
9 | */
10 | export class SemanticApi {
11 | private static searchUrl = 'https://api.weixin.qq.com/semantic/semproxy/search?access_token=%s'
12 |
13 | public static async search(jsonStr: string, accessToken?: AccessToken) {
14 | if (!accessToken) {
15 | accessToken = await AccessTokenApi.getAccessToken()
16 | }
17 | let url = util.format(this.searchUrl, accessToken.getAccessToken)
18 | return HttpKit.getHttpDelegate.httpPost(url, jsonStr)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/ShortUrlApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { HttpKit } from '@tnwx/kits'
3 | import { AccessToken, AccessTokenApi } from '@tnwx/accesstoken'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 长链接转成短链接
9 | */
10 | export class ShortUrlApi {
11 | private static apiUrl: string = 'https://api.weixin.qq.com/cgi-bin/shorturl?access_token=%s'
12 |
13 | /**
14 | * 长链接转成短链接
15 | * @param json
16 | * @param accessToken
17 | */
18 | public static async getShorturl(json: string, accessToken?: AccessToken) {
19 | if (!accessToken) {
20 | accessToken = await AccessTokenApi.getAccessToken()
21 | }
22 | let url = util.format(this.apiUrl, accessToken.getAccessToken)
23 | return HttpKit.getHttpDelegate.httpPost(url, json)
24 | }
25 |
26 | /**
27 | * 长链接转成短链接
28 | * @param longUrl
29 | * @param accessToken
30 | */
31 | public static async longToShort(longUrl: string, accessToken?: AccessToken) {
32 | return this.getShorturl(
33 | JSON.stringify({
34 | action: 'long2short',
35 | long_url: longUrl
36 | }),
37 | accessToken
38 | )
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/SubscribeMsgApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import * as urlencode from 'urlencode'
3 | import { AccessToken, AccessTokenApi, ApiConfigKit } from '@tnwx/accesstoken'
4 | import { HttpKit } from '@tnwx/kits'
5 | import { SubscribeMsg } from '@tnwx/commons'
6 |
7 | /**
8 | * @author Javen
9 | * @copyright javendev@126.com
10 | * @description 一次性订阅消息
11 | */
12 | export class SubscribeMsgApi {
13 | private static authorizeUrl: string = 'https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid=%s&scene=%d&template_id=%s&redirect_url=%s'
14 | private static subscribeUrl: string = 'https://api.weixin.qq.com/cgi-bin/message/template/subscribe?access_token=%s'
15 | /**
16 | * 获取授权URL
17 | * @param scene 0-10000 场景值
18 | * @param templateId 订阅消息模板ID
19 | * @param redirectUrl
20 | * @param reserved 可以填写a-zA-Z0-9的参数值
21 | */
22 | public static getAuthorizeURL(scene: number, templateId: string, redirectUrl: string, reserved?: string): string {
23 | let url = util.format(this.authorizeUrl, ApiConfigKit.getApiConfig.getAppId, scene, templateId, urlencode(redirectUrl))
24 | if (reserved) {
25 | url = url + '&reserved=' + urlencode(reserved)
26 | }
27 | return url + '#wechat_redirect'
28 | }
29 |
30 | /**
31 | * 推送订阅模板消息给到授权微信用户
32 | * @param subscribeMsg
33 | * @param accessToken
34 | */
35 | public static async send(subscribeMsg: SubscribeMsg, accessToken?: AccessToken) {
36 | return this.sendMsg(JSON.stringify(subscribeMsg), accessToken)
37 | }
38 |
39 | /**
40 | * 推送订阅模板消息给到授权微信用户
41 | * @param json
42 | * @param accessToken
43 | */
44 | public static async sendMsg(json: string, accessToken?: AccessToken) {
45 | if (!accessToken) {
46 | accessToken = await AccessTokenApi.getAccessToken()
47 | }
48 | let url = util.format(this.subscribeUrl, accessToken.getAccessToken)
49 | return HttpKit.getHttpDelegate.httpPost(url, json)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/wxmp/src/api/shakearound/ShakeAroundUserApi.ts:
--------------------------------------------------------------------------------
1 | import * as util from 'util'
2 | import { AccessToken, AccessTokenApi } from '@tnwx/accesstoken'
3 | import { HttpKit } from '@tnwx/kits'
4 |
5 | /**
6 | * @author Javen
7 | * @copyright javendev@126.com
8 | * @description 获取设备及用户信息
9 | */
10 | export class ShakeAroundUserApi {
11 | private static getShakeInfoUrl: string = 'https://api.weixin.qq.com/shakearound/user/getshakeinfo?access_token=%s'
12 | /**
13 | * 获取设备及用户信息
14 | * @param ticket 摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket
15 | * @param needPoi 是否需要返回门店poi_id
16 | * @param accessToken
17 | */
18 | public static async getShakeInfo(ticket: string, needPoi: boolean = false, accessToken?: AccessToken) {
19 | if (!accessToken) {
20 | accessToken = await AccessTokenApi.getAccessToken()
21 | }
22 | let url = util.format(this.getShakeInfoUrl, accessToken.getAccessToken)
23 | return HttpKit.getHttpDelegate.httpPost(
24 | url,
25 | JSON.stringify({
26 | ticket: ticket,
27 | need_poi: needPoi
28 | })
29 | )
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/wxmp/src/index.ts:
--------------------------------------------------------------------------------
1 | export { WeChat } from './WeChat'
2 |
3 | export { AutoReplyInfoApi } from './api/AutoReplyInfoApi'
4 | export { CallbackApi, CheckAction, CheckOperator } from './api/CallbackApi'
5 | export { CardApi } from './api/CardApi'
6 | export { CustomServiceApi } from './api/CustomServiceApi'
7 | export { DatacubeApi } from './api/DatacubeApi'
8 | export { MediaApi, MediaType, MediaArticles } from './api/MediaApi'
9 | export { MemberCardApi } from './api/MemberCardApi'
10 | export { MenuApi } from './api/MenuApi'
11 | export { MessageApi } from './api/MessageApi'
12 | export { PoiApi } from './api/PoiApi'
13 | export { QrcodeApi } from './api/QrcodeApi'
14 | export { SemanticApi } from './api/SemanticApi'
15 | export { ShortUrlApi } from './api/ShortUrlApi'
16 | export { SnsAccessTokenApi } from './api/SnsAccessTokenApi'
17 | export { SubscribeMsgApi } from './api/SubscribeMsgApi'
18 | export { TagApi } from './api/TagApi'
19 | export { TemplateApi } from './api/TemplateApi'
20 | export { UserApi, BatchUserInfo } from './api/UserApi'
21 |
22 | export { ShakeAroundApi, MaterialType } from './api/shakearound/ShakeAroundApi'
23 | export { ShakeAroundDeviceApi, DeviceIdentifier } from './api/shakearound/ShakeAroundDeviceApi'
24 | export { ShakeAroundPageApi } from './api/shakearound/ShakeAroundPageApi'
25 | export { ShakeAroundStatisticsApi } from './api/shakearound/ShakeAroundStatisticsApi'
26 | export { ShakeAroundUserApi } from './api/shakearound/ShakeAroundUserApi'
27 |
--------------------------------------------------------------------------------
/packages/wxmp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxpay/README.md:
--------------------------------------------------------------------------------
1 | # @tnwx/wxpay
2 |
3 | TNWX 微信系开发脚手架之微信支付
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ### 简介
13 |
14 | **TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业号/企业微信。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)**
15 |
16 | ### 特性
17 |
18 | - 微信支付同时支持 Api-v3 以及 Api-v2 版本接口
19 | - 微信支付同时支持多商户多应用,同时支持国内与境外的普通商户模式和服务商模式
20 | - 微信支付 v2 接口同时支持 MD5 以及 HMAC-SHA256 签名算法
21 |
22 | ### 文档
23 |
24 | [TNWX 微信系开发脚手架文档](https://javen205.gitee.io/tnwx/guide/wxpay)
25 |
26 | ### 交流群
27 |
28 | 群号: [114196246](https:shang.qq.com/wpa/qunwpa?idkey=a1e4fd8c71008961bd4fc8eeea224e726afd5e5eae7bf1d96d3c77897388bf24)
29 |
--------------------------------------------------------------------------------
/packages/wxpay/jest.config.js:
--------------------------------------------------------------------------------
1 | const base = require('../../jest.config')
2 | module.exports = {
3 | ...base,
4 | name: 'wxpay',
5 | displayName: 'wxpay',
6 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$'
7 | }
8 |
--------------------------------------------------------------------------------
/packages/wxpay/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@tnwx/wxpay",
3 | "version": "2.5.5",
4 | "description": "TNWX 微信系开发脚手架之微信支付",
5 | "keywords": [
6 | "tnw",
7 | "tnwx",
8 | "wxpay",
9 | "wxmp",
10 | "wechat",
11 | "miniprogram",
12 | "微信支付",
13 | "微信公众号",
14 | "微信小程序",
15 | "微信小游戏",
16 | "企业微信",
17 | "微信开放平台"
18 | ],
19 | "author": "javen205 ",
20 | "homepage": "http://gitee.com/javen205/TNWX",
21 | "license": "Apache-2.0",
22 | "main": "dist/index.js",
23 | "types": "dist/index.d.ts",
24 | "directories": {
25 | "lib": "dist",
26 | "test": "__tests__"
27 | },
28 | "files": [
29 | "dist"
30 | ],
31 | "publishConfig": {
32 | "access": "public"
33 | },
34 | "repository": {
35 | "type": "git",
36 | "url": "git+http://gitee.com/javen205/TNWX.git"
37 | },
38 | "scripts": {
39 | "tsc": "tsc",
40 | "watch": "tsc --watch",
41 | "prettier": "prettier --check 'src/**/*.ts'",
42 | "test": "jest --passWithNoTests"
43 | },
44 | "bugs": {
45 | "url": "http://gitee.com/javen205/TNWX/issues"
46 | },
47 | "dependencies": {
48 | "@tnwx/cache": "^2.5.5",
49 | "@tnwx/kits": "^2.5.5"
50 | },
51 | "gitHead": "0f631ba19491b13de9828ab1ba5f98eca08d550b"
52 | }
53 |
--------------------------------------------------------------------------------
/packages/wxpay/src/RequestMethod.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description HTTP 请求的方法
5 | */
6 | export enum RequestMethod {
7 | /**
8 | * 上传实质是 post 请求
9 | */
10 | UPLOAD = 'POST',
11 | /**
12 | * post 请求
13 | */
14 | POST = 'POST',
15 | /**
16 | * get 请求
17 | */
18 | GET = 'GET',
19 | /**
20 | * delete 请求
21 | */
22 | DELETE = 'DELETE',
23 | /**
24 | * put 请求
25 | */
26 | PUT = 'PUT'
27 | }
28 |
--------------------------------------------------------------------------------
/packages/wxpay/src/TradeType.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信支付交易类型
5 | */
6 | export enum WX_TRADE_TYPE {
7 | /**
8 | * 微信公众号支付或者小程序支付
9 | */
10 | JSAPI = 'JSAPI',
11 | /**
12 | * 微信扫码支付
13 | */
14 | NATIVE = 'NATIVE',
15 | /**
16 | * 微信APP支付
17 | */
18 | APP = 'APP',
19 | /**
20 | * 付款码支付
21 | */
22 | MICROPAY = 'MICROPAY',
23 | /**
24 | * H5支付
25 | */
26 | MWEB = 'MWEB'
27 | }
28 |
--------------------------------------------------------------------------------
/packages/wxpay/src/WxDomain.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Javen
3 | * @copyright javendev@126.com
4 | * @description 微信支付接口域名
5 | */
6 | export enum WX_DOMAIN {
7 | /**
8 | * 中国国内
9 | */
10 | CHINA = 'https://api.mch.weixin.qq.com',
11 | /**
12 | * 中国国内(备用域名)
13 | */
14 | CHINA2 = 'https://api2.mch.weixin.qq.com',
15 | /**
16 | * 东南亚
17 | */
18 | HK = 'https://apihk.mch.weixin.qq.com',
19 | /**
20 | * 其它
21 | */
22 | US = 'https://apius.mch.weixin.qq.com',
23 | /**
24 | * 获取公钥
25 | */
26 | FRAUD = 'https://fraud.mch.weixin.qq.com',
27 | /**
28 | * 活动
29 | */
30 | ACTION = 'https://action.weixin.qq.com',
31 | }
32 |
--------------------------------------------------------------------------------
/packages/wxpay/src/index.ts:
--------------------------------------------------------------------------------
1 | export { WX_API_TYPE } from './WxApiType'
2 | export { WX_DOMAIN } from './WxDomain'
3 | export { WX_TRADE_TYPE } from './TradeType'
4 | export { WxPay } from './WxPay'
5 | export { WxPayApiConfig } from './WxPayApiConfig'
6 | export { WxPayApiConifgKit } from './WxPayApiConifgKit'
7 | export { PayKit } from './PayKit'
8 | export { RequestMethod } from './RequestMethod'
9 |
--------------------------------------------------------------------------------
/packages/wxpay/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./dist"
5 | },
6 | "include": ["./src"]
7 | }
8 |
--------------------------------------------------------------------------------
/sample/egg/.autod.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | write: true,
5 | plugin: 'autod-egg',
6 | prefix: '^',
7 | devprefix: '^',
8 | exclude: [
9 | 'test/fixtures',
10 | 'coverage',
11 | ],
12 | dep: [
13 | 'egg',
14 | 'egg-scripts',
15 | ],
16 | devdep: [
17 | 'autod',
18 | 'autod-egg',
19 | 'egg-bin',
20 | 'tslib',
21 | 'typescript',
22 | ],
23 | keep: [
24 | ],
25 | semver: [
26 | ],
27 | test: 'scripts',
28 | };
29 |
--------------------------------------------------------------------------------
/sample/egg/.eslintignore:
--------------------------------------------------------------------------------
1 | **/*.d.ts
2 | node_modules/
3 |
--------------------------------------------------------------------------------
/sample/egg/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint-config-egg/typescript",
3 | "parserOptions": {
4 | "project": "./tsconfig.json"
5 | }
6 | }
--------------------------------------------------------------------------------
/sample/egg/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | logs/
8 | .DS_Store
9 | .vscode
10 | *.swp
11 | *.lock
12 | *.js
13 | !.autod.conf.js
14 |
15 | app/**/*.js
16 | test/**/*.js
17 | config/**/*.js
18 | app/**/*.map
19 | test/**/*.map
20 | config/**/*.map
21 | config.dev.ts
22 |
--------------------------------------------------------------------------------
/sample/egg/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '8'
5 | before_install:
6 | - npm i npminstall -g
7 | install:
8 | - npminstall
9 | script:
10 | - npm run ci
11 | after_script:
12 | - npminstall codecov && codecov
13 |
--------------------------------------------------------------------------------
/sample/egg/README.md:
--------------------------------------------------------------------------------
1 | ## QuickStart
2 |
3 | ### Development
4 |
5 | 默认加载 dev 配置,此文件 git 上并没有上传,请复制 config.default.ts 并命名为 config.dev.ts
6 | 如果需修改环境,修改 config/env 即可。 [官方文档-运行环境](https://eggjs.org/zh-cn/basics/env.html)
7 |
8 | ```bash
9 | $ npm i
10 | $ npm run dev
11 | $ open http://localhost:8888/
12 | ```
13 |
14 | Don't tsc compile at development mode, if you had run `tsc` then you need to `npm run clean` before `npm run dev`.
15 |
16 | ### Deploy
17 |
18 | ```bash
19 | $ npm run tsc
20 | $ npm start
21 | ```
22 |
23 | ### Npm Scripts
24 |
25 | - Use `npm run lint` to check code style
26 | - Use `npm test` to run unit test
27 | - se `npm run clean` to clean compiled js at development mode once
28 |
29 | ### Requirement
30 |
31 | - Node.js 8.x
32 | - Typescript 2.8+
33 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/home.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 |
3 | export default class HomeController extends Controller {
4 | public async index() {
5 | await this.ctx.render('index', {
6 | title: 'TNWX 微信系开发脚手架'
7 | })
8 | }
9 |
10 | public async pay() {
11 | await this.ctx.render('pay')
12 | }
13 |
14 | public async mysql() {
15 | const { ctx } = this
16 | let queryRes = await ctx.app.mysql.query('select * from users where name=?', ['Javen'])
17 | console.log(queryRes)
18 |
19 | const user = await ctx.app.mysql.get('users', { id: 1 })
20 | console.log(user)
21 |
22 | const insertRes = await this.app.mysql.insert('users', { name: 'TNWX' })
23 | console.log(insertRes)
24 |
25 | const deleteRes = await this.app.mysql.delete('users', { id: 12 })
26 | console.log(deleteRes)
27 |
28 | ctx.body = 'MySql 测试...'
29 | }
30 |
31 | public async npm() {
32 | const { ctx } = this
33 |
34 | const result = await ctx.curl('https://registry.npm.taobao.org/tnwx/latest', {
35 | // 自动解析 JSON response
36 | dataType: 'json',
37 | // 3 秒超时
38 | timeout: 3000
39 | })
40 |
41 | ctx.body = {
42 | status: result.status,
43 | headers: result.headers,
44 | package: result.data
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/opencp/opencpapi.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | import { OpenCpAccessTokenApi, AccessTokenType, OpenCorpAccessTokenApi, OpenCpApi, AccessToken, QySendMsgApi, QyTextMsg, QyText } from 'tnwx'
3 |
4 | export default class OpenCpApiController extends Controller {
5 | public async index() {
6 | const { ctx } = this
7 | let type: number = parseInt(ctx.query.type)
8 | let data: string = '企业微信开放平台...'
9 |
10 | ctx.app.logger.info(`type:${type}`)
11 |
12 | switch (type) {
13 | case 1:
14 | data = JSON.stringify(await OpenCpAccessTokenApi.getAccessToken(AccessTokenType.PROVIDER_TOKEN))
15 | break
16 | case 2:
17 | // 需要先获取 suite_ticket
18 | // 1、在 HandMsgAdapter 的 processInSuiteTicket 中有回调 10 分钟回调一次
19 | // 2、在开放平台 https://open.work.weixin.qq.com/ 应用中手动刷新
20 | data = JSON.stringify(await OpenCpAccessTokenApi.getAccessToken(AccessTokenType.SUITE_TOKEN))
21 | break
22 | case 3:
23 | // 安装应用返回的临时授权码
24 | let authCode: string = 'A_m53fEQ0eeY3gsr-sGdlIJqu35qYNKxGmU155MgIPjRz0MYxQsNa-ng69tKjuggOwxSt5sedJdRAv-l44Jk7MMu3lM4oEFT-nrAWdjCBEE'
25 | // 获取企业永久授权码
26 | data = JSON.stringify(await OpenCpApi.getPermanentCode(authCode))
27 | break
28 | case 4:
29 | // getPermanentCode 返回的信息
30 | let authCorpid: string = 'corpid'
31 | let permanentCode: string = 'permanent_code'
32 | let agentId: string = '1000009'
33 |
34 | let accessToken: AccessToken = await OpenCorpAccessTokenApi.getAccessToken(authCorpid, permanentCode)
35 | let text: QyTextMsg = new QyTextMsg(new QyText('开放平台发送文本消息 By TNWX'), agentId, 'Javen')
36 | let result = await QySendMsgApi.sendTextMessage(text, accessToken)
37 | data = JSON.stringify(result)
38 | break
39 | default:
40 | break
41 | }
42 | ctx.app.logger.info(data)
43 | ctx.body = data
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/openmp/openmpmsg.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | import * as getRawBody from 'raw-body'
3 | import { ApiConfigKit, WeChat } from 'tnwx'
4 | import { HandMsgAdapter } from '../../HandMsgAdapter'
5 |
6 | export default class OpenMpController extends Controller {
7 | msgAdapter = new HandMsgAdapter()
8 |
9 | public async openMpEvent() {
10 | const { ctx } = this
11 |
12 | let paramsAppId: string = ctx.params.appId
13 |
14 | console.log(`openMpEvent:appId:${paramsAppId}`)
15 |
16 | let appId = ctx.app.config.openMpConfig.appId
17 |
18 | ApiConfigKit.setCurrentAppId(appId)
19 |
20 | let msgSignature = ctx.query.msg_signature,
21 | timestamp = ctx.query.timestamp,
22 | nonce = ctx.query.nonce
23 |
24 | let buffer: Buffer = await getRawBody(ctx.req)
25 | let msgXml = buffer.toString('utf-8')
26 |
27 | // 接收消息并响应对应的回复
28 | WeChat.handleMsg(this.msgAdapter, msgXml, msgSignature, timestamp, nonce)
29 | .then(data => {
30 | ctx.body = data
31 | })
32 | .catch(error => console.log(error))
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/wxcp/qyjssdk.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | /**
3 | * 企业微信 JSSDK 示例
4 | */
5 | export default class QyJsSdkController extends Controller {
6 | public async index() {
7 | let { ctx } = this
8 | await ctx.render('qyjssdk', ctx.request.body)
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/wxcp/qymsg.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | import * as getRawBody from 'raw-body'
3 | import { QyWeChat, QyApiConfigKit } from 'tnwx'
4 | import { HandMsgAdapter } from '../../HandMsgAdapter'
5 |
6 | export default class QyMsgController extends Controller {
7 | msgAdapter = new HandMsgAdapter()
8 |
9 | public async get() {
10 | const { ctx } = this
11 |
12 | let appId: string = ctx.query.appId
13 | let corpId: string = ctx.query.corpId
14 | if (appId && corpId) {
15 | QyApiConfigKit.setCurrentAppId(appId, corpId)
16 | }
17 |
18 | let signature = ctx.query.signature, //微信加密签名
19 | timestamp = ctx.query.timestamp, //时间戳
20 | nonce = ctx.query.nonce, //随机数
21 | echostr = ctx.query.echostr //随机字符串
22 | ctx.body = QyWeChat.checkSignature(signature, timestamp, nonce, echostr)
23 | }
24 |
25 | public async post() {
26 | const { ctx } = this
27 |
28 | let appId: string = ctx.query.appId
29 | let corpId: string = ctx.query.corpId
30 | if (appId && corpId) {
31 | QyApiConfigKit.setCurrentAppId(appId, corpId)
32 | }
33 |
34 | let msgSignature = ctx.query.msg_signature,
35 | timestamp = ctx.query.timestamp,
36 | nonce = ctx.query.nonce
37 |
38 | let buffer: Buffer = await getRawBody(ctx.req)
39 | let msgXml = buffer.toString('utf-8')
40 |
41 | // 接收消息并响应对应的回复
42 | QyWeChat.handleMsg(this.msgAdapter, msgXml, msgSignature, timestamp, nonce)
43 | .then(data => {
44 | ctx.body = data
45 | })
46 | .catch(error => console.log(error))
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/wxmp/jssdk.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | /**
3 | * 微信公众号 JSSDK 示例
4 | */
5 | export default class JsSdkController extends Controller {
6 | public async index() {
7 | let { ctx } = this
8 | await ctx.render('jssdk', ctx.request.body)
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sample/egg/app/controller/wxmp/mpmsg.ts:
--------------------------------------------------------------------------------
1 | import { Controller } from 'egg'
2 | import * as getRawBody from 'raw-body'
3 | import { ApiConfigKit, WeChat } from 'tnwx'
4 | import { HandMsgAdapter } from '../../HandMsgAdapter'
5 |
6 | export default class MsgController extends Controller {
7 | msgAdapter = new HandMsgAdapter()
8 |
9 | public async get() {
10 | const { ctx } = this
11 |
12 | let appId: string = ctx.query.appId
13 | if (appId) {
14 | ApiConfigKit.setCurrentAppId(appId)
15 | }
16 |
17 | let signature = ctx.query.signature, //微信加密签名
18 | timestamp = ctx.query.timestamp, //时间戳
19 | nonce = ctx.query.nonce, //随机数
20 | echostr = ctx.query.echostr //随机字符串
21 | ctx.body = WeChat.checkSignature(signature, timestamp, nonce, echostr)
22 | }
23 |
24 | public async post() {
25 | const { ctx } = this
26 |
27 | let appId: string = ctx.query.appId
28 | if (appId) {
29 | ApiConfigKit.setCurrentAppId(appId)
30 | }
31 |
32 | let msgSignature = ctx.query.msg_signature,
33 | timestamp = ctx.query.timestamp,
34 | nonce = ctx.query.nonce
35 |
36 | let buffer: Buffer = await getRawBody(ctx.req)
37 | let msgXml = buffer.toString('utf-8')
38 |
39 | // 接收消息并响应对应的回复
40 | WeChat.handleMsg(this.msgAdapter, msgXml, msgSignature, timestamp, nonce)
41 | .then(data => {
42 | ctx.body = data
43 | })
44 | .catch(error => console.log(error))
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sample/egg/app/middleware/jssdk.ts:
--------------------------------------------------------------------------------
1 | import { Context, Application, EggAppConfig } from 'egg'
2 | import { ApiConfigKit, WeChat } from 'tnwx'
3 | import * as uuid from 'uuid'
4 |
5 | /**
6 | * jssdk 拦截器
7 | * @param app
8 | * @param options
9 | */
10 | export default function jssdkMiddleWare(app: Application, options?: EggAppConfig['jssdk']): any {
11 | return async (ctx: Context, next: () => Promise) => {
12 | try {
13 | app.logger.info(`options:${JSON.stringify(options)}`)
14 |
15 | const req = ctx.request
16 |
17 | let appId = ApiConfigKit.getApiConfig.getAppId
18 | let timestamp = new Date().getTime()
19 | let nonceStr = uuid.v1()
20 |
21 | let url: string = req.protocol
22 | .concat('://')
23 | .concat(req.host)
24 | .replace(':80', '')
25 | .concat(req.url)
26 |
27 | ctx.app.logger.info(`url:${url}`)
28 |
29 | let signature = await WeChat.jssdkSignature(nonceStr, String(timestamp), url)
30 |
31 | req.body = {
32 | appId: appId,
33 | timestamp: timestamp,
34 | nonceStr: nonceStr,
35 | signature: signature
36 | }
37 | await next()
38 | } catch (error) {
39 | console.log(error)
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sample/egg/app/middleware/openjssdk.ts:
--------------------------------------------------------------------------------
1 | import { Context, Application, EggAppConfig } from 'egg'
2 | import { ApiConfigKit, WeChat, OpenAuthorizerAccessTokenApi, AccessToken } from 'tnwx'
3 | import * as uuid from 'uuid'
4 |
5 | /**
6 | * jssdk 拦截器
7 | * @param app
8 | * @param options
9 | */
10 | export default function openJssdkMiddleWare(app: Application, options?: EggAppConfig['jssdk']): any {
11 | return async (ctx: Context, next: () => Promise) => {
12 | try {
13 | app.logger.info(`options:${JSON.stringify(options)}`)
14 |
15 | const req = ctx.request
16 |
17 | let appId = ApiConfigKit.getApiConfig.getAppId
18 | let timestamp = new Date().getTime()
19 | let nonceStr = uuid.v1()
20 |
21 | let url: string = req.protocol
22 | .concat('://')
23 | .concat(req.host)
24 | .replace(':80', '')
25 | .concat(req.url)
26 |
27 | ctx.app.logger.info(`url:${url}`)
28 |
29 | let accessToken: AccessToken = await OpenAuthorizerAccessTokenApi.getAccessToken(ctx.app.config.openMpConfig.authAppId)
30 |
31 | let signature = await WeChat.jssdkSignature(nonceStr, String(timestamp), url, accessToken)
32 |
33 | req.body = {
34 | appId: appId,
35 | timestamp: timestamp,
36 | nonceStr: nonceStr,
37 | signature: signature
38 | }
39 | await next()
40 | } catch (error) {
41 | console.log(error)
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sample/egg/app/middleware/qyjssdk.ts:
--------------------------------------------------------------------------------
1 | import { Context, Application, EggAppConfig } from 'egg'
2 | import { QyApiConfigKit, QyWeChat, QyJsApiType } from 'tnwx'
3 | import * as uuid from 'uuid'
4 |
5 | /**
6 | * jssdk 拦截器
7 | * @param app
8 | * @param options
9 | */
10 | export default function qyJsSdkMiddleWare(app: Application, options?: EggAppConfig['qyjssdk']): any {
11 | return async (ctx: Context, next: () => Promise) => {
12 | try {
13 | app.logger.info(`options:${JSON.stringify(options)}`)
14 |
15 | const req = ctx.request
16 |
17 | let appId = QyApiConfigKit.getApiConfig.getAppId
18 | let corpId = QyApiConfigKit.getApiConfig.getCorpId
19 | let timestamp = new Date().getTime().toString()
20 | let nonceStr = uuid.v1()
21 |
22 | let url: string = req.protocol
23 | .concat('://')
24 | .concat(req.host)
25 | .replace(':80', '')
26 | .concat(req.url)
27 |
28 | ctx.app.logger.info(url)
29 |
30 | let signature = await QyWeChat.jssdkSignature(nonceStr, timestamp, url, QyJsApiType.CORP)
31 | let qySignature = await QyWeChat.jssdkSignature(nonceStr, timestamp, url, QyJsApiType.AGENT)
32 | req.body = {
33 | appId: appId,
34 | corpId: corpId,
35 | timestamp: timestamp,
36 | nonceStr: nonceStr,
37 | signature: signature,
38 | qySignature: qySignature
39 | }
40 | await next()
41 | } catch (error) {
42 | app.logger.error(error)
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sample/egg/app/public/5478274718.txt:
--------------------------------------------------------------------------------
1 | 2e475c747521766800b5d3c1b6b26df4
--------------------------------------------------------------------------------
/sample/egg/app/public/WW_verify_YgLiaOHIivF2XgmR.txt:
--------------------------------------------------------------------------------
1 | YgLiaOHIivF2XgmR
--------------------------------------------------------------------------------
/sample/egg/app/public/css/style.css:
--------------------------------------------------------------------------------
1 | h1 {
2 | color: brown;
3 | }
4 |
--------------------------------------------------------------------------------
/sample/egg/app/public/images/coffee.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Javen205/TNWX/681f5606f1940637d835b38cda6b231c968ff412/sample/egg/app/public/images/coffee.jpeg
--------------------------------------------------------------------------------
/sample/egg/app/router.ts:
--------------------------------------------------------------------------------
1 | import { Application } from 'egg'
2 |
3 | export default (app: Application) => {
4 | const { controller, router } = app
5 | // 中间件
6 | const jssdk = app.middleware.jssdk(app)
7 | const qyjssdk = app.middleware.qyjssdk(app)
8 | const openjssdk = app.middleware.openjssdk(app)
9 |
10 | router.get('/', controller.home.index)
11 | router.get('/pay', controller.home.pay)
12 | router.get('/mysql', controller.home.mysql)
13 | router.get('/npm', controller.home.npm)
14 | router.get('/msg', controller.wxmp.mpmsg.get)
15 | router.post('/msg', controller.wxmp.mpmsg.post)
16 | router.get('/qymsg', controller.wxcp.qymsg.get)
17 | router.post('/qymsg', controller.wxcp.qymsg.post)
18 | router.get('/jssdk', jssdk, controller.wxmp.jssdk.index)
19 | router.get('/qyjssdk', qyjssdk, controller.wxcp.qyjssdk.index)
20 | router.get('/qyapi/creatMenu', controller.wxcp.qyapi.creatMenu)
21 | router.get('/qyapi/appChat', controller.wxcp.qyapi.appChat)
22 | router.get('/wxpay', controller.wxpay.index)
23 | router.get('/opencpapi', controller.opencp.opencpapi.index)
24 | router.post('/mp/event/:appId', controller.openmp.openmpmsg.openMpEvent)
25 | router.post('/mp/event', controller.openmp.openmpmsg.openMpEvent)
26 | router.get('/openmpapi', controller.openmp.openmpapi.api)
27 | router.get('/openmpauth', controller.openmp.openmpapi.authRedirect)
28 | router.get('/openmpjssdk', openjssdk, controller.openmp.openmpapi.jssdk)
29 | }
30 |
--------------------------------------------------------------------------------
/sample/egg/app/schedule/sendschedule.ts:
--------------------------------------------------------------------------------
1 | import { Subscription } from 'egg'
2 |
3 | export default class SendSchedule extends Subscription {
4 | /**
5 | * * * * * *
6 | ┬ ┬ ┬ ┬ ┬ ┬
7 | │ │ │ │ │ |
8 | │ │ │ │ │ └ 星期 (0 - 7) (0或7都是星期日)
9 | │ │ │ │ └───── 月份 (1 - 12)
10 | │ │ │ └────────── 日期 (1 - 31)
11 | │ │ └─────────────── 小时 (0 - 23)
12 | │ └──────────────────── 分钟 (0 - 59)
13 | └───────────────────────── 秒 (0 - 59, optional)
14 | ————————————————
15 | */
16 | static get schedule() {
17 | return {
18 | // interval: '10s', // 每 10 秒执行一次
19 | cron: '0 0 7,8 * * *', // 每天 7/8点 执行一次
20 | // cron: '0 53,54 17 * * *',
21 | type: 'all' // 指定所有的 worker 都需要执行
22 | }
23 | }
24 |
25 | // subscribe 是真正定时任务执行时被运行的函数
26 | async subscribe() {
27 | await this.ctx.service.weather.send()
28 | console.log('执行定时器')
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/egg/app/view/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {{ title }}
8 |
9 |
10 |
11 |
12 | {{ title }}
13 | TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业微信/企业号。最最最重要的是能快速的集成至任何 Node.js
14 | 框架(Express、Nest、Egg、Koa 等)
15 | 作者:@Javen
16 | 交流群:114196246
17 | 开源推荐:
18 | 1、IJPay 让支付触手可及:https://gitee.com/javen205/IJPay
19 | 2、SpringBoot 微服务高效开发 mica 工具集:https://gitee.com/596392912/mica
20 | 3、pig 宇宙最强微服务(架构师必备):https://gitee.com/log4j/pig
21 | 4、SpringBlade 完整的线上解决方案(企业开发必备):https://gitee.com/smallc/SpringBlade
22 | 5、Avue 一款基于 vue 可配置化的神奇框架:https://gitee.com/smallweigit/avue
23 |
24 |
25 |
26 |
27 |
28 |
29 | 其他赞助方式
30 |
31 |
32 | 前往赞助
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/sample/egg/app/view/openmp.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 微信开放平台授权页面
8 |
9 |
10 | 点此链接进行授权
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/egg/appveyor.yml:
--------------------------------------------------------------------------------
1 | environment:
2 | matrix:
3 | - nodejs_version: '8'
4 |
5 | install:
6 | - ps: Install-Product node $env:nodejs_version
7 | - npm i npminstall && node_modules\.bin\npminstall
8 |
9 | test_script:
10 | - node --version
11 | - npm --version
12 | - npm run test
13 |
14 | build: off
15 |
--------------------------------------------------------------------------------
/sample/egg/config/config.local.ts:
--------------------------------------------------------------------------------
1 | import { EggAppConfig, PowerPartial } from 'egg';
2 |
3 | export default () => {
4 | const config: PowerPartial = {};
5 | return config;
6 | };
7 |
--------------------------------------------------------------------------------
/sample/egg/config/config.prod.ts:
--------------------------------------------------------------------------------
1 | import { EggAppConfig, PowerPartial } from 'egg'
2 |
3 | export default () => {
4 | const config: PowerPartial = {}
5 | return config
6 | }
7 |
--------------------------------------------------------------------------------
/sample/egg/config/env:
--------------------------------------------------------------------------------
1 | dev
--------------------------------------------------------------------------------
/sample/egg/config/plugin.ts:
--------------------------------------------------------------------------------
1 | import { EggPlugin } from 'egg'
2 |
3 | const plugin: EggPlugin = {
4 | static: true,
5 | nunjucks: {
6 | enable: true,
7 | package: 'egg-view-nunjucks'
8 | },
9 | mysql: {
10 | enable: false,
11 | package: 'egg-mysql'
12 | }
13 | }
14 |
15 | export default plugin
16 |
--------------------------------------------------------------------------------
/sample/egg/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "egg",
3 | "version": "1.0.0",
4 | "description": "egg example for tnwx",
5 | "private": true,
6 | "egg": {
7 | "typescript": true,
8 | "declarations": true
9 | },
10 | "scripts": {
11 | "start": "egg-scripts start --daemon --title=egg-server-egg",
12 | "stop": "egg-scripts stop --title=egg-server-egg",
13 | "dev": "egg-bin dev --port 8888",
14 | "debug": "egg-bin debug",
15 | "test-local": "egg-bin test",
16 | "test": "npm run lint -- --fix && npm run test-local",
17 | "cov": "egg-bin cov",
18 | "tsc": "ets && tsc -p tsconfig.json",
19 | "ci": "npm run lint && npm run cov && npm run tsc",
20 | "autod": "autod",
21 | "lint": "eslint . --ext .ts",
22 | "clean": "ets clean"
23 | },
24 | "dependencies": {
25 | "egg": "^2.6.1",
26 | "egg-mysql": "^3.0.0",
27 | "egg-scripts": "^2.6.0",
28 | "egg-view-nunjucks": "^2.2.0",
29 | "raw-body": "^2.4.1",
30 | "tnwx": "^2.4.0",
31 | "x509": "^0.3.4"
32 | },
33 | "devDependencies": {
34 | "@types/mocha": "^2.2.40",
35 | "@types/node": "^7.0.12",
36 | "@types/supertest": "^2.0.0",
37 | "autod": "^3.0.1",
38 | "autod-egg": "^1.1.0",
39 | "egg-ci": "^1.8.0",
40 | "egg-bin": "^4.11.0",
41 | "egg-mock": "^3.16.0",
42 | "tslib": "^1.9.0",
43 | "eslint": "^6.7.2",
44 | "eslint-config-egg": "^8.0.0",
45 | "typescript": "^3.0.0"
46 | },
47 | "engines": {
48 | "node": ">=8.9.0"
49 | },
50 | "ci": {
51 | "version": "8"
52 | },
53 | "repository": {
54 | "type": "git",
55 | "url": ""
56 | },
57 | "eslintIgnore": [
58 | "coverage"
59 | ],
60 | "author": "Javen",
61 | "license": "MIT"
62 | }
63 |
--------------------------------------------------------------------------------
/sample/egg/test/app/controller/home.test.ts:
--------------------------------------------------------------------------------
1 | import * as assert from 'assert';
2 | import { app } from 'egg-mock/bootstrap';
3 |
4 | describe('test/app/controller/home.test.ts', () => {
5 | it('should GET /', async () => {
6 | const result = await app.httpRequest().get('/').expect(200);
7 | assert(result.text === 'hi, egg');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/sample/egg/test/app/service/Test.test.ts:
--------------------------------------------------------------------------------
1 | import * as assert from 'assert';
2 | import { Context } from 'egg';
3 | import { app } from 'egg-mock/bootstrap';
4 |
5 | describe('test/app/service/Test.test.js', () => {
6 | let ctx: Context;
7 |
8 | before(async () => {
9 | ctx = app.mockContext();
10 | });
11 |
12 | it('sayHi', async () => {
13 | const result = await ctx.service.test.sayHi('egg');
14 | assert(result === 'hi, egg');
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/sample/egg/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": true,
3 | "compilerOptions": {
4 | "target": "es2017",
5 | "module": "commonjs",
6 | "strict": true,
7 | "noImplicitAny": false,
8 | "experimentalDecorators": true,
9 | "emitDecoratorMetadata": true,
10 | "charset": "utf8",
11 | "allowJs": false,
12 | "pretty": true,
13 | "noEmitOnError": false,
14 | "noUnusedLocals": true,
15 | "noUnusedParameters": true,
16 | "allowUnreachableCode": false,
17 | "allowUnusedLabels": false,
18 | "strictPropertyInitialization": false,
19 | "noFallthroughCasesInSwitch": true,
20 | "skipLibCheck": true,
21 | "skipDefaultLibCheck": true,
22 | "inlineSourceMap": true,
23 | "importHelpers": true
24 | },
25 | "exclude": [
26 | "app/public",
27 | "app/views",
28 | "node_modules*"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/sample/egg/typings/app/controller/index.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | import ExportHome from '../../../app/controller/home';
6 | import ExportWxpay from '../../../app/controller/wxpay';
7 | import ExportOpencpOpencpapi from '../../../app/controller/opencp/opencpapi';
8 | import ExportOpenmpOpenmpapi from '../../../app/controller/openmp/openmpapi';
9 | import ExportOpenmpOpenmpmsg from '../../../app/controller/openmp/openmpmsg';
10 | import ExportWxcpQyapi from '../../../app/controller/wxcp/qyapi';
11 | import ExportWxcpQyjssdk from '../../../app/controller/wxcp/qyjssdk';
12 | import ExportWxcpQymsg from '../../../app/controller/wxcp/qymsg';
13 | import ExportWxmpJssdk from '../../../app/controller/wxmp/jssdk';
14 | import ExportWxmpMpmsg from '../../../app/controller/wxmp/mpmsg';
15 |
16 | declare module 'egg' {
17 | interface IController {
18 | home: ExportHome;
19 | wxpay: ExportWxpay;
20 | opencp: {
21 | opencpapi: ExportOpencpOpencpapi;
22 | }
23 | openmp: {
24 | openmpapi: ExportOpenmpOpenmpapi;
25 | openmpmsg: ExportOpenmpOpenmpmsg;
26 | }
27 | wxcp: {
28 | qyapi: ExportWxcpQyapi;
29 | qyjssdk: ExportWxcpQyjssdk;
30 | qymsg: ExportWxcpQymsg;
31 | }
32 | wxmp: {
33 | jssdk: ExportWxmpJssdk;
34 | mpmsg: ExportWxmpMpmsg;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/egg/typings/app/index.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | export * from 'egg';
6 | export as namespace Egg;
7 |
--------------------------------------------------------------------------------
/sample/egg/typings/app/middleware/index.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | import ExportJssdk from '../../../app/middleware/jssdk';
6 | import ExportOpenjssdk from '../../../app/middleware/openjssdk';
7 | import ExportQyjssdk from '../../../app/middleware/qyjssdk';
8 |
9 | declare module 'egg' {
10 | interface IMiddleware {
11 | jssdk: typeof ExportJssdk;
12 | openjssdk: typeof ExportOpenjssdk;
13 | qyjssdk: typeof ExportQyjssdk;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample/egg/typings/app/service/index.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | type AnyClass = new (...args: any[]) => any;
6 | type AnyFunc = (...args: any[]) => T;
7 | type CanExportFunc = AnyFunc> | AnyFunc>;
8 | type AutoInstanceType : T> = U extends AnyClass ? InstanceType : U;
9 | import ExportWeather from '../../../app/service/Weather';
10 |
11 | declare module 'egg' {
12 | interface IService {
13 | weather: AutoInstanceType;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample/egg/typings/config/index.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | import { EggAppConfig } from 'egg';
6 | import ExportConfigDefault from '../../config/config.default';
7 | type ConfigDefault = ReturnType;
8 | type NewEggAppConfig = ConfigDefault;
9 | declare module 'egg' {
10 | interface EggAppConfig extends NewEggAppConfig { }
11 | }
--------------------------------------------------------------------------------
/sample/egg/typings/config/plugin.d.ts:
--------------------------------------------------------------------------------
1 | // This file is created by egg-ts-helper@1.25.7
2 | // Do not modify this file!!!!!!!!!
3 |
4 | import 'egg';
5 | import 'egg-onerror';
6 | import 'egg-session';
7 | import 'egg-i18n';
8 | import 'egg-watcher';
9 | import 'egg-multipart';
10 | import 'egg-security';
11 | import 'egg-logrotator';
12 | import 'egg-schedule';
13 | import 'egg-static';
14 | import 'egg-jsonp';
15 | import 'egg-view';
16 | import 'egg-view-nunjucks';
17 | import { EggPluginItem } from 'egg';
18 | declare module 'egg' {
19 | interface EggPlugin {
20 | onerror?: EggPluginItem;
21 | session?: EggPluginItem;
22 | i18n?: EggPluginItem;
23 | watcher?: EggPluginItem;
24 | multipart?: EggPluginItem;
25 | security?: EggPluginItem;
26 | development?: EggPluginItem;
27 | logrotator?: EggPluginItem;
28 | schedule?: EggPluginItem;
29 | static?: EggPluginItem;
30 | jsonp?: EggPluginItem;
31 | view?: EggPluginItem;
32 | nunjucks?: EggPluginItem;
33 | mysql?: EggPluginItem;
34 | }
35 | }
--------------------------------------------------------------------------------
/sample/egg/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | import 'egg'
2 |
3 | declare module 'egg' {
4 | interface mysql {
5 | get(tableName: String, find: {}): Promise
6 | query(sql: String, values: Any[]): Promise
7 | insert(sql: String, object: Object): Promise
8 | select(sql: String, object: Object): Promise
9 | delete(sql: String, object: Object): Promise
10 | }
11 | interface Application {
12 | mysql: mysql
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sample/express/README.md:
--------------------------------------------------------------------------------
1 | ## QuickStart
2 |
3 | ```bash
4 | $ yarn # 安装依赖
5 | $ yarn build #编译
6 | $ yarn dev # 运行
7 | ```
--------------------------------------------------------------------------------
/sample/express/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@express/tnwx",
3 | "main": "dist/index.js",
4 | "license": "Apache-2.0",
5 | "scripts": {
6 | "dev": "supervisor -w dist ./dist/App.js",
7 | "build": "tsc"
8 | },
9 | "dependencies": {
10 | "express": "^4.17.1"
11 | },
12 | "devDependencies": {
13 | "@types/express": "^4.17.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sample/express/src/http.ts:
--------------------------------------------------------------------------------
1 | import * as http from 'http'
2 | import * as fs from 'fs'
3 | import * as url from 'url'
4 |
5 | let pathname: string
6 | // 创建服务器
7 | http
8 | .createServer(function(request: http.IncomingMessage, response: http.ServerResponse) {
9 | // 解析请求,包括文件名
10 | pathname = url.parse(request.url || '').pathname
11 |
12 | // 输出请求的文件名
13 | console.log('Request for ' + pathname + ' received.')
14 |
15 | // 从文件系统中读取请求的文件内容
16 | fs.readFile('./views/' + pathname.substr(1), function(err, data) {
17 | if (err) {
18 | console.log(err)
19 | // HTTP 状态码: 404 : NOT FOUND
20 | // Content Type: text/plain
21 | response.writeHead(404, { 'Content-Type': 'text/html' })
22 | } else {
23 | // HTTP 状态码: 200 : OK
24 | // Content Type: text/plain
25 | response.writeHead(200, { 'Content-Type': 'text/html' })
26 |
27 | // 响应文件内容
28 | response.write(data.toString())
29 | }
30 | // 发送响应数据
31 | response.end()
32 | })
33 | })
34 | .listen(8081)
35 |
36 | // 控制台会输出以下信息
37 | console.log('Server running at http://127.0.0.1:8081/')
38 |
--------------------------------------------------------------------------------
/sample/express/static/WW_verify_iDBWSTNEMIzAbXYN.txt:
--------------------------------------------------------------------------------
1 | iDBWSTNEMIzAbXYN
--------------------------------------------------------------------------------
/sample/express/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | TNWX 微信系脚手架
8 |
9 |
10 |
11 |
12 | 欢迎使用 TNWX 微信系脚手架 By Javen
13 | TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业微信/企业号。最最最重要的是能快速的集成至任何 Node.js
14 | 框架(Express、Nest、Egg、Koa 等)
15 | 作者:@Javen
16 | 交流群:114196246
17 | 开源推荐:
18 | 1、IJPay 让支付触手可及:https://gitee.com/javen205/IJPay
19 | 2、SpringBoot 微服务高效开发 mica 工具集:https://gitee.com/596392912/mica
20 | 3、pig 宇宙最强微服务(架构师必备):https://gitee.com/log4j/pig
21 | 4、SpringBlade 完整的线上解决方案(企业开发必备):https://gitee.com/smallc/SpringBlade
22 | 5、Avue 一款基于 vue 可配置化的神奇框架:https://gitee.com/smallweigit/avue
23 |
24 |
25 |
26 |
27 |
28 |
29 | 其他赞助方式
30 |
31 |
32 | 前往赞助
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/sample/express/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "declaration": true,
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "noLib": false,
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es6",
11 | "sourceMap": true,
12 | "lib": ["es6"],
13 | "outDir": "./dist",
14 | "watch": true
15 | },
16 | "exclude": [
17 | "node_modules",
18 | ],
19 | "include": [
20 | "./src"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "declaration": true,
5 | "noImplicitAny": false,
6 | "removeComments": false,
7 | "noLib": false,
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es6",
11 | "sourceMap": true,
12 | "lib": ["es6"]
13 | },
14 | "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"]
15 | }
16 |
--------------------------------------------------------------------------------