Commit 4c11a9a4 authored by Hsinli's avatar Hsinli

add

parent ae0458fd
Pipeline #6047 passed with stage
in 7 seconds
......@@ -33,6 +33,25 @@ class CollectionController extends Controller {
ctx.success(ret);
}
async unCollection(){
const { ctx } = this;
let inputParams = ctx.request.body;
const rule = {
id: {
type: 'integer',
required: true,
},
type: {
type: 'integer',
required: true,
}
};
ctx.validate(rule, inputParams);
let ret = await ctx.service.house.collection.unCollection(inputParams);
ctx.success(ret);
}
}
module.exports = CollectionController;
......@@ -28,12 +28,13 @@ module.exports = app => {
router.post('/order', loginAuth, 'house.order.addOrder');//预约
router.get('/order/list', loginAuth, 'house.order.getOrderList');//预约列表
//收藏
router.post('/collection', loginAuth, 'house.collection.addCollection');//收藏
router.get('/collection/list', loginAuth, 'house.collection.getCollectionList');//收藏列表
//关注
router.post('/collection', loginAuth, 'house.collection.addCollection');//关注
router.get('/collection/list', loginAuth, 'house.collection.getCollectionList');//关注列表
router.put('/collection', loginAuth, 'house.collection.unCollection');//取消关注
//搜索历史
router.get('/search_history', 'house.searchHistory.getsearchHistory');//收藏列表
router.get('/search_history', 'house.searchHistory.getsearchHistory');//搜索历史
router.put('/search_history/:type', 'house.searchHistory.cleanSearchHistory');//用户点击清除搜索记录
//足迹
......
......@@ -7,7 +7,7 @@ const moment = require('moment');
class CollectionService extends Service {
/**
* 添加收藏
* 添加关注
* @param {object} inputParams
*/
async addCollection(inputParams) {
......@@ -53,6 +53,48 @@ class CollectionService extends Service {
}
/**
* 取消关注
* @param {object} inputParams
*/
async unCollection(inputParams) {
const { ctx, service } = this;
let ret = { status: true };
if (!ctx.appUserId || !ctx.deviceId || !ctx.deviceLoginId || !ctx.userId) {
//如果没有登录就不做处理
return ret;
}
let filter = {
pageIndex: 1,
pageSize: 999,
queryConditions: [{
key: "state",
value: 1,
operator: "equal"
}, {
key: "userId",
value: ctx.userId,
operator: "equal"
}, {
key: "connectId",
value: inputParams.id,
operator: "equal"
}, {
key: "houseStyle",
value: inputParams.type,
operator: "equal"
},
],
orderConditions: [],
}
let collectionHistory = await service.houseCommon.collection.all(filter);
if (collectionHistory.rowCount > 0) {
await service.houseCommon.collection.delete(collectionHistory.results[0].id);
}
return ret;
}
/**
* 获取用户关注信息
* @param {object} inputParams
*/
......@@ -99,7 +141,7 @@ class CollectionService extends Service {
/**
* 获取收藏列表 保留最近6个月的记录,条数不超过50条
* 获取关注列表 保留最近6个月的记录,条数不超过50条
* @param {object} condition
*/
async getCollectionList() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment