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
a906d7bd
Commit
a906d7bd
authored
Jun 13, 2019
by
任国军
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
12226915
98f5af10
Pipeline
#8884
passed with stage
in 5 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1170 additions
and
4 deletions
+1170
-4
answer.js
app/controller/house/v2/answer.js
+28
-0
house_analysis.js
app/controller/house/v2/house_analysis.js
+79
-0
like.js
app/controller/house/v2/like.js
+30
-0
question.js
app/controller/house/v2/question.js
+75
-0
answer_like.js
app/model/realestate/answer_like.js
+125
-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_analysis.js
app/model/realestate/house_analysis.js
+114
-0
house.js
app/router/house.js
+32
-1
answer_like.js
app/service/house/v2/answer_like.js
+99
-0
hot_question_answer.js
app/service/house/v2/hot_question_answer.js
+97
-0
hot_question_put.js
app/service/house/v2/hot_question_put.js
+120
-0
house_analysis.js
app/service/house/v2/house_analysis.js
+105
-0
mine.js
app/service/house/v2/mine.js
+2
-3
No files found.
app/controller/house/v2/answer.js
0 → 100644
View file @
a906d7bd
'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
},
question_id
:
{
type
:
'integer'
,
required
:
true
},
city_code
:
{
type
:
'integer'
,
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/house_analysis.js
0 → 100644
View file @
a906d7bd
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
HouseAnalysisController
extends
Controller
{
//购房解析列表
async
getHouseAnalysisList
()
{
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
if
(
!
input_params
.
city_code
)
{
ctx
.
failed
(
'city_code error'
);
}
let
results
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
getHouseAnalysisByFilter
(
input_params
);
const
format_rows
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
formatHouseAnalysis
(
results
.
results
);
results
.
results
=
format_rows
;
ctx
.
success
(
results
);
}
//购房解析详情
async
getHouseAnalysisInfo
()
{
const
{
ctx
}
=
this
;
const
house_analysis_id
=
ctx
.
params
.
house_analysis_id
;
const
city_code
=
ctx
.
query
.
city_code
;
const
results
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
getHouseAnalysis
(
house_analysis_id
);
//推荐楼盘
let
where
=
{
corner
:
{
$ne
:
''
}
};
if
(
city_code
)
{
where
.
option_city_code
=
city_code
;
}
let
new_houses_rows
=
await
ctx
.
realestateModel
.
NewHouse
.
list
({
page
:
1
,
limit
:
3
,
where
:
where
,
order
:
[[
'order_id'
,
'asc'
]]
});
const
similar_list
=
[];
for
(
let
i
in
new_houses_rows
.
rows
)
{
const
new_house
=
new_houses_rows
.
rows
[
i
];
similar_list
.
push
({
id
:
new_house
.
id
,
name
:
new_house
.
name
,
image
:
new_house
.
image
,
corner
:
new_house
.
corner
,
});
}
ctx
.
success
({
results
:
{
info
:
results
,
similar_list
}
});
}
async
uploadHouseAnalysis
()
{
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
rule
=
{
name
:
{
type
:
'string'
,
required
:
true
},
city_code
:
{
type
:
'string'
,
required
:
true
},
house_type
:
{
type
:
'string'
,
required
:
true
},
area
:
{
type
:
'string'
,
required
:
true
},
image
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
input_params
);
const
result
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
addHouseAnalysis
(
input_params
);
ctx
.
success
({
result
});
}
async
getUserHouseAnalysis
()
{
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
query
;
const
results
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
getMineHouseAnalysis
(
input_params
);
const
format_rows
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
formatHouseAnalysis
(
results
.
rows
);
ctx
.
success
({
page
:
results
.
page
,
count
:
results
.
count
,
results
:
format_rows
});
}
}
module
.
exports
=
HouseAnalysisController
;
app/controller/house/v2/like.js
0 → 100644
View file @
a906d7bd
'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 @
a906d7bd
'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
:
'integer'
,
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
.
mineQuestion
(
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
},
key_word
:
{
type
:
'string'
,
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
:
true
},
page
:
{
type
:
'integer'
,
required
:
false
},
limit
:
{
type
:
'integer'
,
required
:
false
},
};
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 @
a906d7bd
'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
},
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
AnswerLike
.
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 @
a906d7bd
'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
HotQuestionAnswer
.
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 @
a906d7bd
'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
HotQuestionPut
.
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/model/realestate/house_analysis.js
0 → 100644
View file @
a906d7bd
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
ENUM
,
DATE
}
=
app
.
Sequelize
;
const
HouseAnalysis
=
app
.
realestateModel
.
define
(
'house_analysis'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_id
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
residential
:
STRING
,
city
:
STRING
,
house_type
:
STRING
,
house_area
:
STRING
,
image
:
STRING
,
text
:
STRING
,
status
:
ENUM
(
'pass'
,
'refuse'
,
'wait'
),
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
:
'house_analysis'
,
});
HouseAnalysis
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
HouseAnalysis
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
HouseAnalysis
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
HouseAnalysis
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
HouseAnalysis
.
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
HouseAnalysis
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
HouseAnalysis
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
HouseAnalysis
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
HouseAnalysis
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
res
=
await
HouseAnalysis
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
HouseAnalysis
;
};
app/router/house.js
View file @
a906d7bd
...
...
@@ -48,6 +48,14 @@ module.exports = app => {
//房产v2
router
.
get
(
'/v2/tool/:house_style/:area_code/:level'
,
'house.tool.getMapPoint'
);
//购房计划地图点位
router
.
post
(
'/v2/tool/plan'
,
'house.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
get
(
'/v2/tool/:type/:area_code'
,
'house.tool.getHousePriceFeature'
);
//房价指数 房价涨跌 购房资格、贷款额度问答
router
.
post
(
'/v2/tool/calculate_price'
,
'house.tool.calculateHousePrice'
);
//房产估价
router
.
get
(
'/v2/tool/qfang_area_list'
,
'house.tool.getQFangAreaList'
);
//房产估价模糊匹配到的小区列表
router
.
get
(
'/v2/tool/map_houses'
,
'house.tool.getMapHouses'
);
//房产估价模糊匹配到的小区列表
//租房列表
router
.
get
(
'/v2/rental_house/home'
,
'house.v2.rentalHouse.home'
);
//租房首页信息
router
.
get
(
'/v2/rental_house/list'
,
'house.v2.rentalHouse.getRentalHouses'
);
//租房列表
...
...
@@ -81,6 +89,28 @@ module.exports = app => {
router
.
get
(
'/v2/mine'
,
'house.v2.mine.getMineInfo'
);
//获取用户的头像昵称和关注等信息
//
router
.
get
(
'/tool/gjj/loan/measure/:area'
,
'house.v2.tool.gjjLoanMeasureInfo'
);
//貸款測算
router
.
get
(
'/v2/tool/gjj/loan/measure/:area'
,
'house.v2.tool.gjjLoanMeasureInfo'
);
//貸款測算
//户型解析
router
.
get
(
'/v2/house_analysis/list'
,
'house.v2.houseAnalysis.getHouseAnalysisList'
);
//户型解析列表
router
.
post
(
'/v2/house_analysis/list'
,
'house.v2.houseAnalysis.getHouseAnalysisList'
);
//户型解析列表
router
.
get
(
'/v2/house_analysis/info/:house_analysis_id'
,
'house.v2.houseAnalysis.getHouseAnalysisInfo'
);
//户型解析列表
router
.
post
(
'/v2/house_analysis/'
,
loginAuth
,
'house.v2.houseAnalysis.uploadHouseAnalysis'
);
//上传户型信息
router
.
get
(
'/v2/house_analysis/mine'
,
loginAuth
,
'house.v2.houseAnalysis.getUserHouseAnalysis'
);
//我的户型
//提问
router
.
post
(
'/v2/question'
,
loginAuth
,
'house.v2.question.addQuestion'
);
//提问
router
.
post
(
'/v2/question/mine'
,
loginAuth
,
'house.v2.question.mineQuestion'
);
//我的问题
router
.
post
(
'/v2/question/list'
,
'house.v2.question.questionList'
);
//问题列表
router
.
post
(
'/v2/question/detail'
,
'house.v2.question.questionDetail'
);
//问题详情
//回答
router
.
post
(
'/v2/answer'
,
loginAuth
,
'house.v2.answer.answer'
);
//回答
//点赞回答
router
.
post
(
'/v2/answer/like/:id'
,
loginAuth
,
'house.v2.like.like'
);
//点赞
router
.
put
(
'/v2/answer/like/:id'
,
loginAuth
,
'house.v2.like.unLike'
);
//取消点赞
};
\ No newline at end of file
app/service/house/v2/answer_like.js
0 → 100644
View file @
a906d7bd
'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 @
a906d7bd
'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_code
,
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
.
question_id
),
status
:
'pass'
,
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
res
=
await
ctx
.
realestateModel
.
HotQuestionAnswer
.
list
(
filter
);
let
taskList
=
[];
for
(
let
i
in
res
.
rows
)
{
taskList
[
i
]
=
this
.
formatAnswer
(
res
.
rows
[
i
]);
}
let
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
.
id
));
//本人是否点赞
let
isLike
=
await
ctx
.
service
.
house
.
v2
.
answerLike
.
isLike
(
Number
(
data
.
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 @
a906d7bd
'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
:
Number
(
inputParams
.
city_code
),
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'
]]
}
if
(
condition
.
key_word
)
{
//关键词搜索 模糊查询
//增加搜索历史
// let addHistory = {
// type: 1,
// key_word: condition.name
// };
// await ctx.service.house.v2.searchHistory.addSearchHistory(addHistory);
filter
.
where
.
question
=
{
$like
:
'%'
+
condition
.
key_word
+
'%'
}
}
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
,
attributes
:
[
'id'
,
'question'
,
'status'
],
where
:
{
user_id
:
ctx
.
userId
,
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
res
=
await
ctx
.
realestateModel
.
HotQuestionPut
.
list
(
filter
);
let
ret
=
{
results
:
res
.
rows
,
count
:
res
.
count
}
return
ret
;
}
}
module
.
exports
=
HotQuestionPutService
;
app/service/house/v2/house_analysis.js
0 → 100644
View file @
a906d7bd
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
R
=
require
(
'ramda'
);
const
moment
=
require
(
'moment'
);
class
HouseAnalysisService
extends
Service
{
//户型解析列表
async
getHouseAnalysisByFilter
(
condition
)
{
const
{
ctx
}
=
this
;
let
{
city_code
,
keyword
,
page
}
=
condition
;
page
=
page
?
page
:
1
;
let
where
=
{
status
:
'pass'
};
if
(
city_code
)
{
where
.
city
=
city_code
;
}
if
(
keyword
&&
keyword
.
length
!==
0
)
{
where
.
residential
=
{
$like
:
`%
${
keyword
}
%`
}
}
const
house_analysis_rows
=
await
ctx
.
realestateModel
.
HouseAnalysis
.
list
({
page
:
page
,
where
:
where
,
order
:
[[
'id'
,
'desc'
]]
});
const
house_analysis
=
R
.
project
([
'id'
,
'image'
,
'residential'
,
'house_type'
,
'house_area'
,
'text'
])(
house_analysis_rows
.
rows
);
return
{
page
:
page
,
count
:
house_analysis_rows
.
count
,
results
:
house_analysis
};
}
//户型解析详情
async
getHouseAnalysis
(
house_analysis_id
)
{
const
{
ctx
}
=
this
;
const
house_analysis
=
await
ctx
.
realestateModel
.
HouseAnalysis
.
one
({
where
:
{
id
:
house_analysis_id
}
});
return
{
id
:
house_analysis
.
id
,
image
:
house_analysis
.
image
,
name
:
house_analysis
.
residential
,
house_type
:
house_analysis
.
house_type
,
area
:
house_analysis
.
house_area
,
description
:
house_analysis
.
text
,
status
:
house_analysis
.
status
,
}
}
async
addHouseAnalysis
(
params
)
{
const
{
ctx
}
=
this
;
const
user_id
=
ctx
.
userId
;
const
app_user_id
=
ctx
.
appUserId
;
const
app_id
=
ctx
.
appId
;
const
app_type_id
=
ctx
.
appTypeId
;
if
(
!
user_id
||
!
app_user_id
||
!
app_id
||
!
app_type_id
)
{
ctx
.
failed
(
'login error'
);
}
const
data
=
{
user_id
,
app_user_id
,
app_id
,
app_type_id
,
residential
:
params
.
name
,
house_type
:
params
.
house_type
,
city
:
params
.
city_code
,
house_area
:
params
.
area
,
image
:
params
.
image
,
created_at
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD HH:mm:ss'
),
}
const
ret
=
await
ctx
.
realestateModel
.
HouseAnalysis
.
add
(
data
);
return
ret
;
}
async
getMineHouseAnalysis
(
condition
)
{
const
{
ctx
}
=
this
;
const
page
=
condition
.
page
?
condition
.
page
:
1
;
const
limit
=
condition
.
page_size
?
condition
.
page_size
:
10
;
const
user_id
=
ctx
.
userId
;
const
app_type_id
=
ctx
.
appTypeId
;
if
(
!
user_id
||
!
app_type_id
)
{
ctx
.
failed
(
'login error'
);
}
const
results
=
await
ctx
.
realestateModel
.
HouseAnalysis
.
list
({
page
:
page
,
limit
:
limit
,
where
:
{
user_id
:
user_id
,
app_type_id
:
app_type_id
},
order
:
[[
'id'
,
'desc'
]]
});
return
results
;
}
async
formatHouseAnalysis
(
house_analysis
)
{
const
{
ctx
}
=
this
;
if
(
!
Array
.
isArray
(
house_analysis
)
||
house_analysis
.
length
===
0
)
{
return
[];
}
const
ret
=
house_analysis
.
map
(
item
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
residential
,
status
:
item
.
status
,
house_type
:
item
.
house_type
,
area
:
item
.
house_area
,
description
:
item
.
text
,
image
:
item
.
image
}
});
return
ret
;
}
}
module
.
exports
=
HouseAnalysisService
;
app/service/house/v2/mine.js
View file @
a906d7bd
...
...
@@ -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