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
d88737a2
Commit
d88737a2
authored
Apr 09, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add house image
parent
7b1d1133
Pipeline
#5754
passed with stage
in 2 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
125 additions
and
9 deletions
+125
-9
rental_house.js
app/controller/house/rental_house.js
+14
-3
house.js
app/router/house.js
+2
-1
rental_house.js
app/service/house/rental_house.js
+49
-4
house_image.js
app/service/house_common/house_image.js
+55
-0
rental_house.js
app/service/house_common/rental_house.js
+5
-1
No files found.
app/controller/house/rental_house.js
View file @
d88737a2
...
...
@@ -4,17 +4,28 @@ const Controller = require('egg').Controller;
class
RentalHouseController
extends
Controller
{
async
getRentHouses
()
{
async
getRent
al
Houses
()
{
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
query
;
const
rule
=
{
brand
:
{
type
:
'string'
,
required
:
false
},
//品牌
district
:
{
type
:
'string'
,
required
:
false
},
//区域
price
:
{
type
:
'enum'
,
required
:
false
,
values
:
[
'1'
,
'2'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
]
},
//价格
//
price: { type: 'enum', required: false, values: ['1', '2', '4', '5', '6', '7', '8', '9'] },//价格
house_type
:
{
type
:
'enum'
,
required
:
false
,
values
:
[
'1'
,
'2'
,
'4'
,
'5'
,
'6'
]
},
//房型
};
ctx
.
validate
(
rule
,
input_params
);
const
ret
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHouses
(
input_params
);
const
ret
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHousesByFilter
(
input_params
);
ctx
.
success
(
ret
);
}
async
getRentalHouse
()
{
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
params
;
if
(
!
input_params
.
rental_house_id
)
{
ctx
.
failed
(
'rental_house_id error'
);
}
const
rental_house_id
=
input_params
.
rental_house_id
;
const
ret
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHouse
(
rental_house_id
);
ctx
.
success
(
ret
);
}
...
...
app/router/house.js
View file @
d88737a2
...
...
@@ -5,6 +5,7 @@ module.exports = app => {
// const loginAuth = app.middleware.loginAuth({type: 'new'});//登录中间件
router
.
get
(
'/options/:city_code'
,
'house.options.getOptions'
);
//筛选项信息
router
.
get
(
'/rental_house'
,
'house.rentalHouse.getRentHouses'
);
//租房列表
router
.
get
(
'/rental_house'
,
'house.rentalHouse.getRentalHouses'
);
//租房列表
router
.
get
(
'/rental_house/:rental_house_id'
,
'house.rentalHouse.getRentalHouse'
);
//租房列表
};
app/service/house/rental_house.js
View file @
d88737a2
...
...
@@ -30,25 +30,70 @@ class RentalHouseService extends Service {
const
{
ctx
}
=
this
;
const
queryConditions
=
[];
if
(
condition
.
brand
)
{
if
(
condition
.
brand
)
{
queryConditions
.
push
();
}
const
filter
=
{
pageSize
:
30
,
queryConditions
:
[{
key
:
"
S
tate"
,
key
:
"
s
tate"
,
value
:
1
,
operator
:
"equal"
},
{
key
:
"price"
,
value
:
19000
,
operator
:
"greater"
},
{
key
:
"price"
,
value
:
29000
,
operator
:
"less"
},],
orderConditions
:
[{
key
:
'
P
rice'
,
key
:
'
p
rice'
,
orderSequence
:
'asc'
,
},],
}
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
{}
);
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
filter
);
return
rental_houses_results
;
}
async
getRentalHouse
(
rental_house_id
)
{
const
{
ctx
}
=
this
;
//获取房源基本信息
const
house_basic
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
one
(
rental_house_id
);
if
(
!
house_basic
||
!
house_basic
.
id
){
ctx
.
failed
(
'house not found'
);
}
//获取房源图片信息
const
house_image_filter
=
{
queryConditions
:
[
{
key
:
'state'
,
value
:
1
,
operator
:
'equal'
},
{
key
:
'type'
,
value
:
0
,
operator
:
'equal'
},
{
key
:
'connectId'
,
value
:
house_basic
.
id
,
operator
:
'equal'
},
],
};
const
house_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_image_filter
);
const
house_images
=
house_images_results
.
results
;
return
{
house_basic
,
house_images
};
}
}
module
.
exports
=
RentalHouseService
;
app/service/house_common/house_image.js
0 → 100644
View file @
d88737a2
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
HouseImageService
extends
Service
{
async
all
(
data
)
{
const
{
ctx
}
=
this
;
const
pageIndex
=
data
.
page
||
1
;
const
pageSize
=
data
.
pageSize
||
10
;
const
queryConditions
=
data
.
queryConditions
||
[];
const
orderConditions
=
data
.
orderConditions
||
[];
data
.
queryConditions
=
queryConditions
;
data
.
orderConditions
=
orderConditions
;
data
.
pageIndex
=
pageIndex
;
data
.
pageSize
=
pageSize
;
ctx
.
logger
.
info
(
'houseimage_list_conditions: '
+
JSON
.
stringify
(
data
));
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/houseimage/list'
,
data
,
{
method
:
'POST'
,
dataType
:
'json'
});
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
.
data
;
}
async
one
(
id
)
{
const
{
ctx
}
=
this
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/houseimage/'
+
id
,
{},
{
method
:
'GET'
,
dataType
:
'json'
});
ctx
.
logger
.
info
(
'house_image_result: '
+
JSON
.
stringify
(
result
));
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
;
}
}
module
.
exports
=
HouseImageService
;
app/service/house_common/rental_house.js
View file @
d88737a2
...
...
@@ -46,7 +46,8 @@ class RentalHouseService extends Service {
async
one
(
id
)
{
const
{
ctx
}
=
this
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/rentalhouse/'
+
id
,
{},
{});
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/rentalhouse/'
+
id
,
{},
{
method
:
'GET'
,
dataType
:
'json'
});
ctx
.
logger
.
info
(
'rentalhouse_result: '
+
JSON
.
stringify
(
result
));
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
...
...
@@ -56,6 +57,9 @@ class RentalHouseService extends Service {
}
ctx
.
failed
(
err
);
}
ctx
.
logger
.
info
(
'rental_house_result: '
+
JSON
.
stringify
(
result
));
return
result
.
data
;
}
...
...
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