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
935baa11
Commit
935baa11
authored
Feb 08, 2022
by
Mindfaker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充controller层代码
parent
007a8317
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
206 additions
and
25 deletions
+206
-25
SpecialSqlMapper.java
...a/cn/exploring/engine/server/db/dao/SpecialSqlMapper.java
+27
-0
StudentPointInfo.java
...n/exploring/engine/server/db/domain/StudentPointInfo.java
+4
-1
ClassService.java
...a/cn/exploring/engine/server/db/service/ClassService.java
+20
-10
StudentInfoService.java
...xploring/engine/server/db/service/StudentInfoService.java
+40
-3
StudentPointService.java
...ploring/engine/server/db/service/StudentPointService.java
+10
-1
ClassController.java
...va/cn/exploring/engine/server/wx/web/ClassController.java
+23
-4
PointController.java
...va/cn/exploring/engine/server/wx/web/PointController.java
+32
-6
StudentController.java
.../cn/exploring/engine/server/wx/web/StudentController.java
+50
-0
No files found.
server-db/src/main/java/cn/exploring/engine/server/db/dao/SpecialSqlMapper.java
View file @
935baa11
...
...
@@ -203,6 +203,33 @@ public interface SpecialSqlMapper {
)
Map
selectUnfinishLessonCount
(
@Param
(
"userId"
)
Integer
userId
);
/**
* 打卡评分
* @param
* @return
*/
@Select
(
"<script> "
+
"SELECT t1.*, t2.class_name FROM "
+
"(SELECT * FROM "
+
"(SELECT id, student_unique_id, `name`, class_id FROM student_info WHERE deleted = FALSE "
+
"<if test = 'studentName != null'> AND `name` like '%${studentName}%' </if>"
+
"<if test = 'studentUniqueId != null'> AND student_unique_id like '%${studentUniqueId}%' </if>"
+
"<if test = 'classId != null'> AND class_id = ${classId} </if>"
+
") target_stu INNER JOIN ("
+
"SELECT student_id, record_time, point FROM student_point_info WHERE deleted = FALSE "
+
"<if test = 'startTime != null'> AND record_time >= '${startTime}' </if>"
+
"<if test = 'endTime != null'> AND '${endTime} ' >= record_time </if>"
+
" ) point_info ON target_stu.id = point_info.student_id) t1 "
+
" LEFT JOIN (SELECT id, class_name FROM class_info WHERE deleted = FALSE ) t2 ON t1.class_id = t2.id"
+
"ORDER by ${sort} ${order} "
+
"LIMIT ${(page - 1) * size}, ${page * size} "
+
"</script>"
)
List
<
Map
>
selectPoint
(
@Param
(
"studentName"
)
String
studentName
,
@Param
(
"studentUniqueId"
)
String
studentUniqueId
,
@Param
(
"classId"
)
Integer
classId
,
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"page"
)
Integer
page
,
@Param
(
"limit"
)
Integer
limit
,
@Param
(
"sort"
)
String
sort
,
@Param
(
"order"
)
String
order
);
/**
* 随机选择一个的学生
* @param classId
...
...
server-db/src/main/java/cn/exploring/engine/server/db/domain/StudentPointInfo.java
View file @
935baa11
package
cn
.
exploring
.
engine
.
server
.
db
.
domain
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -66,6 +68,7 @@ public class StudentPointInfo {
*
* @mbg.generated
*/
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
recordTime
;
/**
...
...
@@ -552,4 +555,4 @@ public class StudentPointInfo {
}
}
}
}
\ No newline at end of file
}
server-db/src/main/java/cn/exploring/engine/server/db/service/ClassService.java
View file @
935baa11
...
...
@@ -3,12 +3,16 @@ package cn.exploring.engine.server.db.service;
import
cn.exploring.engine.server.db.dao.ClassInfoMapper
;
import
cn.exploring.engine.server.db.domain.ClassInfo
;
import
cn.exploring.engine.server.db.domain.ClassInfoExample
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
ClassService
{
...
...
@@ -16,16 +20,18 @@ public class ClassService {
@Resource
ClassInfoMapper
classInfoMapper
;
public
List
<
ClassInfo
>
selectClass
(
String
className
)
{
public
List
<
ClassInfo
>
selectClass
(
String
className
,
List
<
Integer
>
idList
)
{
ClassInfoExample
example
=
new
ClassInfoExample
();
ClassInfoExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
idList
!=
null
&&
idList
.
size
()
>
0
)
{
criteria
.
andIdIn
(
idList
);
}
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andClassNameEqualTo
(
className
);
criteria
.
andDeletedEqualTo
(
false
).
andClassNameEqualTo
(
className
);
return
classInfoMapper
.
selectByExample
(
example
);
}
public
List
<
ClassInfo
>
webSelectClass
(
String
className
,
List
<
Integer
>
idList
)
{
public
Map
webSelectClass
(
String
className
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
ClassInfoExample
example
=
new
ClassInfoExample
();
ClassInfoExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
@@ -33,11 +39,15 @@ public class ClassService {
if
(!
StringUtils
.
isEmpty
(
className
))
{
criteria
.
andClassNameLike
(
"%"
+
className
+
"%"
);
}
if
(
idList
!=
null
&&
idList
.
size
()
>
0
)
{
criteria
.
andIdIn
(
idList
);
}
PageHelper
.
startPage
(
page
,
limit
);
example
.
setOrderByClause
(
sort
+
" "
+
order
);
criteria
.
andClassNameEqualTo
(
className
);
return
classInfoMapper
.
selectByExample
(
example
);
List
<
ClassInfo
>
dataList
=
classInfoMapper
.
selectByExample
(
example
);
Long
total
=
PageInfo
.
of
(
dataList
).
getTotal
();
return
new
HashMap
(){{
put
(
"total"
,
total
);
put
(
"items"
,
dataList
);
}};
}
/**
...
...
@@ -46,7 +56,7 @@ public class ClassService {
* @return
*/
public
String
addClassInfo
(
String
className
)
{
List
<
ClassInfo
>
classInfoList
=
selectClass
(
className
);
List
<
ClassInfo
>
classInfoList
=
selectClass
(
className
,
null
);
if
(
classInfoList
!=
null
&&
classInfoList
.
size
()
!=
0
)
{
return
"fail 当前已存在该班级"
;
}
...
...
@@ -67,7 +77,7 @@ public class ClassService {
}
public
Object
batchDeletedData
(
List
<
Integer
>
idList
)
{
List
<
ClassInfo
>
classInfoList
=
webS
electClass
(
null
,
idList
);
List
<
ClassInfo
>
classInfoList
=
s
electClass
(
null
,
idList
);
classInfoList
.
forEach
(
x
->
{
x
.
setDeleted
(
null
);
updateClassInfo
(
x
);
...
...
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentInfoService.java
View file @
935baa11
...
...
@@ -4,11 +4,14 @@ import cn.exploring.engine.server.db.dao.SpecialSqlMapper;
import
cn.exploring.engine.server.db.dao.StudentInfoMapper
;
import
cn.exploring.engine.server.db.domain.StudentInfo
;
import
cn.exploring.engine.server.db.domain.StudentInfoExample
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -21,17 +24,19 @@ public class StudentInfoService {
@Resource
SpecialSqlMapper
specialSqlMapper
;
/**
* 添加
* @param studentInfo
* @return
*/
public
Object
addStudentInfo
(
StudentInfo
studentInfo
)
{
public
String
addStudentInfo
(
StudentInfo
studentInfo
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
studentInfo
.
setAddTime
(
now
);
studentInfo
.
setUpdateTime
(
now
);
studentInfoMapper
.
insertSelective
(
studentInfo
);
return
"添加成功"
;
return
"
OK
添加成功"
;
}
/**
...
...
@@ -51,7 +56,7 @@ public class StudentInfoService {
public
Object
updateStudentInfo
(
StudentInfo
studentInfo
)
{
studentInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
studentInfoMapper
.
updateByPrimaryKey
(
studentInfo
);
return
"修改成功"
;
return
"
OK
修改成功"
;
}
/**
...
...
@@ -90,6 +95,38 @@ 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
)
{
StudentInfoExample
example
=
new
StudentInfoExample
();
StudentInfoExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
studentName
))
{
criteria
.
andNameLike
(
"%"
+
studentName
+
"%"
);
}
if
(!
StringUtils
.
isEmpty
(
studentId
))
{
criteria
.
andStudentUniqueIdLike
(
"%"
+
studentId
+
"%"
);
}
if
(
idList
!=
null
&&
idList
.
size
()
>
0
)
{
criteria
.
andIdIn
(
idList
);
}
if
(
classId
!=
null
)
{
criteria
.
andClassIdEqualTo
(
classId
);
}
PageHelper
.
startPage
(
page
,
limit
);
example
.
setOrderByClause
(
sort
+
" "
+
order
);
List
<
StudentInfo
>
studentInfoList
=
studentInfoMapper
.
selectByExample
(
example
);
Long
total
=
PageInfo
.
of
(
studentInfoList
).
getTotal
();
return
new
HashMap
(){{
put
(
"total"
,
total
);
put
(
"items"
,
studentInfoList
);
}};
}
}
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentPointService.java
View file @
935baa11
package
cn
.
exploring
.
engine
.
server
.
db
.
service
;
import
cn.exploring.engine.server.db.dao.SpecialSqlMapper
;
import
cn.exploring.engine.server.db.dao.StudentPointInfoMapper
;
import
cn.exploring.engine.server.db.domain.StudentPointInfo
;
import
cn.exploring.engine.server.db.domain.StudentPointInfoExample
;
...
...
@@ -8,6 +9,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
StudentPointService
{
...
...
@@ -15,6 +17,13 @@ public class StudentPointService {
@Resource
StudentPointInfoMapper
studentPointInfoMapper
;
@Resource
SpecialSqlMapper
specialSqlMapper
;
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
);
}
/**
* id 检索
* @param idList
...
...
@@ -31,7 +40,7 @@ public class StudentPointService {
}
public
Object
addPoint
(
StudentPointInfo
studentPoint
)
{
public
String
addPoint
(
StudentPointInfo
studentPoint
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
studentPoint
.
setRecordTime
(
now
);
studentPoint
.
setUpdateTime
(
now
);
...
...
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/ClassController.java
View file @
935baa11
...
...
@@ -3,12 +3,11 @@ package cn.exploring.engine.server.wx.web;
import
cn.exploring.engine.server.core.util.ResponseUtil
;
import
cn.exploring.engine.server.db.domain.ClassInfo
;
import
cn.exploring.engine.server.db.service.ClassService
;
import
cn.exploring.engine.server.db.service.StudentPointService
;
import
cn.exploring.engine.server.wx.annotation.LoginUser
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/wx/class"
)
...
...
@@ -18,12 +17,32 @@ public class ClassController {
@Resource
ClassService
classService
;
@GetMapping
(
"selectClass"
)
public
Object
selectClass
(
@RequestParam
String
className
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
required
=
false
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
required
=
false
,
defaultValue
=
"add_time"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
return
ResponseUtil
.
ok
(
classService
.
webSelectClass
(
className
,
page
,
limit
,
sort
,
order
));
}
@GetMapping
(
"addClass"
)
public
Object
commitUserLessonRecord
(
@RequestParam
String
className
)
{
public
Object
addClass
(
@RequestParam
String
className
)
{
String
status
=
classService
.
addClassInfo
(
className
);
return
status
.
contains
(
"OK"
)
?
ResponseUtil
.
ok
(
status
)
:
ResponseUtil
.
fail
(
502
,
status
);
}
@PostMapping
(
"updateClass"
)
public
Object
updateClass
(
@RequestBody
ClassInfo
classInfo
)
{
classService
.
updateClassInfo
(
classInfo
);
return
ResponseUtil
.
ok
(
"OK"
);
}
@PostMapping
(
"batchDeleted"
)
public
Object
batchDeleted
(
@RequestBody
List
<
Integer
>
idList
)
{
return
ResponseUtil
.
ok
(
classService
.
batchDeletedData
(
idList
));
}
}
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/PointController.java
View file @
935baa11
package
cn
.
exploring
.
engine
.
server
.
wx
.
web
;
import
cn.exploring.engine.server.core.util.ResponseUtil
;
import
cn.exploring.engine.server.db.
service.ClassService
;
import
cn.exploring.engine.server.db.
domain.StudentPointInfo
;
import
cn.exploring.engine.server.db.service.StudentPointService
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/wx/point"
)
...
...
@@ -19,7 +17,35 @@ public class PointController {
@Resource
StudentPointService
pointService
;
@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_time"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
return
ResponseUtil
.
ok
(
pointService
.
selectPointByWeb
(
studentName
,
studentUniqueId
,
classId
,
startTime
,
endTime
,
page
,
limit
,
sort
,
order
));
}
@GetMapping
(
"add"
)
public
Object
add
(
@RequestBody
StudentPointInfo
pointInfo
)
{
String
status
=
pointService
.
addPoint
(
pointInfo
);
return
status
.
contains
(
"OK"
)
?
ResponseUtil
.
ok
(
status
)
:
ResponseUtil
.
fail
(
502
,
status
);
}
@PostMapping
(
"update"
)
public
Object
update
(
@RequestBody
StudentPointInfo
pointInfo
)
{
pointService
.
updatePoint
(
pointInfo
);
return
ResponseUtil
.
ok
(
"OK"
);
}
@PostMapping
(
"batchDeleted"
)
public
Object
batchDeleted
(
@RequestBody
List
<
Integer
>
idList
)
{
return
ResponseUtil
.
ok
(
pointService
.
batchDeleted
(
idList
));
}
}
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/StudentController.java
0 → 100644
View file @
935baa11
package
cn
.
exploring
.
engine
.
server
.
wx
.
web
;
import
cn.exploring.engine.server.core.util.ResponseUtil
;
import
cn.exploring.engine.server.db.domain.StudentInfo
;
import
cn.exploring.engine.server.db.service.StudentInfoService
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/wx/student"
)
@Validated
public
class
StudentController
{
@Resource
StudentInfoService
studentInfoService
;
@GetMapping
(
"selectStudent"
)
public
Object
selectClass
(
@RequestParam
String
studentName
,
@RequestParam
String
studentId
,
@RequestParam
Integer
classId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
required
=
false
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
required
=
false
,
defaultValue
=
"add_time"
)
String
sort
,
@RequestParam
(
required
=
false
,
defaultValue
=
"desc"
)
String
order
)
{
return
ResponseUtil
.
ok
(
studentInfoService
.
selectStudentInfoByWeb
(
studentName
,
studentId
,
null
,
classId
,
page
,
limit
,
sort
,
order
));
}
@GetMapping
(
"randomSelect"
)
public
Object
randomSelect
(
@RequestParam
Integer
classId
)
{
return
ResponseUtil
.
ok
(
studentInfoService
.
selectStudentInfo
(
classId
));
}
@GetMapping
(
"add"
)
public
Object
add
(
@RequestBody
StudentInfo
studentInfo
)
{
String
status
=
studentInfoService
.
addStudentInfo
(
studentInfo
);
return
status
.
contains
(
"OK"
)
?
ResponseUtil
.
ok
(
status
)
:
ResponseUtil
.
fail
(
502
,
status
);
}
@PostMapping
(
"update"
)
public
Object
update
(
@RequestBody
StudentInfo
studentInfo
)
{
studentInfoService
.
updateStudentInfo
(
studentInfo
);
return
ResponseUtil
.
ok
(
"OK"
);
}
@PostMapping
(
"batchDeleted"
)
public
Object
batchDeleted
(
@RequestBody
List
<
Integer
>
idList
)
{
return
ResponseUtil
.
ok
(
studentInfoService
.
batchDeleted
(
idList
));
}
}
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