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
b2fa8538
Commit
b2fa8538
authored
Oct 15, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add limit page
parent
e471087a
Pipeline
#14939
passed with stage
in 38 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
1 deletion
+68
-1
abroad_house.js
app/controller/house/v2/abroad_house.js
+2
-0
abroad_house.js
app/model/realestate/abroad_house.js
+60
-0
abroad_house.js
app/service/house/v2/abroad_house.js
+6
-1
No files found.
app/controller/house/v2/abroad_house.js
View file @
b2fa8538
...
...
@@ -11,6 +11,8 @@ class AbroadHouseController extends Controller {
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
page
:
{
type
:
'int'
,
required
:
false
},
page_size
:
{
type
:
'int'
,
required
:
false
},
name
:
{
type
:
'string'
,
required
:
false
},
};
ctx
.
validate
(
rule
,
inputParams
);
...
...
app/model/realestate/abroad_house.js
View file @
b2fa8538
...
...
@@ -70,6 +70,66 @@ module.exports = app => {
tableName
:
'abroad_house'
,
});
AbroadHouse
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
AbroadHouse
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
AbroadHouse
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
AbroadHouse
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
AbroadHouse
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
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
AbroadHouse
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
AbroadHouse
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
AbroadHouse
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
AbroadHouse
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
await
AbroadHouse
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
AbroadHouse
;
...
...
app/service/house/v2/abroad_house.js
View file @
b2fa8538
...
...
@@ -12,7 +12,11 @@ class AbroadHouseService extends Service {
*/
async
abroadHouseList
(
condition
)
{
const
{
ctx
}
=
this
;
let
page
=
Number
(
condition
.
page
)
||
1
;
let
pageSize
=
Number
(
condition
.
page_size
)
||
10
;
let
filter
=
{
page
:
page
,
limit
:
pageSize
,
where
:
{
valid
:
1
,
status
:
'online'
,
...
...
@@ -28,7 +32,8 @@ class AbroadHouseService extends Service {
await
ctx
.
service
.
house
.
v2
.
searchHistory
.
addSearchHistory
(
addHistory
);
filter
.
where
.
name
=
{
$like
:
'%'
+
condition
.
name
+
'%'
}
}
let
list
=
await
ctx
.
realestateModel
.
AbroadHouse
.
findAll
(
filter
);
let
abroadList
=
await
ctx
.
realestateModel
.
AbroadHouse
.
list
(
filter
);
let
list
=
abroadList
.
rows
;
let
data
=
[];
for
(
let
i
in
list
)
{
data
[
i
]
=
{
...
...
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