Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
engine-class-work
Project
Project
Details
Activity
Releases
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
liuchengjiu
engine-class-work
Commits
b8abc2c6
Commit
b8abc2c6
authored
Feb 16, 2022
by
Mindfaker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
b51ddf51
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
StudentPointService.java
...ploring/engine/server/db/service/StudentPointService.java
+5
-1
Util.java
...rc/main/java/cn/exploring/engine/server/db/util/Util.java
+56
-2
No files found.
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentPointService.java
View file @
b8abc2c6
...
@@ -4,12 +4,15 @@ import cn.exploring.engine.server.db.dao.SpecialSqlMapper;
...
@@ -4,12 +4,15 @@ import cn.exploring.engine.server.db.dao.SpecialSqlMapper;
import
cn.exploring.engine.server.db.dao.StudentPointInfoMapper
;
import
cn.exploring.engine.server.db.dao.StudentPointInfoMapper
;
import
cn.exploring.engine.server.db.domain.StudentPointInfo
;
import
cn.exploring.engine.server.db.domain.StudentPointInfo
;
import
cn.exploring.engine.server.db.domain.StudentPointInfoExample
;
import
cn.exploring.engine.server.db.domain.StudentPointInfoExample
;
import
cn.exploring.engine.server.db.util.Util
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
@Service
public
class
StudentPointService
{
public
class
StudentPointService
{
...
@@ -21,7 +24,8 @@ public class StudentPointService {
...
@@ -21,7 +24,8 @@ public class StudentPointService {
SpecialSqlMapper
specialSqlMapper
;
SpecialSqlMapper
specialSqlMapper
;
public
List
<
Map
>
selectPointByWeb
(
String
studentName
,
String
studentUniqueId
,
Integer
classId
,
String
startTime
,
String
endTime
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
public
List
<
Map
>
selectPointByWeb
(
String
studentName
,
String
studentUniqueId
,
Integer
classId
,
String
startTime
,
String
endTime
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
return
specialSqlMapper
.
selectPoint
(
studentName
,
studentUniqueId
,
classId
,
startTime
,
endTime
,
page
,
limit
,
sort
,
order
);
List
<
Map
>
dataList
=
specialSqlMapper
.
selectPoint
(
studentName
,
studentUniqueId
,
classId
,
startTime
,
endTime
,
page
,
limit
,
sort
,
order
);
return
dataList
.
stream
().
map
((
Function
<
Map
,
Map
>)
Util:
:
exchangeMapKeyName
).
collect
(
Collectors
.
toList
());
}
}
/**
/**
...
...
server-db/src/main/java/cn/exploring/engine/server/db/util/Util.java
View file @
b8abc2c6
package
cn
.
exploring
.
engine
.
server
.
db
.
util
;
package
cn
.
exploring
.
engine
.
server
.
db
.
util
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
Util
{
public
class
Util
{
private
static
Pattern
humpPattern
=
Pattern
.
compile
(
"[A-Z]"
);
/**
* 将驼峰式的字符串转换成 _ 分隔的字符串
* @param aa
* @return
*/
public
static
String
humpToLine2
(
String
aa
)
{
Matcher
matcher
=
humpPattern
.
matcher
(
aa
);
StringBuffer
sb
=
new
StringBuffer
();
while
(
matcher
.
find
())
{
matcher
.
appendReplacement
(
sb
,
"_"
+
matcher
.
group
(
0
).
toLowerCase
());
}
matcher
.
appendTail
(
sb
);
return
sb
.
toString
();
}
/**
* 将字典中的以"_"切分的Key,转换成驼峰式命名。
* @param rawMap
* @return
*/
public
static
Map
<
String
,
Object
>
exchangeMapKeyName
(
Map
<
String
,
Object
>
rawMap
){
Map
target
=
new
HashMap
();
for
(
String
mapKey:
rawMap
.
keySet
()){
target
.
put
(
exchangeStringToHump
(
mapKey
),
rawMap
.
get
(
mapKey
));
}
return
target
;
}
/**
* 将以_分割的字符串,转成驼峰式命名的字符串,获取到的sql字段名通过反射操作实体类的时候需要使用
* @param rawData
* @return
*/
public
static
String
exchangeStringToHump
(
String
rawData
){
List
<
String
>
fieldList
=
Arrays
.
asList
(
rawData
.
split
(
"_"
));
StringBuffer
targetString
=
new
StringBuffer
();
// 首个字段全变小写,后续字段首字母大写
for
(
int
i
=
0
;
i
<
fieldList
.
size
();
i
++){
if
(
i
==
0
){
targetString
.
append
(
fieldList
.
get
(
0
).
toLowerCase
());
}
else
{
String
oneRawField
=
fieldList
.
get
(
i
).
toLowerCase
();
targetString
.
append
(
oneRawField
.
substring
(
0
,
1
).
toUpperCase
()+
oneRawField
.
substring
(
1
));
}
}
return
targetString
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
Integer
>
list
=
new
ArrayList
<>();
List
<
Integer
>
list
=
new
ArrayList
<>();
list
.
add
(
100
);
list
.
add
(
100
);
...
...
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