Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
govdna
Project
Project
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
开发共享交流平台
govdna
Commits
d6ab3746
Commit
d6ab3746
authored
Aug 08, 2018
by
Fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111
parent
ddd25bb7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
26 deletions
+49
-26
Constant.java
src/main/java/com/govmade/common/utils/Constant.java
+3
-0
Assert.java
src/main/java/com/govmade/common/validator/Assert.java
+26
-0
UserController.java
...com/govmade/modules/system/controller/UserController.java
+20
-26
No files found.
src/main/java/com/govmade/common/utils/Constant.java
View file @
d6ab3746
...
...
@@ -11,6 +11,9 @@ public class Constant {
/** 超级管理员ID */
public
static
final
int
SUPER_ADMIN
=
1
;
/** 重置默认密码 */
public
static
final
String
DEFAULT_PASSWORD
=
"abc123456"
;
/** 数据状态 */
public
static
final
int
STATE_DELETE
=
0
;
...
...
src/main/java/com/govmade/common/validator/Assert.java
0 → 100644
View file @
d6ab3746
package
com
.
govmade
.
common
.
validator
;
import
com.govmade.common.exception.RRException
;
import
cn.hutool.core.util.StrUtil
;
/**
* 数据校验
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月8日
*/
public
abstract
class
Assert
{
public
static
void
isBlank
(
String
str
,
String
message
)
{
if
(
StrUtil
.
isBlank
(
str
))
{
throw
new
RRException
(
message
);
}
}
public
static
void
isNull
(
Object
object
,
String
message
)
{
if
(
object
==
null
)
{
throw
new
RRException
(
message
);
}
}
}
src/main/java/com/govmade/modules/system/controller/UserController.java
View file @
d6ab3746
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.shiro.crypto.hash.Sha256Hash
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -15,11 +13,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.google.common.collect.Sets
;
import
com.govmade.common.utils.Constant
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.
utils.ShiroUtils
;
import
com.govmade.common.
validator.Assert
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.UserEntity
;
import
com.govmade.modules.system.service.UserService
;
...
...
@@ -50,7 +47,7 @@ public class UserController extends AbstractController {
if
(
this
.
userService
.
checkUser
(
ue
.
getUsername
())
>
0
)
{
return
R
.
error
(
ue
.
getUsername
()
+
" 已存在!"
);
}
String
password
=
SecureUtil
.
md5
(
"123456"
);
String
password
=
SecureUtil
.
md5
(
Constant
.
DEFAULT_PASSWORD
);
ue
.
setPassword
(
password
);
}
userService
.
save
(
ue
);
...
...
@@ -88,17 +85,15 @@ public class UserController extends AbstractController {
}
/**
*
删除、
批量删除用户
* 批量删除用户
*
* @param ids
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteUser
()
{
Set
<
Long
>
ids
=
Sets
.
newHashSet
();
ids
.
add
(
1L
);
ids
.
add
(
2L
);
public
R
deleteUser
(
@RequestBody
Set
<
Long
>
ids
)
{
Assert
.
isNull
(
ids
,
"删除项不能为空"
);
userService
.
deleteBatch
(
ids
);
return
R
.
ok
();
}
...
...
@@ -110,13 +105,13 @@ public class UserController extends AbstractController {
* @return
*/
@PostMapping
(
"/reset"
)
public
R
reset
(
UserEntity
ue
)
{
if
(
null
!=
ue
.
getId
())
{
public
R
reset
(
Long
id
)
{
Assert
.
isNull
(
id
,
"必选选择一个用户"
);
String
password
=
SecureUtil
.
md5
(
"123456"
);
ue
.
setPassword
(
password
);
userService
.
updateById
(
ue
);
}
String
password
=
SecureUtil
.
md5
(
Constant
.
DEFAULT_PASSWORD
);
UserEntity
ue
=
new
UserEntity
(
);
ue
.
setPassword
(
password
);
userService
.
updateById
(
ue
);
return
R
.
ok
();
}
...
...
@@ -126,18 +121,17 @@ public class UserController extends AbstractController {
*/
@PutMapping
(
"updatePassword"
)
public
R
password
(
String
password
,
String
newPassword
)
{
Assert
.
isBlank
(
newPassword
,
"新密码不为能空"
);
password
=
new
Sha256Hash
(
password
).
toHex
(
);
newPassword
=
new
Sha256Hash
(
newPassword
).
toHex
(
);
password
=
SecureUtil
.
md5
(
password
);
newPassword
=
SecureUtil
.
md5
(
newPassword
);
// int count = userService.updatePassword(ShiroUtils.getUserId(), password,
// newPassword);
// if (count == 0) {
// return R.error("原密码不正确");
// }
ShiroUtils
.
logout
();
// 更新密码
boolean
flag
=
userService
.
updatePassword
(
getUserId
(),
password
,
newPassword
);
if
(!
flag
)
{
return
R
.
error
(
"原密码不正确"
);
}
return
R
.
ok
();
}
...
...
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