Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
Overview
Overview
Details
Activity
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
base_platform_enterprise
gic-platform-auth
Commits
f39408f3
Commit
f39408f3
authored
Sep 02, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增用户添加事务
parent
01494451
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
UserServiceImpl.java
.../main/java/com/gic/auth/service/impl/UserServiceImpl.java
+4
-0
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+23
-5
UserController.java
...main/java/com/gic/auth/web/controller/UserController.java
+4
-1
No files found.
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/UserServiceImpl.java
View file @
f39408f3
...
...
@@ -10,6 +10,7 @@ import com.gic.auth.dto.UserDTO;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.service.UserService
;
import
com.gic.commons.util.EntityUtil
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @author guojx
...
...
@@ -19,6 +20,8 @@ import com.gic.commons.util.EntityUtil;
public
class
UserServiceImpl
implements
UserService
{
@Autowired
private
TabSysUserMapper
tabSysUserMapper
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
int
saveUser
(
UserDTO
userDTO
)
{
TabSysUser
tabUser
=
EntityUtil
.
changeEntityNew
(
TabSysUser
.
class
,
userDTO
);
...
...
@@ -26,6 +29,7 @@ public class UserServiceImpl implements UserService {
return
tabUser
.
getUserId
();
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
editUser
(
UserDTO
userDTO
)
{
TabSysUser
tabUser
=
EntityUtil
.
changeEntityNew
(
TabSysUser
.
class
,
userDTO
);
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
f39408f3
...
...
@@ -3,6 +3,7 @@ package com.gic.auth.service.outer.impl;
import
java.util.Date
;
import
java.util.List
;
import
com.gic.enterprise.exception.CommonException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -23,7 +24,7 @@ import com.gic.store.utils.valid.ValidUtil;
* @date 2019/7/16 6:55 PM
*/
@Service
(
"userApiService"
)
public
class
UserApiServiceImpl
implements
UserApiService
{
public
class
UserApiServiceImpl
implements
UserApiService
{
@Autowired
private
UserService
userService
;
@Autowired
...
...
@@ -34,6 +35,7 @@ public class UserApiServiceImpl implements UserApiService{
private
UserRoleService
userRoleService
;
@Autowired
private
UserResourceService
userResourceService
;
@Override
public
ServiceResponse
<
Integer
>
saveUser
(
UserDTO
userDTO
)
{
//valid param
...
...
@@ -50,7 +52,14 @@ public class UserApiServiceImpl implements UserApiService{
userDTO
.
setStatus
(
1
);
Integer
userId
=
userService
.
saveUser
(
userDTO
);
return
saveRole
(
userId
,
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
ServiceResponse
<
Integer
>
response
=
saveRole
(
userId
,
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
if
(
response
.
isSuccess
())
{
return
response
;
}
else
{
//事物回滚
throw
new
CommonException
(
response
);
}
}
@Override
...
...
@@ -69,7 +78,15 @@ public class UserApiServiceImpl implements UserApiService{
}
userDTO
.
setUpdateTime
(
new
Date
());
userService
.
editUser
(
userDTO
);
return
saveRole
(
userDTO
.
getUserId
(),
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
ServiceResponse
<
Integer
>
response
=
saveRole
(
userDTO
.
getUserId
(),
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
if
(
response
.
isSuccess
())
{
return
response
;
}
else
{
//事物回滚
throw
new
CommonException
(
response
);
}
}
@Override
...
...
@@ -111,7 +128,7 @@ public class UserApiServiceImpl implements UserApiService{
@Override
public
ServiceResponse
<
List
<
UserDTO
>>
listUserByPhoneNumber
(
String
phoneNumber
)
{
List
<
TabSysUser
>
list
=
this
.
userService
.
listAllUserByPhoneNumber
(
phoneNumber
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityListByJSON
(
UserDTO
.
class
,
list
));
}
return
ServiceResponse
.
success
();
...
...
@@ -134,7 +151,8 @@ public class UserApiServiceImpl implements UserApiService{
* @param userResourceIds
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
*/
private
ServiceResponse
<
Integer
>
saveRole
(
Integer
userId
,
Integer
enterpriseId
,
String
userRoleIds
,
String
userResourceIds
)
{
private
ServiceResponse
<
Integer
>
saveRole
(
Integer
userId
,
Integer
enterpriseId
,
String
userRoleIds
,
String
userResourceIds
)
{
String
[]
userRoleIdArr
;
String
[]
userResourceIdArr
;
ServiceResponse
<
Object
>
userRoleValid
=
validStr
(
userRoleIds
);
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/UserController.java
View file @
f39408f3
...
...
@@ -2,6 +2,7 @@ package com.gic.auth.web.controller;
import
com.gic.auth.web.vo.UserDetailVO
;
import
com.gic.enterprise.utils.ResultControllerUtils
;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,11 +30,13 @@ public class UserController {
@RequestMapping
(
"/save-or-update-user"
)
public
RestResponse
editUser
(
@Validated
({
UserDTO
.
UserQoValid
.
class
})
UserDTO
userDTO
)
{
userDTO
.
setEnterpriseId
(
StoreGroupConstant
.
TEST_ENTERPRISE_ID
);
userDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
()
);
String
password
=
UserPasswordUtils
.
validPassword
(
userDTO
.
getPasswordType
(),
userDTO
.
getPassword
(),
userDTO
.
getConfirmPassword
());
userDTO
.
setPassword
(
UserPasswordUtils
.
getEncryptPassword
(
password
));
ServiceResponse
userResult
;
//普通用户
userDTO
.
setSuperAdmin
(
0
);
if
(
userDTO
.
getUserId
()
==
null
)
{
userResult
=
userApiService
.
saveUser
(
userDTO
);
}
else
{
...
...
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