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
a0271d31
Commit
a0271d31
authored
Oct 15, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
d145d535
Pipeline
#14924
passed with stage
in 36 seconds
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
241 additions
and
32 deletions
+241
-32
abroad_house.js
app/controller/house/v2/abroad_house.js
+24
-0
foot_print.js
app/controller/house/v2/foot_print.js
+16
-0
search_history.js
app/controller/house/v2/search_history.js
+7
-2
abroad_house.js
app/model/realestate/abroad_house.js
+76
-0
house.js
app/router/house.js
+7
-0
abroad_house.js
app/service/house/v2/abroad_house.js
+52
-0
foot_print.js
app/service/house/v2/foot_print.js
+53
-20
search_history.js
app/service/house/v2/search_history.js
+4
-8
config.local.js
config/config.local.js
+2
-2
No files found.
app/controller/house/v2/abroad_house.js
0 → 100644
View file @
a0271d31
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
AbroadHouseController
extends
Controller
{
/**
* 获取海外房列表
*/
async
list
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
name
:
{
type
:
'string'
,
required
:
false
},
};
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
await
ctx
.
service
.
house
.
v2
.
abroadHouse
.
abroadHouseList
(
inputParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
AbroadHouseController
;
app/controller/house/v2/foot_print.js
View file @
a0271d31
...
...
@@ -13,6 +13,22 @@ class FootPrintController extends Controller {
ctx
.
success
(
ret
);
}
/**
* 海外房的足迹记录需要额外记录
*/
async
addAbroadFootPrint
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
id
:
{
type
:
'int'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
inputParams
);
inputParams
.
type
=
4
;
let
ret
=
await
ctx
.
service
.
house
.
v2
.
footPrint
.
addFootPrint
(
inputParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
FootPrintController
;
app/controller/house/v2/search_history.js
View file @
a0271d31
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
const
ConfigType
=
{
1
:
'new_house'
,
2
:
'rental_house'
,
4
:
'abroad_house'
,
}
class
searchHistoryController
extends
Controller
{
...
...
@@ -19,9 +24,9 @@ class searchHistoryController extends Controller {
};
ctx
.
validate
(
rule
,
inputParams
);
let
ret
=
{};
let
type
=
[
1
,
2
];
let
type
=
[
1
,
2
,
4
];
for
(
let
i
in
type
)
{
let
tag
=
type
[
i
]
===
1
?
'new_house'
:
'rental_house'
;
let
tag
=
ConfigType
[
type
[
i
]]
;
ret
[
tag
]
=
await
ctx
.
service
.
house
.
v2
.
searchHistory
.
getSearchHistoryList
({
type
:
type
[
i
],
city_code
:
Number
(
inputParams
.
city_code
)
});
}
...
...
app/model/realestate/abroad_house.js
0 → 100644
View file @
a0271d31
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
TEXT
,
DECIMAL
}
=
app
.
Sequelize
;
const
AbroadHouse
=
app
.
realestateModel
.
define
(
'abroad_house'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
name
:
{
type
:
STRING
,
allowNull
:
true
},
images
:
{
type
:
TEXT
,
allowNull
:
true
},
tags
:
{
type
:
STRING
,
allowNull
:
true
},
total_price
:
{
type
:
DECIMAL
,
allowNull
:
true
},
url
:
{
type
:
STRING
,
allowNull
:
true
},
order
:
{
type
:
INTEGER
,
allowNull
:
true
},
valid
:
{
type
:
INTEGER
,
allowNull
:
true
},
status
:
{
type
:
STRING
,
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
:
'abroad_house'
,
});
return
AbroadHouse
;
};
app/router/house.js
View file @
a0271d31
...
...
@@ -129,6 +129,12 @@ module.exports = app => {
router
.
post
(
'/v2/answer/like/:id'
,
loginAuth
,
'house.v2.like.like'
);
//点赞
router
.
put
(
'/v2/answer/like/:id'
,
loginAuth
,
'house.v2.like.unLike'
);
//取消点赞
//海外房列表
router
.
post
(
'/v2/abroad_house/list'
,
'house.v2.abroadHouse.list'
);
//海外房足迹记录
router
.
post
(
'/v2/foot_print/abroad_house'
,
'house.v2.footPrint.addAbroadFootPrint'
);
};
\ No newline at end of file
app/service/house/v2/abroad_house.js
0 → 100644
View file @
a0271d31
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
const
_
=
require
(
'lodash'
);
class
AbroadHouseService
extends
Service
{
/**
* 海外房列表
*/
async
abroadHouseList
(
condition
)
{
const
{
ctx
}
=
this
;
let
filter
=
{
where
:
{
valid
:
1
,
status
:
'online'
,
},
order
:
[[
'order'
,
'asc'
]]
}
if
(
condition
.
name
)
{
//关键词搜索 模糊查询
//增加搜索历史
let
addHistory
=
{
type
:
4
,
key_word
:
condition
.
name
};
await
ctx
.
service
.
house
.
v2
.
searchHistory
.
addSearchHistory
(
addHistory
);
filter
.
where
.
name
=
{
$like
:
'%'
+
condition
.
name
+
'%'
}
}
let
list
=
await
ctx
.
realestateModel
.
AbroadHouse
.
findAll
(
filter
);
let
data
=
[];
for
(
let
i
in
list
)
{
data
[
i
]
=
{
name
:
list
[
i
].
name
||
''
,
images
:
list
[
i
].
images
?
JSON
.
parse
(
list
[
i
].
images
)
:
[],
tags
:
list
[
i
].
tags
?
JSON
.
parse
(
list
[
i
].
tags
)
:
[],
total_price
:
list
[
i
].
total_price
||
'--'
,
url
:
list
[
i
].
url
||
''
,
}
}
let
ret
=
{
results
:
data
,
count
:
data
.
length
};
return
ret
;
}
}
module
.
exports
=
AbroadHouseService
;
app/service/house/v2/foot_print.js
View file @
a0271d31
...
...
@@ -2,7 +2,13 @@
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
const
ConfigType
=
{
1
:
'new_house'
,
2
:
'rental_house'
,
4
:
'abroad_house'
,
}
class
FootPrintService
extends
Service
{
...
...
@@ -29,8 +35,7 @@ class FootPrintService extends Service {
state
:
1
,
remark
:
inputParams
.
remark
||
''
,
}
let
ret
=
await
ctx
.
realestateModel
.
FootPrint
.
add
(
data
);
let
ret
=
await
ctx
.
realestateModel
.
FootPrint
.
create
(
data
);
return
{
id
:
ret
.
id
};
}
...
...
@@ -57,7 +62,6 @@ class FootPrintService extends Service {
limit
:
50
,
where
:
{
user_id
:
user_id
,
// app_type_id: app_type_id,
state
:
1
,
created_at
:
{
$gt
:
endDate
},
},
...
...
@@ -69,10 +73,13 @@ class FootPrintService extends Service {
for
(
let
i
in
foot_prints
)
{
let
foot_print
=
foot_prints
[
i
];
if
(
foot_print
.
house_style
===
1
)
{
//获取房源信息
p_houses
[
i
]
=
ctx
.
realestateModel
.
NewHouse
.
one
({
where
:
{
id
:
foot_print
.
connect_id
}
});
p_houses
[
i
]
=
ctx
.
realestateModel
.
NewHouse
.
one
({
attributes
:
[
'id'
,
'name'
,
'status'
,
'valid'
],
where
:
{
id
:
foot_print
.
connect_id
}
});
}
else
if
(
foot_print
.
house_style
===
2
)
{
p_houses
[
i
]
=
ctx
.
realestateModel
.
RentalHouse
.
one
({
where
:
{
id
:
foot_print
.
connect_id
}
});
p_houses
[
i
]
=
ctx
.
realestateModel
.
RentalHouse
.
one
({
attributes
:
[
'id'
,
'name'
,
'status'
,
'valid'
],
where
:
{
id
:
foot_print
.
connect_id
}
});
}
else
if
(
foot_print
.
house_style
===
4
)
{
p_houses
[
i
]
=
ctx
.
realestateModel
.
AbroadHouse
.
findOne
({
attributes
:
[
'id'
,
'name'
,
'url'
,
'status'
,
'valid'
],
where
:
{
id
:
foot_print
.
connect_id
}
});
}
}
const
houses
=
await
Promise
.
all
(
p_houses
).
then
(
result
=>
{
//等待所有异步内容获取完成
return
result
;
...
...
@@ -89,7 +96,7 @@ class FootPrintService extends Service {
}
const
house
=
houses
[
j
];
const
foot_print
=
foot_prints
[
j
];
const
type
=
foot_print
.
house_style
===
1
?
'new_house'
:
'rental_house'
;
const
type
=
ConfigType
[
foot_print
.
house_style
]
;
const
create_time
=
moment
(
foot_print
.
created_at
).
format
(
'X'
);
let
time
=
moment
(
foot_print
.
created_at
).
format
(
'YYYY-MM-DD'
);
const
du_time
=
now_time
-
create_time
;
...
...
@@ -105,10 +112,11 @@ class FootPrintService extends Service {
name
:
house
.
name
,
time
:
time
,
type
:
type
,
url
:
type
===
'abroad_house'
?
house
.
url
:
''
,
});
}
return
{
results
:
foot_print_records
,
count
:
foot_print
s_rows
.
count
};
return
{
results
:
foot_print_records
,
count
:
foot_print
_records
.
length
};
}
...
...
@@ -122,7 +130,6 @@ class FootPrintService extends Service {
}
let
endDate
=
moment
().
subtract
(
6
,
'months'
).
format
(
'YYYY-MM-DD HH:mm:ss'
);
const
filter
=
{
page
:
1
,
limit
:
50
,
attributes
:
[
'connect_id'
,
'house_style'
],
where
:
{
...
...
@@ -135,29 +142,55 @@ class FootPrintService extends Service {
const
list
=
await
ctx
.
realestateModel
.
FootPrint
.
findAll
(
filter
);
let
count
=
0
;
if
(
list
.
length
>
0
)
{
let
taskList
=
[];
let
newIds
=
[];
let
rentalIds
=
[];
let
abroadIds
=
[];
for
(
let
i
in
list
)
{
let
taskFilter
=
{
attributes
:
[
'id'
],
where
:
{
status
:
'online'
,
valid
:
1
,
id
:
list
[
i
].
connect_id
}
}
if
(
Number
(
list
[
i
].
house_style
)
===
1
)
{
taskList
[
i
]
=
ctx
.
realestateModel
.
NewHouse
.
one
(
taskFilter
);
newIds
.
push
(
list
[
i
].
connect_id
);
}
if
(
Number
(
list
[
i
].
house_style
)
===
2
)
{
taskList
[
i
]
=
ctx
.
realestateModel
.
RentalHouse
.
one
(
taskFilter
);
rentalIds
.
push
(
list
[
i
].
connect_id
);
}
if
(
Number
(
list
[
i
].
house_style
)
===
4
)
{
abroadIds
.
push
(
list
[
i
].
connect_id
);
}
}
let
newTaskFilter
=
{
attributes
:
[
'id'
],
where
:
{
status
:
'online'
,
valid
:
1
,
id
:
{
$in
:
newIds
}
}
}
let
rentalTaskFilter
=
{
attributes
:
[
'id'
],
where
:
{
status
:
'online'
,
valid
:
1
,
id
:
{
$in
:
rentalIds
}
}
}
let
abroadTaskFilter
=
{
attributes
:
[
'id'
],
where
:
{
status
:
'online'
,
valid
:
1
,
id
:
{
$in
:
abroadIds
}
}
}
let
taskList
=
[
ctx
.
realestateModel
.
NewHouse
.
findAll
(
newTaskFilter
),
ctx
.
realestateModel
.
RentalHouse
.
findAll
(
rentalTaskFilter
),
ctx
.
realestateModel
.
AbroadHouse
.
findAll
(
abroadTaskFilter
),
];
const
retList
=
await
Promise
.
all
(
taskList
).
then
(
result
=>
{
return
result
;
}).
catch
(
error
=>
{
ctx
.
failed
(
error
);
});
count
=
Number
(
retList
.
length
);
let
validNewIds
=
_
.
map
(
retList
[
0
],
'id'
);
let
validRentalIds
=
_
.
map
(
retList
[
1
],
'id'
);
let
validAbroadIds
=
_
.
map
(
retList
[
2
],
'id'
);
for
(
let
i
in
list
)
{
if
(
Number
(
list
[
i
].
house_style
)
===
1
&&
validNewIds
.
includes
(
Number
(
list
[
i
].
connect_id
)))
{
count
++
;
}
if
(
Number
(
list
[
i
].
house_style
)
===
2
&&
validRentalIds
.
includes
(
Number
(
list
[
i
].
connect_id
)))
{
count
++
;
}
if
(
Number
(
list
[
i
].
house_style
)
===
4
&&
validAbroadIds
.
includes
(
Number
(
list
[
i
].
connect_id
)))
{
count
++
;
}
}
}
let
ret
=
{
count
:
count
...
...
app/service/house/v2/search_history.js
View file @
a0271d31
...
...
@@ -2,6 +2,7 @@
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
_
=
require
(
'lodash'
);
const
moment
=
require
(
'moment'
);
class
searchHistoryService
extends
Service
{
...
...
@@ -50,7 +51,9 @@ class searchHistoryService extends Service {
}
};
//不管有没有登录获取城市相关的热门搜索
if
(
condition
.
type
&&
[
1
,
2
].
includes
(
condition
.
type
))
{
ret
.
hot_search
.
results
=
await
ctx
.
service
.
house
.
v2
.
hotSearch
.
getHotSearch
(
condition
);
}
if
(
!
ctx
.
appUserId
||
!
ctx
.
userId
)
{
//如果没有登录就返回
...
...
@@ -124,14 +127,7 @@ class searchHistoryService extends Service {
order
:
[[
'created_at'
,
'desc'
]],
}
let
searchHistoryList
=
await
ctx
.
realestateModel
.
SearchHistory
.
findAll
(
filter
);
let
list
=
[];
if
(
searchHistoryList
.
length
>
0
)
{
for
(
let
i
in
searchHistoryList
)
{
if
(
list
.
indexOf
(
searchHistoryList
[
i
].
key_word
)
===
-
1
)
{
list
.
push
(
searchHistoryList
[
i
].
key_word
);
}
}
}
let
list
=
_
.
uniq
(
_
.
map
(
searchHistoryList
,
'key_word'
));
ret
=
{
results
:
list
,
count
:
list
.
length
...
...
config/config.local.js
View file @
a0271d31
...
...
@@ -139,8 +139,8 @@ module.exports = appInfo => {
};
config
.
PHP_URL
=
'https://kaifa.jianbing.com'
;
config
.
NODE_URL
=
'https://
uat
-nginx.jianbing.com/user_api/v1'
;
config
.
NODE_BASE_URL
=
'https://
uat
-nginx.jianbing.com'
;
config
.
NODE_URL
=
'https://
dev
-nginx.jianbing.com/user_api/v1'
;
config
.
NODE_BASE_URL
=
'https://
dev
-nginx.jianbing.com'
;
config
.
HOUSE_SERVICE_API
=
'https://uat-nginx.jianbing.com/house-service'
;
config
.
CDN_BASE_URL
=
'https://r.51gjj.com/image/'
;
...
...
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