This commit is contained in:
Ling53666
2025-08-18 09:11:51 +08:00
commit 02554225da
2516 changed files with 133155 additions and 0 deletions

View File

@ -0,0 +1,57 @@
const cloud = require("@alipay/faas-server-sdk");
exports.main = async (event, context) => {
const {name, number, address,type,person } = event; // 从事件参数中获取传入的值
// 获取当前时间,并格式化成字符串
const currentTime = new Date();
const createTime = formatTime(currentTime); // formatTime 为自定义函数,见下面
const db = cloud.database();
// 通过 add 在 example 中添加文档
return await db.collection('mysql2').add({
data: {
name: name,
number: number,
address:address,
type:type,
person:person,
createTime: createTime, // 将 createTime 加入文档
},
});
};
// 自定义函数,用于将时间对象格式化成字符串
function formatTime(date) {
const year = date.getFullYear();
const month = padZero(date.getMonth() + 1);
const day = padZero(date.getDate());
const hour = padZero(date.getHours());
const minute = padZero(date.getMinutes());
const second = padZero(date.getSeconds());
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
}
// 自定义函数,用于补齐数字前面的零
function padZero(num) {
return num < 10 ? '0' + num : num;
}

View File

@ -0,0 +1,12 @@
{
"name": "add01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,9 @@
const cloud = require('@alipay/faas-server-sdk');
cloud.init();
exports.main = async (event, context) => {
const res = {
"ikun":"登陆成功"
}
return res;
};

View File

@ -0,0 +1,12 @@
{
"name": "demo02",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,16 @@
const cloud = require('@alipay/faas-server-sdk');
cloud.init();
exports.main = async (event, context) => {
const res = await cloud.openapi.alipayOpenAppQrcodeCreate.request({
bizContent: {
url_param: 'page/component/component-pages/view/view',
query_param: 'x=1',
describe: '二维码描述',
color: '0x00BFFF',
size: 's',
},
});
console.log('云调用结果:', res);
return res;
};

View File

@ -0,0 +1,12 @@
{
"name": "demo3",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,6 @@
exports.main = async (event, context) => {
let data = {
"message": "Hello World!"
};
return data;
};

View File

@ -0,0 +1,32 @@
const cloud = require('@alipay/faas-server-sdk');
exports.main = async (event, context) => {
try {
// 获取 cloud 环境中的 mongoDB 数据库对象
const db = cloud.database();
// 使用 where 条件查询集合对象test
const data = await db.collection('user')
// 使用 get 获取文档数据
.get();
return { success: true, msg: '查询成功', data };
} catch (err) {
return { success: false, msg: `查询失败 - ${err.toString()}` };
}
};

View File

@ -0,0 +1,12 @@
{
"name": "query",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,28 @@
const cloud = require('@alipay/faas-server-sdk');
exports.main = async (event, context) => {
try {
// 获取 cloud 环境中的 mongoDB 数据库对象
const db = cloud.database();
// 使用 where 条件查询集合对象test
const data = await db.collection('mysql3')
// 使用 get 获取文档数据
.get();
return { success: true, msg: '查询成功', data };
} catch (err) {
return { success: false, msg: `查询失败 - ${err.toString()}` };
}
};

View File

@ -0,0 +1,12 @@
{
"name": "queryAllShop",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,32 @@
const cloud = require('@alipay/faas-server-sdk');
exports.main = async (event, context) => {
try {
const { name } = event;
// 获取 cloud 环境中的 mongoDB 数据库对象
const db = cloud.database();
// 使用 where 条件查询集合对象test
const data = await db.collection('mysql3')
.where({
name: name,
})
// 使用 get 获取文档数据
.get();
return { success: true, msg: '查询成功', data };
} catch (err) {
return { success: false, msg: `查询失败 - ${err.toString()}` };
}
};

View File

@ -0,0 +1,12 @@
{
"name": "querySelectByName",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,28 @@
const cloud = require('@alipay/faas-server-sdk');
exports.main = async (event, context) => {
try {
// 获取 cloud 环境中的 mongoDB 数据库对象
const db = cloud.database();
const data = await db.collection('mysql3')
// 使用 get 获取文档数据
.get();
return { success: true, msg: '查询成功', data };
} catch (err) {
return { success: false, msg: `查询失败 - ${err.toString()}` };
}
};

View File

@ -0,0 +1,12 @@
{
"name": "sclect01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}

View File

@ -0,0 +1,34 @@
const cloud = require('@alipay/faas-server-sdk');
exports.main = async (event, context) => {
try {
const { username , password } = event;
// 获取 cloud 环境中的 mongoDB 数据库对象
const db = cloud.database();
// 使用 where 条件查询集合对象test
const data = await db.collection('mysql1')
.where({
username: username,
password: password
})
// 使用 get 获取文档数据
.get();
return { success: true, msg: '查询成功', data };
} catch (err) {
return { success: false, msg: `查询失败 - ${err.toString()}` };
}
};

View File

@ -0,0 +1,12 @@
{
"name": "select",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"@alipay/faas-server-sdk": "^1.0.0"
}
}