用户更新个人资料模块

master
星期八 5 years ago
parent 411cd3f1b4
commit 8ca3de2f0d
  1. 9
      src/main/java/com/lq/cms/web/IndexController.java
  2. 14
      src/main/java/com/lq/cms/web/sys/UserController.java
  3. 2
      src/main/profile/dev/jdbc.properties
  4. 2
      src/main/profile/dev/redis.properties
  5. 24
      src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp
  6. 71
      src/main/webapp/WEB-INF/views/jsp/cms/main/userEdit.jsp
  7. 14
      src/main/webapp/WEB-INF/views/jsp/cms/sys/user/edit.jsp
  8. 2
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp
  9. BIN
      src/main/webapp/resources/code/images/uploadIcon.png
  10. 12
      src/main/webapp/resources/code/js/imageUtil.js

@ -22,6 +22,7 @@ import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@ -109,4 +110,12 @@ public class IndexController {
return ajaxResult;
}
@RequestMapping("/userEdit")
public String toUserEdit(Model model){
Subject subject = SecurityUtils.getSubject();
SysUser sysUser = (SysUser) subject.getPrincipal();
model.addAttribute("sysUser",sysUser);
return "cms/main/userEdit";
}
}

@ -133,7 +133,6 @@ public class UserController {
if (sysUser!=null&&sysUser.getId()!=null){
sysUserService.delete(sysUser.getId());
}
return ajaxResult;
}
@ -145,7 +144,6 @@ public class UserController {
String fileType = FileUtil.fileFormat(multipartFile.getOriginalFilename());
newFileName = "user/"+uuid.toString()+"."+fileType;
File newFile = new File(FILE_LOAD_PATH +newFileName);
if (!newFile.exists()){
newFile.mkdirs();
}
@ -173,7 +171,6 @@ public class UserController {
sysUserService.update(sysUser);
subject.logout();
SecurityUtils.getSecurityManager().logout(subject);
}else {
ajaxResult.setSuccess(false);
ajaxResult.setMsg("旧密码不正确!,请重新输入.");
@ -186,4 +183,15 @@ public class UserController {
}
public AjaxResult updateUser(SysUser sysUser){
Subject subject = SecurityUtils.getSubject();
SysUser loginUser =(SysUser)subject.getPrincipal();
if (loginUser!=null){
BeanUtil.copyNotNull(loginUser,sysUser);
sysUserService.update(loginUser);
}
return new AjaxResult();
}
}

@ -1,6 +1,6 @@
#--------- jdbc 配置---------
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.url=jdbc:mysql://192.168.31.110:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.user=root
jdbc.password=mysql
#--------数据库连接池配置 -------

@ -1,4 +1,4 @@
redis.host=127.0.0.1
redis.host=192.168.31.110
redis.port=6379
redis.pass=
redis.timeout=-1

@ -350,8 +350,30 @@
}
//设置用户资料
var iframeWin ;
function setUserData() {
alert("开发中.....");
layer.open({
id:"setUserDate",
type: 2,
area: ['380px', '400px'],
fixed: false, //不固定
maxmin: false,
title:"编辑个人信息",
btn:["确定","取消"],
btn1:function(index){
var body = layer.getChildFrame('body', index);
// var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
iframeWin.postDate();
layer.close(index);
},
btnAlign: 'c',
content: '${ctx}/cms/userEdit',
success: function(layero, index){
iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
}
});
}
</script>

@ -6,12 +6,81 @@
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../common/import-tag.jsp" %>
<html>
<head>
<title>用户资料编辑</title>
<script type="text/javascript">
function imageError(imager) {
imager.setAttribute("src", "${ctx}/resources/code/images/uploadIcon.png");
}
</script>
<style type="text/css">
.left_td{
width: 120px;
text-align:right;
}
.right_td{
padding-left:20px;
}
</style>
</head>
<body>
<table>
<tr>
<td class="left_td" >
用户名:
</td>
<td class="right_td">
<input type="text" name="userName" value="${sysUser.loginName}">
</td>
</tr>
<tr>
<td class="left_td">
邮箱:
</td>
<td class="right_td">
<input type="text" name="email" value="${sysUser.email}" >
</td>
</tr>
<tr>
<td class="left_td">
头像:
</td>
<td class="right_td">
<img src="${ctx}/loadFile/${sysUser.imgUrl}" border="2"
width="100" height="100" style="border-radius:12px;"
id="uploadBtn" onerror="imageError(this)">
<input type="file" style="visibility:hidden;" id="uploadFile">
</td>
</tr>
<tr>
<td class="left_td">
备注:
</td>
<td>
<textarea id="" rows="4"> </textarea>
</td>
</tr>
</table>
</body>
<script type="text/javascript" src="${ctx}/resources/code/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/code/js/imageUtil.js"></script>
<script>
$(function () {
$("#uploadBtn").click(function () {
$("#uploadFile").trigger("click");
});
$("#uploadFile").change(function () {
var imageUrl = getObjectURL(this.files[0]);
$("#uploadBtn").attr("src",imageUrl);
});
});
function postDate() {
alert("提交数据");
}
</script>
</html>

@ -4,6 +4,7 @@
<html>
<head>
<title>编辑</title>
<script type="text/javascript" src="${ctx}/resources/code/js/imageUtil.js"/>
<script type="text/javascript">
$(function () {
$("#image_td").hide();
@ -22,18 +23,7 @@
}
});
//构建本地图片路径
function getObjectURL(file) {
var url = null ;
if (window.createObjectURL!=undefined) {
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) {
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) {
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
</script>
</head>
<body>

@ -403,7 +403,6 @@
btn:['确定','取消'],
btn1:function(index,layero){
messageSet = bufferSet;
console.log(messageSet);
layer.close(index);
},
skin: 'layui-layer-rim', //加上边框
@ -629,7 +628,6 @@
}
function appendAlertHtml(data){
console.log(data);
var isShow ;
var wechatMessageList = data.wechatMessageVoList;
var html = '<div class="alert"><div class="left-navigation"><p>图文('+data.wechatMessageCount+')</p></div>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

@ -0,0 +1,12 @@
//构建本地图片路径
function getObjectURL(file) {
var url = null ;
if (window.createObjectURL!=undefined) {
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) {
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) {
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
Loading…
Cancel
Save