You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
'use strict';
|
|
|
|
const Service = require('egg').Service;
|
|
const _ = require("lodash")
|
|
const tencentcloud = require('tencentcloud-sdk-nodejs');
|
|
// 导入对应产品模块的client models。
|
|
const CvmClient = tencentcloud.iotexplorer.v20190423.Client
|
|
|
|
class UserService extends Service {
|
|
async index(params) {
|
|
let { ctx } = this
|
|
let modelLocal = ctx.model.User
|
|
let returnData = { hasError: false, msg: "数据错误", list: [] }
|
|
console.log(77777, params)
|
|
// 新增
|
|
paramsLocal["update_at"] = Date.now();
|
|
let paramsLocal = {
|
|
name: params.name,
|
|
age: params.age,
|
|
imgbase64: params.img,
|
|
}
|
|
let pngRes = await this.createPng(params)
|
|
// let res = await modelLocal.create(paramsLocal)
|
|
returnData.hasError = false
|
|
returnData.msg = "数据新增成功"
|
|
returnData.list = res
|
|
return returnData
|
|
}
|
|
async createPng(params) {
|
|
let { ctx } = this
|
|
let modelLocal = ctx.model.User
|
|
let returnData = { hasError: false, msg: "数据错误", list: [] }
|
|
console.log(77777, params)
|
|
const client = new CvmClient({
|
|
// 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中,请参考本文凭证管理章节。
|
|
// 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
|
|
credential: {
|
|
secretId: "AKIDLgwLkIcpoZ6PZht382oUMCC6wdFhMwZ8",
|
|
secretKey: "TmvwtkcYWTJ5qkEg3FIB2sokccepOsCO",
|
|
},
|
|
// 产品地域
|
|
region: "ap-chengdu",
|
|
// 可选配置实例
|
|
profile: {
|
|
signMethod: "TC3-HMAC-SHA256", // 签名方法
|
|
httpProfile: {
|
|
reqMethod: "POST", // 请求方法
|
|
reqTimeout: 30, // 请求超时时间,默认60s
|
|
},
|
|
},
|
|
}
|
|
);
|
|
const params = {
|
|
// 这里填写接口所需的参数,例如:
|
|
ImageUrl: params.img, // 图片URL
|
|
Age: params.age, // 想要改变的年龄,比如50表示变老50岁
|
|
// 其他参数根据接口文档填充
|
|
};
|
|
|
|
let res = client.ChangeFaceAge(params)
|
|
console.log(777, res)
|
|
return returnData
|
|
}
|
|
async downloadPng(params) {
|
|
let { ctx } = this
|
|
let modelLocal = ctx.model.User
|
|
let returnData = { hasError: false, msg: "数据错误", list: [] }
|
|
console.log(77777, params)
|
|
//查询后下载8张图片
|
|
return returnData
|
|
}
|
|
}
|
|
|
|
module.exports = UserService;
|
|
|