Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-springboot-train
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
Fcant
hls-springboot-train
Commits
741e2367
Commit
741e2367
authored
Dec 03, 2019
by
Fcant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Code-Updates]:添加修改删除更新后返回UserInfo信息
parent
12b3c48f
Pipeline
#4023
failed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
14 deletions
+40
-14
UserController.java
...rain/springboot/springboot/controller/UserController.java
+5
-4
UserMapper.java
...g/hand/train/springboot/springboot/mapper/UserMapper.java
+4
-0
UserService.java
...hand/train/springboot/springboot/service/UserService.java
+3
-3
UserServiceImpl.java
...n/springboot/springboot/service/impl/UserServiceImpl.java
+24
-6
UserMapper.xml
SpringBoot_HLS/src/main/resources/mapper/UserMapper.xml
+4
-1
No files found.
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/controller/UserController.java
View file @
741e2367
...
...
@@ -55,8 +55,9 @@ public class UserController {
* @date 18:40 2019/12/3
*/
@PostMapping
(
"/add"
)
int
addUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
addUser
(
userInfo
);
UserInfo
addUser
(
@RequestBody
UserInfo
userInfo
)
{
userService
.
addUser
(
userInfo
);
return
userInfo
;
}
/**
...
...
@@ -68,7 +69,7 @@ public class UserController {
* @date 18:41 2019/12/3
*/
@PutMapping
(
"/update"
)
int
updateUser
(
@RequestBody
UserInfo
userInfo
)
{
UserInfo
updateUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
updateUser
(
userInfo
);
}
...
...
@@ -81,7 +82,7 @@ public class UserController {
* @date 18:41 2019/12/3
*/
@DeleteMapping
(
"/del"
)
int
delUser
(
@RequestBody
UserInfo
userInfo
)
{
UserInfo
delUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
delUser
(
userInfo
);
}
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/mapper/UserMapper.java
View file @
741e2367
package
org
.
hand
.
train
.
springboot
.
springboot
.
mapper
;
import
org.hand.train.springboot.springboot.bean.UserInfo
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -41,6 +42,7 @@ public interface UserMapper {
* @author Fcant
* @date 18:40 2019/12/3
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
int
addUser
(
UserInfo
userInfo
);
/**
...
...
@@ -51,6 +53,7 @@ public interface UserMapper {
* @author Fcant
* @date 18:41 2019/12/3
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
int
updateUser
(
UserInfo
userInfo
);
/**
...
...
@@ -61,5 +64,6 @@ public interface UserMapper {
* @author Fcant
* @date 18:41 2019/12/3
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
int
delUser
(
UserInfo
userInfo
);
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/service/UserService.java
View file @
741e2367
...
...
@@ -41,7 +41,7 @@ public interface UserService {
* @author Fcant
* @date 18:40 2019/12/3
*/
int
addUser
(
UserInfo
userInfo
);
UserInfo
addUser
(
UserInfo
userInfo
);
/**
* 更新用户信息
...
...
@@ -51,7 +51,7 @@ public interface UserService {
* @author Fcant
* @date 18:41 2019/12/3
*/
int
updateUser
(
UserInfo
userInfo
);
UserInfo
updateUser
(
UserInfo
userInfo
);
/**
* 删除用户
...
...
@@ -61,5 +61,5 @@ public interface UserService {
* @author Fcant
* @date 18:41 2019/12/3
*/
int
delUser
(
UserInfo
userInfo
);
UserInfo
delUser
(
UserInfo
userInfo
);
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/service/impl/UserServiceImpl.java
View file @
741e2367
...
...
@@ -19,6 +19,11 @@ import java.util.List;
@Service
public
class
UserServiceImpl
implements
UserService
{
/**
* 数据库操作失败的数字返回值
*/
private
final
int
FAILURE_CODE
=
0
;
@Autowired
UserMapper
userMapper
;
...
...
@@ -56,8 +61,12 @@ public class UserServiceImpl implements UserService {
* @date 18:40 2019/12/3
*/
@Override
public
int
addUser
(
UserInfo
userInfo
)
{
return
userMapper
.
addUser
(
userInfo
);
public
UserInfo
addUser
(
UserInfo
userInfo
)
{
int
i
=
userMapper
.
addUser
(
userInfo
);
if
(
i
==
FAILURE_CODE
)
{
return
null
;
}
return
userInfo
;
}
/**
...
...
@@ -69,8 +78,12 @@ public class UserServiceImpl implements UserService {
* @date 18:41 2019/12/3
*/
@Override
public
int
updateUser
(
UserInfo
userInfo
)
{
return
userMapper
.
updateUser
(
userInfo
);
public
UserInfo
updateUser
(
UserInfo
userInfo
)
{
int
i
=
userMapper
.
updateUser
(
userInfo
);
if
(
i
==
FAILURE_CODE
)
{
return
null
;
}
return
userInfo
;
}
/**
...
...
@@ -82,7 +95,12 @@ public class UserServiceImpl implements UserService {
* @date 18:41 2019/12/3
*/
@Override
public
int
delUser
(
UserInfo
userInfo
)
{
return
userMapper
.
delUser
(
userInfo
);
public
UserInfo
delUser
(
UserInfo
userInfo
)
{
int
i
=
userMapper
.
delUser
(
userInfo
);
if
(
i
==
FAILURE_CODE
)
{
return
null
;
}
userInfo
=
userMapper
.
selectUserById
(
userInfo
.
getUserId
());
return
userInfo
;
}
}
SpringBoot_HLS/src/main/resources/mapper/UserMapper.xml
View file @
741e2367
...
...
@@ -33,7 +33,10 @@
user_id =#{id}
</select>
<insert
id=
"addUser"
keyProperty=
"userId"
useGeneratedKeys=
"true"
parameterType=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
<insert
id=
"addUser"
keyProperty=
"userId"
useGeneratedKeys=
"true"
parameterType=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
INSERT INTO user_info(user_id, user_name, age, create_time)
VALUES (#{userId}, #{userName}, #{age}, #{createTime})
</insert>
...
...
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