Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
f6cf7806
Commit
f6cf7806
authored
May 05, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加用户和修改用户的数据传输bean修改
parent
7cde7d54
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
5 deletions
+177
-5
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
+8
-5
src/main/java/com/stylefeng/guns/modular/system/factory/UserFactory.java
+24
-0
src/main/java/com/stylefeng/guns/modular/system/transfer/UserDto.java
+145
-0
No files found.
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
View file @
f6cf7806
...
...
@@ -15,6 +15,8 @@ import com.stylefeng.guns.core.shiro.ShiroKit;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.modular.system.dao.UserMgrDao
;
import
com.stylefeng.guns.modular.system.factory.UserFactory
;
import
com.stylefeng.guns.modular.system.transfer.UserDto
;
import
com.stylefeng.guns.modular.system.warpper.UserWarpper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.model.User
;
...
...
@@ -160,7 +162,7 @@ public class UserMgrController extends BaseController {
@BussinessLog
(
"添加管理员"
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
public
Tip
add
(
@Valid
User
user
,
BindingResult
result
)
{
public
Tip
add
(
@Valid
User
Dto
user
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
...
...
@@ -176,7 +178,8 @@ public class UserMgrController extends BaseController {
user
.
setPassword
(
ShiroKit
.
md5
(
user
.
getPassword
(),
user
.
getSalt
()));
user
.
setStatus
(
ManagerStatus
.
OK
.
getCode
());
user
.
setCreatetime
(
new
Date
());
this
.
userMapper
.
insert
(
user
);
this
.
userMapper
.
insert
(
UserFactory
.
createUser
(
user
));
return
SUCCESS_TIP
;
}
...
...
@@ -189,17 +192,17 @@ public class UserMgrController extends BaseController {
@BussinessLog
(
"修改管理员"
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
public
Tip
edit
(
@Valid
User
user
,
BindingResult
result
)
throws
NoPermissionException
{
public
Tip
edit
(
@Valid
User
Dto
user
,
BindingResult
result
)
throws
NoPermissionException
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
if
(
ShiroKit
.
hasRole
(
Const
.
ADMIN_NAME
))
{
this
.
userMapper
.
updateById
(
user
);
this
.
userMapper
.
updateById
(
UserFactory
.
createUser
(
user
)
);
return
SUCCESS_TIP
;
}
else
{
ShiroUser
shiroUser
=
ShiroKit
.
getUser
();
if
(
shiroUser
.
getId
()
==
user
.
getId
())
{
this
.
userMapper
.
updateById
(
user
);
this
.
userMapper
.
updateById
(
UserFactory
.
createUser
(
user
)
);
return
SUCCESS_TIP
;
}
else
{
throw
new
AuthenticationException
();
...
...
src/main/java/com/stylefeng/guns/modular/system/factory/UserFactory.java
0 → 100644
View file @
f6cf7806
package
com
.
stylefeng
.
guns
.
modular
.
system
.
factory
;
import
com.stylefeng.guns.modular.system.transfer.UserDto
;
import
com.stylefeng.guns.persistence.model.User
;
import
org.springframework.beans.BeanUtils
;
/**
* 用户创建工厂
*
* @author fengshuonan
* @date 2017-05-05 22:43
*/
public
class
UserFactory
{
public
static
User
createUser
(
UserDto
userDto
){
if
(
userDto
==
null
){
return
null
;
}
else
{
User
user
=
new
User
();
BeanUtils
.
copyProperties
(
userDto
,
user
);
return
user
;
}
}
}
src/main/java/com/stylefeng/guns/modular/system/transfer/UserDto.java
0 → 100644
View file @
f6cf7806
package
com
.
stylefeng
.
guns
.
modular
.
system
.
transfer
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
/**
* 用户传输bean
*
* @author stylefeng
* @Date 2017/5/5 22:40
*/
public
class
UserDto
{
private
Integer
id
;
private
String
account
;
private
String
password
;
private
String
salt
;
private
String
name
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
birthday
;
private
Integer
sex
;
private
String
email
;
private
String
phone
;
private
String
roleid
;
private
Integer
deptid
;
private
Integer
status
;
private
Date
createtime
;
private
Integer
version
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getAccount
()
{
return
account
;
}
public
void
setAccount
(
String
account
)
{
this
.
account
=
account
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getSalt
()
{
return
salt
;
}
public
void
setSalt
(
String
salt
)
{
this
.
salt
=
salt
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Date
getBirthday
()
{
return
birthday
;
}
public
void
setBirthday
(
Date
birthday
)
{
this
.
birthday
=
birthday
;
}
public
Integer
getSex
()
{
return
sex
;
}
public
void
setSex
(
Integer
sex
)
{
this
.
sex
=
sex
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
public
String
getRoleid
()
{
return
roleid
;
}
public
void
setRoleid
(
String
roleid
)
{
this
.
roleid
=
roleid
;
}
public
Integer
getDeptid
()
{
return
deptid
;
}
public
void
setDeptid
(
Integer
deptid
)
{
this
.
deptid
=
deptid
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Date
getCreatetime
()
{
return
createtime
;
}
public
void
setCreatetime
(
Date
createtime
)
{
this
.
createtime
=
createtime
;
}
public
Integer
getVersion
()
{
return
version
;
}
public
void
setVersion
(
Integer
version
)
{
this
.
version
=
version
;
}
}
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