Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
1edc206e
Commit
1edc206e
authored
1 year ago
by
Ryan Loong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 使用BeanSearcher重构
parent
7d488592
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
347 additions
and
90 deletions
+347
-90
pom.xml
pom.xml
+6
-0
pom.xml
server-db/pom.xml
+6
-0
StudentInfo.java
...ava/cn/exploring/engine/server/db/domain/StudentInfo.java
+37
-0
StudentInfoExample.java
...exploring/engine/server/db/domain/StudentInfoExample.java
+90
-0
StudentPointWithStudentInfoVo.java
...ne/server/db/domain/vo/StudentPointWithStudentInfoVo.java
+47
-0
StudentVo.java
...va/cn/exploring/engine/server/db/domain/vo/StudentVo.java
+13
-15
StudentInfoService.java
...xploring/engine/server/db/service/StudentInfoService.java
+37
-56
StudentPointService.java
...ploring/engine/server/db/service/StudentPointService.java
+31
-9
DateTimeUtil.java
...java/cn/exploring/engine/server/db/util/DateTimeUtil.java
+4
-0
SqlUtil.java
...main/java/cn/exploring/engine/server/db/util/SqlUtil.java
+39
-1
application-dbDev.yml
server-db/src/main/resources/application-dbDev.yml
+4
-0
application-dbTest.yml
server-db/src/main/resources/application-dbTest.yml
+4
-0
application.yml
server-db/src/main/resources/application.yml
+4
-0
StudentInfoMapper.xml
...s/cn/exploring/engine/server/db/dao/StudentInfoMapper.xml
+21
-5
PointController.java
...va/cn/exploring/engine/server/wx/web/PointController.java
+3
-3
StudentController.java
.../cn/exploring/engine/server/wx/web/StudentController.java
+1
-1
No files found.
pom.xml
View file @
1edc206e
...
...
@@ -135,6 +135,12 @@
<artifactId>
spring-boot-starter-mail
</artifactId>
<version>
2.0.4.RELEASE
</version>
</dependency>
<dependency>
<groupId>
cn.zhxu
</groupId>
<artifactId>
bean-searcher-boot-starter
</artifactId>
<version>
4.2.2
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
This diff is collapsed.
Click to expand it.
server-db/pom.xml
View file @
1edc206e
...
...
@@ -89,6 +89,12 @@
<artifactId>
easyexcel
</artifactId>
<version>
3.2.0
</version>
</dependency>
<!-- BeanSearcher-->
<dependency>
<groupId>
cn.zhxu
</groupId>
<artifactId>
bean-searcher-boot-starter
</artifactId>
</dependency>
</dependencies>
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/domain/StudentInfo.java
View file @
1edc206e
...
...
@@ -66,6 +66,15 @@ public class StudentInfo {
*/
private
String
head
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column student_info.call_times
*
* @mbg.generated
*/
private
Integer
callTimes
;
/**
*
* This field was generated by MyBatis Generator.
...
...
@@ -213,6 +222,30 @@ public class StudentInfo {
this
.
head
=
head
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column student_info.call_times
*
* @return the value of student_info.call_times
*
* @mbg.generated
*/
public
Integer
getCallTimes
()
{
return
callTimes
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column student_info.call_times
*
* @param callTimes the value for student_info.call_times
*
* @mbg.generated
*/
public
void
setCallTimes
(
Integer
callTimes
)
{
this
.
callTimes
=
callTimes
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column student_info.add_time
...
...
@@ -314,6 +347,7 @@ public class StudentInfo {
sb
.
append
(
", classId="
).
append
(
classId
);
sb
.
append
(
", name="
).
append
(
name
);
sb
.
append
(
", head="
).
append
(
head
);
sb
.
append
(
", callTimes="
).
append
(
callTimes
);
sb
.
append
(
", addTime="
).
append
(
addTime
);
sb
.
append
(
", updateTime="
).
append
(
updateTime
);
sb
.
append
(
", deleted="
).
append
(
deleted
);
...
...
@@ -344,6 +378,7 @@ public class StudentInfo {
&&
(
this
.
getClassId
()
==
null
?
other
.
getClassId
()
==
null
:
this
.
getClassId
().
equals
(
other
.
getClassId
()))
&&
(
this
.
getName
()
==
null
?
other
.
getName
()
==
null
:
this
.
getName
().
equals
(
other
.
getName
()))
&&
(
this
.
getHead
()
==
null
?
other
.
getHead
()
==
null
:
this
.
getHead
().
equals
(
other
.
getHead
()))
&&
(
this
.
getCallTimes
()
==
null
?
other
.
getCallTimes
()
==
null
:
this
.
getCallTimes
().
equals
(
other
.
getCallTimes
()))
&&
(
this
.
getAddTime
()
==
null
?
other
.
getAddTime
()
==
null
:
this
.
getAddTime
().
equals
(
other
.
getAddTime
()))
&&
(
this
.
getUpdateTime
()
==
null
?
other
.
getUpdateTime
()
==
null
:
this
.
getUpdateTime
().
equals
(
other
.
getUpdateTime
()))
&&
(
this
.
getDeleted
()
==
null
?
other
.
getDeleted
()
==
null
:
this
.
getDeleted
().
equals
(
other
.
getDeleted
()));
...
...
@@ -364,6 +399,7 @@ public class StudentInfo {
result
=
prime
*
result
+
((
getClassId
()
==
null
)
?
0
:
getClassId
().
hashCode
());
result
=
prime
*
result
+
((
getName
()
==
null
)
?
0
:
getName
().
hashCode
());
result
=
prime
*
result
+
((
getHead
()
==
null
)
?
0
:
getHead
().
hashCode
());
result
=
prime
*
result
+
((
getCallTimes
()
==
null
)
?
0
:
getCallTimes
().
hashCode
());
result
=
prime
*
result
+
((
getAddTime
()
==
null
)
?
0
:
getAddTime
().
hashCode
());
result
=
prime
*
result
+
((
getUpdateTime
()
==
null
)
?
0
:
getUpdateTime
().
hashCode
());
result
=
prime
*
result
+
((
getDeleted
()
==
null
)
?
0
:
getDeleted
().
hashCode
());
...
...
@@ -484,6 +520,7 @@ public class StudentInfo {
classId
(
"class_id"
,
"classId"
,
"INTEGER"
,
false
),
name
(
"name"
,
"name"
,
"VARCHAR"
,
true
),
head
(
"head"
,
"head"
,
"VARCHAR"
,
false
),
callTimes
(
"call_times"
,
"callTimes"
,
"INTEGER"
,
false
),
addTime
(
"add_time"
,
"addTime"
,
"TIMESTAMP"
,
false
),
updateTime
(
"update_time"
,
"updateTime"
,
"TIMESTAMP"
,
false
),
deleted
(
"deleted"
,
"deleted"
,
"BIT"
,
false
);
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/domain/StudentInfoExample.java
View file @
1edc206e
...
...
@@ -754,6 +754,96 @@ public class StudentInfoExample {
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesIsNull
()
{
addCriterion
(
"call_times is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesIsNotNull
()
{
addCriterion
(
"call_times is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesEqualTo
(
Integer
value
)
{
addCriterion
(
"call_times ="
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesEqualToColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times = "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesNotEqualTo
(
Integer
value
)
{
addCriterion
(
"call_times <>"
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesNotEqualToColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times <> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesGreaterThan
(
Integer
value
)
{
addCriterion
(
"call_times >"
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesGreaterThanColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times > "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"call_times >="
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesGreaterThanOrEqualToColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times >= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesLessThan
(
Integer
value
)
{
addCriterion
(
"call_times <"
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesLessThanColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times < "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"call_times <="
,
value
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesLessThanOrEqualToColumn
(
StudentInfo
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"call_times <= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"call_times in"
,
values
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"call_times not in"
,
values
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"call_times between"
,
value1
,
value2
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCallTimesNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"call_times not between"
,
value1
,
value2
,
"callTimes"
);
return
(
Criteria
)
this
;
}
public
Criteria
andAddTimeIsNull
()
{
addCriterion
(
"add_time is null"
);
return
(
Criteria
)
this
;
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/domain/vo/StudentPointWithStudentInfoVo.java
0 → 100644
View file @
1edc206e
package
cn
.
exploring
.
engine
.
server
.
db
.
domain
.
vo
;
import
cn.exploring.engine.server.db.domain.StudentPointInfo
;
import
cn.zhxu.bs.bean.DbField
;
import
cn.zhxu.bs.bean.SearchBean
;
@SearchBean
(
tables
=
"(select * from student_point_info where deleted = false) p "
+
"left join (select * from student_info where deleted = false) st on p.student_id = st.id "
+
"left join (select * from class_info) cl on p.class_id = cl.id "
,
autoMapTo
=
"p"
)
public
class
StudentPointWithStudentInfoVo
extends
StudentPointInfo
{
@DbField
(
"st.student_unique_id"
)
private
String
studentUniqueId
;
@DbField
(
"st.name"
)
private
String
name
;
@DbField
(
"cl.class_name"
)
private
String
className
;
public
String
getStudentUniqueId
()
{
return
studentUniqueId
;
}
public
void
setStudentUniqueId
(
String
studentUniqueId
)
{
this
.
studentUniqueId
=
studentUniqueId
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getClassName
()
{
return
className
;
}
public
void
setClassName
(
String
className
)
{
this
.
className
=
className
;
}
}
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/domain/vo/StudentVo.java
View file @
1edc206e
package
cn
.
exploring
.
engine
.
server
.
db
.
domain
.
vo
;
import
cn.exploring.engine.server.db.domain.StudentInfo
;
import
cn.zhxu.bs.bean.DbField
;
import
cn.zhxu.bs.bean.SearchBean
;
/**
* @author Liu_c
*/
import
java.time.LocalDateTime
;
@SearchBean
(
tables
=
"(select * from student_info where deleted = false) st left join (select * from class_info where deleted = false) cl on cl.id = st.class_id"
,
autoMapTo
=
"st"
)
public
class
StudentVo
extends
StudentInfo
{
public
String
ClassName
;
private
Integer
callTimes
;
@DbField
(
"cl.class_name"
)
public
String
className
;
public
String
getClassName
()
{
return
C
lassName
;
return
c
lassName
;
}
public
void
setClassName
(
String
className
)
{
ClassName
=
className
;
}
public
Integer
getCallTimes
()
{
return
callTimes
;
}
public
void
setCallTimes
(
Integer
callTimes
)
{
this
.
callTimes
=
callTimes
;
this
.
className
=
className
;
}
}
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentInfoService.java
View file @
1edc206e
...
...
@@ -11,17 +11,24 @@ import cn.exploring.engine.server.db.domain.vo.StudentVo;
import
cn.exploring.engine.server.db.util.SqlUtil
;
import
cn.exploring.engine.server.db.util.excel.ExcelReaderListener
;
import
cn.exploring.engine.server.db.util.excel.StudentInfoExcelReaderListener
;
import
cn.zhxu.bs.BeanSearcher
;
import
cn.zhxu.bs.SearchResult
;
import
cn.zhxu.bs.operator.*
;
import
cn.zhxu.bs.util.MapBuilder
;
import
cn.zhxu.bs.util.MapUtils
;
import
com.alibaba.excel.EasyExcel
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
...
...
@@ -47,6 +54,9 @@ public class StudentInfoService {
@Resource
StudentPointService
studentPointService
;
@Autowired
BeanSearcher
beanSearcher
;
public
static
final
String
STRING_DEFAULT_HEAD
=
"{{default}}"
;
public
static
final
String
URL_DEFAULT_HEAD
=
"https://storage.exploring.cn/class-work/static/img/head-student-default.png"
;
...
...
@@ -150,72 +160,43 @@ public class StudentInfoService {
return
studentInfoMapper
.
selectByExample
(
example
);
}
/**
* 检索学生相关的信息
* @param studentName
* @param studentId
* @return
*/
public
Map
selectStudentInfoByWeb
(
String
studentName
,
String
studentId
,
List
<
Integer
>
idList
,
Integer
classId
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
,
Integer
minCall
,
Integer
maxCall
)
{
StudentInfoExample
example
=
new
StudentInfoExample
();
StudentInfoExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
studentName
))
{
criteria
.
andNameLike
(
SqlUtil
.
likeStr
(
studentName
));
}
if
(!
StringUtils
.
isEmpty
(
studentId
))
{
criteria
.
andStudentUniqueIdLike
(
SqlUtil
.
likeStr
(
studentId
));
}
if
(
idList
!=
null
&&
idList
.
size
()
>
0
)
{
criteria
.
andIdIn
(
idList
);
}
if
(
classId
!=
null
)
{
criteria
.
andClassIdEqualTo
(
classId
);
}
Map
<
Integer
,
Integer
>
callTimeMap
=
studentPointService
.
countByClassGroupByStudent
(
classId
);
if
(
Objects
.
nonNull
(
minCall
))
{
List
<
Integer
>
included
=
callTimeMap
.
entrySet
().
stream
().
filter
(
entry
->
entry
.
getValue
()
>=
minCall
).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
included
))
{
criteria
.
andIdEqualTo
(-
1
);
}
else
{
criteria
.
andIdIn
(
included
);
}
}
public
MapBuilder
voWrapper
(
String
studentName
,
String
studentId
,
List
<
Integer
>
idList
,
Integer
classId
,
Integer
minCall
,
Integer
maxCall
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
MapBuilder
wrapper
=
MapUtils
.
builder
()
.
field
(
StudentVo:
:
getDeleted
,
StudentInfo
.
NOT_DELETED
).
op
(
Equal
.
class
)
.
field
(
StudentVo:
:
getClassId
,
classId
).
op
(
Equal
.
class
)
.
field
(
StudentVo:
:
getCallTimes
,
minCall
,
maxCall
).
op
(
Between
.
class
)
.
field
(
StudentVo:
:
getName
,
studentName
).
op
(
Contain
.
class
)
.
field
(
StudentVo:
:
getStudentUniqueId
,
studentId
).
op
(
Contain
.
class
);
if
(
Objects
.
nonNull
(
maxCall
))
{
List
<
Integer
>
excluded
=
callTimeMap
.
entrySet
().
stream
().
filter
(
entry
->
entry
.
getValue
()
>
maxCall
).
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
excluded
))
{
criteria
.
andIdNotIn
(
excluded
);
}
if
(!
CollectionUtils
.
isEmpty
(
idList
)
&&
!
CollectionUtils
.
isEmpty
(
idList
=
idList
.
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
())))
{
wrapper
.
field
(
StudentVo:
:
getId
,
idList
).
op
(
InList
.
class
);
}
try
(
Page
<?>
ignored
=
PageHelper
.
startPage
(
page
,
limit
,
sort
+
" "
+
order
))
{
List
<
StudentInfo
>
studentInfoList
=
studentInfoMapper
.
selectByExample
(
example
);
return
SqlUtil
.
page
(
wrapper
,
page
,
limit
,
sort
,
order
);
if
(
CollectionUtils
.
isEmpty
(
studentInfoList
))
{
return
ImmutableMap
.
of
(
"total"
,
0
,
"items"
,
Collections
.
emptyList
());
}
Map
<
Integer
,
String
>
classMap
=
classService
.
getClassNameMap
();
/**
* 检索学生相关的信息
* @param studentName
* @param studentId
* @return
*/
public
Map
<
String
,
Object
>
selectStudentInfoByWeb
(
String
studentName
,
String
studentId
,
List
<
Integer
>
idList
,
Integer
classId
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
,
Integer
minCall
,
Integer
maxCall
)
{
List
<
StudentVo
>
dataList
=
studentInfoList
.
stream
().
map
(
x
->
{
StudentVo
voData
=
new
StudentVo
();
BeanUtils
.
copyProperties
(
x
,
voData
);
voData
.
setClassName
(
classMap
.
get
(
x
.
getClassId
()));
voData
.
setCallTimes
(
callTimeMap
.
getOrDefault
(
x
.
getId
(),
0
));
SearchResult
<
StudentVo
>
result
=
beanSearcher
.
search
(
StudentVo
.
class
,
voWrapper
(
studentName
,
studentId
,
idList
,
classId
,
minCall
,
maxCall
,
page
,
limit
,
sort
,
order
).
build
());
if
(
StringUtils
.
isEmpty
(
x
.
getHead
())
||
x
.
getHead
().
trim
().
equalsIgnoreCase
(
STRING_DEFAULT_HEAD
))
{
voData
.
setHead
(
URL_DEFAULT_HEAD
);
return
ImmutableMap
.
of
(
"total"
,
result
.
getTotalCount
().
longValue
(),
"items"
,
updateHead
(
result
.
getDataList
()));
}
return
voData
;
}).
collect
(
Collectors
.
toList
());
Long
total
=
PageInfo
.
of
(
studentInfoList
).
getTotal
();
return
ImmutableMap
.
of
(
"total"
,
total
,
"items"
,
dataList
);
public
static
<
T
extends
StudentInfo
>
Collection
<
T
>
updateHead
(
Collection
<
T
>
list
)
{
list
.
forEach
(
x
->
{
if
(
Objects
.
nonNull
(
x
)
&&
(
StringUtils
.
isBlank
(
x
.
getHead
())
||
StringUtils
.
equalsIgnoreCase
(
x
.
getHead
(),
STRING_DEFAULT_HEAD
)))
{
x
.
setHead
(
URL_DEFAULT_HEAD
);
}
});
return
list
;
}
// /**
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentPointService.java
View file @
1edc206e
...
...
@@ -6,21 +6,34 @@ import cn.exploring.engine.server.db.domain.StudentInfo;
import
cn.exploring.engine.server.db.domain.StudentPointInfo
;
import
cn.exploring.engine.server.db.domain.StudentPointInfoExample
;
import
cn.exploring.engine.server.db.domain.vo.StudentPointExcelExportVo
;
import
cn.exploring.engine.server.db.domain.vo.StudentPointWithStudentInfoVo
;
import
cn.exploring.engine.server.db.util.DateTimeUtil
;
import
cn.exploring.engine.server.db.util.SqlUtil
;
import
cn.exploring.engine.server.db.util.StrUtil
;
import
cn.exploring.engine.server.db.util.Util
;
import
cn.zhxu.bs.BeanSearcher
;
import
cn.zhxu.bs.SearchResult
;
import
cn.zhxu.bs.operator.*
;
import
cn.zhxu.bs.util.MapBuilder
;
import
cn.zhxu.bs.util.MapUtils
;
import
com.alibaba.excel.EasyExcel
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -39,14 +52,23 @@ public class StudentPointService {
@Resource
StudentInfoService
studentInfoService
;
public
Map
selectPointByWeb
(
String
studentName
,
String
studentUniqueId
,
Integer
classId
,
String
startTime
,
String
endTime
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
List
<
Map
>
dataList
=
specialSqlMapper
.
selectPoint
(
studentName
,
studentUniqueId
,
classId
,
startTime
,
endTime
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
String
>
countInfoData
=
specialSqlMapper
.
selectPointCount
(
studentName
,
studentUniqueId
,
classId
,
startTime
,
endTime
);
List
<
Map
>
targetDataList
=
dataList
.
stream
().
map
((
Function
<
Map
,
Map
>)
Util:
:
exchangeMapKeyName
).
collect
(
Collectors
.
toList
());
return
new
HashMap
()
{{
put
(
"items"
,
targetDataList
);
put
(
"total"
,
StringUtils
.
isEmpty
(
countInfoData
.
get
(
"count_info"
))
?
0L
:
countInfoData
.
get
(
"count_info"
));
}};
@Autowired
BeanSearcher
beanSearcher
;
public
Map
<
String
,
Object
>
selectPointByWeb
(
String
studentName
,
String
studentUniqueId
,
Integer
classId
,
String
startTime
,
String
endTime
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
LocalDateTime
start
=
Optional
.
ofNullable
(
startTime
).
filter
(
StringUtils:
:
isNotBlank
).
map
(
s
->
LocalDateTime
.
parse
(
s
,
DateTimeUtil
.
DATE_TIME_FORMATTER3
)).
orElse
(
null
);
LocalDateTime
end
=
Optional
.
ofNullable
(
endTime
).
filter
(
StringUtils:
:
isNotBlank
).
map
(
s
->
LocalDateTime
.
parse
(
s
,
DateTimeUtil
.
DATE_TIME_FORMATTER3
)).
orElse
(
null
);
MapBuilder
wrapper
=
MapUtils
.
builder
()
.
field
(
StudentPointWithStudentInfoVo:
:
getDeleted
,
StudentPointInfo
.
NOT_DELETED
).
op
(
Equal
.
class
)
.
field
(
StudentPointWithStudentInfoVo:
:
getName
,
studentName
).
op
(
Contain
.
class
)
.
field
(
StudentPointWithStudentInfoVo:
:
getStudentUniqueId
,
studentUniqueId
).
op
(
Contain
.
class
)
.
field
(
StudentPointWithStudentInfoVo:
:
getClassId
,
classId
).
op
(
Equal
.
class
)
.
field
(
StudentPointWithStudentInfoVo:
:
getRecordTime
,
start
).
op
(
GreaterEqual
.
class
)
.
field
(
StudentPointWithStudentInfoVo:
:
getRecordTime
,
end
).
op
(
LessEqual
.
class
);
SearchResult
<
StudentPointWithStudentInfoVo
>
result
=
beanSearcher
.
search
(
StudentPointWithStudentInfoVo
.
class
,
SqlUtil
.
page
(
wrapper
,
page
,
limit
,
sort
,
order
).
build
());
return
ImmutableMap
.
of
(
"total"
,
result
.
getTotalCount
().
longValue
(),
"items"
,
result
.
getDataList
());
}
/**
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/util/DateTimeUtil.java
View file @
1edc206e
...
...
@@ -11,6 +11,10 @@ public class DateTimeUtil {
public
static
final
String
DATE_FORMAT1
=
"yyyy-MM-dd"
;
public
static
final
String
DATE_FORMAT2
=
"yyyy-MM"
;
public
static
final
String
DATE_FORMAT3
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
DateTimeFormatter
DATE_TIME_FORMATTER3
=
DateTimeFormatter
.
ofPattern
(
DATE_FORMAT3
);
/**
* 得到DATE_FORMAT1格式的时间字段串
* @param time
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/java/cn/exploring/engine/server/db/util/SqlUtil.java
View file @
1edc206e
package
cn
.
exploring
.
engine
.
server
.
db
.
util
;
import
cn.zhxu.bs.operator.Contain
;
import
cn.zhxu.bs.util.FieldFns
;
import
cn.zhxu.bs.util.MapBuilder
;
import
cn.zhxu.bs.util.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.
Optional
;
import
java.util.
*
;
public
class
SqlUtil
{
...
...
@@ -14,4 +18,38 @@ public class SqlUtil {
.
orElse
(
"%"
);
}
public
static
List
<
String
>
likeList
(
String
str
)
{
return
Optional
.
ofNullable
(
str
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
map
(
String:
:
trim
)
.
map
(
s
->
s
.
replaceAll
(
"\\s+"
,
" "
))
.
map
(
s
->
s
.
split
(
" "
))
.
map
(
Arrays:
:
asList
)
.
orElse
(
Collections
.
emptyList
());
}
public
static
<
T
>
MapBuilder
like
(
MapBuilder
wrapperBuilder
,
FieldFns
.
FieldFn
<
T
,
?>
fieldFn
,
String
str
)
{
likeList
(
str
).
forEach
(
s
->
{
wrapperBuilder
.
field
(
fieldFn
,
s
).
op
(
Contain
.
class
);
});
return
wrapperBuilder
;
}
public
static
MapBuilder
page
(
MapBuilder
wrapperBuilder
,
Integer
page
,
Integer
size
,
String
column
,
String
order
)
{
if
(
Objects
.
nonNull
(
page
)
&&
Objects
.
nonNull
(
size
))
{
wrapperBuilder
.
page
(
page
,
size
);
}
if
(
StringUtils
.
isNotBlank
(
column
))
{
wrapperBuilder
.
orderBy
(
column
,
Optional
.
ofNullable
(
order
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
filter
(
o
->
StringUtils
.
equalsIgnoreCase
(
"desc"
,
o
))
.
map
(
o
->
"desc"
).
orElse
(
"asc"
)
);
}
return
wrapperBuilder
;
}
}
This diff is collapsed.
Click to expand it.
server-db/src/main/resources/application-dbDev.yml
View file @
1edc206e
logging
:
level
:
cn.zhxu.bs
:
debug
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/resources/application-dbTest.yml
View file @
1edc206e
logging
:
level
:
cn.zhxu.bs
:
info
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
...
...
This diff is collapsed.
Click to expand it.
server-db/src/main/resources/application.yml
View file @
1edc206e
...
...
@@ -10,3 +10,7 @@ logging:
org.springframework
:
ERROR
org.mybatis
:
ERROR
cn.exploring.engine.server.db
:
DEBUG
bean-searcher
:
sql
:
dialect
:
mysql
This diff is collapsed.
Click to expand it.
server-db/src/main/resources/cn/exploring/engine/server/db/dao/StudentInfoMapper.xml
View file @
1edc206e
...
...
@@ -11,6 +11,7 @@
<result
column=
"class_id"
jdbcType=
"INTEGER"
property=
"classId"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"head"
jdbcType=
"VARCHAR"
property=
"head"
/>
<result
column=
"call_times"
jdbcType=
"INTEGER"
property=
"callTimes"
/>
<result
column=
"add_time"
jdbcType=
"TIMESTAMP"
property=
"addTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"deleted"
jdbcType=
"BIT"
property=
"deleted"
/>
...
...
@@ -86,7 +87,8 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, student_unique_id, class_id, `name`, head, add_time, update_time, deleted
id, student_unique_id, class_id, `name`, head, call_times, add_time, update_time,
deleted
</sql>
<select
id=
"selectByExample"
parameterType=
"cn.exploring.engine.server.db.domain.StudentInfoExample"
resultMap=
"BaseResultMap"
>
<!--
...
...
@@ -208,11 +210,11 @@
SELECT LAST_INSERT_ID()
</selectKey>
insert into student_info (student_unique_id, class_id, `name`,
head,
add_time, update
_time,
deleted)
head,
call_times, add
_time,
update_time,
deleted)
values (#{studentUniqueId,jdbcType=VARCHAR}, #{classId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{head,jdbcType=VARCHAR}, #{
addTime,jdbcType=TIMESTAMP}, #{update
Time,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT})
#{head,jdbcType=VARCHAR}, #{
callTimes,jdbcType=INTEGER}, #{add
Time,jdbcType=TIMESTAMP},
#{
updateTime,jdbcType=TIMESTAMP}, #{
deleted,jdbcType=BIT})
</insert>
<insert
id=
"insertSelective"
parameterType=
"cn.exploring.engine.server.db.domain.StudentInfo"
>
<!--
...
...
@@ -236,6 +238,9 @@
<if
test=
"head != null"
>
head,
</if>
<if
test=
"callTimes != null"
>
call_times,
</if>
<if
test=
"addTime != null"
>
add_time,
</if>
...
...
@@ -259,6 +264,9 @@
<if
test=
"head != null"
>
#{head,jdbcType=VARCHAR},
</if>
<if
test=
"callTimes != null"
>
#{callTimes,jdbcType=INTEGER},
</if>
<if
test=
"addTime != null"
>
#{addTime,jdbcType=TIMESTAMP},
</if>
...
...
@@ -302,6 +310,9 @@
<if
test=
"record.head != null"
>
head = #{record.head,jdbcType=VARCHAR},
</if>
<if
test=
"record.callTimes != null"
>
call_times = #{record.callTimes,jdbcType=INTEGER},
</if>
<if
test=
"record.addTime != null"
>
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
...
...
@@ -327,6 +338,7 @@
class_id = #{record.classId,jdbcType=INTEGER},
`name` = #{record.name,jdbcType=VARCHAR},
head = #{record.head,jdbcType=VARCHAR},
call_times = #{record.callTimes,jdbcType=INTEGER},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
deleted = #{record.deleted,jdbcType=BIT}
...
...
@@ -353,6 +365,9 @@
<if
test=
"head != null"
>
head = #{head,jdbcType=VARCHAR},
</if>
<if
test=
"callTimes != null"
>
call_times = #{callTimes,jdbcType=INTEGER},
</if>
<if
test=
"addTime != null"
>
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
...
...
@@ -375,6 +390,7 @@
class_id = #{classId,jdbcType=INTEGER},
`name` = #{name,jdbcType=VARCHAR},
head = #{head,jdbcType=VARCHAR},
call_times = #{callTimes,jdbcType=INTEGER},
add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
deleted = #{deleted,jdbcType=BIT}
...
...
This diff is collapsed.
Click to expand it.
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/PointController.java
View file @
1edc206e
...
...
@@ -36,7 +36,7 @@ public class PointController {
@GetMapping
(
"selectPoint"
)
public
Object
selectPoint
(
@RequestParam
String
studentName
,
@RequestParam
String
studentUniqueId
,
@RequestParam
Integer
classId
,
@RequestParam
String
startTime
,
@RequestParam
String
endTime
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
required
=
false
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
required
=
false
,
defaultValue
=
"add
_t
ime"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
@RequestParam
(
required
=
false
,
defaultValue
=
"add
T
ime"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
studentUniqueId
=
StringUtils
.
isEmpty
(
studentUniqueId
)
?
null
:
studentUniqueId
;
studentName
=
StringUtils
.
isEmpty
(
studentName
)
?
null
:
studentName
;
startTime
=
StringUtils
.
isEmpty
(
startTime
)
?
null
:
startTime
;
...
...
@@ -76,8 +76,8 @@ public class PointController {
}
@GetMapping
(
"export"
)
public
Object
export
(
Integer
classId
)
{
@GetMapping
(
"export
ByClass
"
)
public
Object
export
ByClass
(
Integer
classId
)
{
List
<
StudentPointInfo
>
list
=
pointService
.
listByClassId
(
classId
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
ResponseUtil
.
fail
(
402
,
"暂无数据"
);
...
...
This diff is collapsed.
Click to expand it.
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/StudentController.java
View file @
1edc206e
...
...
@@ -35,7 +35,7 @@ public class StudentController {
public
Object
selectClass
(
@RequestParam
String
studentName
,
@RequestParam
String
studentUniqueId
,
@Nullable
@RequestParam
Integer
classId
,
@Nullable
@RequestParam
Integer
minCall
,
@Nullable
@RequestParam
Integer
maxCall
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
required
=
false
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
required
=
false
,
defaultValue
=
"add
_t
ime"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
@RequestParam
(
required
=
false
,
defaultValue
=
"add
T
ime"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
return
ResponseUtil
.
ok
(
studentInfoService
.
selectStudentInfoByWeb
(
studentName
,
studentUniqueId
,
null
,
classId
,
page
,
limit
,
sort
,
order
,
minCall
,
maxCall
));
}
...
...
This diff is collapsed.
Click to expand it.
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