接口:
用户接口 (集合名:lemon_user)
接口:/api/userList
方式:post
参数:用户名(name)密码(pwd)
返回:用户ID
router.post('/api/user', function (req, res, next) {
var name = req.body.name,
pwd = req.body.pwd;
if (!name || !pwd) {
res.json({ code: 0, msg: '用户名或者密码为空!'})
} else {
Mongo.find(db, col, { name: name }, function (result) {
//console.log(result)//注意,此时是数组类型
if (result.length > 0) {
res.json({ code: 3, msg: '改用户已经存在!',data:result[0]._id})
} else {
find(); //添加
}
})
}
//添加函数
function find() {
Mongo.insert(db, col, { name: name, pwd: pwd }, function (result) {
console.log(result)
if (result) {
res.json({ code: 1, msg: '添加成功'})
} else {
res.json({ code: 0, msg: '添加失败' })
}
})
}
});
获取账单列表 (集合名:bill_list)
接口: /api/getBillList
方式:post
参数:用户ID(uid)年/月(timer)
返回:type(收支类型)/money(金额)/timer(时间)/intro(说明)icon(图标)
删除账单 (集合名:bill_list)
接口:/api/deleteBill
方式:post
参数:_id(ID)
返回:成功/失败
添加账单 (集合名:bill_list)
接口:/api/addBill
方式:post
参数:uid(用户ID)type(收支类型)/money(金额)/timer(时间)/intro(说明)icon(图标)
返回:成功/失败
分类图标接口(查询用户下面的分类)(集合名:classify)
接口: /api/getClassify
方式:post
参数:uid(用户ID)type(收支类型)
返回参数:uid(用户ID)type(收支类型)icon(图标)intro(说明/分类)
获取所有图标icon (集合名:icon_list)
接口:/api/getIcon
方式:get
参数:无
返回:成功/失败
添加分类接口 (集合名:classify)
接口: /api/addClassify
参数:uid(用户ID)type(收支类型)icon(图标)intro(说明/分类)
返回参数:uid(用户ID)type(收支类型)icon(图标)intro(说明/分类)