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
c6ee4a92
Commit
c6ee4a92
authored
Oct 31, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账号分组接口
parent
972f7180
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
273 additions
and
11 deletions
+273
-11
TabSysAccountGroupRelMapper.java
.../com/gic/auth/dao/mapper/TabSysAccountGroupRelMapper.java
+14
-0
TabSysUserMapper.java
...c/main/java/com/gic/auth/dao/mapper/TabSysUserMapper.java
+12
-1
AccountGroupRelService.java
...ain/java/com/gic/auth/service/AccountGroupRelService.java
+12
-0
UserService.java
...rvice/src/main/java/com/gic/auth/service/UserService.java
+10
-0
AccountGroupRelServiceImpl.java
...com/gic/auth/service/impl/AccountGroupRelServiceImpl.java
+15
-0
UserServiceImpl.java
.../main/java/com/gic/auth/service/impl/UserServiceImpl.java
+5
-0
AccountGroupApiServiceImpl.java
...c/auth/service/outer/impl/AccountGroupApiServiceImpl.java
+169
-10
TabSysAccountGroupRelMapper.xml
...src/main/resources/mapper/TabSysAccountGroupRelMapper.xml
+22
-0
TabSysUserMapper.xml
...th-service/src/main/resources/mapper/TabSysUserMapper.xml
+14
-0
No files found.
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabSysAccountGroupRelMapper.java
View file @
c6ee4a92
...
...
@@ -85,6 +85,9 @@ public interface TabSysAccountGroupRelMapper {
*/
void
deleteByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"type"
)
Integer
type
);
void
deleteByUserIdList
(
@Param
(
"userIdList"
)
List
<
Integer
>
userIdList
,
@Param
(
"type"
)
Integer
type
);
/**
* 查询用户分组列表数据
* @Title: listByUserId
...
...
@@ -106,4 +109,14 @@ public interface TabSysAccountGroupRelMapper {
* @return void
*/
void
deleteByAccountGroupIdAndUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"accountGroupId"
)
Integer
accountGroupId
,
@Param
(
"type"
)
Integer
type
);
/**
* 查询分组下的组员列表数据
* @Title: listByAccountGroupId
* @Description:
* @author guojuxing
* @param accountGroupId
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>
*/
List
<
TabSysAccountGroupRel
>
listByAccountGroupId
(
@Param
(
"accountGroupId"
)
Integer
accountGroupId
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/dao/mapper/TabSysUserMapper.java
View file @
c6ee4a92
...
...
@@ -97,5 +97,15 @@ public interface TabSysUserMapper {
Integer
countUserByUserIds
(
@Param
(
"ids"
)
List
<
Integer
>
userIdList
);
List
<
TabSysUser
>
listUserByIdList
(
@Param
(
"ids"
)
List
<
Integer
>
userIdList
);
List
<
TabSysUser
>
listUserByIdList
(
@Param
(
"ids"
)
List
<
Integer
>
userIdList
);
/**
* 查询不在范围内的用户
* @Title: listUserNotInIdList
* @Description:
* @author guojuxing
* @param userIdList
* @return java.util.List<com.gic.auth.entity.TabSysUser>
*/
List
<
TabSysUser
>
listUserNotInIdList
(
@Param
(
"ids"
)
List
<
Integer
>
userIdList
);
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/AccountGroupRelService.java
View file @
c6ee4a92
...
...
@@ -44,6 +44,8 @@ public interface AccountGroupRelService {
*/
void
deleteByUserId
(
Integer
userId
,
Integer
type
);
void
deleteByUserId
(
List
<
Integer
>
userId
,
Integer
type
);
/**
* 用户所在分组列表数据
* @Title: listByUserId
...
...
@@ -66,4 +68,14 @@ public interface AccountGroupRelService {
* @return void
*/
void
deleteByAccountGroupIdAndUserId
(
Integer
userId
,
Integer
accountGroupId
,
Integer
type
);
/**
* 查询分组下的组员
* @Title: listByAccountGroupId
* @Description:
* @author guojuxing
* @param accountGroupId
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>
*/
List
<
TabSysAccountGroupRel
>
listByAccountGroupId
(
Integer
accountGroupId
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/UserService.java
View file @
c6ee4a92
...
...
@@ -89,4 +89,14 @@ public interface UserService {
* @return java.util.List<com.gic.auth.entity.TabSysUser>
*/
List
<
TabSysUser
>
listUserByIdList
(
List
<
Integer
>
userIdList
);
/**
* 查询不在范围内的用户
* @Title: listUserNotInIdList
* @Description:
* @author guojuxing
* @param userIdList
* @return java.util.List<com.gic.auth.entity.TabSysUser>
*/
List
<
TabSysUser
>
listUserNotInIdList
(
List
<
Integer
>
userIdList
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/AccountGroupRelServiceImpl.java
View file @
c6ee4a92
...
...
@@ -20,6 +20,7 @@ public class AccountGroupRelServiceImpl implements AccountGroupRelService{
tabSysAccountGroupRelMapper
.
insertForeach
(
list
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
deleteByAccountGroupId
(
Integer
accountGroupId
)
{
tabSysAccountGroupRelMapper
.
deleteByAccountGroupId
(
accountGroupId
);
...
...
@@ -34,6 +35,15 @@ public class AccountGroupRelServiceImpl implements AccountGroupRelService{
tabSysAccountGroupRelMapper
.
deleteByUserId
(
userId
,
type
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
deleteByUserId
(
List
<
Integer
>
userId
,
Integer
type
)
{
if
(
type
==
null
)
{
type
=
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
();
}
tabSysAccountGroupRelMapper
.
deleteByUserIdList
(
userId
,
type
);
}
@Override
public
List
<
TabSysAccountGroupRel
>
listByUserId
(
Integer
userId
,
Integer
type
)
{
if
(
type
==
null
)
{
...
...
@@ -49,4 +59,9 @@ public class AccountGroupRelServiceImpl implements AccountGroupRelService{
}
tabSysAccountGroupRelMapper
.
deleteByAccountGroupIdAndUserId
(
userId
,
accountGroupId
,
type
);
}
@Override
public
List
<
TabSysAccountGroupRel
>
listByAccountGroupId
(
Integer
accountGroupId
)
{
return
tabSysAccountGroupRelMapper
.
listByAccountGroupId
(
accountGroupId
);
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/UserServiceImpl.java
View file @
c6ee4a92
...
...
@@ -104,4 +104,9 @@ public class UserServiceImpl implements UserService {
public
List
<
TabSysUser
>
listUserByIdList
(
List
<
Integer
>
userIdList
)
{
return
tabSysUserMapper
.
listUserByIdList
(
userIdList
);
}
@Override
public
List
<
TabSysUser
>
listUserNotInIdList
(
List
<
Integer
>
userIdList
)
{
return
tabSysUserMapper
.
listUserNotInIdList
(
userIdList
);
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/AccountGroupApiServiceImpl.java
View file @
c6ee4a92
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
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
com.gic.auth.dto.AccountGroupRelDTO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.constant.AccountGroupMemberTypeEnum
;
import
com.gic.auth.dto.AccountGroupDTO
;
import
com.gic.auth.dto.AccountGroupMemberDTO
;
import
com.gic.auth.entity.TabSysAccountGroup
;
import
com.gic.auth.entity.TabSysAccountGroupRel
;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.service.AccountGroupApiService
;
import
com.gic.auth.service.AccountGroupRelService
;
import
com.gic.auth.service.AccountGroupService
;
import
com.gic.auth.service.UserService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.utils.valid.ValidParamsUtils
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
(
"accountGroupApiService"
)
public
class
AccountGroupApiServiceImpl
implements
AccountGroupApiService
{
public
class
AccountGroupApiServiceImpl
implements
AccountGroupApiService
{
@Autowired
private
AccountGroupService
accountGroupService
;
@Autowired
private
AccountGroupRelService
accountGroupRelService
;
@Autowired
private
UserService
userService
;
@Override
public
ServiceResponse
<
Integer
>
save
(
AccountGroupDTO
dto
)
{
//参数校验
...
...
@@ -51,7 +61,8 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
if
(!
paramValid
.
isSuccess
())
{
return
paramValid
;
}
if
(
accountGroupService
.
isAccountGroupNameRepeat
(
dto
.
getEnterpriseId
(),
dto
.
getAccountGroupId
(),
dto
.
getAccountGroupName
()))
{
if
(
accountGroupService
.
isAccountGroupNameRepeat
(
dto
.
getEnterpriseId
(),
dto
.
getAccountGroupId
(),
dto
.
getAccountGroupName
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组名称不能重复"
);
}
dto
.
setEnterpriseId
(
record
.
getEnterpriseId
());
...
...
@@ -92,4 +103,152 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
accountGroupService
.
setSort
(
record
,
sort
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
List
<
AccountGroupMemberDTO
>>
listNotInAccountGroupByAccountGroupId
(
Integer
accountGroupId
)
{
TabSysAccountGroup
record
=
accountGroupService
.
getById
(
accountGroupId
);
if
(
record
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组id有误,查无数据"
);
}
List
<
AccountGroupMemberDTO
>
result
=
new
ArrayList
<>();
List
<
TabSysAccountGroupRel
>
list
=
listByAccountGroupId
(
accountGroupId
);
//查询管理员列表
result
.
addAll
(
getMemberOfUser
(
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
(),
list
,
false
));
//todo 查询协作人列表
return
ServiceResponse
.
success
(
result
);
}
@Override
public
ServiceResponse
<
List
<
AccountGroupMemberDTO
>>
listInAccountGroupByAccountGroupId
(
Integer
accountGroupId
)
{
TabSysAccountGroup
record
=
accountGroupService
.
getById
(
accountGroupId
);
if
(
record
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组id有误,查无数据"
);
}
List
<
AccountGroupMemberDTO
>
result
=
new
ArrayList
<>();
List
<
TabSysAccountGroupRel
>
list
=
listByAccountGroupId
(
accountGroupId
);
//查询管理员列表
result
.
addAll
(
getMemberOfUser
(
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
(),
list
,
true
));
//todo 查询协作人列表
return
ServiceResponse
.
success
(
result
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
ServiceResponse
<
Void
>
saveAccountGroupRelFetch
(
List
<
AccountGroupMemberDTO
>
list
)
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
//逻辑删除之前的数据,先删后增
accountGroupRelService
.
deleteByAccountGroupId
(
list
.
get
(
0
).
getAccountGroupId
());
List
<
AccountGroupRelDTO
>
result
=
new
ArrayList
<>(
list
.
size
());
Date
now
=
new
Date
();
for
(
AccountGroupMemberDTO
dto
:
list
)
{
AccountGroupRelDTO
temp
=
new
AccountGroupRelDTO
();
temp
.
setStatus
(
1
);
temp
.
setAccountGroupId
(
dto
.
getAccountGroupId
());
temp
.
setCreateTime
(
now
);
temp
.
setUpdateTime
(
now
);
temp
.
setUserId
(
dto
.
getUserId
());
temp
.
setType
(
dto
.
getType
());
temp
.
setEnterpriseId
(
dto
.
getEnterpriseId
());
result
.
add
(
temp
);
}
accountGroupRelService
.
insertFetch
(
result
);
}
return
ServiceResponse
.
success
();
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
ServiceResponse
<
Void
>
groupingOfUser
(
List
<
Integer
>
userIdList
,
List
<
Integer
>
accountGroupId
,
Integer
enterpriseId
)
{
return
grouping
(
userIdList
,
accountGroupId
,
enterpriseId
,
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
ServiceResponse
<
Void
>
groupingOfCollaborator
(
List
<
Integer
>
collaboratorIdList
,
List
<
Integer
>
accountGroupId
,
Integer
enterpriseId
)
{
return
grouping
(
collaboratorIdList
,
accountGroupId
,
enterpriseId
,
AccountGroupMemberTypeEnum
.
COLLABORATOR
.
getCode
());
}
/**
* 查询分组下的组员列表数据
* @param accountGroupId
* @return
*/
private
List
<
TabSysAccountGroupRel
>
listByAccountGroupId
(
Integer
accountGroupId
)
{
return
accountGroupRelService
.
listByAccountGroupId
(
accountGroupId
);
}
private
List
<
Integer
>
getUserIdList
(
int
type
,
List
<
TabSysAccountGroupRel
>
accountGroupRelList
)
{
List
<
Integer
>
userIdList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
accountGroupRelList
))
{
for
(
TabSysAccountGroupRel
rel
:
accountGroupRelList
)
{
if
(
rel
.
getType
().
intValue
()
==
type
)
{
userIdList
.
add
(
rel
.
getUserId
());
}
else
if
(
rel
.
getType
().
intValue
()
==
type
)
{
userIdList
.
add
(
rel
.
getUserId
());
}
}
}
return
userIdList
;
}
/**
* 获取管理员列表
* @param type
* @param accountGroupRelList
* @param isIn 是否在分组内
* @return
*/
private
List
<
AccountGroupMemberDTO
>
getMemberOfUser
(
int
type
,
List
<
TabSysAccountGroupRel
>
accountGroupRelList
,
boolean
isIn
)
{
List
<
Integer
>
userIdList
=
getUserIdList
(
type
,
accountGroupRelList
);
List
<
TabSysUser
>
userList
;
//查询管理员列表
if
(
isIn
)
{
userList
=
userService
.
listUserByIdList
(
userIdList
);
}
else
{
userList
=
userService
.
listUserNotInIdList
(
userIdList
);
}
return
userToMember
(
userList
);
}
private
List
<
AccountGroupMemberDTO
>
userToMember
(
List
<
TabSysUser
>
userList
)
{
List
<
AccountGroupMemberDTO
>
result
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
for
(
TabSysUser
user
:
userList
)
{
AccountGroupMemberDTO
dto
=
new
AccountGroupMemberDTO
();
dto
.
setMemberName
(
user
.
getUserName
());
dto
.
setUserId
(
user
.
getUserId
());
dto
.
setPhone
(
user
.
getPhoneNumber
());
dto
.
setType
(
AccountGroupMemberTypeEnum
.
ADMIN
.
getCode
());
result
.
add
(
dto
);
}
}
return
result
;
}
private
ServiceResponse
<
Void
>
grouping
(
List
<
Integer
>
userIdList
,
List
<
Integer
>
accountGroupId
,
Integer
enterpriseId
,
int
type
)
{
//先删除
accountGroupRelService
.
deleteByUserId
(
userIdList
,
type
);
Date
now
=
new
Date
();
for
(
Integer
groupId
:
accountGroupId
)
{
List
<
AccountGroupRelDTO
>
result
=
new
ArrayList
<>();
for
(
Integer
userId
:
userIdList
)
{
AccountGroupRelDTO
temp
=
new
AccountGroupRelDTO
();
temp
.
setStatus
(
1
);
temp
.
setAccountGroupId
(
groupId
);
temp
.
setCreateTime
(
now
);
temp
.
setUpdateTime
(
now
);
temp
.
setUserId
(
userId
);
temp
.
setType
(
type
);
temp
.
setEnterpriseId
(
enterpriseId
);
result
.
add
(
temp
);
}
accountGroupRelService
.
insertFetch
(
result
);
}
return
ServiceResponse
.
success
();
}
}
gic-platform-auth-service/src/main/resources/mapper/TabSysAccountGroupRelMapper.xml
View file @
c6ee4a92
...
...
@@ -163,6 +163,19 @@
and type = #{type}
</update>
<update
id=
"deleteByUserIdList"
>
update tab_sys_account_group_rel
set status = 0
where status = 1
<if
test=
"userIdList != null and userIdList.size() > 0"
>
and user_id in
<foreach
collection=
"userIdList"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
and type = #{type}
</update>
<select
id=
"listByUserId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
@@ -180,4 +193,12 @@
and account_group_id = #{accountGroupId}
and type = #{type}
</update>
<select
id=
"listByAccountGroupId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_account_group_rel
where account_group_id = #{accountGroupId}
and status = 1
</select>
</mapper>
\ No newline at end of file
gic-platform-auth-service/src/main/resources/mapper/TabSysUserMapper.xml
View file @
c6ee4a92
...
...
@@ -301,4 +301,17 @@
</foreach>
</if>
</select>
<select
id=
"listUserNotInIdList"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_user
where status = 1
<if
test=
"ids != null and ids.size() > 0"
>
and user_id not in
<foreach
collection=
"ids"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
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