找幫手設計

領域模型

微信雲開發

雲函數

登陸

wx.cloud.callFunction({
	name: 'login',
	data: {}
}
return {
	is_new_register: true,
	user: {
		_id: "10001",
		_openid: "oOPyL5fGUU01L-THxvrYFRI9Tq6c",
		name: "小馬哥",
		avatar: "https://wx.qlogo.cn/mmopen/vi_32/qWf1krg/132"
	}
}

 

發送消息

wx.cloud.callFunction({
	name: 'sendMsg',
	data: {
		_id: '雪花算法',
		user_id: '10001',  // 發送人user_id
		group_id: 'groupId',  // group_id與receiver_id至少傳一個,都傳時以group_id爲準
		receiver_id: '1239197665867206656',  // 接收人user_id
		avatar: 'cloud://test-b51be.7465-test-b51be-1301504934/timg.jpg',
		name: '小馬哥',
		msg_type: 'text',  // text,image
		text_content: '小馬哥發送的消息'
	}
}
return {
	_id: "100010002001",
	groupId: "groupId"
}

 

消息已讀

wx.cloud.callFunction({
	name: 'msgReaded',
	data: {
		user_id: '10001',
		group_id: 'groupId',  // group_id與receiver_id至少傳一個,都傳時以group_id爲準
		msg_id: '100010002001'  // 已讀最新消息的id
	}
}
return {}

下單

// 接單時調用
wx.cloud.callFunction({
	name: 'placeOrder',
	data: {
		user_id: '10002',
		requirement_id: '需求id'
	}
}
return {
	id: "order_id"
}

接受訂單

// 需求發佈者接受申請
wx.cloud.callFunction({
	name: 'acceptOrder',
	data: {
		user_id: '10001',  // 需求發佈者id
		order_id: 'orderId'
	}
}
return {}

數據庫示例

chatgroups: {
	"_id": "1583740868254290081",
	"user_id_1": "10001",
	"unread_1": 2,
	"last_msg_1": "我再考慮一下",
	"user_id_2": "10002",
	"unread_2": 0,
	"last_msg_2": "您考慮的如何了"
}

chatroom: {
	"_id": "1583740869258595063",
	"user_id": "10001",
	"name": "小馬哥",
	"group_id": "1583740868254290081",
	"avatar": "https://wx.qlogo.cn/mmopen/vi_32/6rW8JKW0ZbSz4tguEUgDKc7PgC1g3feg0YCiadr5ybOWwhqAEe33QyyRF18Azd6Nd49anpU9d3LmIVrgqWf1krg/132",
	"text_content": "我再考慮一下",
	"msg_type": "text",
	"send_time": {
		"$date": "2020-03-09T08:01:08.254Z"
	}
}

users: {
	"_id": "10001",
	"openid": "oOPyL5fGUU01L-THxvrYFRI9Tq6c",
	"avatar": "https://wx.qlogo.cn/mmopen/vi_32/6rW8JKW0ZbSz4tguEUgDKc7PgC1g3feg0YCiadr5ybOWwhqAEe33QyyRF18Azd6Nd49anpU9d3LmIVrgqWf1krg/132",
	"name": "小馬哥",
	"sex": "男",
	"birthday": "1964-10",
	"mobile": "1800000001",
	"email": "mht@qq.com",
	"ability": "企業管理,充錢教學",
	"location": {
		"_id": 10201,
		"name": "靜安區"
	},
	"stars": 5,
	"certificate": "MBA",
	"self_description": "你如今遇到的全部問題,充錢都能解決",
	"educations": [{
		"college": "清華大學",
		"major": "土木工程",
		"degree": "學士",
		"begin": "2008",
		"end": "2012"
	}],
	"comments": [{
		"comment_by": 10002,
		"stars": 1,
		"remark": "只會騙氪",
		"createTime": "2020-03-09T01:24:51.254Z"
	}],
	"create_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	},
	"modify_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	}
}

favorites: {
	"_id": "1583740869258495067",
	"user_id": "10002",
	"requirement_id": "1583750869268195888",
	"person_id": 10001,
	"tyoe": "" // requirement,person
	"create_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	}
}

requirementTickets: {
	"_id": "1583740869258495066",
	"state": "PROCESSED",
	"user_id": "10001",
	"name": "三室兩廳裝修設計圖",
	"reward": 6000,
	"location": {
		"_id": 10201,
		"name": "靜安區"
	},
	"description": "xxxx",
	"create_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	},
	"modify_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	}
}

orders: {
	"_id": "1583740869258495068",
	"user_id": "10002",
	"state": "ACCEPTED",
	"img_url": "https://wx.qlogo.cn/mmopen/vi_32/6rW8JKW0ZbSz4tguEUgDKc7PgC1g3feg0YCiadr5ybOWwhqAEe33QyyRF18Azd6Nd49anpU9d3LmIVrgqWf1krg/132",
	"name": "三室兩廳裝修設計圖",
	"amount": 6000,
	"requirement_id": "1583740869258495066",
	"create_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	},
	"modify_time": {
		"$date": "2020-03-09T01:24:51.254Z"
	}
}

後端接口設計(後續實現)

認證方式

http headers中添加以下屬性:javascript

"ACCESS_TOKEN": "xbj:dsruvhgngr==" // token由登陸接口獲取java

REST接口

接口參數中紅色字體表示必填
接口名 微信一鍵登陸
url POST://{host}/login_wx
request body {
    "code": "xbj:sdsxcdf==",
    "avatar": "https://xcx.qq.com/ajde",
    "name": "張三",
    "sex": "male"
}
response body {
    "id": 10001,
    "token":"xbj:dsruvhgngr==",

    "openId": "xxx",
    "avatar": "xxx",
    "name":"張三"
}
http status 200 - 成功
201 - 新註冊用戶
400 - 缺少必填參數
接口名 編輯用戶信息
url PUT://{host}/users/{id}
request body {
    "name": "張三",
    "avatar": "https://xcx.qq.com/ajde",
    "sex": "male",
    "birthday":"1999-10-10",
    "ability":"外賣運營平臺",
    "mobile":18000000001,
    "email":"100001@qq.com",
    "location": {"id": 10201}
}
http status 200 -  成功
400 - 缺少必填參數
401 - 登陸認證失敗
403 - 禁止訪問
404 - 用戶不存在
接口名 編輯自我介紹
url PUT://{host}/users/{id}/self-description
request body {
    "selfDescription":"xxxxxxxxx"
}
http status 200 -  成功
401 - 認證失敗
403 - 禁止訪問
404 - 用戶不存在
接口名 編輯自我介紹
url PUT://{host}/users/{id}/educations
request body [{
    "college": "清華大學",
    "major": "土木工程",
    "degree": "碩士學位",
    "begin": "2008-09",
    "end": "2012-06"
}]
http status 200 -  成功
401 - 認證失敗
403 - 禁止訪問
404 - 用戶不存在
接口名 編輯技能證書
url PUT://{host}/users/{id}/certificate
request body {
    "certificate":"xxxxxxxxx"
}
http status 200 -  成功
401 - 認證失敗
403 - 禁止訪問
404 - 用戶不存在
接口名 用戶信息
url GET://{host}/users/{id}
request params optional=educations&optional=comments
response body {
    "id": 10001,
    "openId": "mht-321",
    "name": "小馬哥",
    "sex": "male",
    "birthday": "1990-09-16",
    "mobile": 18666888999,
    "email": "xmg666@qq.com",
    "ability": "忽悠,充錢",
    "location": {
        "id": 10201,
        "name": "靜安區"
    },
    "stars": 1,
    "certificate": "MBA",
    "selfDescription": "來,我來教你充值!",
    "educations": [{
        "id": 1,
        "userId": 10001,
        "college": "清華大學",
        "major": "土木工程",
        "degree": "學士",
        "begin": "2008",
        "end": "2012"
    }],
    "comments": [{
        "id": 1,
        "user_id": 10001,
        "comment_by": 10002,
        "stars": 1,
        "remark": "只會騙氪",
        "createTime": "2020-03-09 01:24:51"
    }]
}
http status 200 -  成功
401 - 認證失敗
404 - 用戶不存在
接口名 個人接單
url GET://{host}/users/{id}/orders
request params optional=requirement_details
response body [{
    "id":"10002",
    "state":"ACCEPTED",

    "img_url": "https://wx.qlogo.cn/mmopen/vi_32/rg/132",
    "name":"三室兩廳裝修設計圖",
    "amount":"6000",
    "requirement_id": 10086

}]
http status 200 -  成功
401 - 認證失敗
403 - 禁止訪問
404 - 用戶不存在
接口名 個人收藏
url GET://{host}/users/{id}/favorites
response body [{
    "id":"10002",
    "userId":"10001",
    "state":"PUBLISHED",
    "name":"三室兩廳裝修設計圖",
    "amount":"6000",
    "description":"xxxx"

}]
http status 200 -  成功 401 - 認證失敗 403 - 禁止訪問 404 - 用戶不存在
相關文章
相關標籤/搜索