Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2acf9bda
authored
Oct 07, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:实验代码
1 parent
2c2ec011
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
project-user/src/main/java/com/dituhui/pea/user/controller/RoleController.java
project-user/src/main/java/com/dituhui/pea/user/service/RoleService.java
project-user/src/main/java/com/dituhui/pea/user/controller/RoleController.java
View file @
2acf9bd
...
@@ -43,7 +43,7 @@ public class RoleController implements IRole {
...
@@ -43,7 +43,7 @@ public class RoleController implements IRole {
@Override
@Override
public
Result
<
RoleInfo
>
deleteRole2
(
@Validated
RoleInfo
roleInfo
)
{
public
Result
<
RoleInfo
>
deleteRole2
(
@Validated
RoleInfo
roleInfo
)
{
roleInfo
=
roleService
.
addRole
(
roleInfo
);
roleInfo
=
roleService
.
deleteRole2
(
roleInfo
);
return
Result
.
success
(
roleInfo
);
return
Result
.
success
(
roleInfo
);
}
}
...
...
project-user/src/main/java/com/dituhui/pea/user/service/RoleService.java
View file @
2acf9bd
...
@@ -24,8 +24,12 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -24,8 +24,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -59,7 +63,8 @@ public class RoleService {
...
@@ -59,7 +63,8 @@ public class RoleService {
@Autowired
@Autowired
RedisService
redisService
;
RedisService
redisService
;
@Autowired
private
DataSourceTransactionManager
dataSourceTransactionManager
;
/**
/**
* 失效时间ms
* 失效时间ms
*/
*/
...
@@ -128,6 +133,11 @@ public class RoleService {
...
@@ -128,6 +133,11 @@ public class RoleService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
RoleInfo
deleteRole2
(
RoleInfo
roleInfo
)
{
public
RoleInfo
deleteRole2
(
RoleInfo
roleInfo
)
{
DefaultTransactionDefinition
defaultTransactionDefinition
=
new
DefaultTransactionDefinition
();
defaultTransactionDefinition
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRES_NEW
);
TransactionStatus
transaction
=
dataSourceTransactionManager
.
getTransaction
(
defaultTransactionDefinition
);
String
name
=
roleInfo
.
getName
();
String
name
=
roleInfo
.
getName
();
String
createdBy
=
roleInfo
.
getCreatedBy
();
String
createdBy
=
roleInfo
.
getCreatedBy
();
String
notes
=
roleInfo
.
getNotes
();
String
notes
=
roleInfo
.
getNotes
();
...
@@ -148,8 +158,17 @@ public class RoleService {
...
@@ -148,8 +158,17 @@ public class RoleService {
roleResourceDao
.
save
(
roleResourceEntity
);
roleResourceDao
.
save
(
roleResourceEntity
);
}
}
}
}
roleDao
.
flush
();
log
.
info
(
"新增角色信息:"
+
JSONObject
.
toJSONString
(
roleInfo
));
log
.
info
(
"新增角色信息:"
+
JSONObject
.
toJSONString
(
roleInfo
));
try
{
// 业务代码
// 手动提交事务
dataSourceTransactionManager
.
commit
(
transaction
);
}
catch
(
Exception
e
)
{
// 手动回滚事务
dataSourceTransactionManager
.
rollback
(
transaction
);
}
return
roleInfo
;
return
roleInfo
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment