Compare commits

..

82 Commits

Author SHA1 Message Date
温雍敬 a60134437a message
2 years ago
温雍敬 d8a681bbc7 message
2 years ago
温雍敬 bbddcfa9db message
2 years ago
温雍敬 9288d10d38 结项文档
2 years ago
温雍敬 dbc8dea9df 需求/设计规格说明书
2 years ago
温雍敬 1b0bdcf27e Tutor-service miniprogram
2 years ago
温雍敬 78d1d8c247 Comments function
2 years ago
温雍敬 cdcc21bc72 comments function
2 years ago
温雍敬 27ee2e6871 Comments function
2 years ago
温雍敬 b5786cd580 Comments function
2 years ago
孔维屿 da7f53c554 compelete login system
2 years ago
孔维屿 8ef89e26a9 compelete login system
2 years ago
孔维屿 e5478db4de Merge branch 'dev' into kongweiyu_branch
2 years ago
孔维屿 f0a3712530 create the deatils page
2 years ago
温雍敬 28bd0c455e miniprogram/app.json
2 years ago
孔维屿 e649f769f3 create the deatils page
2 years ago
孔维屿 e59bd68d97 Merge branch 'dev' into kongweiyu_branch
2 years ago
孔维屿 cbd067b010 some changes
2 years ago
温雍敬 e5f0e9ec2e miniprogram/pages/Comments
2 years ago
孔维屿 909bc5573c none
2 years ago
温雍敬 45fda71950 miniprogram
2 years ago
孔维屿 ee10fad031 modified some style sheet
2 years ago
孔维屿 1fb735ebcd Merge branch 'dev' into kongweiyu_branch
2 years ago
温雍敬 197b30a141 miniprogram
2 years ago
孔维屿 80ee48d8ba add a dialog component
2 years ago
孔维屿 3b82cb9c2f add two methods
2 years ago
温雍敬 6ffd16b692 已修改
2 years ago
孔维屿 dc8ab695c5 Merge branch 'dev' into kongweiyu_branch
2 years ago
孔维屿 0df4d216a9 polish the main page
2 years ago
温雍敬 dde67b878b Merge branch 'kongweiyu_branch' of https://bdgit.educoder.net/mvpola2e5/gitProject1 into dev
2 years ago
孔维屿 bbb5919bb8 add some methods
2 years ago
温雍敬 97e10672a9 add.image
2 years ago
孔维屿 fc8a36472c 1
2 years ago
温雍敬 732b7d2b4f miniprogram
2 years ago
孔维屿 02adbd9c27 Merge branch 'dev' into kongweiyu_branch
2 years ago
孔维屿 7fdc64367a fix the teacherprofile page
2 years ago
温雍敬 b82317c981 miniprogram
2 years ago
温雍敬 0c9380cf10 miniprogram
2 years ago
温雍敬 55820b258f miniprogram
2 years ago
温雍敬 ed5644edcf Merge branch 'master' of https://bdgit.educoder.net/mvpola2e5/gitProject1 into dev
2 years ago
温雍敬 41ee8a4f0e miniprogram
2 years ago
温雍敬 d9523c5a1d Merge branch 'kongweiyu_branch' of https://bdgit.educoder.net/mvpola2e5/gitProject1 into dev
2 years ago
孔维屿 e41319be09 some small changes
2 years ago
温雍敬 9265819916 Merge branch 'kongweiyu_branch' of https://bdgit.educoder.net/mvpola2e5/gitProject1 into dev
2 years ago
温雍敬 b8d89aac7e miniprogram
2 years ago
孔维屿 b0508e3050 add a wx:for
2 years ago
孔维屿 6015f30e13 add some database methead
2 years ago
温雍敬 c9b59f17aa miniprogram
2 years ago
温雍敬 eb14b5cbf4 miniprogram
2 years ago
孔维屿 fa481b2f20 handin
2 years ago
温雍敬 ea08ac4594 miniprogram
2 years ago
温雍敬 664bde5164 miniprogram
2 years ago
温雍敬 a37ea6826e miniprogram
2 years ago
mvpola2e5 1544e42e85 Merge pull request '需求模型/设计模型_家教服务系统(v2.0)' (#9) from dev into master
2 years ago
温雍敬 31e0335543 设计模型_家教服务系统(v2.0)
2 years ago
温雍敬 3467a7e094 需求模型_家教服务系统(v2.0)
2 years ago
温雍敬 88e2d69994 model_design
2 years ago
mvpola2e5 2cb6fab085 Merge pull request 'init miniprogram' (#8) from dev into master
2 years ago
温雍敬 8a117b9dcb program
2 years ago
温雍敬 18209c20bf 设计模型修改
2 years ago
mvpola2e5 58fb8864f1 Merge pull request 'init miniprogram' (#7) from dev into master
2 years ago
温雍敬 daf026ea81 program
2 years ago
mvpola2e5 048f8d3bbd Merge pull request 'init miniprogram' (#6) from dev into master
2 years ago
温雍敬 9789cecedc init miniprogram
2 years ago
mvpola2e5 9840e962bc Merge pull request '初始化项目文件' (#5) from kongweiyu_branch into master
2 years ago
温雍敬 01885408a7 init miniprogram
2 years ago
温雍敬 4519fa4e9c Merge branch 'kongweiyu_branch' of https://bdgit.educoder.net/mvpola2e5/gitProject1 into dev
2 years ago
温雍敬 0fc5b102ef Merge branch 'zhouludong_branch' into dev
2 years ago
孔维屿 2ca5a78def init miniprogram
2 years ago
mvpola2e5 3349b398a9 Merge pull request '设计模型' (#4) from dev into master
2 years ago
温雍敬 83808ff572 设计模型_家教服务系统_温雍敬
2 years ago
mvpola2e5 3ff9ac998a Merge pull request '需求模型修改' (#3) from dev into master
2 years ago
温雍敬 6aaa95e611 需求模型修改
2 years ago
mvpola2e5 1988418b9f Merge pull request '需求模型' (#2) from dev into master
2 years ago
温雍敬 3b7cbf79c5 需求模型
2 years ago
温雍敬 5a8afb942b 需求模型
2 years ago
mvpola2e5 4465b65288 Merge pull request '需求模型' (#1) from dev into master
2 years ago
温雍敬 ca15ec421c 需求模型
2 years ago
温雍敬 530c5169c3 需求模型
2 years ago
温雍敬 c1cecb73dd test
2 years ago
温雍敬 d2a320a82f test
2 years ago
温雍敬 a7a8c0d094 test
2 years ago

@ -1,2 +0,0 @@
# gitProject1

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

14
src/.gitignore vendored

@ -0,0 +1,14 @@
# Windows
[Dd]esktop.ini
Thumbs.db
$RECYCLE.BIN/
# macOS
.DS_Store
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
# Node.js
node_modules/

@ -0,0 +1,12 @@
# 云开发 quickstart
这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
## 参考文档
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)

@ -0,0 +1,26 @@
# 三维识别与重建云服务
## proto更新
### 依赖安装
```
// ARModel 下
tnpm install --save-dev @tencent/cloud-functions-tools@latest
```
### 基于 proto 文件生成脚本逻辑
```
// ARModel 下
npm run svrkit
```
## 服务更新
```
1. 安装 ARModel 下本地 npm 依赖
2. 云函数环境切为 test环境
3. ARModel 右键上传所有文件(由于有@tencent的子包
```

@ -0,0 +1,23 @@
#!/usr/bin/env node
const path = require('path')
const yargs = require('yargs')
yargs
.usage('Usage: $0 -c [config] -o [output]')
.example('$0 -c ./svrkit.config.js -o ./svrkit-utils.js')
.alias('c', 'config')
.describe('c', 'svrkit config js file path')
.alias('o', 'output')
.describe('o', 'svrkit-utils output file path, defaults to svrkit-utils.js under the same folder of svrkit config file')
.describe('--keep-case', 'keeps field casing instead of converting to camcel case')
.demandOption(['c'])
.help('h')
.alias('h', 'help')
.argv
const cli = require(path.join(__dirname, '../cli/svrkit-utils.js'))
const ret = cli.main(process.argv.slice(2))
if (typeof ret === 'number') {
process.exit(ret)
}

@ -0,0 +1,114 @@
function generate(options) {
if (!options) {
throw new Error('options must be provided')
}
const { serviceName, funcName, data } = options
const serviceConfig = config.find(c => c.serviceName === serviceName)
if (!serviceConfig) {
throw new Error('service not found')
}
if (!serviceConfig.functions[funcName]) {
throw new Error('function not found')
}
const reqProtoName = serviceConfig.functions[funcName].req
const reqProto = proto[reqProtoName]
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = serviceConfig.functions[funcName].res
const resProto = resProtoName && proto[resProtoName]
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
serviceName,
funcName,
magic: serviceConfig.magic,
cmdid: serviceConfig.functions[funcName].cmdid,
existResp: Boolean(resProto),
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
function generateV2(options) {
if (!options) {
throw new Error('options must be provided')
}
const { apiName, data } = options
const apiConfig = config.find(c => c.apiName === apiName)
const reqProtoName = apiConfig.req
const reqProto = proto[reqProtoName]
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = apiConfig.res
const resProto = proto[resProtoName]
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
apiName,
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
module.exports = {
generate,
generateV2,
}

@ -0,0 +1,98 @@
const fs = require('fs')
const path = require('path')
const yargs = require('yargs')
const chalk = require('chalk')
const debug = require('debug')('cli')
const pbjs = require("protobufjs/cli/pbjs")
const log = (...msg) => {
console.log(chalk.blue('svrkit-utils'), ...msg)
}
function main() {
debug('process.cwd', process.cwd())
debug('yargs.argv', yargs.argv)
if (yargs.argv.config) {
const configPath = path.resolve(process.cwd(), yargs.argv.config)
const config = require(configPath)
const protos = config.map(c => path.resolve(path.dirname(configPath), c.proto))
if (yargs.argv.output) {
if (!yargs.argv.output.endsWith('.js')) {
throw new Error('output file name must ends with .js')
}
}
const outputDest = yargs.argv.output || path.resolve(path.dirname(configPath), 'svrkit-utils.js')
const outputFileName = path.basename(outputDest)
const outputFilePath = path.resolve(process.cwd(), outputDest)
debug('outputDest', outputDest)
debug('outputFilePath', outputFilePath)
const staticModuleFileName = `${outputFileName.slice(0, -3)}.static.js`
const staticModuleFilePath = path.resolve(path.dirname(outputFilePath), staticModuleFileName)
const staticJsonFileName = `${outputFileName.slice(0, -3)}.static.json`
const staticJsonFilePath = path.resolve(path.dirname(outputFilePath), staticJsonFileName)
log('generating static module')
const pbjsArgs = ['-t', 'static-module', '-w', 'commonjs', '-l', 'eslint-disable', '-o', staticModuleFilePath, ...protos]
if (yargs.argv.keepCase) {
pbjsArgs.unshift('--keep-case')
}
pbjs.main(pbjsArgs, (err, out) => {
if (err) {
throw err
}
let staticModuleContent = fs.readFileSync(staticModuleFilePath, 'utf8')
fs.writeFileSync(staticModuleFilePath, `// #lizard forgives
${staticModuleContent}`, 'utf8')
log('static module generated')
log('generating json descriptors')
pbjs.main(['-t', 'json', '-o', staticJsonFilePath, ...protos], (err, out) => {
if (err) {
throw err
}
log('json descriptors generated')
try {
const protoUtils = fs.readFileSync(path.join(__dirname, './svrkit-utils-template.js'), 'utf8')
let svrkitConfigRelativePath = path.relative(path.dirname(outputDest), configPath)
if (!svrkitConfigRelativePath.startsWith('.')) {
svrkitConfigRelativePath = `./${svrkitConfigRelativePath}`
}
const output = `
const config = require('${svrkitConfigRelativePath}')
const proto = require('./${staticModuleFileName}')
const protoJSON = require('./${staticJsonFileName}')
${protoUtils}
`
fs.writeFileSync(outputFilePath, output, 'utf8')
log(`${outputFileName} generated`)
} catch (err) {
throw err
}
})
})
} else {
throw new Error('config file must be provided')
}
}
module.exports = {
main,
}

@ -0,0 +1,20 @@
{
"name": "@tencent/cloud-functions-tools",
"version": "1.5.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "alankldeng",
"license": "ISC",
"bin": {
"svrkit-utils": "bin/svrkit-utils"
},
"dependencies": {
"chalk": "^2.4.1",
"debug": "^4.1.0",
"protobufjs": "^6.8.8",
"yargs": "^12.0.5"
}
}

@ -0,0 +1,38 @@
const config = require('./svrkit.config.js')
const proto = require('./bundle.js')
function generate(options) {
if (!options) {
throw new Error('options must be provided')
}
const { serviceName, funcName, data } = options
const serviceConfig = config.find(c => c.serviceName === serviceName)
if (!serviceConfig) {
throw new Error('service not found')
}
if (!serviceConfig.functions[funcName]) {
throw new Error('function not found')
}
const reqProto = proto[serviceConfig.functions[funcName].req]
const resProto = proto[serviceConfig.functions[funcName].res]
return {
data: {
serviceName,
funcName,
magic: serviceConfig.magic,
cmdid: serviceConfig.functions[funcName].cmdid,
existResp: serviceConfig.functions[funcName].existResp,
reqBodyBuffer: reqProto.encode(data),
},
decode: buf => resProto.decode(resProto)
}
}
module.exports = {
generate,
}

@ -0,0 +1,9 @@
message ApiDemoReq
{
optional string str = 2;
}
message ApiDemoResp
{
optional string str = 2;
}

@ -0,0 +1,20 @@
message GetWeAppMemberByUserReq
{
optional uint32 useruin = 1;
optional uint32 type = 2; //1: 2: 3: 4:
optional uint32 status = 3; //SAFECENTER_WEAPP_STATUS_XXX
}
message WeAppMemberInfo
{
optional uint32 type = 1;
optional uint32 weappuin = 2;
optional uint32 useruin = 3;
optional uint32 status = 4;
optional uint32 createtime = 5;
optional uint32 updatetime = 6;
optional string ticket = 7;
}
message WeAppMemberInfoList
{
repeated WeAppMemberInfo infos = 1;
}

@ -0,0 +1,11 @@
message GenWxaCloudTmpCodeReq
{
optional uint32 CloudPlatform = 1;
optional uint32 AppUin = 2;
optional uint32 UserUin = 3;
}
message GenWxaCloudTmpCodeResp
{
optional string TmpCode = 1;
}

@ -0,0 +1,119 @@
const config = require('./svrkit.config.js')
const proto = require('./svrkit-utils.static.js')
const protoJSON = require('./svrkit-utils.static.json')
function generate(options) {
if (!options) {
throw new Error('options must be provided')
}
const { serviceName, funcName, data } = options
const serviceConfig = config.find(c => c.serviceName === serviceName)
if (!serviceConfig) {
throw new Error('service not found')
}
if (!serviceConfig.functions[funcName]) {
throw new Error('function not found')
}
const reqProtoName = serviceConfig.functions[funcName].req
const reqProto = proto[reqProtoName]
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = serviceConfig.functions[funcName].res
const resProto = resProtoName && proto[resProtoName]
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
serviceName,
funcName,
magic: serviceConfig.magic,
cmdid: serviceConfig.functions[funcName].cmdid,
existResp: Boolean(resProto),
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
function generateV2(options) {
if (!options) {
throw new Error('options must be provided')
}
const { apiName, data } = options
const apiConfig = config.find(c => c.apiName === apiName)
const reqProtoName = apiConfig.req
const reqProto = proto[reqProtoName]
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = apiConfig.res
const resProto = proto[resProtoName]
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
apiName,
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
module.exports = {
generate,
generateV2,
}

@ -0,0 +1,101 @@
{
"nested": {
"ApiDemoReq": {
"fields": {
"str": {
"type": "string",
"id": 2
}
}
},
"ApiDemoResp": {
"fields": {
"str": {
"type": "string",
"id": 2
}
}
},
"GenWxaCloudTmpCodeReq": {
"fields": {
"CloudPlatform": {
"type": "uint32",
"id": 1
},
"AppUin": {
"type": "uint32",
"id": 2
},
"UserUin": {
"type": "uint32",
"id": 3
}
}
},
"GenWxaCloudTmpCodeResp": {
"fields": {
"TmpCode": {
"type": "string",
"id": 1
}
}
},
"GetWeAppMemberByUserReq": {
"fields": {
"useruin": {
"type": "uint32",
"id": 1
},
"type": {
"type": "uint32",
"id": 2
},
"status": {
"type": "uint32",
"id": 3
}
}
},
"WeAppMemberInfo": {
"fields": {
"type": {
"type": "uint32",
"id": 1
},
"weappuin": {
"type": "uint32",
"id": 2
},
"useruin": {
"type": "uint32",
"id": 3
},
"status": {
"type": "uint32",
"id": 4
},
"createtime": {
"type": "uint32",
"id": 5
},
"updatetime": {
"type": "uint32",
"id": 6
},
"ticket": {
"type": "string",
"id": 7
}
}
},
"WeAppMemberInfoList": {
"fields": {
"infos": {
"rule": "repeated",
"type": "WeAppMemberInfo",
"id": 1
}
}
}
}
}

@ -0,0 +1,32 @@
module.exports = [
{
proto: './proto/demo.proto',
apiName: 'demo',
req: 'ApiDemoReq',
res: 'ApiDemoResp'
},
{
proto: './proto/mmbizwxatmpcode.proto',
serviceName: 'MMBizWxaCloud',
magic: 13299,
functions: {
GenWxaCloudTmpCode: {
cmdid: 3,
req: 'GenWxaCloudTmpCodeReq',
res: 'GenWxaCloudTmpCodeResp',
},
}
},
{
proto: './proto/mmbizsafecenter.proto',
serviceName: 'mmbizsafecenter',
magic: 12085,
functions: {
GetWeAppMemberByUser: {
cmdid: 73,
req: 'GetWeAppMemberByUserReq',
res: 'WeAppMemberInfoList',
},
}
},
]

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -0,0 +1,62 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
const wxgService = require('./wx-server-sdk-wxg-service')
const svrkitUtils = require('./svrkit-utils.js')
cloud.registerService(wxgService)
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
const bizuin = wxContext.APPUIN
switch (event.type) {
case "GenerateARModel":
return await cloud.callWXSvrkit({
pbInstance: svrkitUtils.generate({
serviceName: "Mmbizwxaintpar",
funcName: "GenerateARModel",
data: {
bizuin: bizuin,
name: event.name,
url: event.url,
algoType: event.algoType,
getmesh: event.getMesh,
gettexture: event.getTexture
},
}),
timeout: 30000,
});
case "GetARModel":
return await cloud.callWXSvrkit({
pbInstance: svrkitUtils.generate({
serviceName: "Mmbizwxaintpar",
funcName: "GetARModel",
data: {
bizuin: bizuin,
cosid: event.cosid,
modelType: event.modelType,
needData: event.needData,
useIntranet: event.useIntranet,
expireTime: event.expireTime
},
}),
timeout: 30000,
});
// GetARModelList 废弃,完全依赖本地缓存
// case "GetARModelList":
// return await cloud.callWXSvrkit({
// pbInstance: svrkitUtils.generate({
// serviceName: "Mmbizwxaintpar",
// funcName: "GetARModelList",
// data: {
// bizuin: bizuin,
// modelStatus: event.modelStatus,
// algoType: event.algoType
// },
// }),
// timeout: 30000,
// });
}
}

@ -0,0 +1,18 @@
{
"name": "ARDemo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"svrkit": "svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "^2.6.3"
},
"devDependencies": {
"@tencent/cloud-functions-tools": "^1.7.0"
}
}

@ -0,0 +1,115 @@
enum enARModelStatus
{
ARModel_Status_Default = 0;
ARModel_Status_Init = 1;
ARModel_Status_Sparse_Finished = 2;
ARModel_Status_3d_Finished = 3;
ARModel_Status_Object_Finished = 4;
ARModel_Status_Marker_Finished = 5;
ARModel_Status_Fail = 100;
}
enum enARAlgorithmType
{
Algorithm_Type_3D_Object = 1;
Algorithm_Type_3D_Marker = 2;
}
enum enARModelType
{
ARModel_Type_Sparse = 1;
ARModel_Type_3D = 2;
ARModel_Type_Marker = 3;
}
message ModelCos
{
message ModelCosId
{
optional enARModelType model_type = 1;
optional string model_cosid = 2;
optional string errmsg = 3;
}
repeated ModelCosId model_list = 1;
}
message ARModel
{
//option(mmbizintpkv.KvTableID) = 493;
option(mmbizintpkv.KvTableTestID) = 916;
optional string cosid = 1; // cosid
optional uint32 bizuin = 2;
optional string name = 3; //
optional uint32 upload_time = 4;
optional enARModelStatus model_status = 5;
optional enARAlgorithmType algo_type = 6;
optional ModelCos model_cos = 7;
}
message GetARModelListReq
{
optional uint32 bizuin = 1;
optional uint32 model_status = 2; // enARModelStatus
optional uint32 start_time = 3;
optional uint32 end_time = 4;
optional uint32 offset = 5;
optional uint32 limit = 6;
optional uint32 algo_type = 7; // enARAlgorithmType
}
message GetARModelListResp
{
repeated ARModel model_list = 1;
}
message GenerateARModelReq
{
optional uint32 bizuin = 1;
optional string name = 2;
optional bytes buffer = 3;
optional string url = 4;
optional enARAlgorithmType algo_type = 5;
optional uint32 lod = 6[default=0]; // , 0, 1,2,3
optional bool getmesh = 7[default=false];
optional bool gettexture = 8[default=false];
}
message GenerateARModelResp
{
optional string url = 1;
optional string host = 2;
optional string cosid = 3;
optional uint32 lod = 4[default=0];
optional bool getmesh = 5[default=false];
optional bool gettexture = 6[default=false];
}
message ARModelData
{
optional bytes mesh_model = 1; // ()
optional bytes texture_model = 2; // png
optional bytes preview = 3;
optional bytes mesh_blob = 4; // obj, getmesh = true
optional bytes texture_blob = 5; // , gettexture = true
}
message GetARModelReq
{
optional uint32 bizuin = 1;
optional string cosid = 2;
optional uint32 model_type = 3; // 1: 2:3d
optional uint32 need_data = 4[default=1]; // 0: 1:
optional uint32 use_intranet = 5[default=0]; // need_data0 0: 1:
optional uint32 expire_time = 6; // url,5,
}
message GetARModelResp
{
optional ARModelData model_data = 1;
optional string url = 2;
optional string host = 3;
optional string errMsg = 4;
optional uint32 expire_time = 5;
optional uint32 status = 6; // 0 1 2
}

@ -0,0 +1,136 @@
const config = require('./svrkit.config.js')
const proto = require('./svrkit-utils.static.js')
const protoJSON = require('./svrkit-utils.static.json')
function getProto(proto, serviceName, protoName) {
if (proto[protoName]) {
return proto[protoName];
}
if (proto[serviceName] && proto[serviceName][protoName]) {
return proto[serviceName][protoName];
}
/** 处理 mmpayolcirclemodel.QueryActivityReq 的形式*/
const [realServiceName, realProtoName] = protoName.split('.')
if (proto[realServiceName]) {
return proto[realServiceName][realProtoName]
}
return undefined;
}
function generate(options) {
if (!options) {
throw new Error('options must be provided')
}
const { serviceName, funcName, data } = options
const serviceConfig = config.find(c => c.serviceName === serviceName)
if (!serviceConfig) {
throw new Error('service not found')
}
if (!serviceConfig.functions[funcName]) {
throw new Error('function not found')
}
const reqProtoName = serviceConfig.functions[funcName].req
const reqProto = getProto(proto, serviceName, reqProtoName);
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = serviceConfig.functions[funcName].res
const resProto = resProtoName && getProto(proto, serviceName, resProtoName);
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
serviceName,
funcName,
magic: serviceConfig.magic,
cmdid: serviceConfig.functions[funcName].cmdid,
existResp: Boolean(resProto),
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
function generateV2(options) {
if (!options) {
throw new Error('options must be provided')
}
const { apiName, data } = options
const apiConfig = config.find(c => c.apiName === apiName)
const reqProtoName = apiConfig.req
const reqProto = proto[reqProtoName]
if (!reqProto) {
throw new Error('request proto not found')
}
const resProtoName = apiConfig.res
const resProto = proto[resProtoName]
const reqProtoVerifyErr = reqProto.verify(data)
if (reqProtoVerifyErr) {
throw new Error(`verify proto data error: ${reqProtoVerifyErr}`)
}
const reqProtoJSON = protoJSON.nested[reqProtoName]
if (reqProtoJSON && reqProtoJSON.fields) {
if (Object.prototype.toString.call(data).slice(8, -1) === 'Object') {
for (const key in data) {
if (!reqProtoJSON.fields[key]) {
throw new Error(`'${key}' doesn't exist in '${reqProtoName}' proto, valid keys are ${Object.keys(reqProtoJSON.fields)}`)
}
}
} else {
throw new Error('data must be object')
}
}
return {
data: {
apiName,
reqBodyBuffer: reqProto.encode(data).finish(),
},
reqProto,
resProto,
decode: buf => resProto && resProto.decode(buf)
}
}
module.exports = {
generate,
generateV2,
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,299 @@
{
"nested": {
"enARModelStatus": {
"values": {
"ARModel_Status_Default": 0,
"ARModel_Status_Init": 1,
"ARModel_Status_Sparse_Finished": 2,
"ARModel_Status_3d_Finished": 3,
"ARModel_Status_Object_Finished": 4,
"ARModel_Status_Marker_Finished": 5,
"ARModel_Status_Fail": 100
}
},
"enARAlgorithmType": {
"values": {
"Algorithm_Type_3D_Object": 1,
"Algorithm_Type_3D_Marker": 2
}
},
"enARModelType": {
"values": {
"ARModel_Type_Sparse": 1,
"ARModel_Type_3D": 2,
"ARModel_Type_Marker": 3
}
},
"ModelCos": {
"fields": {
"modelList": {
"rule": "repeated",
"type": "ModelCosId",
"id": 1
}
},
"nested": {
"ModelCosId": {
"fields": {
"modelType": {
"type": "enARModelType",
"id": 1
},
"modelCosid": {
"type": "string",
"id": 2
},
"errmsg": {
"type": "string",
"id": 3
}
}
}
}
},
"ARModel": {
"options": {
"(mmbizintpkv.KvTableTestID)": 916
},
"fields": {
"cosid": {
"type": "string",
"id": 1
},
"bizuin": {
"type": "uint32",
"id": 2
},
"name": {
"type": "string",
"id": 3
},
"uploadTime": {
"type": "uint32",
"id": 4
},
"modelStatus": {
"type": "enARModelStatus",
"id": 5
},
"algoType": {
"type": "enARAlgorithmType",
"id": 6
},
"modelCos": {
"type": "ModelCos",
"id": 7
}
}
},
"GetARModelListReq": {
"fields": {
"bizuin": {
"type": "uint32",
"id": 1
},
"modelStatus": {
"type": "uint32",
"id": 2
},
"startTime": {
"type": "uint32",
"id": 3
},
"endTime": {
"type": "uint32",
"id": 4
},
"offset": {
"type": "uint32",
"id": 5
},
"limit": {
"type": "uint32",
"id": 6
},
"algoType": {
"type": "uint32",
"id": 7
}
}
},
"GetARModelListResp": {
"fields": {
"modelList": {
"rule": "repeated",
"type": "ARModel",
"id": 1
}
}
},
"GenerateARModelReq": {
"fields": {
"bizuin": {
"type": "uint32",
"id": 1
},
"name": {
"type": "string",
"id": 2
},
"buffer": {
"type": "bytes",
"id": 3
},
"url": {
"type": "string",
"id": 4
},
"algoType": {
"type": "enARAlgorithmType",
"id": 5
},
"lod": {
"type": "uint32",
"id": 6,
"options": {
"default": 0
}
},
"getmesh": {
"type": "bool",
"id": 7,
"options": {
"default": false
}
},
"gettexture": {
"type": "bool",
"id": 8,
"options": {
"default": false
}
}
}
},
"GenerateARModelResp": {
"fields": {
"url": {
"type": "string",
"id": 1
},
"host": {
"type": "string",
"id": 2
},
"cosid": {
"type": "string",
"id": 3
},
"lod": {
"type": "uint32",
"id": 4,
"options": {
"default": 0
}
},
"getmesh": {
"type": "bool",
"id": 5,
"options": {
"default": false
}
},
"gettexture": {
"type": "bool",
"id": 6,
"options": {
"default": false
}
}
}
},
"ARModelData": {
"fields": {
"meshModel": {
"type": "bytes",
"id": 1
},
"textureModel": {
"type": "bytes",
"id": 2
},
"preview": {
"type": "bytes",
"id": 3
},
"meshBlob": {
"type": "bytes",
"id": 4
},
"textureBlob": {
"type": "bytes",
"id": 5
}
}
},
"GetARModelReq": {
"fields": {
"bizuin": {
"type": "uint32",
"id": 1
},
"cosid": {
"type": "string",
"id": 2
},
"modelType": {
"type": "uint32",
"id": 3
},
"needData": {
"type": "uint32",
"id": 4,
"options": {
"default": 1
}
},
"useIntranet": {
"type": "uint32",
"id": 5,
"options": {
"default": 0
}
},
"expireTime": {
"type": "uint32",
"id": 6
}
}
},
"GetARModelResp": {
"fields": {
"modelData": {
"type": "ARModelData",
"id": 1
},
"url": {
"type": "string",
"id": 2
},
"host": {
"type": "string",
"id": 3
},
"errMsg": {
"type": "string",
"id": 4
},
"expireTime": {
"type": "uint32",
"id": 5
},
"status": {
"type": "uint32",
"id": 6
}
}
}
}
}

@ -0,0 +1,34 @@
// 模块导出一个数组,每个元素是一个模块配置项
module.exports = [
{
// 模块对应的 proto 文件相对于该文件的路径
proto: './proto/mmbizwxaintparDemo.proto',
// 模块 service name
serviceName: 'Mmbizwxaintpar',
// 模块 magic 数字
magic: 11081,
// 模块导出的接口方法
functions: {
// 接口名字及其对应的接口调用信息
GenerateARModel: {
// 接口的 cmdid
cmdid: 1,
// 接口的 request 对应的 protobuf message 名字,需在 proto 文件中定义
req: 'GenerateARModelReq',
// 接口的 response 对应的 protobuf message 名字,需在 proto 文件中定义
res: 'GenerateARModelResp',
},
// 接口的名字及其对应的接口调用信息
GetARModelList: {
cmdid: 3,
req: 'GetARModelListReq',
res: 'GetARModelListResp',
},
GetARModel: {
cmdid: 4,
req: 'GetARModelReq',
res: 'GetARModelResp',
}
}
}
]

@ -0,0 +1,12 @@
## 0.6.0
1. `A` 新增 `callWXSvrkit` 支持传入 `headuin``routeMethod`
## 0.2.0
1. `A` 新增 `callTencentInnerAPI` 内部接口
## 0.1.0
1. `A` 新增 `callWXSvrkit` 内部接口
2. `A` 新增 `callWXInnerAPI` 内部接口

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2018 wechat-miniprogram
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,326 @@
# WXG Service for Mini Program Server SDK
## wx-server-sdk 插件使用方式
需同时安装依赖 `wx-server-sdk``@tencent/wx-server-sdk-wxg-service`,后者必须使用 `tnpm` 安装。
注册 SDK 插件的示例代码:
```js
const cloud = require('wx-server-sdk')
const wxgService = require('@tencent/wx-server-sdk-wxg-service')
// 将 wxg service 注册到 cloud 上,获得 callWXSvrkit, callTencentInnerAPI 等内部接口
cloud.registerService(wxgService)
exports.main = async (event, context) => {
// 现在可以使用 callWXSvrkit 等内部接口了
cloud.callWXSvrkit({
// ....
})
}
```
## 兼容性说明
`0.6.1` 起,需搭配 `wx-server-sdk` `2.0.3` 或以上使用。
## 接口
WXG Service 包含以下接口
### callTencentInnerAPI调用腾讯内部服务
```js
const cloud = require('wx-server-sdk')
const wxgService = require('@tencent/wx-server-sdk-wxg-service')
// 将 wxg service 注册到 cloud 上,获得 callWXSvrkit 接口
cloud.registerService(wxgService)
exports.main = async (event, context) => {
const callResult = await cloud.callTencentInnerAPI({
cmdid: 12345, // 必填
modid: 67890, // 必填
path: '/aaa/bbb?xxx=1', // 必填,除域名外 URL 路径。URL 参数选填
https: false, // 选填,是否使用 https
method: 'post', // 必填HTTP Method
// 选填HTTP 头部
headers: {
'Content-Type': 'application/json'
},
// 选填body 可以是 string 类型或 Buffer 类型
body: JSON.stringify({
x: 1,
y: 2,
}),
/**
* autoParse:
* 是否自动 parse 回包包体,如果是,则:
* 在 content-type 为 application/json 时自动 parse JSON
* 在 content-type 为 text/plain 时自动转为 string
* 其余情况不 parse返回原始包体 buffer
*/
autoParse: true,
})
console.log(callResult)
/**
* callResult:
* {
* errCode: 0,
* errMsg: 'callTencetnInnerAPI:ok',
* contentType: 'application/json', // 回包 content-type
* body: { x: 1 }, // 回包 http response body
* statusCode: 200, // 回包 http status code
* rawHeaders: [ // 回包 http headers
* {
* key: 'content-type',
* value: 'application'
* },
* // ...
* ]
* }
*/
return callResult
}
```
### callWXSvrkit调用微信 Svrkit 服务
供 WXG 内部小程序通过云函数调用微信 svrkit 模块。
因为 svrkit 的数据交换协议是 `protobuf`,且 svrkit 的模块调用需要一些模块信息因此为了简化前端调用方式、省去接口数据处理和调用信息处理pb 序列化与反序列化、模块信息传入)、我们也提供了一个 `@tencent/cloud-functions-tools` 工具用于将 svrkit 的调用流程配置化、标准化,开发者只需填写配置文件和放置 `proto` 文件,即可用工具生成辅助模块,实际调用时即可传入 `JSON` 对象获取 `JSON` 返回值。
示例云函数已放置在公开的内部 git 仓库,仓库 `cloudfunctions` 目录下有两个子目录分别是 `svrkit-echo``svrkit-check-developer`这两个示例云函数,仓库地址 https://git.code.oa.com/mp-public/cloud-demos
### Step 1安装 `@tencent/cloud-functions-tools`
首先在需要使用该能力的云函数的目录下安装 `@tencent/cloud-functions-tools`
```shell
npm install --save-dev @tencent/cloud-functions-tools@latest
```
注意,云函数中同时需安装 `wx-server-sdk``@tencent/wx-server-sdk-wxg-service`
```bash
npm install --save wx-server-sdk@latest
npm install --save @tencent/wx-server-sdk-wxg-service@latest
```
### Step 2配置
在云函数目录下建立 `svrkit.config.js` 文件,用于填写 `svrkit` 调用的配置信息,并放置好相应 proto 文件,示例如下(从后台的原始 pb 文件提取模块调用信息的方法参见底部的[svrkit 调用信息提取](#extract_pb_info)
```js
// 模块导出一个数组,每个元素是一个模块配置项
module.exports = [
{
// 模块对应的 proto 文件相对于该文件的路径
proto: './proto/mmbizwxaqbasedemo.proto',
// 模块 service name
serviceName: 'MMBizWxaQbaseDemo',
// 模块 magic 数字
magic: 18501,
// 模块导出的接口方法
functions: {
// 接口 EchoTest 的名字及其对应的接口调用信息
EchoTest: {
// 接口的 cmdid
cmdid: 1,
// 接口的 request 对应的 protobuf message 名字,需在 proto 文件中定义
req: 'EchoTestRequest',
// 接口的 response 对应的 protobuf message 名字,需在 proto 文件中定义
res: 'EchoTestResponse',
},
// 接口 CheckWxaDeveloper 的名字及其对应的接口调用信息
CheckWxaDeveloper: {
cmdid: 2,
req: 'CheckWxaDeveloperRequest',
}
}
}
]
```
示例的 `./proto/mmbizwxaqbasedemo.proto` 文件:
```
message MessageData
{
optional string Data = 1;
}
message EchoTestRequest
{
required bool OpenTime = 1; // 是否需要服务端返回时间戳required 必填
// 以下 optional 字段如果有填在Resp中返回对应字段
optional int32 IntData = 2;
optional string StringData = 3;
repeated uint32 UintListData = 4;
optional MessageData MessageData = 5;
}
message EchoTestResponse
{
optional uint32 TimeStamp = 1;
optional int32 IntRespData = 2;
optional string StringRespData = 3;
repeated uint32 UintListRespData = 4;
optional MessageData MessageRespData = 5;
}
// 校验是否为小程序开发者, 接口返回0 是1 否
message CheckWxaDeveloperRequest
{
optional uint32 appuin = 1;
optional uint32 useruin = 2;
}
```
### Step 3用工具生成辅助类
`@tencent/cloud-functions-tools` 提供的工具根据 `svrkit.config.js` 生成辅助的 `svrkit-utils.js` 模块:
```bash
# 在云函数目录执行以下命令,--config (或 -c 对应的路径如果不同则替换为自己的路径
./node_modules/.bin/svrkit-utils --config ./svrkit.config.js
# 如需自定义输出文件的路径,可以传入 --output (或 -o
./node_modules/.bin/svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js
```
> 注:可用此命令查看 cloud-functions-tools 的用法:./node_modules/.bin/svrkit-utils -h
可以在 `package.json` 中添加一个 `script` 命令自动化这个流程:
```json
{
"scripts": {
"svrkit": "svrkit-utils --config ./svrkit.config.js --output ./svrkit-utils.js"
}
}
```
然后之后就可以用如下命令生成 js 模块了:
```bash
npm run svrkit
```
### Step 4发起调用
`callWXSvrkit` 方法配合生成的 `svrkit-utils.js` 模块发起 svrkit 调用
**callWXSvrkit 接口参数说明**
| 参数 | 类型 | 必填 | 说明 |
| ---------- | ---- | ---- | --------------------------------------------------- |
| pbInstance | | 是 | 通过 `svrkit-utils.js``generate` 方法生成的对象 |
| timeout | number | 否 | 超时失败时间 |
**callWXSvrkit 接口返回值说明**
| 参数 | 类型 | 说明 | 最低版本 |
| -------------- | ------ | ------------------------------------------------------------ | -------- |
| errMsg | String | 通用返回结果 | |
| ret | Number | svrkit 模块调用结果0 表示成功调到了目标模块,-306 表示小程序未在内部小程序登记平台登记,-307 表示小程序没有调用目标模块的权限 | |
| result | Number | 目标模块的调用返回码 | |
| respBody | Object | 目标模块返回的最终 JSON 对象 | |
| respBodyBuffer | Buffer | 目标模块返回的 pb buffer有 respBody 可不用关注 | |
调用代码示例:
```js
const cloud = require('wx-server-sdk')
const wxgService = require('@tencent/wx-server-sdk-wxg-service')
cloud.registerService(wxgService)
cloud.init()
const svrkitUtils = require('./svrkit-utils.js')
exports.main = async (event, context) => {
return await cloud.callWXSvrkit({
pbInstance: svrkitUtils.generate({
serviceName: 'MMBizWxaQbaseDemo',
funcName: 'EchoTest',
data: {
OpenTime: event.OpenTime || true,
IntData: event.IntData || 10,
StringData: event.StringData || 'default_string',
UintListData: event.UintListData || [1, 2, 3],
MessageData: event.MessageData || {
Data: 'default_data_string'
},
}
})
})
}
```
预期返回:
```js
{
"ret": 0,
"result": 0,
"respBodyBuffer": Buffer,
"respBody": {
"TimeStamp": 1543501760,
"IntRespData": 10,
"StringRespData": "default_string",
"UintListRespData": [
1,
2,
3
],
"MessageRespData": {
"Data": "default_data_string"
}
},
"errMsg": "callWXSvrkit:ok"
}
```
调用数据流如图:
![svrkit 调用数据流](http://km.oa.com/files/photos/pictures//20181130//1543559018_58.png)
<a id="extract_pb_info"></a>
从后台原始 svrkit pb 信息中提取模块调用信息:
1. `message` 定义的是 pb 数据接口体的定义,通常即是请求包与回包的定义
2. `service` 定义的是 svrkit 模块的 `serviceName`
3. `tlvpickle.Magic` 定义的是模块 `magic`
4. `rpc` 后跟的词即是模块暴露的接口方法名,即 `funcName`
5. `rpc` 定义中包含了请求体结构和返回体结构,如 `EchoTest` 方法的请求体结构为 `EchoTestRequest`,返回体结构为 `EchoTestResponse`
6. `tlvpickle.SKBuiltinEmpty_PB` 是特殊的结构体,表示空结构体
![svrkit 模块调用信息](http://km.oa.com/files/photos/captures/201812/1543846169_62_w1668_h2228.png)
### callSvrkit: 调用微信 Svrkit 服务
> 已废弃,请使用 callWXSvrkit

File diff suppressed because it is too large Load Diff

@ -0,0 +1,11 @@
{
"name": "@tencent/wx-server-sdk-wxg-service",
"version": "0.7.0",
"description": "wxg service plugin for mini program cloud server sdk",
"main": "index.js",
"author": "wechat mini program team",
"license": "MIT",
"dependencies": {
"tslib": "^1.9.3"
}
}

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -0,0 +1,9 @@
const saveProfile = require('./saveProfile/index')
// 云函数入口函数
exports.main = async (event, context) => {
switch (event.type) {
case 'saveProfile':
return await getProfile.main(event, context);
}
};

@ -0,0 +1,14 @@
{
"name": "db",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -0,0 +1,28 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 保存个人信息云函数入口函数
exports.main = async (event, context) => {
// 返回数据库结果
return db.collection('user_Data').add({
// data 字段表示需新增的 JSON 数据
data: {
// _id: 'todo-identifiant-aleatoire', // 可选自定义 _id在此处场景下用数据库自动分配的就可以了
user_Name: "learn cloud database",
user_Sex: null,
user_Age: null,
user_Phone: null,
user_Addr: null,
isTeacher: false
},
success: function(res) {
// res 是一个对象,其中有 _id 字段标记刚创建的记录的 id
console.log(res)
}
})
};

@ -0,0 +1,13 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
// 云函数入口函数
exports.main = async () => {
cloud.init({
env: process.env.TCB_ENV,
})
const db = cloud.database()
return db.collection('perm4').where({
_openid: 'server'
}).limit(1).get()
}

@ -0,0 +1,14 @@
{
"name": "getServerDataDemo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -0,0 +1,14 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
// 云函数入口函数
exports.main = async (event) => {
cloud.init({
env: process.env.TCB_ENV,
})
const fileList = event.fileIdList
const result = await cloud.getTempFileURL({
fileList,
})
return result.fileList
}

@ -0,0 +1,14 @@
{
"name": "getTempFileURL",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -0,0 +1,3 @@
exports.main = (event) => ({
openid: event.userInfo.openId,
})

@ -0,0 +1,14 @@
{
"name": "login",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -0,0 +1,19 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
if (event.op == "")
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -0,0 +1,21 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
const db = wx.cloud.database().collection("orders")
const wxContext = cloud.getWXContext()
// 云函数入口函数
exports.main = async () => {
const result;
db.where({
_openid: wxContext.OPENID
}).get({
success: function (res) {
result = res
}
})
return result
}

@ -0,0 +1,20 @@
// 云函数入口文件
// const cloud = require('wx-server-sdk')
const get = require("./get")
const add = require("./add")
// cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
// const wxContext = cloud.getWXContext()
if (event.op == "get") {
return await get.main();
} else if(event.op == "add") {
add()
//TODO add paramas
return
}
return true
}

@ -0,0 +1,14 @@
{
"name": "orders",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.6.3"
}
}

@ -0,0 +1,7 @@
{
"permissions": {
"openapi": [
"wxacode.get"
]
}
}

@ -0,0 +1,56 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 创建集合云函数入口函数
exports.main = async (event, context) => {
try {
// 创建集合
await db.createCollection('sales');
await db.collection('sales').add({
// data 字段表示需新增的 JSON 数据
data: {
region: '华东',
city: '上海',
sales: 11
}
});
await db.collection('sales').add({
// data 字段表示需新增的 JSON 数据
data: {
region: '华东',
city: '南京',
sales: 11
}
});
await db.collection('sales').add({
// data 字段表示需新增的 JSON 数据
data: {
region: '华南',
city: '广州',
sales: 22
}
});
await db.collection('sales').add({
// data 字段表示需新增的 JSON 数据
data: {
region: '华南',
city: '深圳',
sales: 22
}
});
return {
success: true
};
} catch (e) {
// 这里catch到的是该collection已经存在从业务逻辑上来说是运行成功的所以catch返回success给前端避免工具在前端抛出异常
return {
success: true,
data: 'create collection success'
};
}
};

@ -0,0 +1,20 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
// 获取小程序二维码云函数入口函数
exports.main = async (event, context) => {
// 获取小程序二维码的buffer
const resp = await cloud.openapi.wxacode.get({
path: 'pages/index/index'
});
const { buffer } = resp;
// 将图片上传云存储空间
const upload = await cloud.uploadFile({
cloudPath: 'code.png',
fileContent: buffer
});
return upload.fileID;
};

@ -0,0 +1,17 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
// 获取openId云函数入口函数
exports.main = async (event, context) => {
// 获取基础信息
const wxContext = cloud.getWXContext();
return {
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
};
};

@ -0,0 +1,25 @@
const getOpenId = require('./getOpenId/index');
const getMiniProgramCode = require('./getMiniProgramCode/index');
const createCollection = require('./createCollection/index');
const selectRecord = require('./selectRecord/index');
const updateRecord = require('./updateRecord/index');
const sumRecord = require('./sumRecord/index');
// 云函数入口函数
exports.main = async (event, context) => {
switch (event.type) {
case 'getOpenId':
return await getOpenId.main(event, context);
case 'getMiniProgramCode':
return await getMiniProgramCode.main(event, context);
case 'createCollection':
return await createCollection.main(event, context);
case 'selectRecord':
return await selectRecord.main(event, context);
case 'updateRecord':
return await updateRecord.main(event, context);
case 'sumRecord':
return await sumRecord.main(event, context);
}
};

@ -0,0 +1,14 @@
{
"name": "quickstartFunctions",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.4.0"
}
}

@ -0,0 +1,12 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 查询数据库集合云函数入口函数
exports.main = async (event, context) => {
// 返回数据库查询结果
return await db.collection('sales').get();
};

@ -0,0 +1,18 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
const $ = db.command.aggregate;
// 聚合记录云函数入口函数
exports.main = async (event, context) => {
// 返回数据库聚合结果
return db.collection('sales').aggregate()
.group({
_id: '$region',
sum: $.sum('$sales')
})
.end();
};

@ -0,0 +1,32 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
// 修改数据库信息云函数入口函数
exports.main = async (event, context) => {
try {
// 遍历修改数据库信息
for (let i = 0; i < event.data.length; i++) {
await db.collection('sales').where({
_id: event.data[i]._id
})
.update({
data: {
sales: event.data[i].sales
},
});
}
return {
success: true,
data: event.data
};
} catch (e) {
return {
success: false,
errMsg: e
};
}
};

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save