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
cc033ddf
Commit
cc033ddf
authored
Jul 24, 2023
by
Ryan Loong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 点名次数增加失败的bug
parent
19b4f820
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
195 deletions
+30
-195
generatorConfig.xml
server-db/mybatis-generator/generatorConfig.xml
+0
-2
StudentInfo.java
...ava/cn/exploring/engine/server/db/domain/StudentInfo.java
+0
-81
StudentInfoService.java
...xploring/engine/server/db/service/StudentInfoService.java
+10
-4
StudentInfoMapper.xml
...s/cn/exploring/engine/server/db/dao/StudentInfoMapper.xml
+20
-108
No files found.
server-db/mybatis-generator/generatorConfig.xml
View file @
cc033ddf
...
...
@@ -125,8 +125,6 @@
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"student_info"
>
<!-- 配置需要进行增量操作的列名称(英文半角逗号分隔) -->
<property
name=
"incrementColumns"
value=
"call_times"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
...
...
server-db/src/main/java/cn/exploring/engine/server/db/domain/StudentInfo.java
View file @
cc033ddf
...
...
@@ -3,8 +3,6 @@ package cn.exploring.engine.server.db.domain;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
StudentInfo
{
/**
...
...
@@ -104,14 +102,6 @@ public class StudentInfo {
*/
private
Boolean
deleted
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table student_info
*
* @mbg.generated
*/
protected
final
Map
<
String
,
Object
>
incrementColumnsInfoMap
=
new
HashMap
<>();
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column student_info.id
...
...
@@ -426,17 +416,6 @@ public class StudentInfo {
return
new
StudentInfo
.
Builder
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table student_info
*
* @mbg.generated
*/
public
StudentInfo
increment
(
Increment
.
Item
increment
)
{
this
.
incrementColumnsInfoMap
.
put
(
increment
.
getColumn
().
value
(),
increment
);
return
this
;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table student_info
...
...
@@ -878,64 +857,4 @@ public class StudentInfo {
return
this
.
getEscapedColumnName
();
}
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table student_info
*
* @mbg.generated
*/
public
enum
Increment
{
callTimes
(
Column
.
callTimes
);
private
final
Column
column
;
Increment
(
Column
column
)
{
this
.
column
=
column
;
}
public
Column
getColumn
()
{
return
this
.
column
;
}
public
Increment
.
Item
inc
(
Object
value
)
{
return
new
Increment
.
Item
(
this
.
column
,
"+"
,
value
);
}
public
Increment
.
Item
dec
(
Object
value
)
{
return
new
Increment
.
Item
(
this
.
column
,
"-"
,
value
);
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table student_info
*
* @mbg.generated
*/
class
Item
{
private
Column
column
;
private
String
operate
;
private
Object
value
;
public
Column
getColumn
()
{
return
this
.
column
;
}
public
String
getOperate
()
{
return
this
.
operate
;
}
public
Object
getValue
()
{
return
this
.
value
;
}
public
Item
(
Column
column
,
String
operate
,
Object
value
)
{
this
.
column
=
column
;
this
.
operate
=
operate
;
this
.
value
=
value
;
}
}
}
}
\ No newline at end of file
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentInfoService.java
View file @
cc033ddf
...
...
@@ -396,9 +396,15 @@ public class StudentInfoService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
increaseCallTimeByPrimaryKey
(
Integer
id
)
{
studentInfoMapper
.
updateByPrimaryKeySelective
(
StudentInfo
.
builder
().
id
(
id
).
updateTime
(
LocalDateTime
.
now
()).
build
().
increment
(
StudentInfo
.
Increment
.
callTimes
.
inc
(
1
)),
StudentInfo
.
Column
.
callTimes
,
StudentInfo
.
Column
.
updateTime
);
StudentInfo
studentInfo
=
selectByPrimaryKey
(
id
);
Integer
callTimes
=
studentInfo
.
getCallTimes
();
studentInfo
.
setCallTimes
(
callTimes
+
1
);
studentInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
int
i
=
studentInfoMapper
.
updateByExampleSelective
(
studentInfo
,
new
StudentInfoExample
().
createCriteria
().
andDeletedEqualTo
(
StudentInfo
.
NOT_DELETED
).
andIdEqualTo
(
id
).
andCallTimesEqualTo
(
callTimes
).
example
(),
StudentInfo
.
Column
.
updateTime
,
StudentInfo
.
Column
.
callTimes
);
if
(
i
<=
0
)
{
throw
new
RuntimeException
(
"更新点名次数失败"
);
}
}
}
server-db/src/main/resources/cn/exploring/engine/server/db/dao/StudentInfoMapper.xml
View file @
cc033ddf
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