Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
cd51b868
Commit
cd51b868
authored
Nov 03, 2023
by
chenzai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化分页查询
parent
eb797018
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
51 deletions
+52
-51
IdxBizSyncService.java
...n/amos/boot/module/cas/api/service/IdxBizSyncService.java
+5
-47
IdxBizSyncServiceImpl.java
...s/boot/module/cas/service/impl/IdxBizSyncServiceImpl.java
+43
-0
application-dev.properties
...ule-cas-biz/src/main/resources/application-dev.properties
+4
-4
No files found.
amos-boot-system-cas/amos-boot-module-cas-api/src/main/java/com/yeejoin/amos/boot/module/cas/api/service/IdxBizSyncService.java
View file @
cd51b868
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cas
.
api
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.yeejoin.amos.boot.module.cas.api.entity.IdxBizXnzs
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -11,56 +13,13 @@ import java.util.List;
import
java.sql.*
;
import
java.util.*
;
@Service
public
class
IdxBizSyncService
{
@Value
(
"${spring.datasource.url}"
)
private
String
url
;
@Value
(
"${spring.datasource.username}"
)
private
String
user
;
@Value
(
"${spring.datasource.password}"
)
private
String
passwd
;
public
interface
IdxBizSyncService
extends
IService
<
IdxBizXnzs
>
{
// 多个查询(分页)
public
List
selectAllPageQuery
(
String
tableName
,
Map
params
,
int
current
,
int
size
)
throws
SQLException
{
Connection
connection
=
DriverManager
.
getConnection
(
url
,
user
,
passwd
);
System
.
out
.
println
(
getSql
(
tableName
,
params
,
current
,
size
));
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
getSql
(
tableName
,
params
,
current
,
size
));
ResultSet
set
=
preparedStatement
.
executeQuery
();
List
list
=
convertList
(
set
);
Iterator
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
System
.
out
.
println
(
iterator
.
next
());
}
return
list
;
}
List
selectAllPageQuery
(
String
tableName
,
Map
params
,
int
current
,
int
size
);
public
String
getSql
(
String
tableName
,
Map
params
,
int
current
,
int
size
)
{
String
sql
=
"select * from "
+
tableName
;
sql
+=
" where "
;
Iterator
<
Map
.
Entry
<
String
,
Object
>>
it
=
params
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
<
String
,
Object
>
entry
=
it
.
next
();
sql
=
sql
+
entry
.
getKey
()
+
" = "
+
"'"
+
entry
.
getValue
()
+
"'"
+
" AND "
;
}
sql
+=
"1 = 1 "
;
sql
+=
" limit "
+
(
current
-
1
)
*
size
+
","
+
size
;
// Page
return
sql
;
}
String
getSql
(
String
tableName
,
Map
params
,
int
current
,
int
size
);
public
List
convertList
(
ResultSet
rs
)
throws
SQLException
{
List
list
=
new
ArrayList
();
ResultSetMetaData
md
=
rs
.
getMetaData
();
int
columnCount
=
md
.
getColumnCount
();
//Map rowData;
while
(
rs
.
next
())
{
//rowData = new HashMap(columnCount);
Map
rowData
=
new
HashMap
();
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
rowData
.
put
(
md
.
getColumnName
(
i
),
rs
.
getObject
(
i
));
}
list
.
add
(
rowData
);
}
return
list
;
}
}
\ No newline at end of file
amos-boot-system-cas/amos-boot-module-cas-biz/src/main/java/com/yeejoin/amos/boot/module/cas/service/impl/IdxBizSyncServiceImpl.java
0 → 100644
View file @
cd51b868
package
com
.
yeejoin
.
amos
.
boot
.
module
.
cas
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.cas.api.dto.IdxBizXnzsDto
;
import
com.yeejoin.amos.boot.module.cas.api.entity.IdxBizXnzs
;
import
com.yeejoin.amos.boot.module.cas.api.mapper.IdxBizXnzsMapper
;
import
com.yeejoin.amos.boot.module.cas.api.service.IIdxBizXnzsService
;
import
com.yeejoin.amos.boot.module.cas.api.service.IdxBizSyncService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
IdxBizSyncServiceImpl
extends
BaseService
<
IdxBizXnzsDto
,
IdxBizXnzs
,
IdxBizXnzsMapper
>
implements
IdxBizSyncService
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Override
public
List
selectAllPageQuery
(
String
tableName
,
Map
params
,
int
current
,
int
size
)
{
List
<
Map
<
String
,
Object
>>
list
=
jdbcTemplate
.
queryForList
(
getSql
(
tableName
,
params
,
current
,
size
));
return
list
;
}
@Override
public
String
getSql
(
String
tableName
,
Map
params
,
int
current
,
int
size
)
{
String
sql
=
"select * from "
+
tableName
;
sql
+=
" where "
;
Iterator
<
Map
.
Entry
<
String
,
Object
>>
it
=
params
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
<
String
,
Object
>
entry
=
it
.
next
();
sql
=
sql
+
entry
.
getKey
()
+
" = "
+
"'"
+
entry
.
getValue
()
+
"'"
+
" AND "
;
}
sql
+=
"1 = 1 "
;
sql
+=
" limit "
+
(
current
-
1
)
*
size
+
","
+
size
;
return
sql
;
}
}
amos-boot-system-cas/amos-boot-module-cas-biz/src/main/resources/application-dev.properties
View file @
cd51b868
#DB properties:
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.url
=
jdbc:mysql://3
6.46.151.113:5432/project_test
?allowMultiQueries=true&serverTimezone=GMT%2B8
\
&characterEncoding=utf8
spring.datasource.username
=
admin
spring.datasource.password
=
Yeejoin@202
3
spring.datasource.url
=
jdbc:mysql://3
9.98.45.134:3306/amos_idx
?allowMultiQueries=true&serverTimezone=GMT%2B8
\
&characterEncoding=utf8
&useSSL=false&autoReconnect=true&zeroDateTimeBehavior=CONVERT_TO_NULL
spring.datasource.username
=
root
spring.datasource.password
=
Yeejoin@202
0
##eureka properties:
eureka.client.service-url.defaultZone
=
http://172.16.10.210:10001/eureka/
...
...
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