Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
3185c388
Commit
3185c388
authored
Jun 13, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adddd
parent
c0ae3180
Pipeline
#8858
passed with stage
in 12 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
858 additions
and
3 deletions
+858
-3
answer.js
app/controller/house/v2/answer.js
+28
-0
like.js
app/controller/house/v2/like.js
+30
-0
question.js
app/controller/house/v2/question.js
+74
-0
answer_like.js
app/model/realestate/answer_like.js
+129
-0
hot_question_answer.js
app/model/realestate/hot_question_answer.js
+134
-0
hot_question_put.js
app/model/realestate/hot_question_put.js
+130
-0
house.js
app/router/house.js
+16
-0
answer_like.js
app/service/house/v2/answer_like.js
+99
-0
hot_question_answer.js
app/service/house/v2/hot_question_answer.js
+96
-0
hot_question_put.js
app/service/house/v2/hot_question_put.js
+120
-0
mine.js
app/service/house/v2/mine.js
+2
-3
No files found.
app/controller/house/v2/answer.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
AnswerController
extends
Controller
{
/**
* 回答
*/
async
answer
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
answer
:
{
type
:
'string'
,
required
:
true
},
id
:
{
type
:
'integer'
,
required
:
true
},
city_code
:
{
type
:
'string'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
inputParams
);
if
(
inputParams
.
answer
.
length
>
500
)
{
ctx
.
failed
(
'最多输入500个字符'
);
}
let
ret
=
await
ctx
.
service
.
house
.
v2
.
hotQuestionAnswer
.
addAnswer
(
inputParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
AnswerController
;
app/controller/house/v2/like.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
LikeController
extends
Controller
{
/**
* 点赞
*/
async
like
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
params
;
let
ret
=
await
ctx
.
service
.
house
.
v2
.
answerLike
.
like
(
Number
(
inputParams
.
id
));
ctx
.
success
(
ret
);
}
/**
* 取消点赞
*/
async
unLike
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
params
;
let
ret
=
await
ctx
.
service
.
house
.
v2
.
answerLike
.
unLike
(
Number
(
inputParams
.
id
));
ctx
.
success
(
ret
);
}
}
module
.
exports
=
LikeController
;
app/controller/house/v2/question.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
QuestionController
extends
Controller
{
/**
* 提问
*/
async
addQuestion
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
question
:
{
type
:
'string'
,
required
:
true
},
city_code
:
{
type
:
'string'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
inputParams
);
if
(
inputParams
.
question
.
length
>
100
)
{
ctx
.
failed
(
'提问最多100个字符'
);
}
let
ret
=
await
ctx
.
service
.
house
.
v2
.
hotQuestionPut
.
addQuestion
(
inputParams
);
ctx
.
success
(
ret
);
}
/**
* 我的问题
*/
async
mineQuestion
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
page
:
{
type
:
'integer'
,
required
:
false
},
limit
:
{
type
:
'integer'
,
required
:
false
},
};
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
await
ctx
.
service
.
house
.
v2
.
hotQuestionPut
.
addQuestion
(
inputParams
);
ctx
.
success
(
ret
);
}
/**
* 问题列表
*/
async
questionList
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
page
:
{
type
:
'integer'
,
required
:
false
},
limit
:
{
type
:
'integer'
,
required
:
false
},
city_code
:
{
type
:
'integer'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
await
ctx
.
service
.
house
.
v2
.
hotQuestionPut
.
questionList
(
inputParams
);
ctx
.
success
(
ret
);
}
/**
* 问题详情
*/
async
questionDetail
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
id
:
{
type
:
'integer'
,
required
:
false
},
page
:
{
type
:
'integer'
,
required
:
false
},
limit
:
{
type
:
'integer'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
await
ctx
.
service
.
house
.
v2
.
hotQuestionPut
.
questionDetail
(
inputParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
QuestionController
;
app/model/realestate/answer_like.js
0 → 100644
View file @
3185c388
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
ENUM
,
DATE
}
=
app
.
Sequelize
;
const
AnswerLike
=
app
.
realestateModel
.
define
(
'answer_like'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_type_id
:
{
type
:
STRING
,
allowNull
:
true
},
answer_id
:
{
type
:
INTEGER
,
allowNull
:
true
},
answer
:
{
type
:
STRING
,
allowNull
:
true
},
state
:
{
type
:
INTEGER
,
allowNull
:
true
},
created_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
deleted_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'deleted_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'answer_like'
,
});
AnswerLike
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
SearchHistory
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
AnswerLike
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
AnswerLike
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
AnswerLike
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
data
.
limit
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
AnswerLike
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
AnswerLike
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
AnswerLike
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
AnswerLike
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
await
AnswerLike
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
AnswerLike
;
};
app/model/realestate/hot_question_answer.js
0 → 100644
View file @
3185c388
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
ENUM
,
DATE
}
=
app
.
Sequelize
;
const
HotQuestionAnswer
=
app
.
realestateModel
.
define
(
'hot_question_answer'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_type_id
:
{
type
:
STRING
,
allowNull
:
true
},
question_id
:
{
type
:
INTEGER
,
allowNull
:
true
},
answer
:
{
type
:
STRING
,
allowNull
:
true
},
city
:
{
type
:
INTEGER
,
allowNull
:
true
},
status
:
{
type
:
ENUM
(
'pass'
,
'refuse'
,
'wait'
),
allowNull
:
true
},
created_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
deleted_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'deleted_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'hot_question_answer'
,
});
HotQuestionAnswer
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
SearchHistory
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
HotQuestionAnswer
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
HotQuestionAnswer
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
HotQuestionAnswer
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
data
.
limit
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
HotQuestionAnswer
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
HotQuestionAnswer
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
HotQuestionAnswer
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
HotQuestionAnswer
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
await
HotQuestionAnswer
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
HotQuestionAnswer
;
};
app/model/realestate/hot_question_put.js
0 → 100644
View file @
3185c388
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
ENUM
,
DATE
}
=
app
.
Sequelize
;
const
HotQuestionPut
=
app
.
realestateModel
.
define
(
'hot_question_put'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_user_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_id
:
{
type
:
STRING
,
allowNull
:
true
},
app_type_id
:
{
type
:
STRING
,
allowNull
:
true
},
question
:
{
type
:
STRING
,
allowNull
:
true
},
city
:
{
type
:
INTEGER
,
allowNull
:
true
},
status
:
{
type
:
ENUM
(
'pass'
,
'refuse'
,
'wait'
),
allowNull
:
true
},
created_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
deleted_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'deleted_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'hot_question_put'
,
});
HotQuestionPut
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
SearchHistory
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
HotQuestionPut
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
HotQuestionPut
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
HotQuestionPut
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
data
.
limit
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
HotQuestionPut
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
HotQuestionPut
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
HotQuestionPut
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
HotQuestionPut
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
await
HotQuestionPut
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
HotQuestionPut
;
};
app/router/house.js
View file @
3185c388
...
...
@@ -83,4 +83,19 @@ module.exports = app => {
//
router
.
get
(
'/tool/gjj/loan/measure/:area'
,
'house.v2.tool.gjjLoanMeasureInfo'
);
//貸款測算
//点赞
router
.
get
(
'/v2/like/:id'
,
'house.v2.like.like'
);
//点赞
router
.
put
(
'/v2/like/:id'
,
'house.v2.like.unLike'
);
//取消点赞
//提问
router
.
post
(
'/v2/question'
,
'house.v2.question.addQuestion'
);
//提问
router
.
post
(
'/v2/question/mine'
,
'house.v2.question.mineQuestion'
);
//我的问题
router
.
post
(
'/v2/question/list'
,
'house.v2.question.questionList'
);
//问题列表
router
.
post
(
'/v2/question/detail'
,
'house.v2.question.addQuestion'
);
//问题详情
//回答
router
.
post
(
'/v2/answer'
,
'house.v2.answer.answer'
);
//回答
};
\ No newline at end of file
app/service/house/v2/answer_like.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
AnswerLikeService
extends
Service
{
/**
* 回答
* @param {object} inputParams
*/
async
like
(
id
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
where
:
{
answer_id
:
id
,
user_id
:
ctx
.
userId
,
state
:
1
}
}
let
likeInfo
=
await
ctx
.
realestateModel
.
AnswerLike
.
one
(
filter
);
if
(
likeInfo
!==
null
)
{
return
{
id
:
likeInfo
.
id
};
}
let
data
=
{
user_id
:
ctx
.
userId
,
app_user_id
:
ctx
.
appUserId
,
app_id
:
ctx
.
appId
,
app_type_id
:
ctx
.
appTypeId
,
answer_id
:
id
,
state
:
1
,
};
let
retId
=
await
ctx
.
realestateModel
.
AnswerLike
.
add
(
data
);
return
{
id
:
retId
};
}
/**
* 取消点赞
* @param {*} inputParams
*/
async
unLike
(
id
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
params
:
{
state
:
0
},
where
:
{
answer_id
:
id
,
user_id
:
ctx
.
userId
,
state
:
1
}
}
let
res
=
await
ctx
.
realestateModel
.
AnswerLike
.
edit
(
filter
);
return
{
status
:
true
};
}
/**
* 是否点赞某个回答
* @param {*} id
*/
async
isLike
(
id
)
{
const
{
ctx
}
=
this
;
let
isLike
=
false
;
if
(
!
ctx
.
userId
)
{
return
isLike
;
}
let
filter
=
{
where
:
{
answer_id
:
id
,
state
:
1
,
user_id
:
ctx
.
userId
}
}
let
likeInfo
=
await
ctx
.
realestateModel
.
answerLike
.
all
(
filter
);
isLike
=
likeInfo
.
length
>
0
?
true
:
false
;
return
ret
;
}
/**
* 获取某个回答被点赞的数量
* @param {*} id
*/
async
getLikeCount
(
id
)
{
const
{
ctx
}
=
this
;
let
likeFilter
=
{
attributes
:
[
'id'
],
where
:
{
answer_id
:
Number
(
id
),
state
:
1
}
}
let
answerLikeList
=
await
ctx
.
realestateModel
.
answerLike
.
all
(
likeFilter
);
return
answerLikeList
.
length
;
}
}
module
.
exports
=
AnswerLikeService
;
app/service/house/v2/hot_question_answer.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
HotQuestionAnswerService
extends
Service
{
/**
* 回答
* @param {object} inputParams
*/
async
addAnswer
(
inputParams
)
{
const
{
ctx
}
=
this
;
let
data
=
{
user_id
:
ctx
.
userId
,
app_user_id
:
ctx
.
appUserId
,
app_id
:
ctx
.
appId
,
app_type_id
:
ctx
.
appTypeId
,
question_id
:
inputParams
.
question_id
,
answer
:
inputParams
.
answer
,
city
:
inputParams
.
city
,
status
:
'wait'
,
};
let
retId
=
await
ctx
.
realestateModel
.
HotQuestionAnswer
.
add
(
data
);
return
{
id
:
retId
};
}
/**
* 回答列表
* @param {*} condition
*/
async
answerList
(
condition
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
page
:
condition
.
page
||
1
,
limit
:
condition
.
limit
||
10
,
where
:
{
question_id
:
Number
(
condition
.
id
),
status
:
'pass'
,
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
res
=
await
ctx
.
realestateModel
.
HotQuestionAnswer
.
list
(
filter
);
let
taskList
=
[];
for
(
let
i
in
res
)
{
taskList
[
i
]
=
this
.
formatAnswer
(
res
[
i
]);
}
retList
=
await
Promise
.
all
(
taskList
).
then
(
result
=>
{
return
result
;
}).
catch
(
error
=>
{
ctx
.
failed
(
error
);
});
let
ret
=
{
results
:
retList
,
count
:
res
.
count
}
return
ret
;
}
/**
* 获取该回答的点赞数量
* 用户头像昵称
* 本人是否点赞
* @param {*} data
*/
async
formatAnswer
(
data
)
{
const
{
ctx
}
=
this
;
//回答的用户信息
let
answerUserInfo
=
await
ctx
.
service
.
house
.
v2
.
mine
.
getAppUserInfo
(
data
.
app_user_id
);
//点赞的数量
let
LikeCount
=
await
ctx
.
service
.
house
.
v2
.
answerLike
.
getLikeCount
(
Number
(
data
.
answer_id
));
//本人是否点赞
let
isLike
=
await
ctx
.
service
.
house
.
v2
.
answerLike
.
isLike
(
Number
(
data
.
answer_id
));
let
ret
=
{
id
:
data
.
id
,
question
:
data
.
question
,
time
:
data
.
created_at
,
avatar
:
answerUserInfo
.
avatar
||
''
,
nickname
:
answerUserInfo
.
nickname
||
''
,
like
:
isLike
,
count
:
LikeCount
,
}
return
ret
;
}
}
module
.
exports
=
HotQuestionAnswerService
;
app/service/house/v2/hot_question_put.js
0 → 100644
View file @
3185c388
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
HotQuestionPutService
extends
Service
{
/**
* 添加预约信息
* @param {object} inputParams
*/
async
addQuestion
(
inputParams
)
{
const
{
ctx
}
=
this
;
let
data
=
{
user_id
:
ctx
.
userId
,
app_user_id
:
ctx
.
appUserId
,
app_id
:
ctx
.
appId
,
app_type_id
:
ctx
.
appTypeId
,
question
:
inputParams
.
question
,
city
:
inputParams
.
city
,
status
:
'wait'
,
};
let
retId
=
await
ctx
.
realestateModel
.
HotQuestionPut
.
add
(
data
);
return
{
id
:
retId
};
}
/**
* 根据条件获取热门问题列表
* 默认城市北京110000
* 默认取20条
* @param {object} condition
*/
async
questionList
(
condition
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
attributes
:
[
'id'
,
'question'
],
page
:
condition
.
page
||
1
,
limit
:
condition
.
limit
||
20
,
where
:
{
city
:
condition
.
city_code
||
110000
,
status
:
'pass'
,
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
res
=
await
ctx
.
realestateModel
.
HotQuestionPut
.
list
(
filter
);
let
ret
=
{
count
:
res
.
count
,
results
:
res
.
rows
}
return
ret
;
}
/**
* 问题详情
* @param {*} condition
*/
async
questionDetail
(
condition
)
{
const
{
ctx
}
=
this
;
//问题内容
let
filter
=
{
attributes
:
[
'question'
],
where
:
{
id
:
Number
(
condition
.
id
),
status
:
"pass"
}
}
let
question
=
await
ctx
.
realestateModel
.
HotQuestionPut
.
one
(
filter
);
//回答的列表
let
answerFliter
=
{
page
:
Number
(
condition
.
page
)
||
1
,
limit
:
Number
(
condition
.
limit
)
||
10
,
question_id
:
Number
(
condition
.
id
),
}
let
answerLsit
=
await
ctx
.
service
.
house
.
v2
.
HotQuestionAnswer
.
answerList
(
answerFliter
);
let
ret
=
{
question
:
question
.
question
,
answerList
:
answerLsit
}
return
ret
;
}
async
mineQuestion
(
condition
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
page
:
condition
.
page
||
1
,
limit
:
condition
.
limit
||
10
,
where
:
{
user_id
:
ctx
.
userId
,
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
res
=
await
ctx
.
realestateModel
.
HotQuestionPut
.
list
(
filter
);
let
list
=
[];
if
(
res
.
count
>
0
)
{
for
(
let
i
in
res
.
rows
)
{
list
[
i
]
=
{
id
:
res
.
row
[
i
].
id
,
question
:
res
.
row
[
i
].
question
,
status
:
res
.
row
[
i
].
status
,
}
}
}
let
ret
=
{
results
:
list
,
count
:
list
.
count
}
return
ret
;
}
}
module
.
exports
=
HotQuestionPutService
;
app/service/house/v2/mine.js
View file @
3185c388
...
...
@@ -34,7 +34,7 @@ class MineService extends Service {
if
(
!
ctx
.
userId
)
{
return
ret
;
}
let
appUserInfo
=
await
this
.
getAppUserInfo
();
let
appUserInfo
=
await
this
.
getAppUserInfo
(
ctx
.
appUserId
);
ctx
.
logger
.
info
(
'appUserInfo:'
+
JSON
.
stringify
(
appUserInfo
));
let
footPrintList
=
await
service
.
house
.
v2
.
footPrint
.
getFootPrintCount
();
let
collectionList
=
await
service
.
house
.
v2
.
collection
.
getCollectionCount
();
...
...
@@ -59,9 +59,8 @@ class MineService extends Service {
/**
* 获取用户信息
*/
async
getAppUserInfo
()
{
async
getAppUserInfo
(
appUserId
)
{
const
{
ctx
}
=
this
;
let
appUserId
=
ctx
.
appUserId
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
USER_CENTER_API_URI
+
'/v1/appusers/'
+
appUserId
,
{},
{
method
:
'GET'
,
dataType
:
'json'
});
const
ret
=
result
.
status
===
200
?
result
.
data
:
{};
if
(
ret
.
avatar
&&
ret
.
avatar
.
indexOf
(
'http'
)
===
-
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment