Compare commits
1 Commits
master
...
minxinchen
Author | SHA1 | Date |
---|---|---|
|
68a404954b | 2 years ago |
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 630 KiB |
Before Width: | Height: | Size: 1.3 MiB |
@ -1,23 +0,0 @@
|
|||||||
#!/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)
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
|
|
||||||
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,
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
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,
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
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,
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
message ApiDemoReq
|
|
||||||
{
|
|
||||||
optional string str = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ApiDemoResp
|
|
||||||
{
|
|
||||||
optional string str = 2;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
message GenWxaCloudTmpCodeReq
|
|
||||||
{
|
|
||||||
optional uint32 CloudPlatform = 1;
|
|
||||||
optional uint32 AppUin = 2;
|
|
||||||
optional uint32 UserUin = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GenWxaCloudTmpCodeResp
|
|
||||||
{
|
|
||||||
optional string TmpCode = 1;
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
|||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
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',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"permissions": {
|
|
||||||
"openapi": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
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,
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
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_data为0时生效 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 失败
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
@ -1,299 +0,0 @@
|
|||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
// 模块导出一个数组,每个元素是一个模块配置项
|
|
||||||
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',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,12 +0,0 @@
|
|||||||
## 0.6.0
|
|
||||||
|
|
||||||
1. `A` 新增 `callWXSvrkit` 支持传入 `headuin` 和 `routeMethod`
|
|
||||||
|
|
||||||
## 0.2.0
|
|
||||||
|
|
||||||
1. `A` 新增 `callTencentInnerAPI` 内部接口
|
|
||||||
|
|
||||||
## 0.1.0
|
|
||||||
|
|
||||||
1. `A` 新增 `callWXSvrkit` 内部接口
|
|
||||||
2. `A` 新增 `callWXInnerAPI` 内部接口
|
|
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
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.
|
|
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"permissions": {
|
|
||||||
"openapi": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
const saveProfile = require('./saveProfile/index')
|
|
||||||
|
|
||||||
// 云函数入口函数
|
|
||||||
exports.main = async (event, context) => {
|
|
||||||
switch (event.type) {
|
|
||||||
case 'saveProfile':
|
|
||||||
return await getProfile.main(event, context);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
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()
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
exports.main = (event) => ({
|
|
||||||
openid: event.userInfo.openId,
|
|
||||||
})
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"permissions": {
|
|
||||||
"openapi": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
// 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
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"permissions": {
|
|
||||||
"openapi": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
// 云函数入口文件
|
|
||||||
const cloud = require('wx-server-sdk')
|
|
||||||
|
|
||||||
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
|
||||||
|
|
||||||
const db = cloud.database()
|
|
||||||
const MAX_LIMIT = 100
|
|
||||||
|
|
||||||
exports.main = async (event, context) => {
|
|
||||||
|
|
||||||
// 先取出集合记录总数
|
|
||||||
const countResult = await db.collection('teacher_Data').count()
|
|
||||||
const total = countResult.total
|
|
||||||
// 计算需分几次取
|
|
||||||
const batchTimes = Math.ceil(total / 100)
|
|
||||||
// 承载所有读操作的 promise 的数组
|
|
||||||
const tasks = []
|
|
||||||
for (let i = 0; i < batchTimes; i++) {
|
|
||||||
const promise = db.collection('teacher_Data').skip(i * MAX_LIMIT).limit(MAX_LIMIT).get()
|
|
||||||
tasks.push(promise)
|
|
||||||
}
|
|
||||||
// 等待所有
|
|
||||||
return (await Promise.all(tasks)).reduce((acc, cur) => {
|
|
||||||
return {
|
|
||||||
data: acc.data.concat(cur.data),
|
|
||||||
errMsg: acc.errMsg,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "recommend",
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
// components/dialog/dialog.js
|
|
||||||
Component({
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的属性列表
|
|
||||||
*/
|
|
||||||
properties: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
|
||||||
showModal: true
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的方法列表
|
|
||||||
*/
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"component": true,
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<!--components/dialog/dialog.wxml-->
|
|
||||||
<view class="container-view">
|
|
||||||
<view>主题内容</view>
|
|
||||||
</view>
|
|
||||||
<!--modal-->
|
|
||||||
<!--弹窗-->
|
|
||||||
<view>
|
|
||||||
<view class="modal-mask" bindtap="hideModal" catchtouchmove="preventTouchMove" wx:if="{{showModal}}">
|
|
||||||
<view class="modal-dialog" wx:if="{{showModal}}">
|
|
||||||
<video src="https://res.wx.qq.com/wxaliveplayer/htdocs/video14e1eea.mov"></video>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
@ -1,41 +0,0 @@
|
|||||||
/* components/dialog/dialog.wxss */
|
|
||||||
.container-view {
|
|
||||||
width: 100vh;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-mask {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
|
||||||
z-index: 999;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-dialog {
|
|
||||||
width: 80%;
|
|
||||||
height: 70%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
overflow: hidden;
|
|
||||||
position: fixed;
|
|
||||||
margin: 0 auto;
|
|
||||||
z-index: 9999;
|
|
||||||
background: #f9f9f9;
|
|
||||||
border-radius: 36rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container-view {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
// components/grid-tile/index.js
|
|
||||||
Component({
|
|
||||||
/**
|
|
||||||
* 组件的属性列表
|
|
||||||
*/
|
|
||||||
properties: {
|
|
||||||
height: {
|
|
||||||
type: Number,
|
|
||||||
value: 0,
|
|
||||||
},
|
|
||||||
index: {
|
|
||||||
type: Number,
|
|
||||||
value: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的方法列表
|
|
||||||
*/
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"component": true,
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|