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
9b496dd6
Commit
9b496dd6
authored
Oct 31, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员增删改添加账号分组
parent
c19f3aee
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
640 additions
and
32 deletions
+640
-32
TabSysAccountGroupRelMapper.java
.../com/gic/auth/dao/mapper/TabSysAccountGroupRelMapper.java
+110
-0
TabSysAccountGroupRel.java
.../main/java/com/gic/auth/entity/TabSysAccountGroupRel.java
+113
-0
AccountGroupRelService.java
...ain/java/com/gic/auth/service/AccountGroupRelService.java
+69
-0
AccountGroupRelServiceImpl.java
...com/gic/auth/service/impl/AccountGroupRelServiceImpl.java
+52
-0
AccountGroupApiServiceImpl.java
...c/auth/service/outer/impl/AccountGroupApiServiceImpl.java
+5
-2
MenuApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
+3
-7
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+89
-23
TabSysAccountGroupRelMapper.xml
...src/main/resources/mapper/TabSysAccountGroupRelMapper.xml
+184
-0
UserController.java
...main/java/com/gic/auth/web/controller/UserController.java
+15
-0
No files found.
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabSysAccountGroupRelMapper.java
0 → 100644
View file @
9b496dd6
package
com
.
gic
.
auth
.
dao
.
mapper
;
import
com.gic.auth.dto.AccountGroupRelDTO
;
import
com.gic.auth.entity.TabSysAccountGroupRel
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
TabSysAccountGroupRelMapper
{
/**
* 根据主键删除
*
* @param accountGroupRelId 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
accountGroupRelId
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
TabSysAccountGroupRel
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
TabSysAccountGroupRel
record
);
/**
* 根据主键查询
*
* @param accountGroupRelId 主键
* @return 实体对象
*/
TabSysAccountGroupRel
selectByPrimaryKey
(
Integer
accountGroupRelId
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
TabSysAccountGroupRel
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabSysAccountGroupRel
record
);
/**
* 逻辑删除分组下的组员关联
* @Title: deleteByAccountGroupId
* @Description:
* @author guojuxing
* @param accountGroupId
* @return void
*/
void
deleteByAccountGroupId
(
@Param
(
"accountGroupId"
)
Integer
accountGroupId
);
/**
* 批量插入
* @Title: insertForeach
* @Description:
* @author guojuxing
* @param list
* @return void
*/
void
insertForeach
(
@Param
(
"list"
)
List
<
AccountGroupRelDTO
>
list
);
/**
* 逻辑删除用户分组关联
* @Title: deleteByUserId
* @Description:
* @author guojuxing
* @param userId
* @return void
*/
void
deleteByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"type"
)
Integer
type
);
/**
* 查询用户分组列表数据
* @Title: listByUserId
* @Description:
* @author guojuxing
* @param userId
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>
*/
List
<
TabSysAccountGroupRel
>
listByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"type"
)
Integer
type
);
/**
* 逻辑删除用户对应分组数据
* @Title: deleteByAccountGroupIdAndUserId
* @Description:
* @author guojuxing
* @param userId
* @param accountGroupId
* @param type
* @return void
*/
void
deleteByAccountGroupIdAndUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"accountGroupId"
)
Integer
accountGroupId
,
@Param
(
"type"
)
Integer
type
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/entity/TabSysAccountGroupRel.java
0 → 100644
View file @
9b496dd6
package
com
.
gic
.
auth
.
entity
;
import
java.util.Date
;
/**
* tab_sys_account_group_rel
*/
public
class
TabSysAccountGroupRel
{
/**
* ID
*/
private
Integer
accountGroupRelId
;
/**
* 账号分组ID
*/
private
Integer
accountGroupId
;
/**
* 用户ID/协作人ID
*/
private
Integer
userId
;
/**
*
*/
private
Integer
enterpriseId
;
/**
* 1:有效 0:无效
*/
private
Integer
status
;
/**
* 1:管理员 2:协作人
*/
private
Integer
type
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
Integer
getAccountGroupRelId
()
{
return
accountGroupRelId
;
}
public
void
setAccountGroupRelId
(
Integer
accountGroupRelId
)
{
this
.
accountGroupRelId
=
accountGroupRelId
;
}
public
Integer
getAccountGroupId
()
{
return
accountGroupId
;
}
public
void
setAccountGroupId
(
Integer
accountGroupId
)
{
this
.
accountGroupId
=
accountGroupId
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/AccountGroupRelService.java
0 → 100644
View file @
9b496dd6
package
com
.
gic
.
auth
.
service
;
import
com.gic.auth.dto.AccountGroupRelDTO
;
import
com.gic.auth.entity.TabSysAccountGroupRel
;
import
java.util.List
;
/**
* 账号分组组员关联
* @ClassName: AccountGroupRelService
* @Description:
* @author guojuxing
* @date 2019/10/31 9:35 AM
*/
public
interface
AccountGroupRelService
{
/**
* 批量新增
* @Title: insertFetch
* @Description:
* @author guojuxing
* @param list
* @return void
*/
void
insertFetch
(
List
<
AccountGroupRelDTO
>
list
);
/**
* 逻辑删除分组下的关联
* @Title: deleteByAccountGroupId
* @Description:
* @author guojuxing
* @param accountGroupId
* @return void
*/
void
deleteByAccountGroupId
(
Integer
accountGroupId
);
/**
* 逻辑删除用户分组关联
* @Title: deleteByUserId
* @Description:
* @author guojuxing
* @param userId
* @param type
* @return void
*/
void
deleteByUserId
(
Integer
userId
,
Integer
type
);
/**
* 用户所在分组列表数据
* @Title: listByUserId
* @Description:
* @author guojuxing
* @param userId
* @param type
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>
*/
List
<
TabSysAccountGroupRel
>
listByUserId
(
Integer
userId
,
Integer
type
);
/**
* 删除用户对应分组数据
* @Title: deleteByAccountGroupIdAndUserId
* @Description:
* @author guojuxing
* @param userId
* @param accountGroupId
* @param type
* @return void
*/
void
deleteByAccountGroupIdAndUserId
(
Integer
userId
,
Integer
accountGroupId
,
Integer
type
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/AccountGroupRelServiceImpl.java
0 → 100644
View file @
9b496dd6
package
com
.
gic
.
auth
.
service
.
impl
;
import
com.gic.auth.constant.AccountGroupMemberTypeEnum
;
import
com.gic.auth.dao.mapper.TabSysAccountGroupRelMapper
;
import
com.gic.auth.dto.AccountGroupRelDTO
;
import
com.gic.auth.entity.TabSysAccountGroupRel
;
import
com.gic.auth.service.AccountGroupRelService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
(
"accountGroupRelService"
)
public
class
AccountGroupRelServiceImpl
implements
AccountGroupRelService
{
@Autowired
private
TabSysAccountGroupRelMapper
tabSysAccountGroupRelMapper
;
@Override
public
void
insertFetch
(
List
<
AccountGroupRelDTO
>
list
)
{
tabSysAccountGroupRelMapper
.
insertForeach
(
list
);
}
@Override
public
void
deleteByAccountGroupId
(
Integer
accountGroupId
)
{
tabSysAccountGroupRelMapper
.
deleteByAccountGroupId
(
accountGroupId
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
deleteByUserId
(
Integer
userId
,
Integer
type
)
{
if
(
type
==
null
)
{
type
=
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
();
}
tabSysAccountGroupRelMapper
.
deleteByUserId
(
userId
,
type
);
}
@Override
public
List
<
TabSysAccountGroupRel
>
listByUserId
(
Integer
userId
,
Integer
type
)
{
if
(
type
==
null
)
{
type
=
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
();
}
return
tabSysAccountGroupRelMapper
.
listByUserId
(
userId
,
type
);
}
@Override
public
void
deleteByAccountGroupIdAndUserId
(
Integer
userId
,
Integer
accountGroupId
,
Integer
type
)
{
if
(
type
==
null
)
{
type
=
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
();
}
tabSysAccountGroupRelMapper
.
deleteByAccountGroupIdAndUserId
(
userId
,
accountGroupId
,
type
);
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/AccountGroupApiServiceImpl.java
View file @
9b496dd6
package
com
.
gic
.
auth
.
service
.
outer
.
impl
;
import
com.gic.auth.entity.TabSysAccountGroup
;
import
com.gic.auth.service.AccountGroupRelService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.error.ErrorCode
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -21,6 +22,8 @@ import java.util.List;
public
class
AccountGroupApiServiceImpl
implements
AccountGroupApiService
{
@Autowired
private
AccountGroupService
accountGroupService
;
@Autowired
private
AccountGroupRelService
accountGroupRelService
;
@Override
public
ServiceResponse
<
Integer
>
save
(
AccountGroupDTO
dto
)
{
//参数校验
...
...
@@ -75,8 +78,8 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
}
//逻辑删除分组
accountGroupService
.
updateStatusByAccountGroupId
(
accountGroupId
);
//
todo
删除组员分组关系数据
//删除组员分组关系数据
accountGroupRelService
.
deleteByAccountGroupId
(
accountGroupId
);
return
ServiceResponse
.
success
();
}
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
View file @
9b496dd6
...
...
@@ -154,7 +154,7 @@ public class MenuApiServiceImpl implements MenuApiService {
saveHasBuyAppMenu
(
appList
);
List
<
String
>
projectList
=
new
ArrayList
<>(
appList
.
size
());
for
(
ApplicationDTO
app
:
appList
)
{
projectList
.
add
(
app
.
get
ModuleCode
());
projectList
.
add
(
app
.
get
ApplicationId
().
toString
());
}
List
<
MenuDTO
>
menuList
=
EntityUtil
.
changeEntityListNew
(
MenuDTO
.
class
,
menuService
.
selectByProjectList
(
projectList
));
...
...
@@ -543,22 +543,18 @@ public class MenuApiServiceImpl implements MenuApiService {
if
(
appListResponse
.
isSuccess
())
{
List
<
ApplicationDTO
>
appList
=
appListResponse
.
getResult
();
for
(
ApplicationDTO
app
:
appList
)
{
if
(
StringUtils
.
isBlank
(
app
.
getModuleCode
()))
{
//没有唯一code,则不存数据
continue
;
}
if
(
appMenu
.
containsKey
(
app
.
getApplicationId
().
toString
()))
{
//如果已存在,则更新版本信息
MenuDTO
menuDTO
=
new
MenuDTO
();
menuDTO
.
setMenuName
(
app
.
getName
());
menuDTO
.
setProject
(
app
.
get
ModuleCode
());
menuDTO
.
setProject
(
app
.
get
ApplicationId
().
toString
());
setMenuVersion
(
app
.
getPropDTOList
(),
menuDTO
);
menuDTO
.
setMenuId
(
appMenu
.
get
(
app
.
getApplicationId
().
toString
()).
getMenuId
());
menuService
.
updatePage
(
menuDTO
);
}
else
{
MenuDTO
menuDTO
=
new
MenuDTO
();
menuDTO
.
setMenuName
(
app
.
getName
());
menuDTO
.
setProject
(
app
.
get
ModuleCode
());
menuDTO
.
setProject
(
app
.
get
ApplicationId
().
toString
());
setMenuVersion
(
app
.
getPropDTOList
(),
menuDTO
);
setNormalFieldValue
(
menuDTO
);
menuService
.
savePage
(
menuDTO
);
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
9b496dd6
package
com
.
gic
.
auth
.
service
.
outer
.
impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
com.gic.auth.entity.*
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.dto.UserListDTO
;
import
com.gic.auth.dto.UserResourceDTO
;
import
com.gic.auth.dto.UserRoleDTO
;
import
com.gic.auth.entity.TabSysResource
;
import
com.gic.auth.entity.TabSysRole
;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.constant.AccountGroupMemberTypeEnum
;
import
com.gic.auth.dto.*
;
import
com.gic.auth.qo.UserListQO
;
import
com.gic.auth.service.*
;
import
com.gic.auth.utils.ValidSplitUtils
;
...
...
@@ -18,19 +25,8 @@ import com.gic.enterprise.constants.Constants;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.utils.AutoCreatePasswordUtils
;
import
com.gic.enterprise.utils.UserDetail
;
import
com.gic.enterprise.utils.UserDetailUtils
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.store.utils.valid.ValidUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author guojx
...
...
@@ -52,6 +48,10 @@ public class UserApiServiceImpl implements UserApiService {
private
ResourceService
resourceService
;
@Autowired
private
RoleService
roleService
;
@Autowired
private
AccountGroupRelService
accountGroupRelService
;
@Autowired
private
AccountGroupService
accountGroupService
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
...
...
@@ -79,8 +79,8 @@ public class UserApiServiceImpl implements UserApiService {
//默认是普通管理员
userDTO
.
setSuperAdmin
(
0
);
}
//超级管理员不能创建多条,需要判断控制
if
(
userDTO
.
getSuperAdmin
().
intValue
()
==
1
)
{
//超级官员
TabSysUser
adminUser
=
userService
.
getUserByEnterpriseId
(
userDTO
.
getEnterpriseId
());
if
(
adminUser
!=
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"已存在超级管理员,重复创建"
);
...
...
@@ -102,9 +102,13 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService
.
deleteByUserId
(
userId
);
userResourceService
.
deleteByUserId
(
userId
);
//如果账号分组有数据,则需要维护分组数据
if
(
StringUtils
.
isNotBlank
(
userDTO
.
getAccountGroupIds
()))
{
accountGroupRelService
.
deleteByUserId
(
userId
,
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
}
ServiceResponse
<
Integer
>
response
=
saveRole
(
userId
,
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
userDTO
.
getUserResourceIds
()
,
userDTO
.
getAccountGroupIds
()
);
if
(
response
.
isSuccess
())
{
return
response
;
}
else
{
...
...
@@ -170,9 +174,13 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService
.
deleteByUserId
(
userDTO
.
getUserId
());
userResourceService
.
deleteByUserId
(
userDTO
.
getUserId
());
//如果账号分组有数据,则需要维护分组数据
if
(
StringUtils
.
isNotBlank
(
userDTO
.
getAccountGroupIds
()))
{
accountGroupRelService
.
deleteByUserId
(
userDTO
.
getUserId
(),
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
}
ServiceResponse
response
=
saveRole
(
userDTO
.
getUserId
(),
userDTO
.
getEnterpriseId
(),
userDTO
.
getUserRoleIds
(),
userDTO
.
getUserResourceIds
());
userDTO
.
getUserResourceIds
()
,
userDTO
.
getAccountGroupIds
()
);
if
(
response
.
isSuccess
())
{
return
response
;
}
else
{
...
...
@@ -218,7 +226,6 @@ public class UserApiServiceImpl implements UserApiService {
for
(
UserRoleDTO
userRoleDTO
:
userRoleDTOList
)
{
userRoleStr
.
append
(
userRoleDTO
.
getRoleId
()).
append
(
","
);
}
String
userRoleResult
=
userRoleStr
.
toString
();
if
(
StringUtils
.
isBlank
(
userRoleResult
))
{
result
.
setUserRoleIds
(
""
);
...
...
@@ -237,6 +244,20 @@ public class UserApiServiceImpl implements UserApiService {
}
else
{
result
.
setUserResourceIds
(
userResourceResult
.
substring
(
0
,
userResourceResult
.
length
()
-
1
));
}
//账号分组
List
<
TabSysAccountGroupRel
>
tabSysAccountGroupRelList
=
accountGroupRelService
.
listByUserId
(
userId
,
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
StringBuilder
accountGroupIdStr
=
new
StringBuilder
();
if
(
CollectionUtils
.
isNotEmpty
(
tabSysAccountGroupRelList
))
{
for
(
TabSysAccountGroupRel
accountGroupRel
:
tabSysAccountGroupRelList
)
{
accountGroupIdStr
.
append
(
accountGroupRel
.
getAccountGroupId
()).
append
(
","
);
}
}
String
accountGroupIdResult
=
accountGroupIdStr
.
toString
();
if
(
StringUtils
.
isBlank
(
accountGroupIdResult
))
{
result
.
setAccountGroupIds
(
""
);
}
else
{
result
.
setAccountGroupIds
(
accountGroupIdResult
.
substring
(
0
,
accountGroupIdResult
.
length
()
-
1
));
}
return
ServiceResponse
.
success
(
result
);
}
...
...
@@ -250,6 +271,8 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService
.
deleteByUserId
(
userId
);
//删除资源关联
userResourceService
.
deleteByUserId
(
userId
);
//删除账号分组关联
accountGroupRelService
.
deleteByUserId
(
userId
,
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
userService
.
delete
(
userId
);
return
ServiceResponse
.
success
();
}
...
...
@@ -326,6 +349,20 @@ public class UserApiServiceImpl implements UserApiService {
return
ServiceResponse
.
success
((
UserDetail
)
cache
);
}
@Override
public
ServiceResponse
<
Void
>
removeAccountGroup
(
Integer
accountGroupId
,
Integer
userId
,
Integer
type
)
{
TabSysUser
tabUser
=
userService
.
getUserById
(
userId
);
if
(
tabUser
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户ID输入有误,无此数据"
);
}
TabSysAccountGroup
tabSysAccountGroup
=
accountGroupService
.
getById
(
accountGroupId
);
if
(
tabSysAccountGroup
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组ID输入有误,无此数据"
);
}
accountGroupRelService
.
deleteByAccountGroupIdAndUserId
(
userId
,
accountGroupId
,
type
);
return
ServiceResponse
.
success
();
}
/**
* 保存关联数据,角色关联、资源关联
* @Title: saveRole
...
...
@@ -338,9 +375,10 @@ public class UserApiServiceImpl implements UserApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
*/
private
ServiceResponse
<
Integer
>
saveRole
(
Integer
userId
,
Integer
enterpriseId
,
String
userRoleIds
,
String
userResourceIds
)
{
String
userResourceIds
,
String
accountGroupIds
)
{
String
[]
userRoleIdArr
;
String
[]
userResourceIdArr
;
String
[]
accountGroupIdArr
;
ServiceResponse
<
String
[]>
userRoleValid
=
ValidSplitUtils
.
validStr
(
userRoleIds
);
if
(
userRoleValid
.
isSuccess
())
{
userRoleIdArr
=
userRoleValid
.
getResult
();
...
...
@@ -385,6 +423,34 @@ public class UserApiServiceImpl implements UserApiService {
return
result
;
}
}
//账号分组用户关联数据维护
if
(
StringUtils
.
isNotBlank
(
accountGroupIds
))
{
ServiceResponse
<
String
[]>
accountGroupIdValid
=
ValidSplitUtils
.
validStr
(
userResourceIds
);
if
(
accountGroupIdValid
.
isSuccess
())
{
accountGroupIdArr
=
accountGroupIdValid
.
getResult
();
}
else
{
return
ServiceResponse
.
failure
(
accountGroupIdValid
.
getCode
(),
accountGroupIdValid
.
getMessage
());
}
List
<
AccountGroupRelDTO
>
accountGroupRelDTOList
=
new
ArrayList
<>();
Date
now
=
new
Date
();
for
(
String
accountGroup
:
accountGroupIdArr
)
{
int
accountGroupId
=
Integer
.
parseInt
(
accountGroup
);
TabSysAccountGroup
tabSysAccountGroup
=
accountGroupService
.
getById
(
accountGroupId
);
if
(
tabSysAccountGroup
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组有误,无此数据"
);
}
AccountGroupRelDTO
accountGroupRelDTO
=
new
AccountGroupRelDTO
();
accountGroupRelDTO
.
setType
(
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
accountGroupRelDTO
.
setUserId
(
userId
);
accountGroupRelDTO
.
setAccountGroupId
(
accountGroupId
);
accountGroupRelDTO
.
setCreateTime
(
now
);
accountGroupRelDTO
.
setUpdateTime
(
now
);
accountGroupRelDTO
.
setEnterpriseId
(
enterpriseId
);
accountGroupRelDTO
.
setStatus
(
1
);
accountGroupRelDTOList
.
add
(
accountGroupRelDTO
);
}
accountGroupRelService
.
insertFetch
(
accountGroupRelDTOList
);
}
return
ServiceResponse
.
success
(
userId
);
}
...
...
gic-platform-auth-service/src/main/resources/mapper/TabSysAccountGroupRelMapper.xml
0 → 100644
View file @
9b496dd6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.gic.auth.dao.mapper.TabSysAccountGroupRelMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.auth.entity.TabSysAccountGroupRel"
>
<id
column=
"account_group_rel_id"
jdbcType=
"INTEGER"
property=
"accountGroupRelId"
/>
<result
column=
"account_group_id"
jdbcType=
"INTEGER"
property=
"accountGroupId"
/>
<result
column=
"user_id"
jdbcType=
"INTEGER"
property=
"userId"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"type"
jdbcType=
"INTEGER"
property=
"type"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
account_group_rel_id, account_group_id, user_id, enterprise_id, status, type, create_time,
update_time
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_account_group_rel
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from tab_sys_account_group_rel
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.auth.entity.TabSysAccountGroupRel"
>
insert into tab_sys_account_group_rel (account_group_rel_id, account_group_id,
user_id, enterprise_id, status,
type, create_time, update_time
)
values (#{accountGroupRelId,jdbcType=INTEGER}, #{accountGroupId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.auth.entity.TabSysAccountGroupRel"
>
insert into tab_sys_account_group_rel
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"accountGroupRelId != null"
>
account_group_rel_id,
</if>
<if
test=
"accountGroupId != null"
>
account_group_id,
</if>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"type != null"
>
type,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"accountGroupRelId != null"
>
#{accountGroupRelId,jdbcType=INTEGER},
</if>
<if
test=
"accountGroupId != null"
>
#{accountGroupId,jdbcType=INTEGER},
</if>
<if
test=
"userId != null"
>
#{userId,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
#{status,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.auth.entity.TabSysAccountGroupRel"
>
update tab_sys_account_group_rel
<set>
<if
test=
"accountGroupId != null"
>
account_group_id = #{accountGroupId,jdbcType=INTEGER},
</if>
<if
test=
"userId != null"
>
user_id = #{userId,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
status = #{status,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.auth.entity.TabSysAccountGroupRel"
>
update tab_sys_account_group_rel
set account_group_id = #{accountGroupId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</update>
<update
id=
"deleteByAccountGroupId"
>
update tab_sys_account_group_rel
set status = 0
where status = 1
and account_group_id = #{accountGroupId}
</update>
<insert
id=
"insertForeach"
parameterType=
"java.util.List"
>
insert into tab_sys_account_group_rel (account_group_rel_id, account_group_id,
user_id, enterprise_id, status,
type, create_time, update_time
)
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.accountGroupRelId},
#{item.accountGroupId},
#{item.userId},
#{item.enterpriseId},
#{item.status},
#{item.type},
#{item.createTime},
#{item.updateTime}
)
</foreach>
</insert>
<update
id=
"deleteByUserId"
>
update tab_sys_account_group_rel
set status = 0
where status = 1
and user_id = #{userId}
and type = #{type}
</update>
<select
id=
"listByUserId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_account_group_rel
where user_id = #{userId}
and status = 1
and type = #{type}
</select>
<update
id=
"deleteByAccountGroupIdAndUserId"
>
update tab_sys_account_group_rel
set status = 0
where status = 1
and user_id = #{userId}
and account_group_id = #{accountGroupId}
and type = #{type}
</update>
</mapper>
\ No newline at end of file
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/UserController.java
View file @
9b496dd6
...
...
@@ -87,4 +87,19 @@ public class UserController {
return
ResultControllerUtils
.
commonResult
(
userApiService
.
listUser
(
params
));
}
/**
* 逻辑删除用户对应分组数据
* @Title: removeUserAccountGroup
* @Description:
* @author guojuxing
* @param type
* @param accountGroupId
* @param userId
* @return com.gic.commons.webapi.reponse.RestResponse
*/
@RequestMapping
(
"/remove-user-account-group"
)
public
RestResponse
removeUserAccountGroup
(
Integer
type
,
Integer
accountGroupId
,
Integer
userId
)
{
return
ResultControllerUtils
.
commonResult
(
userApiService
.
removeAccountGroup
(
accountGroupId
,
userId
,
type
));
}
}
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