Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-data-cloud
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-data-cloud
Commits
5dfc6a2b
Commit
5dfc6a2b
authored
Jul 07, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户列表接口
parent
037182f5
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1099 additions
and
4 deletions
+1099
-4
UserDTO.java
...ta-cloud-api/src/main/java/com/gic/cloud/dto/UserDTO.java
+180
-0
PageQO.java
...data-cloud-api/src/main/java/com/gic/cloud/qo/PageQO.java
+46
-0
UserQO.java
...data-cloud-api/src/main/java/com/gic/cloud/qo/UserQO.java
+74
-0
UserApiService.java
...i/src/main/java/com/gic/cloud/service/UserApiService.java
+64
-0
TabSysUserMapper.java
.../main/java/com/gic/cloud/dao/mapper/TabSysUserMapper.java
+74
-0
TabSysUser.java
...ervice/src/main/java/com/gic/cloud/entity/TabSysUser.java
+163
-0
UserService.java
...vice/src/main/java/com/gic/cloud/service/UserService.java
+37
-0
AccountGroupServiceImpl.java
...a/com/gic/cloud/service/impl/AccountGroupServiceImpl.java
+2
-1
UserServiceImpl.java
...main/java/com/gic/cloud/service/impl/UserServiceImpl.java
+82
-0
AccountGroupApiServiceImpl.java
.../cloud/service/outer/impl/AccountGroupApiServiceImpl.java
+17
-3
UserApiServiceImpl.java
.../com/gic/cloud/service/outer/impl/UserApiServiceImpl.java
+133
-0
TabSysUserMapper.xml
...ud-service/src/main/resources/mapper/TabSysUserMapper.xml
+227
-0
No files found.
gic-data-cloud-api/src/main/java/com/gic/cloud/dto/UserDTO.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
dto
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 用户
* @ClassName: UserDTO
* @Description:
* @author guojuxing
* @date 2020/7/6 4:19 PM
*/
public
class
UserDTO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
4014902960332875554L
;
/**
* ID
*/
private
Integer
userId
;
/**
* 名称
*/
private
String
userName
;
/**
*
*/
private
Integer
enterpriseId
;
/**
* 手机号
*/
private
String
phone
;
/**
* 手机号区号
*/
private
String
nationCode
;
/**
* 账号分组ID
*/
private
Integer
accountGroupId
;
/**
* 数据权限集ID
*/
private
Integer
dataAuthId
;
/**
* 功能权限集ID
*/
private
Integer
functionAuthId
;
/**
* 1:有效 0:无效
*/
private
Integer
status
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
private
Integer
memberCount
;
public
Integer
getUserId
()
{
return
userId
;
}
public
UserDTO
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
return
this
;
}
public
String
getUserName
()
{
return
userName
;
}
public
UserDTO
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
return
this
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
UserDTO
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
return
this
;
}
public
String
getPhone
()
{
return
phone
;
}
public
UserDTO
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
return
this
;
}
public
String
getNationCode
()
{
return
nationCode
;
}
public
UserDTO
setNationCode
(
String
nationCode
)
{
this
.
nationCode
=
nationCode
;
return
this
;
}
public
Integer
getAccountGroupId
()
{
return
accountGroupId
;
}
public
UserDTO
setAccountGroupId
(
Integer
accountGroupId
)
{
this
.
accountGroupId
=
accountGroupId
;
return
this
;
}
public
Integer
getDataAuthId
()
{
return
dataAuthId
;
}
public
UserDTO
setDataAuthId
(
Integer
dataAuthId
)
{
this
.
dataAuthId
=
dataAuthId
;
return
this
;
}
public
Integer
getFunctionAuthId
()
{
return
functionAuthId
;
}
public
UserDTO
setFunctionAuthId
(
Integer
functionAuthId
)
{
this
.
functionAuthId
=
functionAuthId
;
return
this
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
UserDTO
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
return
this
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
UserDTO
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
return
this
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
UserDTO
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
return
this
;
}
public
Integer
getMemberCount
()
{
return
memberCount
;
}
public
UserDTO
setMemberCount
(
Integer
memberCount
)
{
this
.
memberCount
=
memberCount
;
return
this
;
}
}
gic-data-cloud-api/src/main/java/com/gic/cloud/qo/PageQO.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
qo
;
import
java.io.Serializable
;
/**
* 分页数据
* @ClassName: PageQO
* @Description:
* @author guojuxing
* @date 2019/8/13 11:29 AM
*/
public
class
PageQO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 页码
*/
private
Integer
currentPage
=
1
;
/**
* 分页大小
*/
private
Integer
pageSize
=
20
;
public
Integer
getCurrentPage
()
{
if
(
currentPage
==
null
)
{
currentPage
=
1
;
}
return
currentPage
;
}
public
void
setCurrentPage
(
Integer
currentPage
)
{
this
.
currentPage
=
currentPage
;
}
public
Integer
getPageSize
()
{
if
(
pageSize
==
null
)
{
pageSize
=
20
;
}
return
pageSize
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
}
gic-data-cloud-api/src/main/java/com/gic/cloud/qo/UserQO.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
qo
;
import
java.io.Serializable
;
public
class
UserQO
extends
PageQO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
2145306520376748998L
;
/**
* 名称/手机号
*/
private
String
search
;
private
Integer
enterpriseId
;
/**
* 账号分组ID
*/
private
Integer
accountGroupId
;
/**
* 数据权限集ID
*/
private
Integer
dataAuthId
;
/**
* 功能权限集ID
*/
private
Integer
functionAuthId
;
public
String
getSearch
()
{
return
search
;
}
public
UserQO
setSearch
(
String
search
)
{
this
.
search
=
search
;
return
this
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
UserQO
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
return
this
;
}
public
Integer
getAccountGroupId
()
{
return
accountGroupId
;
}
public
UserQO
setAccountGroupId
(
Integer
accountGroupId
)
{
this
.
accountGroupId
=
accountGroupId
;
return
this
;
}
public
Integer
getDataAuthId
()
{
return
dataAuthId
;
}
public
UserQO
setDataAuthId
(
Integer
dataAuthId
)
{
this
.
dataAuthId
=
dataAuthId
;
return
this
;
}
public
Integer
getFunctionAuthId
()
{
return
functionAuthId
;
}
public
UserQO
setFunctionAuthId
(
Integer
functionAuthId
)
{
this
.
functionAuthId
=
functionAuthId
;
return
this
;
}
}
gic-data-cloud-api/src/main/java/com/gic/cloud/service/UserApiService.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
service
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.qo.UserQO
;
import
java.util.List
;
public
interface
UserApiService
{
/**
* 新增
* @Title: saveUser
* @Description:
* @author guojuxing
* @param dto
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
*/
ServiceResponse
<
Integer
>
saveUser
(
UserDTO
dto
);
/**
* 编辑
* @Title: editUser
* @Description:
* @author guojuxing
* @param dto
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
*/
ServiceResponse
<
Void
>
editUser
(
UserDTO
dto
);
ServiceResponse
<
Void
>
deleteUser
(
Integer
userId
);
/**
* 删除账号分组下的所有用户
* @Title: deleteUserByAccountGroupid
* @Description:
* @author guojuxing
* @param accountGroupId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
*/
ServiceResponse
<
Void
>
deleteUserByAccountGroupId
(
Integer
accountGroupId
);
/**
* 分页查询用户列表
* @Title: pageUser
* @Description:
* @author guojuxing
* @param userQO
* @return com.gic.api.base.commons.ServiceResponse<com.gic.api.base.commons.Page<com.gic.cloud.dto.UserDTO>>
*/
ServiceResponse
<
Page
<
UserDTO
>>
pageUser
(
UserQO
userQO
);
/**
* 批量转移分组
* @Title: bulkTransferAccountGroup
* @Description:
* @author guojuxing
* @param userIdList
* @param targetAccountGroupId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
*/
ServiceResponse
<
Void
>
bulkTransferAccountGroup
(
List
<
Integer
>
userIdList
,
Integer
targetAccountGroupId
);
}
gic-data-cloud-service/src/main/java/com/gic/cloud/dao/mapper/TabSysUserMapper.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
dao
.
mapper
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.entity.TabSysUser
;
import
com.gic.cloud.qo.UserQO
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
TabSysUserMapper
{
/**
* 根据主键删除
*
* @param userId 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
userId
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
TabSysUser
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
TabSysUser
record
);
/**
* 根据主键查询
*
* @param userId 主键
* @return 实体对象
*/
TabSysUser
selectByPrimaryKey
(
Integer
userId
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
TabSysUser
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabSysUser
record
);
int
countByRepeatPhone
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"nationCode"
)
String
nationCode
,
@Param
(
"phone"
)
String
phone
);
void
deleteUser
(
@Param
(
"userId"
)
Integer
userId
);
void
deleteUserByAccountGroupId
(
@Param
(
"accountGroupId"
)
Integer
accountGroupId
);
List
<
TabSysUser
>
pageUser
(
UserQO
userQO
);
void
bulkTransferAccountGroup
(
@Param
(
"userIdList"
)
List
<
Integer
>
userIdList
,
@Param
(
"targetAccountGroupId"
)
Integer
targetAccountGroupId
);
List
<
UserDTO
>
countGroupByAccountGroupId
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
}
\ No newline at end of file
gic-data-cloud-service/src/main/java/com/gic/cloud/entity/TabSysUser.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
entity
;
import
java.util.Date
;
/**
* tab_sys_user
*/
public
class
TabSysUser
{
/**
* ID
*/
private
Integer
userId
;
/**
* 名称
*/
private
String
userName
;
/**
*
*/
private
Integer
enterpriseId
;
/**
* 手机号
*/
private
String
phone
;
/**
* 手机号区号
*/
private
String
nationCode
;
/**
* 账号分组ID
*/
private
Integer
accountGroupId
;
/**
* 数据权限集ID
*/
private
Integer
dataAuthId
;
/**
* 功能权限集ID
*/
private
Integer
functionAuthId
;
/**
* 1:有效 0:无效
*/
private
Integer
status
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
Integer
getUserId
()
{
return
userId
;
}
public
TabSysUser
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
return
this
;
}
public
String
getUserName
()
{
return
userName
;
}
public
TabSysUser
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
return
this
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
TabSysUser
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
return
this
;
}
public
String
getPhone
()
{
return
phone
;
}
public
TabSysUser
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
return
this
;
}
public
String
getNationCode
()
{
return
nationCode
;
}
public
TabSysUser
setNationCode
(
String
nationCode
)
{
this
.
nationCode
=
nationCode
;
return
this
;
}
public
Integer
getAccountGroupId
()
{
return
accountGroupId
;
}
public
TabSysUser
setAccountGroupId
(
Integer
accountGroupId
)
{
this
.
accountGroupId
=
accountGroupId
;
return
this
;
}
public
Integer
getDataAuthId
()
{
return
dataAuthId
;
}
public
TabSysUser
setDataAuthId
(
Integer
dataAuthId
)
{
this
.
dataAuthId
=
dataAuthId
;
return
this
;
}
public
Integer
getFunctionAuthId
()
{
return
functionAuthId
;
}
public
TabSysUser
setFunctionAuthId
(
Integer
functionAuthId
)
{
this
.
functionAuthId
=
functionAuthId
;
return
this
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
TabSysUser
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
return
this
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
TabSysUser
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
return
this
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
TabSysUser
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
return
this
;
}
}
\ No newline at end of file
gic-data-cloud-service/src/main/java/com/gic/cloud/service/UserService.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
service
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.entity.TabSysUser
;
import
com.gic.cloud.qo.UserQO
;
import
com.github.pagehelper.Page
;
import
java.util.List
;
public
interface
UserService
{
Integer
saveUser
(
UserDTO
dto
);
void
editUser
(
UserDTO
dto
);
TabSysUser
getUser
(
Integer
userId
);
boolean
isRepeatPhone
(
Integer
enterpriseId
,
Integer
userId
,
String
nationCode
,
String
phone
);
void
deleteUser
(
Integer
userId
);
/**
* 删除账号分组下的所有用户
* @Title: deleteUserByAccountGroupid
* @Description:
* @author guojuxing
* @param accountGroupId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
*/
void
deleteUserByAccountGroupId
(
Integer
accountGroupId
);
Page
<
TabSysUser
>
pageUser
(
UserQO
userQO
);
void
bulkTransferAccountGroup
(
List
<
Integer
>
userIdList
,
Integer
targetAccountGroupId
);
List
<
UserDTO
>
countGroupByAccountGroupId
(
Integer
enterpriseId
);
}
gic-data-cloud-service/src/main/java/com/gic/cloud/service/impl/AccountGroupServiceImpl.java
View file @
5dfc6a2b
...
@@ -24,7 +24,8 @@ public class AccountGroupServiceImpl implements AccountGroupService{
...
@@ -24,7 +24,8 @@ public class AccountGroupServiceImpl implements AccountGroupService{
dto
.
setCreateTime
(
now
);
dto
.
setCreateTime
(
now
);
dto
.
setStatus
(
1
);
dto
.
setStatus
(
1
);
TabSysAccountGroup
record
=
EntityUtil
.
changeEntityNew
(
TabSysAccountGroup
.
class
,
dto
);
TabSysAccountGroup
record
=
EntityUtil
.
changeEntityNew
(
TabSysAccountGroup
.
class
,
dto
);
return
tabSysAccountGroupMapper
.
insert
(
record
);
tabSysAccountGroupMapper
.
insert
(
record
);
return
record
.
getAccountGroupId
();
}
}
@Override
@Override
...
...
gic-data-cloud-service/src/main/java/com/gic/cloud/service/impl/UserServiceImpl.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
service
.
impl
;
import
com.gic.cloud.dao.mapper.TabSysUserMapper
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.entity.TabSysUser
;
import
com.gic.cloud.qo.UserQO
;
import
com.gic.cloud.service.UserService
;
import
com.gic.commons.util.EntityUtil
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
@Service
(
"userService"
)
public
class
UserServiceImpl
implements
UserService
{
@Autowired
private
TabSysUserMapper
tabSysUserMapper
;
@Override
public
Integer
saveUser
(
UserDTO
dto
)
{
TabSysUser
record
=
EntityUtil
.
changeEntityNew
(
TabSysUser
.
class
,
dto
);
Date
now
=
new
Date
();
record
.
setStatus
(
1
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
tabSysUserMapper
.
insert
(
record
);
return
record
.
getUserId
();
}
@Override
public
void
editUser
(
UserDTO
dto
)
{
TabSysUser
record
=
EntityUtil
.
changeEntityNew
(
TabSysUser
.
class
,
dto
);
record
.
setUpdateTime
(
new
Date
());
tabSysUserMapper
.
updateByPrimaryKeySelective
(
record
);
}
@Override
public
TabSysUser
getUser
(
Integer
userId
)
{
return
tabSysUserMapper
.
selectByPrimaryKey
(
userId
);
}
@Override
public
boolean
isRepeatPhone
(
Integer
enterpriseId
,
Integer
userId
,
String
nationCode
,
String
phone
)
{
if
(
tabSysUserMapper
.
countByRepeatPhone
(
enterpriseId
,
userId
,
nationCode
,
phone
)
>
0
)
{
return
true
;
}
return
false
;
}
@Override
public
void
deleteUser
(
Integer
userId
)
{
tabSysUserMapper
.
deleteUser
(
userId
);
}
@Override
public
void
deleteUserByAccountGroupId
(
Integer
accountGroupId
)
{
tabSysUserMapper
.
deleteUserByAccountGroupId
(
accountGroupId
);
}
@Override
public
Page
<
TabSysUser
>
pageUser
(
UserQO
userQO
)
{
PageHelper
.
startPage
(
userQO
.
getCurrentPage
(),
userQO
.
getPageSize
());
return
(
Page
<
TabSysUser
>)
tabSysUserMapper
.
pageUser
(
userQO
);
}
@Override
public
void
bulkTransferAccountGroup
(
List
<
Integer
>
userIdList
,
Integer
targetAccountGroupId
)
{
if
(
CollectionUtils
.
isEmpty
(
userIdList
))
{
return
;
}
tabSysUserMapper
.
bulkTransferAccountGroup
(
userIdList
,
targetAccountGroupId
);
}
@Override
public
List
<
UserDTO
>
countGroupByAccountGroupId
(
Integer
enterpriseId
)
{
return
tabSysUserMapper
.
countGroupByAccountGroupId
(
enterpriseId
);
}
}
gic-data-cloud-service/src/main/java/com/gic/cloud/service/outer/impl/AccountGroupApiServiceImpl.java
View file @
5dfc6a2b
...
@@ -2,9 +2,11 @@ package com.gic.cloud.service.outer.impl;
...
@@ -2,9 +2,11 @@ package com.gic.cloud.service.outer.impl;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.cloud.dto.AccountGroupDTO
;
import
com.gic.cloud.dto.AccountGroupDTO
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.entity.TabSysAccountGroup
;
import
com.gic.cloud.entity.TabSysAccountGroup
;
import
com.gic.cloud.service.AccountGroupApiService
;
import
com.gic.cloud.service.AccountGroupApiService
;
import
com.gic.cloud.service.AccountGroupService
;
import
com.gic.cloud.service.AccountGroupService
;
import
com.gic.cloud.service.UserService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.error.ErrorCode
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -14,11 +16,15 @@ import org.springframework.stereotype.Service;
...
@@ -14,11 +16,15 @@ import org.springframework.stereotype.Service;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
(
"accountGroupApiService"
)
@Service
(
"accountGroupApiService"
)
public
class
AccountGroupApiServiceImpl
implements
AccountGroupApiService
{
public
class
AccountGroupApiServiceImpl
implements
AccountGroupApiService
{
@Autowired
@Autowired
private
AccountGroupService
accountGroupService
;
private
AccountGroupService
accountGroupService
;
@Autowired
private
UserService
userService
;
@Override
@Override
public
ServiceResponse
<
Integer
>
saveAccountGroup
(
AccountGroupDTO
dto
)
{
public
ServiceResponse
<
Integer
>
saveAccountGroup
(
AccountGroupDTO
dto
)
{
...
@@ -76,8 +82,15 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
...
@@ -76,8 +82,15 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
public
ServiceResponse
<
List
<
AccountGroupDTO
>>
listAccountGroupOfCountMember
(
Integer
enterpriseId
)
{
public
ServiceResponse
<
List
<
AccountGroupDTO
>>
listAccountGroupOfCountMember
(
Integer
enterpriseId
)
{
List
<
TabSysAccountGroup
>
list
=
accountGroupService
.
listAccountGroupOrderBySort
(
enterpriseId
);
List
<
TabSysAccountGroup
>
list
=
accountGroupService
.
listAccountGroupOrderBySort
(
enterpriseId
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
//todo 统计用户数量
List
<
AccountGroupDTO
>
result
=
EntityUtil
.
changeEntityListNew
(
AccountGroupDTO
.
class
,
list
);
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityListNew
(
AccountGroupDTO
.
class
,
list
));
//统计用户数量
List
<
UserDTO
>
userList
=
userService
.
countGroupByAccountGroupId
(
enterpriseId
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
Map
<
String
,
Integer
>
map
=
userList
.
stream
()
.
collect
(
Collectors
.
toMap
(
e
->
e
.
getAccountGroupId
().
toString
(),
e
->
e
.
getMemberCount
()));
result
.
forEach
(
e
->
e
.
setMemberCount
(
map
.
get
(
e
.
getAccountGroupId
().
toString
())));
}
return
ServiceResponse
.
success
(
result
);
}
}
return
ServiceResponse
.
success
(
Collections
.
emptyList
());
return
ServiceResponse
.
success
(
Collections
.
emptyList
());
}
}
...
@@ -89,7 +102,8 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
...
@@ -89,7 +102,8 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组ID错误,查无数据"
);
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组ID错误,查无数据"
);
}
}
accountGroupService
.
deleteAccountGroup
(
accountGroupId
);
accountGroupService
.
deleteAccountGroup
(
accountGroupId
);
//todo 删除分组下的用户
//删除分组下的用户
userService
.
deleteUserByAccountGroupId
(
accountGroupId
);
return
ServiceResponse
.
success
();
return
ServiceResponse
.
success
();
}
}
}
}
gic-data-cloud-service/src/main/java/com/gic/cloud/service/outer/impl/UserApiServiceImpl.java
0 → 100644
View file @
5dfc6a2b
package
com
.
gic
.
cloud
.
service
.
outer
.
impl
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.cloud.dto.UserDTO
;
import
com.gic.cloud.entity.TabSysAccountGroup
;
import
com.gic.cloud.entity.TabSysUser
;
import
com.gic.cloud.qo.UserQO
;
import
com.gic.cloud.service.AccountGroupService
;
import
com.gic.cloud.service.UserApiService
;
import
com.gic.cloud.service.UserService
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.enterprise.constants.Constants
;
import
com.gic.enterprise.error.ErrorCode
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Service
(
"userApiService"
)
public
class
UserApiServiceImpl
implements
UserApiService
{
@Autowired
private
UserService
userService
;
@Autowired
private
AccountGroupService
accountGroupService
;
@Override
public
ServiceResponse
<
Integer
>
saveUser
(
UserDTO
dto
)
{
dto
.
setUserId
(
null
);
ServiceResponse
validParamResult
=
validParam
(
dto
);
if
(!
validParamResult
.
isSuccess
())
{
return
ServiceResponse
.
failure
(
validParamResult
.
getCode
(),
validParamResult
.
getMessage
());
}
return
ServiceResponse
.
success
(
userService
.
saveUser
(
dto
));
}
@Override
public
ServiceResponse
<
Void
>
editUser
(
UserDTO
dto
)
{
ServiceResponse
validParamResult
=
validParam
(
dto
);
if
(!
validParamResult
.
isSuccess
())
{
return
ServiceResponse
.
failure
(
validParamResult
.
getCode
(),
validParamResult
.
getMessage
());
}
userService
.
editUser
(
dto
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Void
>
deleteUser
(
Integer
userId
)
{
userService
.
deleteUser
(
userId
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Void
>
deleteUserByAccountGroupId
(
Integer
accountGroupId
)
{
userService
.
deleteUserByAccountGroupId
(
accountGroupId
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Page
<
UserDTO
>>
pageUser
(
UserQO
userQO
)
{
com
.
github
.
pagehelper
.
Page
page
=
userService
.
pageUser
(
userQO
);
Page
<
UserDTO
>
resultPage
=
PageHelperUtils
.
changePageHelperToCurrentPage
(
page
,
UserDTO
.
class
);
return
ServiceResponse
.
success
(
resultPage
);
}
@Override
public
ServiceResponse
<
Void
>
bulkTransferAccountGroup
(
List
<
Integer
>
userIdList
,
Integer
targetAccountGroupId
)
{
TabSysAccountGroup
accountGroup
=
accountGroupService
.
getAccountGroupById
(
targetAccountGroupId
);
if
(
accountGroup
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组不存在"
);
}
userService
.
bulkTransferAccountGroup
(
userIdList
,
targetAccountGroupId
);
return
ServiceResponse
.
success
();
}
private
ServiceResponse
<
Void
>
validParam
(
UserDTO
dto
)
{
if
(
dto
.
getUserId
()
!=
null
)
{
TabSysUser
record
=
userService
.
getUser
(
dto
.
getUserId
());
if
(
record
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户ID不能为空"
);
}
dto
.
setEnterpriseId
(
record
.
getEnterpriseId
());
}
Integer
enterpriseId
=
dto
.
getEnterpriseId
();
if
(
enterpriseId
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户ID不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getUserName
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户名称不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getNationCode
()))
{
dto
.
setNationCode
(
Constants
.
NATION_CODE
);
}
if
(
dto
.
getNationCode
().
equals
(
Constants
.
NATION_CODE
)
&&
!
isPhone
(
dto
.
getPhone
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"手机号码非法"
);
}
if
(!
dto
.
getNationCode
().
equals
(
Constants
.
NATION_CODE
)
&&
StringUtils
.
isBlank
(
dto
.
getPhone
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"手机号码不能为空"
);
}
if
(
userService
.
isRepeatPhone
(
enterpriseId
,
dto
.
getUserId
(),
dto
.
getNationCode
(),
dto
.
getPhone
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"手机号码重复"
);
}
if
(
dto
.
getAccountGroupId
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"账号分组不能为空"
);
}
if
(
dto
.
getDataAuthId
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"数据权限集不能为空"
);
}
if
(
dto
.
getFunctionAuthId
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"功能权限集不能为空"
);
}
return
ServiceResponse
.
success
();
}
private
static
boolean
isPhone
(
String
phone
)
{
String
regex
=
"^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$"
;
if
(
StringUtils
.
isBlank
(
phone
)
||
phone
.
length
()
!=
11
)
{
return
false
;
}
else
{
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
phone
);
boolean
isMatch
=
m
.
matches
();
if
(
isMatch
)
{
return
true
;
}
else
{
return
false
;
}
}
}
}
gic-data-cloud-service/src/main/resources/mapper/TabSysUserMapper.xml
0 → 100644
View file @
5dfc6a2b
<?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.cloud.dao.mapper.TabSysUserMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.cloud.entity.TabSysUser"
>
<id
column=
"user_id"
jdbcType=
"INTEGER"
property=
"userId"
/>
<result
column=
"user_name"
jdbcType=
"VARCHAR"
property=
"userName"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
<result
column=
"phone"
jdbcType=
"VARCHAR"
property=
"phone"
/>
<result
column=
"nation_code"
jdbcType=
"VARCHAR"
property=
"nationCode"
/>
<result
column=
"account_group_id"
jdbcType=
"INTEGER"
property=
"accountGroupId"
/>
<result
column=
"data_auth_id"
jdbcType=
"INTEGER"
property=
"dataAuthId"
/>
<result
column=
"function_auth_id"
jdbcType=
"INTEGER"
property=
"functionAuthId"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
user_id, user_name, enterprise_id, phone, nation_code, account_group_id, data_auth_id,
function_auth_id, status, create_time, update_time
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_sys_user
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from tab_sys_user
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.cloud.entity.TabSysUser"
useGeneratedKeys=
"true"
keyProperty=
"userId"
>
insert into tab_sys_user (user_id, user_name, enterprise_id,
phone, nation_code, account_group_id,
data_auth_id, function_auth_id, status,
create_time, update_time)
values (#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=INTEGER},
#{phone,jdbcType=VARCHAR}, #{nationCode,jdbcType=VARCHAR}, #{accountGroupId,jdbcType=INTEGER},
#{dataAuthId,jdbcType=INTEGER}, #{functionAuthId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.cloud.entity.TabSysUser"
>
insert into tab_sys_user
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"userName != null"
>
user_name,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
<if
test=
"phone != null"
>
phone,
</if>
<if
test=
"nationCode != null"
>
nation_code,
</if>
<if
test=
"accountGroupId != null"
>
account_group_id,
</if>
<if
test=
"dataAuthId != null"
>
data_auth_id,
</if>
<if
test=
"functionAuthId != null"
>
function_auth_id,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
#{userId,jdbcType=INTEGER},
</if>
<if
test=
"userName != null"
>
#{userName,jdbcType=VARCHAR},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"phone != null"
>
#{phone,jdbcType=VARCHAR},
</if>
<if
test=
"nationCode != null"
>
#{nationCode,jdbcType=VARCHAR},
</if>
<if
test=
"accountGroupId != null"
>
#{accountGroupId,jdbcType=INTEGER},
</if>
<if
test=
"dataAuthId != null"
>
#{dataAuthId,jdbcType=INTEGER},
</if>
<if
test=
"functionAuthId != null"
>
#{functionAuthId,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
#{status,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.cloud.entity.TabSysUser"
>
update tab_sys_user
<set>
<if
test=
"userName != null"
>
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if
test=
"phone != null"
>
phone = #{phone,jdbcType=VARCHAR},
</if>
<if
test=
"nationCode != null"
>
nation_code = #{nationCode,jdbcType=VARCHAR},
</if>
<if
test=
"accountGroupId != null"
>
account_group_id = #{accountGroupId,jdbcType=INTEGER},
</if>
<if
test=
"dataAuthId != null"
>
data_auth_id = #{dataAuthId,jdbcType=INTEGER},
</if>
<if
test=
"functionAuthId != null"
>
function_auth_id = #{functionAuthId,jdbcType=INTEGER},
</if>
<if
test=
"status != null"
>
status = #{status,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 user_id = #{userId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.cloud.entity.TabSysUser"
>
update tab_sys_user
set user_name = #{userName,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
phone = #{phone,jdbcType=VARCHAR},
nation_code = #{nationCode,jdbcType=VARCHAR},
account_group_id = #{accountGroupId,jdbcType=INTEGER},
data_auth_id = #{dataAuthId,jdbcType=INTEGER},
function_auth_id = #{functionAuthId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<select
id=
"countByRepeatPhone"
resultType=
"int"
>
select count(1) from tab_sys_user
where enterprise_id = #{enterpriseId}
and nation_code = #{nationCode}
and phone = #{phone}
<if
test=
"userId != null"
>
and user_id
<>
#{userId}
</if>
and status = 1
</select>
<update
id=
"deleteUser"
>
update tab_sys_user set status = 0
where user_id = #{userId}
and status = 1
</update>
<update
id=
"deleteUserByAccountGroupId"
>
update tab_sys_user set status = 0
where account_group_id = #{accountGroupId}
and status = 1
</update>
<select
id=
"pageUser"
parameterType=
"com.gic.cloud.qo.UserQO"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
></include>
from tab_sys_user
where status = 1
<if
test=
"enterpriseId != null"
>
and enterprise_id = #{enterpriseId}
</if>
<if
test=
"search != null and search != ''"
>
and (user_name like concat('%', #{search}, '%') or phone like concat('%', #{search}, '%'))
</if>
<if
test=
"accountGroupId != null"
>
and account_group_id = #{accountGroupId}
</if>
<if
test=
"dataAuthId != null"
>
and data_auth_id = #{dataAuthId}
</if>
<if
test=
"functionAuthId != null"
>
and function_auth_id = #{functionAuthId}
</if>
order by create_time desc
</select>
<update
id=
"bulkTransferAccountGroup"
>
update tab_sys_user set account_group_id = #{targetAccountGroupId}
where status = 1
and user_id in
<foreach
collection=
"userIdList"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</update>
<select
id=
"countGroupByAccountGroupId"
resultType=
"com.gic.cloud.dto.UserDTO"
>
select account_group_id accountGroupId, count(user_id) memberCount
from tab_sys_user
where enterprise_id = #{enterpriseId}
and status = 1
group by account_group_id
</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