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
165e7b57
Commit
165e7b57
authored
Apr 09, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add house
parent
ba1e0152
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
298 additions
and
1 deletion
+298
-1
district.js
app/controller/house/district.js
+0
-0
options.js
app/controller/house/options.js
+20
-0
rental_house.js
app/controller/house/rental_house.js
+23
-0
house.js
app/router/house.js
+10
-0
option.js
app/service/house/option.js
+59
-0
rental_house.js
app/service/house/rental_house.js
+54
-0
developer.js
app/service/house_common/developer.js
+66
-0
rental_house.js
app/service/house_common/rental_house.js
+65
-0
config.default.js
config/config.default.js
+1
-1
No files found.
app/controller/house/district.js
0 → 100644
View file @
165e7b57
app/controller/house/options.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
OptionsController
extends
Controller
{
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
params
;
const
rule
=
{
city_code
:
{
type
:
'string'
,
required
:
true
}
}
ctx
.
validate
(
rule
,
input_parmas
);
const
city_code
=
input_parmas
.
city_code
;
const
ret
=
await
ctx
.
service
.
house
.
option
.
getOptions
(
city_code
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
OptionsController
;
app/controller/house/rental_house.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
RentalHouseController
extends
Controller
{
async
getRentHouses
()
{
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'
]
},
//价格
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
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
RentalHouseController
;
app/router/house.js
0 → 100644
View file @
165e7b57
'use strict'
;
module
.
exports
=
app
=>
{
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/house'
);
// const loginAuth = app.middleware.loginAuth({type: 'new'});//登录中间件
router
.
get
(
'/options'
,
'house.options.getOptions'
);
//首页信息
router
.
get
(
'/rental_house'
,
'house.rentalHouse.getRentHouses'
);
//首页信息
};
app/service/house/option.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
PRICE_RANGE
=
{
1
:
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
2
:
{
name
:
'2000元-3000元'
,
min
:
2000
,
max
:
3000
},
3
:
{
name
:
'3000元-4000元'
,
min
:
3000
,
max
:
4000
},
4
:
{
name
:
'4000元-5000元'
,
min
:
4000
,
max
:
5000
},
5
:
{
name
:
'5000元-6000元'
,
min
:
5000
,
max
:
6000
},
6
:
{
name
:
'6000元-7000元'
,
min
:
6000
,
max
:
7000
},
7
:
{
name
:
'7000元-8000元'
,
min
:
7000
,
max
:
8000
},
8
:
{
name
:
'8000元-10000元'
,
min
:
8000
,
max
:
10000
},
9
:
{
name
:
'10000元以上'
,
min
:
10000
,
max
:
10000000000000
},
}
const
HOUSE_TYPE
=
{
1
:
{
name
:
'1室'
,
min
:
1
,
max
:
1
},
2
:
{
name
:
'2室'
,
min
:
2
,
max
:
2
},
3
:
{
name
:
'3室'
,
min
:
3
,
max
:
3
},
4
:
{
name
:
'4室'
,
min
:
4
,
max
:
4
},
5
:
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
},
6
:
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
},
}
class
OptionService
extends
Service
{
async
getOptions
(
city_code
)
{
const
{
ctx
}
=
this
;
const
city
=
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
city_code
}
});
if
(
!
city
||
!
city
.
name
)
{
ctx
.
failed
(
'city code error'
);
}
const
district
=
ctx
.
blockModel
.
District
.
all
({
where
:
{
city_id
:
city
.
code
}
});
if
(
!
district
||
district
){
ctx
.
failed
(
'district error'
);
}
const
bizcircle
=
ctx
.
blockModel
.
Bizcircle
.
all
({
where
:
{}});
const
developers_results
=
await
ctx
.
service
.
houseCommon
.
developer
.
all
({});
const
developers
=
developers_results
.
results
;
const
brands
=
[];
for
(
let
i
in
developers
)
{
const
developer
=
developers
[
i
];
brands
.
push
({
id
:
developer
.
id
,
name
:
developer
.
name
,
image
:
developer
.
logo
,
});
}
const
house_types
=
HOUSE_TYPE
;
const
prices
=
PRICE_RANGE
;
return
{
brands
,
prices
,
house_types
};
}
}
module
.
exports
=
OptionService
;
app/service/house/rental_house.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
PRICE_RANGE
=
{
1
:
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
2
:
{
name
:
'2000元-3000元'
,
min
:
2000
,
max
:
3000
},
3
:
{
name
:
'3000元-4000元'
,
min
:
3000
,
max
:
4000
},
4
:
{
name
:
'4000元-5000元'
,
min
:
4000
,
max
:
5000
},
5
:
{
name
:
'5000元-6000元'
,
min
:
5000
,
max
:
6000
},
6
:
{
name
:
'6000元-7000元'
,
min
:
6000
,
max
:
7000
},
7
:
{
name
:
'7000元-8000元'
,
min
:
7000
,
max
:
8000
},
8
:
{
name
:
'8000元-10000元'
,
min
:
8000
,
max
:
10000
},
9
:
{
name
:
'10000元以上'
,
min
:
10000
,
max
:
10000000000000
},
}
const
HOUSE_TYPE
=
{
1
:
{
name
:
'1室'
,
min
:
1
,
max
:
1
},
2
:
{
name
:
'2室'
,
min
:
2
,
max
:
2
},
3
:
{
name
:
'3室'
,
min
:
3
,
max
:
3
},
4
:
{
name
:
'4室'
,
min
:
4
,
max
:
4
},
5
:
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
},
6
:
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
},
}
class
RentalHouseService
extends
Service
{
async
getRentalHousesByFilter
(
condition
)
{
const
{
ctx
}
=
this
;
const
queryConditions
=
[];
if
(
condition
.
brand
){
queryConditions
.
push
();
}
const
filter
=
{
pageSize
:
30
,
queryConditions
:
[{
key
:
"State"
,
value
:
1
,
operator
:
"equal"
},],
orderConditions
:
[{
key
:
'Price'
,
orderSequence
:
'asc'
,
},],
}
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
({});
return
rental_houses_results
;
}
}
module
.
exports
=
RentalHouseService
;
app/service/house_common/developer.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
DeveloperService
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
||
[];
const
sum
=
queryConditions
.
length
;
for
(
let
i
=
0
;
i
<
sum
;
i
++
)
{
if
(
queryConditions
[
i
].
key
===
'userId'
&&
queryConditions
[
i
].
value
.
length
===
0
)
{
queryConditions
[
i
].
value
=
true
;
queryConditions
[
i
].
operator
=
'isnull'
;
}
}
data
.
queryConditions
=
queryConditions
;
if
(
Object
.
keys
(
orderConditions
).
length
===
0
)
{
data
.
orderConditions
=
[{
key
:
'OrderNum'
,
orderSequence
:
'asc'
,
}];
}
data
.
orderConditions
=
orderConditions
;
data
.
pageIndex
=
pageIndex
;
data
.
pageSize
=
pageSize
;
console
.
info
(
data
);
ctx
.
logger
.
info
(
'developer_list_conditions: '
+
JSON
.
stringify
(
data
));
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/developer/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/developer/'
+
id
,
{},
{});
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
;
}
}
module
.
exports
=
DeveloperService
;
app/service/house_common/rental_house.js
0 → 100644
View file @
165e7b57
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
RentalHouseService
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
||
[];
const
sum
=
queryConditions
.
length
;
for
(
let
i
=
0
;
i
<
sum
;
i
++
)
{
if
(
queryConditions
[
i
].
key
===
'userId'
&&
queryConditions
[
i
].
value
.
length
===
0
)
{
queryConditions
[
i
].
value
=
true
;
queryConditions
[
i
].
operator
=
'isnull'
;
}
}
data
.
queryConditions
=
queryConditions
;
if
(
Object
.
keys
(
orderConditions
).
length
===
0
)
{
data
.
orderConditions
=
[{
key
:
'OrderNum'
,
orderSequence
:
'asc'
,
}];
}
data
.
orderConditions
=
orderConditions
;
data
.
pageIndex
=
pageIndex
;
data
.
pageSize
=
pageSize
;
console
.
info
(
data
);
ctx
.
logger
.
info
(
'rentalhouse_list_conditions: '
+
JSON
.
stringify
(
data
));
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/rentalhouse/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/rentalhouse/'
+
id
,
{},
{});
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
;
}
}
module
.
exports
=
RentalHouseService
;
config/config.default.js
View file @
165e7b57
...
@@ -19,7 +19,7 @@ module.exports = appInfo => {
...
@@ -19,7 +19,7 @@ module.exports = appInfo => {
config
.
projectRootPath
=
'/51business/api'
;
config
.
projectRootPath
=
'/51business/api'
;
// add your middleware config here
// add your middleware config here
config
.
middleware
=
[
'errorHandler'
,
'deviceInit'
];
config
.
middleware
=
[
'errorHandler'
];
// add your user config here
// add your user config here
const
userConfig
=
{
const
userConfig
=
{
...
...
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