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
58375f03
Commit
58375f03
authored
May 15, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
个人资料里边添加头像功能
parent
1586c653
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
89 deletions
+138
-89
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
+1
-0
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
+17
-4
src/main/webapp/WEB-INF/view/common/tags/avatar.tag
+29
-0
src/main/webapp/WEB-INF/view/system/user/user_view.html
+2
-0
src/main/webapp/static/modular/system/user/user_info.js
+89
-85
No files found.
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
View file @
58375f03
...
@@ -20,6 +20,7 @@ public enum BizExceptionEnum {
...
@@ -20,6 +20,7 @@ public enum BizExceptionEnum {
*/
*/
FILE_READING_ERROR
(
400
,
"FILE_READING_ERROR!"
),
FILE_READING_ERROR
(
400
,
"FILE_READING_ERROR!"
),
FILE_NOT_FOUND
(
400
,
"FILE_NOT_FOUND!"
),
FILE_NOT_FOUND
(
400
,
"FILE_NOT_FOUND!"
),
UPLOAD_ERROR
(
500
,
"上传图片出错"
),
/**
/**
* 权限和数据问题
* 权限和数据问题
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
View file @
58375f03
...
@@ -24,14 +24,13 @@ import org.apache.shiro.authc.AuthenticationException;
...
@@ -24,14 +24,13 @@ import org.apache.shiro.authc.AuthenticationException;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.naming.NoPermissionException
;
import
javax.naming.NoPermissionException
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -299,4 +298,18 @@ public class UserMgrController extends BaseController {
...
@@ -299,4 +298,18 @@ public class UserMgrController extends BaseController {
this
.
managerDao
.
setRoles
(
userId
,
roleIds
);
this
.
managerDao
.
setRoles
(
userId
,
roleIds
);
return
SUCCESS_TIP
;
return
SUCCESS_TIP
;
}
}
/**
* 上传图片
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
path
=
"/upload"
)
public
@ResponseBody
String
upload
(
@RequestPart
(
"file"
)
MultipartFile
picture
){
try
{
picture
.
transferTo
(
new
File
(
"e:/tmp/"
+
picture
.
getOriginalFilename
()));
}
catch
(
Exception
e
)
{
throw
new
BussinessException
(
BizExceptionEnum
.
UPLOAD_ERROR
);
}
return
"succesPic"
;
}
}
}
src/main/webapp/WEB-INF/view/common/tags/avatar.tag
0 → 100644
View file @
58375f03
@/*
头像参数的说明:
name : 名称
id : 头像的id
@*/
<div class="form-group">
<label class="col-sm-3 control-label head-scu-label">${name}</label>
<div class="col-sm-4">
<div id="${id}PreId">
<div><img width="100px" height="100px"
@if(isEmpty(avatarImg)){
src="${ctxPath}/static/img/girl.gif"></div>
@}else{
src="${ctxPath}/static/img/${avatarImg}"></div>
@}
</div>
</div>
<div class="col-sm-2">
<div class="head-scu-btn upload-btn" id="${id}BtnId">
<i class="fa fa-upload"></i> 上传
</div>
</div>
<input type="hidden" id="${id}" />
</div>
@if(isNotEmpty(underline) && underline == 'true'){
<div class="hr-line-dashed"></div>
@}
src/main/webapp/WEB-INF/view/system/user/user_view.html
View file @
58375f03
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-6 b-r"
>
<div
class=
"col-sm-6 b-r"
>
<
#
avatar
id=
"avatar"
name=
"头像"
underline=
"true"
avatarImg=
"boy.gif"
/>
<
#
input
id=
"account"
name=
"账户"
underline=
"true"
value=
"${user.account}"
disabled=
"disabled"
/>
<
#
input
id=
"account"
name=
"账户"
underline=
"true"
value=
"${user.account}"
disabled=
"disabled"
/>
<
#
select
id=
"sex"
name=
"性别"
underline=
"true"
value=
"${user.sex}"
>
<
#
select
id=
"sex"
name=
"性别"
underline=
"true"
value=
"${user.sex}"
>
...
...
src/main/webapp/static/modular/system/user/user_info.js
View file @
58375f03
...
@@ -2,71 +2,71 @@
...
@@ -2,71 +2,71 @@
* 用户详情对话框(可用于添加和修改对话框)
* 用户详情对话框(可用于添加和修改对话框)
*/
*/
var
UserInfoDlg
=
{
var
UserInfoDlg
=
{
userInfoData
:
{}
userInfoData
:
{}
};
};
/**
/**
* 清除数据
* 清除数据
*/
*/
UserInfoDlg
.
clearData
=
function
()
{
UserInfoDlg
.
clearData
=
function
()
{
this
.
userInfoData
=
{};
this
.
userInfoData
=
{};
};
};
/**
/**
* 设置对话框中的数据
* 设置对话框中的数据
*
*
* @param key 数据的名称
* @param key 数据的名称
* @param val 数据的具体值
* @param val 数据的具体值
*/
*/
UserInfoDlg
.
set
=
function
(
key
,
val
)
{
UserInfoDlg
.
set
=
function
(
key
,
val
)
{
this
.
userInfoData
[
key
]
=
(
typeof
value
==
"undefined"
)
?
$
(
"#"
+
key
).
val
()
:
value
;
this
.
userInfoData
[
key
]
=
(
typeof
value
==
"undefined"
)
?
$
(
"#"
+
key
).
val
()
:
value
;
return
this
;
return
this
;
};
};
/**
/**
* 设置对话框中的数据
* 设置对话框中的数据
*
*
* @param key 数据的名称
* @param key 数据的名称
* @param val 数据的具体值
* @param val 数据的具体值
*/
*/
UserInfoDlg
.
get
=
function
(
key
)
{
UserInfoDlg
.
get
=
function
(
key
)
{
return
$
(
"#"
+
key
).
val
();
return
$
(
"#"
+
key
).
val
();
};
};
/**
/**
* 关闭此对话框
* 关闭此对话框
*/
*/
UserInfoDlg
.
close
=
function
()
{
UserInfoDlg
.
close
=
function
()
{
parent
.
layer
.
close
(
window
.
parent
.
MgrUser
.
layerIndex
);
parent
.
layer
.
close
(
window
.
parent
.
MgrUser
.
layerIndex
);
};
};
/**
/**
* 点击部门input框时
* 点击部门input框时
*
*
* @param e
* @param e
* @param treeId
* @param treeId
* @param treeNode
* @param treeNode
* @returns
* @returns
*/
*/
UserInfoDlg
.
onClickDept
=
function
(
e
,
treeId
,
treeNode
)
{
UserInfoDlg
.
onClickDept
=
function
(
e
,
treeId
,
treeNode
)
{
$
(
"#citySel"
).
attr
(
"value"
,
instance
.
getSelectedVal
());
$
(
"#citySel"
).
attr
(
"value"
,
instance
.
getSelectedVal
());
$
(
"#deptid"
).
attr
(
"value"
,
treeNode
.
id
);
$
(
"#deptid"
).
attr
(
"value"
,
treeNode
.
id
);
};
};
/**
/**
* 显示部门选择的树
* 显示部门选择的树
*
*
* @returns
* @returns
*/
*/
UserInfoDlg
.
showDeptSelectTree
=
function
()
{
UserInfoDlg
.
showDeptSelectTree
=
function
()
{
var
cityObj
=
$
(
"#citySel"
);
var
cityObj
=
$
(
"#citySel"
);
var
cityOffset
=
$
(
"#citySel"
).
offset
();
var
cityOffset
=
$
(
"#citySel"
).
offset
();
$
(
"#menuContent"
).
css
({
$
(
"#menuContent"
).
css
({
left
:
cityOffset
.
left
+
"px"
,
left
:
cityOffset
.
left
+
"px"
,
top
:
cityOffset
.
top
+
cityObj
.
outerHeight
()
+
"px"
top
:
cityOffset
.
top
+
cityObj
.
outerHeight
()
+
"px"
}).
slideDown
(
"fast"
);
}).
slideDown
(
"fast"
);
$
(
"body"
).
bind
(
"mousedown"
,
onBodyDown
);
$
(
"body"
).
bind
(
"mousedown"
,
onBodyDown
);
};
};
/**
/**
...
@@ -74,12 +74,12 @@ UserInfoDlg.showDeptSelectTree = function() {
...
@@ -74,12 +74,12 @@ UserInfoDlg.showDeptSelectTree = function() {
*
*
* @returns
* @returns
*/
*/
UserInfoDlg
.
showInfoDeptSelectTree
=
function
()
{
UserInfoDlg
.
showInfoDeptSelectTree
=
function
()
{
var
cityObj
=
$
(
"#citySel"
);
var
cityObj
=
$
(
"#citySel"
);
var
cityPosition
=
$
(
"#citySel"
).
position
();
var
cityPosition
=
$
(
"#citySel"
).
position
();
$
(
"#menuContent"
).
css
({
$
(
"#menuContent"
).
css
({
left
:
cityPosition
.
left
+
"px"
,
left
:
cityPosition
.
left
+
"px"
,
top
:
cityPosition
.
top
+
cityObj
.
outerHeight
()
+
"px"
top
:
cityPosition
.
top
+
cityObj
.
outerHeight
()
+
"px"
}).
slideDown
(
"fast"
);
}).
slideDown
(
"fast"
);
$
(
"body"
).
bind
(
"mousedown"
,
onBodyDown
);
$
(
"body"
).
bind
(
"mousedown"
,
onBodyDown
);
...
@@ -88,28 +88,28 @@ UserInfoDlg.showInfoDeptSelectTree = function() {
...
@@ -88,28 +88,28 @@ UserInfoDlg.showInfoDeptSelectTree = function() {
/**
/**
* 隐藏部门选择的树
* 隐藏部门选择的树
*/
*/
UserInfoDlg
.
hideDeptSelectTree
=
function
()
{
UserInfoDlg
.
hideDeptSelectTree
=
function
()
{
$
(
"#menuContent"
).
fadeOut
(
"fast"
);
$
(
"#menuContent"
).
fadeOut
(
"fast"
);
$
(
"body"
).
unbind
(
"mousedown"
,
onBodyDown
);
// mousedown当鼠标按下就可以触发,不用弹起
$
(
"body"
).
unbind
(
"mousedown"
,
onBodyDown
);
// mousedown当鼠标按下就可以触发,不用弹起
};
};
/**
/**
* 收集数据
* 收集数据
*/
*/
UserInfoDlg
.
collectData
=
function
()
{
UserInfoDlg
.
collectData
=
function
()
{
this
.
set
(
'id'
).
set
(
'account'
).
set
(
'sex'
).
set
(
'password'
)
this
.
set
(
'id'
).
set
(
'account'
).
set
(
'sex'
).
set
(
'password'
)
.
set
(
'email'
).
set
(
'name'
).
set
(
'birthday'
).
set
(
'rePassword'
).
set
(
'deptid'
).
set
(
'phone'
);
.
set
(
'email'
).
set
(
'name'
).
set
(
'birthday'
).
set
(
'rePassword'
).
set
(
'deptid'
).
set
(
'phone'
);
};
};
/**
/**
* 验证两个密码是否一致
* 验证两个密码是否一致
*/
*/
UserInfoDlg
.
validatePwd
=
function
()
{
UserInfoDlg
.
validatePwd
=
function
()
{
var
password
=
this
.
get
(
"password"
);
var
password
=
this
.
get
(
"password"
);
var
rePassword
=
this
.
get
(
"rePassword"
);
var
rePassword
=
this
.
get
(
"rePassword"
);
if
(
password
==
rePassword
)
{
if
(
password
==
rePassword
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
};
};
...
@@ -117,55 +117,55 @@ UserInfoDlg.validatePwd = function(){
...
@@ -117,55 +117,55 @@ UserInfoDlg.validatePwd = function(){
/**
/**
* 提交添加用户
* 提交添加用户
*/
*/
UserInfoDlg
.
addSubmit
=
function
()
{
UserInfoDlg
.
addSubmit
=
function
()
{
this
.
clearData
();
this
.
clearData
();
this
.
collectData
();
this
.
collectData
();
if
(
!
this
.
validatePwd
())
{
if
(
!
this
.
validatePwd
())
{
Feng
.
error
(
"两次密码输入不一致"
);
Feng
.
error
(
"两次密码输入不一致"
);
return
;
return
;
}
}
//提交信息
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/add"
,
function
(
data
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/add"
,
function
(
data
)
{
Feng
.
success
(
"添加成功!"
);
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
MgrUser
.
table
.
refresh
();
window
.
parent
.
MgrUser
.
table
.
refresh
();
UserInfoDlg
.
close
();
UserInfoDlg
.
close
();
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
});
ajax
.
set
(
this
.
userInfoData
);
ajax
.
set
(
this
.
userInfoData
);
ajax
.
start
();
ajax
.
start
();
};
};
/**
/**
* 提交修改
* 提交修改
*/
*/
UserInfoDlg
.
editSubmit
=
function
()
{
UserInfoDlg
.
editSubmit
=
function
()
{
this
.
clearData
();
this
.
clearData
();
this
.
collectData
();
this
.
collectData
();
//提交信息
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/edit"
,
function
(
data
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/edit"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
MgrUser
.
table
.
refresh
();
window
.
parent
.
MgrUser
.
table
.
refresh
();
UserInfoDlg
.
close
();
UserInfoDlg
.
close
();
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
});
ajax
.
set
(
this
.
userInfoData
);
ajax
.
set
(
this
.
userInfoData
);
ajax
.
start
();
ajax
.
start
();
};
};
/**
/**
* 修改密码
* 修改密码
*/
*/
UserInfoDlg
.
chPwd
=
function
()
{
UserInfoDlg
.
chPwd
=
function
()
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/changePwd"
,
function
(
data
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/changePwd"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
Feng
.
success
(
"修改成功!"
);
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
});
ajax
.
set
(
"oldPwd"
);
ajax
.
set
(
"oldPwd"
);
...
@@ -176,18 +176,22 @@ UserInfoDlg.chPwd = function(){
...
@@ -176,18 +176,22 @@ UserInfoDlg.chPwd = function(){
};
};
function
onBodyDown
(
event
)
{
function
onBodyDown
(
event
)
{
if
(
!
(
event
.
target
.
id
==
"menuBtn"
||
event
.
target
.
id
==
"menuContent"
||
$
(
if
(
!
(
event
.
target
.
id
==
"menuBtn"
||
event
.
target
.
id
==
"menuContent"
||
$
(
event
.
target
).
parents
(
"#menuContent"
).
length
>
0
))
{
event
.
target
).
parents
(
"#menuContent"
).
length
>
0
))
{
UserInfoDlg
.
hideDeptSelectTree
();
UserInfoDlg
.
hideDeptSelectTree
();
}
}
}
}
$
(
function
()
{
$
(
function
()
{
var
ztree
=
new
$ZTree
(
"treeDemo"
,
"/dept/tree"
);
var
ztree
=
new
$ZTree
(
"treeDemo"
,
"/dept/tree"
);
ztree
.
bindOnClick
(
UserInfoDlg
.
onClickDept
);
ztree
.
bindOnClick
(
UserInfoDlg
.
onClickDept
);
ztree
.
init
();
ztree
.
init
();
instance
=
ztree
;
instance
=
ztree
;
//初始化性别选项
//初始化性别选项
$
(
"#sex"
).
val
(
$
(
"#sexValue"
).
val
());
$
(
"#sex"
).
val
(
$
(
"#sexValue"
).
val
());
// 初始化头像上传
var
avatarUp
=
new
$WebUpload
(
"avatar"
);
avatarUp
.
init
();
});
});
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