Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-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
黄营
datax-cloud
Commits
225f31d5
Commit
225f31d5
authored
Mar 19, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
2e99c473
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
51 additions
and
171 deletions
+51
-171
AuthorizationServerConfig.java
.../java/cn/datax/auth/config/AuthorizationServerConfig.java
+3
-2
DataUserDetailService.java
...ain/java/cn/datax/auth/service/DataUserDetailService.java
+2
-2
DataScope.java
...on-core/src/main/java/cn/datax/common/base/DataScope.java
+2
-6
DataUser.java
...mon-core/src/main/java/cn/datax/common/core/DataUser.java
+1
-1
DataScopeAop.java
...java/cn/datax/common/mybatis/annotation/DataScopeAop.java
+2
-8
DataScopeAspect.java
...java/cn/datax/common/mybatis/aspectj/DataScopeAspect.java
+8
-8
DataScopeInterceptor.java
...atax/common/mybatis/interceptor/DataScopeInterceptor.java
+11
-13
DataUserAuthenticationConverter.java
...ommon/security/utils/DataUserAuthenticationConverter.java
+4
-3
UserDto.java
...rc/main/java/cn/datax/service/system/api/dto/UserDto.java
+2
-3
UserDeptEntity.java
...va/cn/datax/service/system/api/entity/UserDeptEntity.java
+0
-42
UserEntity.java
...n/java/cn/datax/service/system/api/entity/UserEntity.java
+6
-1
UserVo.java
.../src/main/java/cn/datax/service/system/api/vo/UserVo.java
+2
-1
TestController.java
...va/cn/datax/service/system/controller/TestController.java
+1
-1
UserController.java
...va/cn/datax/service/system/controller/UserController.java
+1
-1
UserDeptDao.java
...rc/main/java/cn/datax/service/system/dao/UserDeptDao.java
+0
-25
UserServiceImpl.java
...cn/datax/service/system/service/impl/UserServiceImpl.java
+0
-22
UserDeptMapper.xml
...stem-service/src/main/resources/mapper/UserDeptMapper.xml
+0
-27
UserMapper.xml
...t/system-service/src/main/resources/mapper/UserMapper.xml
+6
-5
No files found.
datax-auth/src/main/java/cn/datax/auth/config/AuthorizationServerConfig.java
View file @
225f31d5
...
...
@@ -8,6 +8,7 @@ import cn.datax.common.security.handler.DataAccessDeniedHandler;
import
cn.datax.common.security.handler.DataAuthExceptionEntryPoint
;
import
cn.datax.common.security.utils.RedisTokenStore
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -124,8 +125,8 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
USERNAME
.
getKey
(),
user
.
getUsername
());
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
NICKNAME
.
getKey
(),
user
.
getNickname
());
if
(
CollUtil
.
isNotEmpty
(
user
.
getDepts
())){
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
DEPT
.
getKey
(),
user
.
getDept
s
());
if
(
StrUtil
.
isNotBlank
(
user
.
getDept
())){
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
DEPT
.
getKey
(),
user
.
getDept
());
}
if
(
CollUtil
.
isNotEmpty
(
user
.
getRoles
())){
additionalInfo
.
put
(
DataConstant
.
UserAdditionalInfo
.
ROLE
.
getKey
(),
user
.
getRoles
());
...
...
datax-auth/src/main/java/cn/datax/auth/service/DataUserDetailService.java
View file @
225f31d5
...
...
@@ -64,8 +64,8 @@ public class DataUserDetailService implements UserDetailsService {
=
AuthorityUtils
.
createAuthorityList
(
authsSet
.
toArray
(
new
String
[
0
]));
DataUser
user
=
new
DataUser
(
userVo
.
getId
(),
userVo
.
getNickname
(),
userVo
.
getUsername
(),
userVo
.
getPassword
(),
enabled
,
accountNonExpired
,
credentialsNonExpired
,
accountNonLocked
,
authorities
);
if
(
CollUtil
.
isNotEmpty
(
userVo
.
getDepts
()))
{
user
.
setDept
s
(
userVo
.
getDepts
().
stream
().
map
(
DeptVo:
:
getId
).
collect
(
Collectors
.
toList
()
));
if
(
StrUtil
.
isNotBlank
(
userVo
.
getDeptId
()))
{
user
.
setDept
(
userVo
.
getDeptId
(
));
}
if
(
CollUtil
.
isNotEmpty
(
userVo
.
getPosts
()))
{
user
.
setPosts
(
userVo
.
getPosts
().
stream
().
map
(
PostVo:
:
getId
).
collect
(
Collectors
.
toList
()));
...
...
datax-common/datax-common-core/src/main/java/cn/datax/common/base/DataScope.java
View file @
225f31d5
...
...
@@ -9,16 +9,12 @@ import lombok.Data;
public
class
DataScope
{
/**
*
部门表的别名
*
表的部门字段
*/
private
String
deptAlias
=
"sys_dept"
;
private
String
deptScopeName
=
"dept_id"
;
/**
*
用户表的别名
*
表的用户字段
*/
private
String
userAlias
=
"sys_user"
;
private
String
userScopeName
=
"create_by"
;
}
datax-common/datax-common-core/src/main/java/cn/datax/common/core/DataUser.java
View file @
225f31d5
...
...
@@ -15,7 +15,7 @@ public class DataUser extends User {
private
String
id
;
private
String
nickname
;
private
List
<
String
>
depts
;
private
String
dept
;
private
List
<
DataRole
>
roles
;
private
List
<
String
>
posts
;
...
...
datax-common/datax-common-mybatis/src/main/java/cn/datax/common/mybatis/annotation/DataScopeAop.java
View file @
225f31d5
...
...
@@ -16,18 +16,12 @@ public @interface DataScopeAop {
* 表的别名
*/
String
alias
()
default
"sys_user"
;
/**
*
部门表的别名
*
表的部门字段
*/
String
deptAlias
()
default
"sys_dept"
;
String
deptScopeName
()
default
"dept_id"
;
/**
*
用户表的别名
*
表的用户字段
*/
String
userAlias
()
default
"sys_user"
;
String
userScopeName
()
default
"create_by"
;
}
datax-common/datax-common-mybatis/src/main/java/cn/datax/common/mybatis/aspectj/DataScopeAspect.java
View file @
225f31d5
...
...
@@ -68,24 +68,24 @@ public class DataScopeAspect {
break
;
}
else
if
(
DataConstant
.
DataScope
.
CUSTOM
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {}.{} )
IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) "
" OR
{}.{}
IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) "
,
dataScope
.
alias
()
,
dataScope
.
user
ScopeName
()
,
dataScope
.
dept
ScopeName
()
,
"'"
+
role
.
getId
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
DEPT
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {}.{} ) IN ( SELECT dept_id FROM sys_user_dept WHERE user_id = {} )
"
" OR
{}.{} = {}
"
,
dataScope
.
alias
()
,
dataScope
.
user
ScopeName
()
,
"'"
+
user
.
get
Id
()
+
"'"
,
dataScope
.
dept
ScopeName
()
,
"'"
+
user
.
get
Dept
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
DEPTANDCHILD
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {}.{} )
IN ( SELECT descendant FROM sys_dept_relation WHERE ancestor = {} )"
" OR
{}.{}
IN ( SELECT descendant FROM sys_dept_relation WHERE ancestor = {} )"
,
dataScope
.
alias
()
,
dataScope
.
user
ScopeName
()
,
"'"
+
role
.
getId
()
+
"'"
,
dataScope
.
dept
ScopeName
()
,
"'"
+
user
.
getDept
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
SELF
.
getKey
().
equals
(
roleDataScope
))
{
if
(
StrUtil
.
isNotBlank
(
dataScope
.
alias
()))
{
...
...
datax-common/datax-common-mybatis/src/main/java/cn/datax/common/mybatis/interceptor/DataScopeInterceptor.java
View file @
225f31d5
...
...
@@ -50,9 +50,7 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
//查找参数中包含DataScope类型的参数
DataScope
dataScope
=
findDataScopeObject
(
parameterObject
);
if
(
dataScope
==
null
)
{
return
invocation
.
proceed
();
}
else
{
if
(
dataScope
!=
null
)
{
// 获取当前的用户
DataUser
currentUser
=
SecurityUtil
.
getDataUser
();
if
(
null
!=
currentUser
)
{
...
...
@@ -60,13 +58,13 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
if
(!
currentUser
.
isAdmin
())
{
String
sqlString
=
dataScopeFilter
(
currentUser
,
dataScope
);
if
(
StrUtil
.
isNotBlank
(
sqlString
))
{
originalSql
=
"SELECT * FROM ("
+
originalSql
+
")
temp_data_scope
WHERE 1=1 AND ("
+
sqlString
.
substring
(
4
)
+
")"
;
originalSql
=
"SELECT * FROM ("
+
originalSql
+
")
TEMP_DATA_SCOPE
WHERE 1=1 AND ("
+
sqlString
.
substring
(
4
)
+
")"
;
metaObject
.
setValue
(
"delegate.boundSql.sql"
,
originalSql
);
}
}
}
return
invocation
.
proceed
();
}
return
invocation
.
proceed
();
}
/**
...
...
@@ -86,21 +84,21 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
break
;
}
else
if
(
DataConstant
.
DataScope
.
CUSTOM
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {} )
IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) "
,
dataScope
.
get
User
ScopeName
()
" OR
{}
IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) "
,
dataScope
.
get
Dept
ScopeName
()
,
"'"
+
role
.
getId
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
DEPT
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {} ) IN ( SELECT dept_id FROM sys_user_dept WHERE user_id = {} )
"
,
dataScope
.
get
User
ScopeName
()
,
"'"
+
user
.
get
Id
()
+
"'"
" OR
{} = {}
"
,
dataScope
.
get
Dept
ScopeName
()
,
"'"
+
user
.
get
Dept
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
DEPTANDCHILD
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR
( SELECT dept_id FROM sys_user_dept WHERE user_id = {} )
IN ( SELECT descendant FROM sys_dept_relation WHERE ancestor = {} )"
,
dataScope
.
get
User
ScopeName
()
,
"'"
+
role
.
getId
()
+
"'"
" OR
{}
IN ( SELECT descendant FROM sys_dept_relation WHERE ancestor = {} )"
,
dataScope
.
get
Dept
ScopeName
()
,
"'"
+
user
.
getDept
()
+
"'"
));
}
else
if
(
DataConstant
.
DataScope
.
SELF
.
getKey
().
equals
(
roleDataScope
))
{
sqlString
.
append
(
StrUtil
.
format
(
" OR {} = {} "
...
...
datax-common/datax-common-security/src/main/java/cn/datax/common/security/utils/DataUserAuthenticationConverter.java
View file @
225f31d5
...
...
@@ -4,6 +4,7 @@ import cn.datax.common.core.DataConstant;
import
cn.datax.common.core.DataRole
;
import
cn.datax.common.core.DataUser
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.GrantedAuthority
;
...
...
@@ -52,14 +53,14 @@ public class DataUserAuthenticationConverter implements UserAuthenticationConver
String
username
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
USERNAME
.
getKey
());
String
nickname
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
NICKNAME
.
getKey
());
List
<
String
>
depts
=
(
List
<
String
>
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
DEPT
.
getKey
());
String
dept
=
(
String
)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
DEPT
.
getKey
());
List
<
DataRole
>
roles
=
(
List
<
DataRole
>)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
ROLE
.
getKey
());
List
<
String
>
posts
=
(
List
<
String
>)
map
.
get
(
DataConstant
.
UserAdditionalInfo
.
POST
.
getKey
());
DataUser
user
=
new
DataUser
(
id
,
nickname
,
username
,
N_A
,
true
,
true
,
true
,
true
,
authorities
);
if
(
CollUtil
.
isNotEmpty
(
depts
)){
user
.
setDept
s
(
depts
);
if
(
StrUtil
.
isNotBlank
(
dept
)){
user
.
setDept
(
dept
);
}
if
(
CollUtil
.
isNotEmpty
(
roles
)){
user
.
setRoles
(
roles
);
...
...
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/dto/UserDto.java
View file @
225f31d5
...
...
@@ -50,9 +50,8 @@ public class UserDto implements Serializable {
private
LocalDate
birthday
;
@ApiModelProperty
(
value
=
"部门"
)
@NotEmpty
(
message
=
"部门不能为空"
,
groups
=
{
ValidationGroups
.
Insert
.
class
,
ValidationGroups
.
Update
.
class
})
@Size
(
min
=
1
,
max
=
1
,
message
=
"部门长度必须位于{min}-{max}之间"
)
private
List
<
String
>
deptList
;
@NotBlank
(
message
=
"部门不能为空"
,
groups
=
{
ValidationGroups
.
Insert
.
class
,
ValidationGroups
.
Update
.
class
})
private
String
deptId
;
@ApiModelProperty
(
value
=
"角色"
)
@NotEmpty
(
message
=
"角色不能为空"
,
groups
=
{
ValidationGroups
.
Insert
.
class
,
ValidationGroups
.
Update
.
class
})
...
...
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/entity/UserDeptEntity.java
deleted
100644 → 0
View file @
2e99c473
package
cn
.
datax
.
service
.
system
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author yuwei
* @since 2019-09-11
*/
@Data
@Accessors
(
chain
=
true
)
@TableName
(
"sys_user_dept"
)
public
class
UserDeptEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
private
String
id
;
/**
* 用户ID
*/
private
String
userId
;
/**
* 部门ID
*/
private
String
deptId
;
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/entity/UserEntity.java
View file @
225f31d5
...
...
@@ -56,8 +56,13 @@ public class UserEntity extends BaseEntity {
*/
private
LocalDate
birthday
;
/**
* 部门
*/
private
String
deptId
;
@TableField
(
exist
=
false
)
private
List
<
DeptEntity
>
depts
;
private
DeptEntity
dept
;
@TableField
(
exist
=
false
)
private
List
<
RoleEntity
>
roles
;
...
...
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/vo/UserVo.java
View file @
225f31d5
...
...
@@ -24,7 +24,8 @@ public class UserVo implements Serializable {
private
String
phone
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
LocalDate
birthday
;
private
List
<
DeptVo
>
depts
;
private
String
deptId
;
private
DeptVo
dept
;
private
List
<
PostVo
>
posts
;
private
List
<
RoleVo
>
roles
;
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/TestController.java
View file @
225f31d5
...
...
@@ -27,7 +27,7 @@ public class TestController extends BaseController {
public
R
getUserPageDataScope
(
UserQuery
userQuery
)
{
QueryWrapper
<
UserEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
userQuery
.
getUsername
()),
"username"
,
userQuery
.
getUsername
());
queryWrapper
.
apply
(
StrUtil
.
isNotBlank
(
userQuery
.
getDeptId
()),
"(select dept_id from sys_user_dept where user_id = id) = {0}
"
,
userQuery
.
getDeptId
());
queryWrapper
.
eq
(
StrUtil
.
isNotBlank
(
userQuery
.
getDeptId
()),
"dept_id
"
,
userQuery
.
getDeptId
());
if
(
CollUtil
.
isNotEmpty
(
userQuery
.
getOrderList
())){
userQuery
.
getOrderList
().
stream
().
forEach
(
orderItem
->
{
queryWrapper
.
orderBy
(
StrUtil
.
isNotBlank
(
orderItem
.
getColumn
()),
orderItem
.
isAsc
(),
orderItem
.
getColumn
());
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/UserController.java
View file @
225f31d5
...
...
@@ -70,7 +70,7 @@ public class UserController extends BaseController {
public
R
getUserPage
(
UserQuery
userQuery
)
{
QueryWrapper
<
UserEntity
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
userQuery
.
getUsername
()),
"username"
,
userQuery
.
getUsername
());
queryWrapper
.
apply
(
StrUtil
.
isNotBlank
(
userQuery
.
getDeptId
()),
"(select dept_id from sys_user_dept where user_id = id) = {0}
"
,
userQuery
.
getDeptId
());
queryWrapper
.
eq
(
StrUtil
.
isNotBlank
(
userQuery
.
getDeptId
()),
"dept_id
"
,
userQuery
.
getDeptId
());
if
(
CollUtil
.
isNotEmpty
(
userQuery
.
getOrderList
())){
userQuery
.
getOrderList
().
stream
().
forEach
(
orderItem
->
{
queryWrapper
.
orderBy
(
StrUtil
.
isNotBlank
(
orderItem
.
getColumn
()),
orderItem
.
isAsc
(),
orderItem
.
getColumn
());
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/dao/UserDeptDao.java
deleted
100644 → 0
View file @
2e99c473
package
cn
.
datax
.
service
.
system
.
dao
;
import
cn.datax.service.system.api.entity.UserDeptEntity
;
import
cn.datax.common.base.BaseDao
;
import
org.apache.ibatis.annotations.Delete
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author yuwei
* @since 2019-09-11
*/
@Mapper
public
interface
UserDeptDao
extends
BaseDao
<
UserDeptEntity
>
{
void
insertBatch
(
List
<
UserDeptEntity
>
list
);
@Delete
(
"delete from sys_user_dept where user_id = #{id}"
)
void
deleteByUserId
(
String
id
);
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/impl/UserServiceImpl.java
View file @
225f31d5
...
...
@@ -47,8 +47,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Autowired
private
UserDao
userDao
;
@Autowired
private
UserDeptDao
userDeptDao
;
@Autowired
private
UserPostDao
userPostDao
;
@Autowired
private
UserRoleDao
userRoleDao
;
...
...
@@ -71,9 +69,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getRoleList
())){
insertBatchRole
(
userDto
.
getRoleList
(),
user
.
getId
());
}
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getDeptList
())){
insertBatchDept
(
userDto
.
getDeptList
(),
user
.
getId
());
}
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getPostList
())){
insertBatchPost
(
userDto
.
getPostList
(),
user
.
getId
());
}
...
...
@@ -90,17 +85,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
userPostDao
.
insertBatch
(
userPostList
);
}
private
void
insertBatchDept
(
List
<
String
>
deptss
,
String
userId
)
{
List
<
UserDeptEntity
>
userDeptList
=
deptss
.
stream
().
map
(
deptId
->
{
UserDeptEntity
userDept
=
new
UserDeptEntity
();
userDept
.
setUserId
(
userId
);
userDept
.
setDeptId
(
deptId
);
return
userDept
;
}).
collect
(
Collectors
.
toList
());
userDeptDao
.
insertBatch
(
userDeptList
);
}
private
void
insertBatchRole
(
List
<
String
>
roles
,
String
userId
)
{
List
<
UserRoleEntity
>
userRoleList
=
roles
.
stream
().
map
(
roleId
->
{
...
...
@@ -122,11 +106,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getRoleList
())){
insertBatchRole
(
userDto
.
getRoleList
(),
user
.
getId
());
}
userDeptDao
.
delete
(
Wrappers
.<
UserDeptEntity
>
lambdaQuery
()
.
eq
(
UserDeptEntity:
:
getUserId
,
user
.
getId
()));
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getDeptList
())){
insertBatchDept
(
userDto
.
getDeptList
(),
user
.
getId
());
}
userPostDao
.
delete
(
Wrappers
.<
UserPostEntity
>
lambdaQuery
()
.
eq
(
UserPostEntity:
:
getUserId
,
user
.
getId
()));
if
(
CollUtil
.
isNotEmpty
(
userDto
.
getPostList
())){
...
...
@@ -138,7 +117,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteUserById
(
String
id
)
{
userRoleDao
.
deleteByUserId
(
id
);
userDeptDao
.
deleteByUserId
(
id
);
userPostDao
.
deleteByUserId
(
id
);
userDao
.
deleteById
(
id
);
}
...
...
datax-modules/system-service-parent/system-service/src/main/resources/mapper/UserDeptMapper.xml
deleted
100644 → 0
View file @
2e99c473
<?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=
"cn.datax.service.system.dao.UserDeptDao"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.datax.service.system.api.entity.UserDeptEntity"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"user_id"
property=
"userId"
/>
<result
column=
"dept_id"
property=
"deptId"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id,
user_id, dept_id
</sql>
<insert
id=
"insertBatch"
parameterType=
"java.util.List"
>
INSERT INTO sys_user_dept
(id, user_id, dept_id)
VALUES
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.id}, #{item.userId}, #{item.deptId})
</foreach>
</insert>
</mapper>
datax-modules/system-service-parent/system-service/src/main/resources/mapper/UserMapper.xml
View file @
225f31d5
...
...
@@ -16,7 +16,8 @@
<result
column=
"phone"
property=
"phone"
/>
<result
column=
"birthday"
property=
"birthday"
/>
<result
column=
"status"
property=
"status"
/>
<collection
property=
"depts"
column=
"{userId=id}"
select=
"getDeptList"
></collection>
<result
column=
"dept_id"
property=
"deptId"
/>
<collection
property=
"dept"
column=
"{userId=id}"
select=
"getDept"
></collection>
<collection
property=
"roles"
column=
"{userId=id}"
select=
"getRoleList"
></collection>
<collection
property=
"posts"
column=
"{userId=id}"
select=
"getPostList"
></collection>
</resultMap>
...
...
@@ -28,23 +29,23 @@
create_time,
update_by,
update_time,
username, nickname, password, email, phone, birthday, status
username, nickname, password, email, phone, birthday, status
, dept_id
</sql>
<update
id=
"updateUserPassword"
>
UPDATE sys_user SET password = #{password} WHERE id = #{id}
</update>
<select
id=
"getDept
List
"
resultType=
"cn.datax.service.system.api.entity.DeptEntity"
>
<select
id=
"getDept"
resultType=
"cn.datax.service.system.api.entity.DeptEntity"
>
SELECT
<include
refid=
"cn.datax.service.system.dao.DeptDao.Dept_Column_List"
>
<property
name=
"alias"
value=
"d"
/>
</include>
FROM sys_dept d
LEFT JOIN sys_user
_dept ud ON d.id = ud
.dept_id
LEFT JOIN sys_user
u ON d.id = u
.dept_id
WHERE 1 = 1 AND d.status = 1
<if
test=
"null != userId and '' != userId"
>
AND u
d.user_
id = #{userId}
AND u
.
id = #{userId}
</if>
</select>
...
...
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