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
a9114029
Commit
a9114029
authored
Nov 02, 2019
by
yw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
97555703
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
37 deletions
+115
-37
UserPasswordDto.java
...java/cn/datax/service/system/api/dto/UserPasswordDto.java
+21
-0
DeptController.java
...va/cn/datax/service/system/controller/DeptController.java
+11
-5
MenuController.java
...va/cn/datax/service/system/controller/MenuController.java
+11
-5
PostController.java
...va/cn/datax/service/system/controller/PostController.java
+19
-6
RoleController.java
...va/cn/datax/service/system/controller/RoleController.java
+22
-8
UserController.java
...va/cn/datax/service/system/controller/UserController.java
+12
-13
UserService.java
...ain/java/cn/datax/service/system/service/UserService.java
+3
-0
UserServiceImpl.java
...cn/datax/service/system/service/impl/UserServiceImpl.java
+16
-0
No files found.
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/dto/UserPasswordDto.java
0 → 100644
View file @
a9114029
package
cn
.
datax
.
service
.
system
.
api
.
dto
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
java.io.Serializable
;
@Data
public
class
UserPasswordDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@NotBlank
(
message
=
"主键ID不能为空"
)
private
String
id
;
@NotBlank
(
message
=
"密码不能为空"
)
private
String
password
;
@NotBlank
(
message
=
"旧密码不能为空"
)
private
String
oldPassword
;
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/DeptController.java
View file @
a9114029
...
@@ -4,6 +4,8 @@ import cn.datax.common.core.R;
...
@@ -4,6 +4,8 @@ import cn.datax.common.core.R;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.system.api.dto.DeptDto
;
import
cn.datax.service.system.api.dto.DeptDto
;
import
cn.datax.service.system.api.entity.DeptEntity
;
import
cn.datax.service.system.mapstruct.DeptMapper
;
import
cn.datax.service.system.service.DeptService
;
import
cn.datax.service.system.service.DeptService
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,18 +23,22 @@ import cn.datax.common.base.BaseController;
...
@@ -21,18 +23,22 @@ import cn.datax.common.base.BaseController;
* @since 2019-09-04
* @since 2019-09-04
*/
*/
@RestController
@RestController
@RequestMapping
(
"/dept"
)
@RequestMapping
(
"/dept
s
"
)
public
class
DeptController
extends
BaseController
{
public
class
DeptController
extends
BaseController
{
@Autowired
@Autowired
private
DeptService
deptService
;
private
DeptService
deptService
;
@Autowired
private
DeptMapper
deptMapper
;
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
R
getDeptById
(
@PathVariable
String
id
)
{
public
R
getDeptById
(
@PathVariable
String
id
)
{
return
R
.
ok
().
setData
(
deptService
.
getById
(
id
));
DeptEntity
deptEntity
=
deptService
.
getById
(
id
);
return
R
.
ok
().
setData
(
deptMapper
.
toVO
(
deptEntity
));
}
}
@GetMapping
(
"/list"
)
@GetMapping
()
public
R
getDeptList
()
{
public
R
getDeptList
()
{
return
R
.
ok
().
setData
(
deptService
.
list
(
Wrappers
.
emptyWrapper
()));
return
R
.
ok
().
setData
(
deptService
.
list
(
Wrappers
.
emptyWrapper
()));
}
}
...
@@ -43,8 +49,8 @@ public class DeptController extends BaseController {
...
@@ -43,8 +49,8 @@ public class DeptController extends BaseController {
return
R
.
ok
();
return
R
.
ok
();
}
}
@PutMapping
()
@PutMapping
(
"/{id}"
)
public
R
updateDept
(
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
DeptDto
dept
)
{
public
R
updateDept
(
@
PathVariable
String
id
,
@
RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
DeptDto
dept
)
{
deptService
.
updateDept
(
dept
);
deptService
.
updateDept
(
dept
);
return
R
.
ok
();
return
R
.
ok
();
}
}
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/MenuController.java
View file @
a9114029
...
@@ -4,6 +4,8 @@ import cn.datax.common.core.R;
...
@@ -4,6 +4,8 @@ import cn.datax.common.core.R;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.system.api.dto.MenuDto
;
import
cn.datax.service.system.api.dto.MenuDto
;
import
cn.datax.service.system.api.entity.MenuEntity
;
import
cn.datax.service.system.mapstruct.MenuMapper
;
import
cn.datax.service.system.service.MenuService
;
import
cn.datax.service.system.service.MenuService
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,18 +23,22 @@ import cn.datax.common.base.BaseController;
...
@@ -21,18 +23,22 @@ import cn.datax.common.base.BaseController;
* @since 2019-09-11
* @since 2019-09-11
*/
*/
@RestController
@RestController
@RequestMapping
(
"/menu"
)
@RequestMapping
(
"/menu
s
"
)
public
class
MenuController
extends
BaseController
{
public
class
MenuController
extends
BaseController
{
@Autowired
@Autowired
private
MenuService
menuService
;
private
MenuService
menuService
;
@Autowired
private
MenuMapper
menuMapper
;
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
R
getMenuById
(
@PathVariable
String
id
)
{
public
R
getMenuById
(
@PathVariable
String
id
)
{
return
R
.
ok
().
setData
(
menuService
.
getById
(
id
));
MenuEntity
menuEntity
=
menuService
.
getById
(
id
);
return
R
.
ok
().
setData
(
menuMapper
.
toVO
(
menuEntity
));
}
}
@GetMapping
(
"/list"
)
@GetMapping
()
public
R
getMenuList
()
{
public
R
getMenuList
()
{
return
R
.
ok
().
setData
(
menuService
.
list
(
Wrappers
.
emptyWrapper
()));
return
R
.
ok
().
setData
(
menuService
.
list
(
Wrappers
.
emptyWrapper
()));
}
}
...
@@ -43,8 +49,8 @@ public class MenuController extends BaseController {
...
@@ -43,8 +49,8 @@ public class MenuController extends BaseController {
return
R
.
ok
();
return
R
.
ok
();
}
}
@PutMapping
()
@PutMapping
(
"/{id}"
)
public
R
updateMenu
(
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
MenuDto
menu
)
{
public
R
updateMenu
(
@
PathVariable
String
id
,
@
RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
MenuDto
menu
)
{
menuService
.
updateMenu
(
menu
);
menuService
.
updateMenu
(
menu
);
return
R
.
ok
();
return
R
.
ok
();
}
}
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/PostController.java
View file @
a9114029
...
@@ -5,7 +5,11 @@ import cn.datax.common.validate.ValidateGroupForSave;
...
@@ -5,7 +5,11 @@ import cn.datax.common.validate.ValidateGroupForSave;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.system.api.dto.PostDto
;
import
cn.datax.service.system.api.dto.PostDto
;
import
cn.datax.service.system.api.entity.PostEntity
;
import
cn.datax.service.system.api.entity.PostEntity
;
import
cn.datax.service.system.mapstruct.PostMapper
;
import
cn.datax.service.system.service.PostService
;
import
cn.datax.service.system.service.PostService
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -23,20 +27,29 @@ import cn.datax.common.base.BaseController;
...
@@ -23,20 +27,29 @@ import cn.datax.common.base.BaseController;
* @since 2019-09-11
* @since 2019-09-11
*/
*/
@RestController
@RestController
@RequestMapping
(
"/post"
)
@RequestMapping
(
"/post
s
"
)
public
class
PostController
extends
BaseController
{
public
class
PostController
extends
BaseController
{
@Autowired
@Autowired
private
PostService
postService
;
private
PostService
postService
;
@Autowired
private
PostMapper
postMapper
;
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
R
getPostById
(
@PathVariable
String
id
)
{
public
R
getPostById
(
@PathVariable
String
id
)
{
return
R
.
ok
().
setData
(
postService
.
getById
(
id
));
PostEntity
postEntity
=
postService
.
getById
(
id
);
return
R
.
ok
().
setData
(
postMapper
.
toVO
(
postEntity
));
}
}
@GetMapping
(
"/page"
)
@GetMapping
(
"/page"
)
public
R
getPostPage
(
Page
page
,
PostEntity
post
)
{
public
R
getPostPage
(
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
,
return
R
.
ok
().
setData
(
postService
.
page
(
page
,
Wrappers
.
query
(
post
)));
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
PostEntity
post
)
{
QueryWrapper
<
PostEntity
>
queryWrapper
=
Wrappers
.
emptyWrapper
();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
post
.
getPostName
()),
"post_name"
,
post
.
getPostName
());
IPage
<
PostEntity
>
page
=
postService
.
page
(
new
Page
<>(
pageNum
,
pageSize
),
queryWrapper
);
return
R
.
ok
().
setData
(
page
);
}
}
@PostMapping
()
@PostMapping
()
...
@@ -45,8 +58,8 @@ public class PostController extends BaseController {
...
@@ -45,8 +58,8 @@ public class PostController extends BaseController {
return
R
.
ok
();
return
R
.
ok
();
}
}
@PutMapping
()
@PutMapping
(
"/{id}"
)
public
R
updatePost
(
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
PostDto
post
)
{
public
R
updatePost
(
@
PathVariable
String
id
,
@
RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
PostDto
post
)
{
postService
.
updatePost
(
post
);
postService
.
updatePost
(
post
);
return
R
.
ok
();
return
R
.
ok
();
}
}
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/RoleController.java
View file @
a9114029
...
@@ -5,7 +5,11 @@ import cn.datax.common.validate.ValidateGroupForSave;
...
@@ -5,7 +5,11 @@ import cn.datax.common.validate.ValidateGroupForSave;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.system.api.dto.RoleDto
;
import
cn.datax.service.system.api.dto.RoleDto
;
import
cn.datax.service.system.api.entity.RoleEntity
;
import
cn.datax.service.system.api.entity.RoleEntity
;
import
cn.datax.service.system.mapstruct.RoleMapper
;
import
cn.datax.service.system.service.RoleService
;
import
cn.datax.service.system.service.RoleService
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -23,12 +27,15 @@ import cn.datax.common.base.BaseController;
...
@@ -23,12 +27,15 @@ import cn.datax.common.base.BaseController;
* @since 2019-09-04
* @since 2019-09-04
*/
*/
@RestController
@RestController
@RequestMapping
(
"/role"
)
@RequestMapping
(
"/role
s
"
)
public
class
RoleController
extends
BaseController
{
public
class
RoleController
extends
BaseController
{
@Autowired
@Autowired
private
RoleService
roleService
;
private
RoleService
roleService
;
@Autowired
private
RoleMapper
roleMapper
;
/**
/**
* 通过ID查询角色信息
* 通过ID查询角色信息
* @param id
* @param id
...
@@ -36,18 +43,25 @@ public class RoleController extends BaseController {
...
@@ -36,18 +43,25 @@ public class RoleController extends BaseController {
*/
*/
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
R
getRoleById
(
@PathVariable
String
id
)
{
public
R
getRoleById
(
@PathVariable
String
id
)
{
return
R
.
ok
().
setData
(
roleService
.
getById
(
id
));
RoleEntity
roleEntity
=
roleService
.
getById
(
id
);
return
R
.
ok
().
setData
(
roleMapper
.
toVO
(
roleEntity
));
}
}
/**
/**
*分页查询角色信息
* 分页查询角色信息
* @param page current=1&size=20
* @param pageNum
* @param pageSize
* @param role
* @param role
* @return
* @return
*/
*/
@GetMapping
(
"/page"
)
@GetMapping
(
"/page"
)
public
R
getRolePage
(
Page
page
,
RoleEntity
role
)
{
public
R
getRolePage
(
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
,
return
R
.
ok
().
setData
(
roleService
.
page
(
page
,
Wrappers
.
query
(
role
)));
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
RoleEntity
role
)
{
QueryWrapper
<
RoleEntity
>
queryWrapper
=
Wrappers
.
emptyWrapper
();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
role
.
getRoleName
()),
"role_name"
,
role
.
getRoleName
());
IPage
<
RoleEntity
>
page
=
roleService
.
page
(
new
Page
<>(
pageNum
,
pageSize
),
queryWrapper
);
return
R
.
ok
().
setData
(
page
);
}
}
/**
/**
...
@@ -66,8 +80,8 @@ public class RoleController extends BaseController {
...
@@ -66,8 +80,8 @@ public class RoleController extends BaseController {
* @param role
* @param role
* @return
* @return
*/
*/
@PutMapping
()
@PutMapping
(
"/{id}"
)
public
R
updateRole
(
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
RoleDto
role
)
{
public
R
updateRole
(
@
PathVariable
String
id
,
@
RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
RoleDto
role
)
{
roleService
.
updateRole
(
role
);
roleService
.
updateRole
(
role
);
return
R
.
ok
();
return
R
.
ok
();
}
}
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/UserController.java
View file @
a9114029
...
@@ -4,23 +4,21 @@ import cn.datax.common.core.R;
...
@@ -4,23 +4,21 @@ import cn.datax.common.core.R;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserPasswordDto
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.mapstruct.UserMapper
;
import
cn.datax.service.system.mapstruct.UserMapper
;
import
cn.datax.service.system.service.UserService
;
import
cn.datax.service.system.service.UserService
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.base.BaseController
;
import
java.security.Principal
;
/**
/**
* <p>
* <p>
* 前端控制器
* 前端控制器
...
@@ -30,7 +28,7 @@ import java.security.Principal;
...
@@ -30,7 +28,7 @@ import java.security.Principal;
* @since 2019-09-04
* @since 2019-09-04
*/
*/
@RestController
@RestController
@RequestMapping
(
"/user"
)
@RequestMapping
(
"/user
s
"
)
public
class
UserController
extends
BaseController
{
public
class
UserController
extends
BaseController
{
@Autowired
@Autowired
...
@@ -39,12 +37,6 @@ public class UserController extends BaseController {
...
@@ -39,12 +37,6 @@ public class UserController extends BaseController {
@Autowired
@Autowired
private
UserMapper
userMapper
;
private
UserMapper
userMapper
;
@GetMapping
(
"/token"
)
public
Principal
tokenUser
()
{
Authentication
authentication
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
return
authentication
;
}
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
public
R
getUserById
(
@PathVariable
String
id
)
{
public
R
getUserById
(
@PathVariable
String
id
)
{
UserEntity
userEntity
=
userService
.
getById
(
id
);
UserEntity
userEntity
=
userService
.
getById
(
id
);
...
@@ -56,6 +48,7 @@ public class UserController extends BaseController {
...
@@ -56,6 +48,7 @@ public class UserController extends BaseController {
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
UserDto
user
)
{
UserDto
user
)
{
QueryWrapper
<
UserEntity
>
queryWrapper
=
Wrappers
.
emptyWrapper
();
QueryWrapper
<
UserEntity
>
queryWrapper
=
Wrappers
.
emptyWrapper
();
queryWrapper
.
like
(
StrUtil
.
isNotBlank
(
user
.
getUsername
()),
"username"
,
user
.
getUsername
());
IPage
<
UserEntity
>
page
=
userService
.
page
(
new
Page
<>(
pageNum
,
pageSize
),
queryWrapper
);
IPage
<
UserEntity
>
page
=
userService
.
page
(
new
Page
<>(
pageNum
,
pageSize
),
queryWrapper
);
page
.
getRecords
().
stream
().
map
(
userMapper:
:
toVO
);
page
.
getRecords
().
stream
().
map
(
userMapper:
:
toVO
);
return
R
.
ok
().
setData
(
page
);
return
R
.
ok
().
setData
(
page
);
...
@@ -67,12 +60,18 @@ public class UserController extends BaseController {
...
@@ -67,12 +60,18 @@ public class UserController extends BaseController {
return
R
.
ok
();
return
R
.
ok
();
}
}
@PutMapping
()
@PutMapping
(
"/{id}"
)
public
R
updateUser
(
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
UserDto
user
)
{
public
R
updateUser
(
@
PathVariable
String
id
,
@
RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
UserDto
user
)
{
userService
.
updateUser
(
user
);
userService
.
updateUser
(
user
);
return
R
.
ok
();
return
R
.
ok
();
}
}
@PutMapping
(
"/{id}/password"
)
public
R
updateUserPassword
(
@PathVariable
String
id
,
@RequestBody
@Validated
UserPasswordDto
user
)
{
userService
.
updateUserPassword
(
user
);
return
R
.
ok
();
}
@DeleteMapping
(
"/{id}"
)
@DeleteMapping
(
"/{id}"
)
public
R
deleteUser
(
@PathVariable
String
id
)
{
public
R
deleteUser
(
@PathVariable
String
id
)
{
userService
.
deleteUserById
(
id
);
userService
.
deleteUserById
(
id
);
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/UserService.java
View file @
a9114029
...
@@ -2,6 +2,7 @@ package cn.datax.service.system.service;
...
@@ -2,6 +2,7 @@ package cn.datax.service.system.service;
import
cn.datax.common.base.BaseService
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserPasswordDto
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.api.entity.UserEntity
;
/**
/**
...
@@ -19,4 +20,6 @@ public interface UserService extends BaseService<UserEntity> {
...
@@ -19,4 +20,6 @@ public interface UserService extends BaseService<UserEntity> {
void
updateUser
(
UserDto
user
);
void
updateUser
(
UserDto
user
);
void
deleteUserById
(
String
id
);
void
deleteUserById
(
String
id
);
void
updateUserPassword
(
UserPasswordDto
user
);
}
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/impl/UserServiceImpl.java
View file @
a9114029
package
cn
.
datax
.
service
.
system
.
service
.
impl
;
package
cn
.
datax
.
service
.
system
.
service
.
impl
;
import
cn.datax.common.exception.DataException
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserDto
;
import
cn.datax.service.system.api.dto.UserPasswordDto
;
import
cn.datax.service.system.api.entity.UserDeptEntity
;
import
cn.datax.service.system.api.entity.UserDeptEntity
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.api.entity.UserEntity
;
import
cn.datax.service.system.api.entity.UserPostEntity
;
import
cn.datax.service.system.api.entity.UserPostEntity
;
...
@@ -12,8 +14,10 @@ import cn.datax.service.system.dao.UserRoleDao;
...
@@ -12,8 +14,10 @@ import cn.datax.service.system.dao.UserRoleDao;
import
cn.datax.service.system.mapstruct.UserMapper
;
import
cn.datax.service.system.mapstruct.UserMapper
;
import
cn.datax.service.system.service.UserService
;
import
cn.datax.service.system.service.UserService
;
import
cn.datax.common.base.BaseServiceImpl
;
import
cn.datax.common.base.BaseServiceImpl
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -46,6 +50,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
...
@@ -46,6 +50,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveUser
(
UserDto
userDto
)
{
public
void
saveUser
(
UserDto
userDto
)
{
UserEntity
user
=
userMapper
.
toEntity
(
userDto
);
UserEntity
user
=
userMapper
.
toEntity
(
userDto
);
String
passwordEncode
=
new
BCryptPasswordEncoder
().
encode
(
user
.
getPassword
());
user
.
setPassword
(
passwordEncode
);
baseMapper
.
insert
(
user
);
baseMapper
.
insert
(
user
);
insertBatchRole
(
userDto
.
getRoles
(),
user
.
getId
());
insertBatchRole
(
userDto
.
getRoles
(),
user
.
getId
());
insertBatchDept
(
userDto
.
getDepts
(),
user
.
getId
());
insertBatchDept
(
userDto
.
getDepts
(),
user
.
getId
());
...
@@ -107,4 +113,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
...
@@ -107,4 +113,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
baseMapper
.
deleteById
(
id
);
baseMapper
.
deleteById
(
id
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateUserPassword
(
UserPasswordDto
userPasswordDto
)
{
UserEntity
userEntity
=
baseMapper
.
selectById
(
userPasswordDto
.
getId
());
if
(!
StrUtil
.
equals
(
userEntity
.
getPassword
(),
new
BCryptPasswordEncoder
().
encode
(
userPasswordDto
.
getOldPassword
()))){
throw
new
DataException
(
"旧密码不正确"
);
}
// todo xml写更新密码sql
}
}
}
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