1.注释不能少于代码的三分之一
2.一般是:获取查询列表使用get请求、保存数据用post请求
3.生命周期函数
4.get请求 接收使用ctx.request.query
post请求 接收使用ctx.request.body
5.登录后返回userId给前台,前台接收后存入cookie(首选)、localstorage 、sessionstorage(网上看下三者的区别)
https://www.cnblogs.com/candy-xia/p/11561542.html
============================================
axios官网:http://www.axios-js.com/
let sql = SELECT * FROM petgoods GoodsNo=${params.goodsNo}
;
//新增会员信息
async function addMemberService (ctx, params) {
let param = [];
let key = [];
for (let item in params) {
let value = "'" + params[item] + "'"
param.push(value)
key.push(item)
}
let sql = insert into member (${key.join(",")}) values(${param.join(",")})
;
try {
let data = await query(sql);
ctx.body = {
"success": true,
"data": data
};
} catch (error) {
ctx.body = {
"success": false,
"message": error
};
}
}