若依开源1.1.2发布
@ -0,0 +1,119 @@
|
||||
package com.ruoyi.project.system.user.controller;
|
||||
|
||||
import org.apache.shiro.crypto.hash.Md5Hash;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.Message;
|
||||
import com.ruoyi.project.system.user.domain.User;
|
||||
import com.ruoyi.project.system.user.service.IUserService;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/system/user/profile")
|
||||
public class ProfileController extends BaseController
|
||||
{
|
||||
private String prefix = "system/user/profile";
|
||||
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping()
|
||||
public String profile(Model model)
|
||||
{
|
||||
User user = getUser();
|
||||
String sex = user.getSex();
|
||||
if ("0".equals(sex))
|
||||
{
|
||||
user.setSex("性别:男");
|
||||
}
|
||||
else if ("1".equals(sex))
|
||||
{
|
||||
user.setSex("性别:女");
|
||||
}
|
||||
String roleGroup = userService.selectUserRoleGroup(user.getUserId());
|
||||
String postGroup = userService.selectUserPostGroup(user.getUserId());
|
||||
model.addAttribute("user", user);
|
||||
model.addAttribute("roleGroup", roleGroup);
|
||||
model.addAttribute("postGroup", postGroup);
|
||||
return prefix + "/profile";
|
||||
}
|
||||
|
||||
@RequestMapping("/checkPassword")
|
||||
@ResponseBody
|
||||
public boolean checkPassword(String password)
|
||||
{
|
||||
User user = getUser();
|
||||
String encrypt = new Md5Hash(user.getLoginName() + password + user.getSalt()).toHex().toString();
|
||||
if (user.getPassword().equals(encrypt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Log(title = "系统管理", action = "个人信息-重置密码")
|
||||
@GetMapping("/resetPwd/{userId}")
|
||||
public String resetPwd(@PathVariable("userId") Long userId, Model model)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
return prefix + "/resetPwd";
|
||||
}
|
||||
|
||||
@Log(title = "系统管理", action = "个人信息-重置密码")
|
||||
@PostMapping("/resetPwd")
|
||||
@ResponseBody
|
||||
public Message resetPwd(User user)
|
||||
{
|
||||
int rows = userService.resetUserPwd(user);
|
||||
if (rows > 0)
|
||||
{
|
||||
setUser(userService.selectUserById(user.getUserId()));
|
||||
return Message.ok();
|
||||
}
|
||||
return Message.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "系统管理", action = "个人信息-修改用户")
|
||||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Long userId, Model model)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "系统管理", action = "个人信息-保存用户")
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(User user)
|
||||
{
|
||||
if (userService.updateUser(user) > 0)
|
||||
{
|
||||
setUser(userService.selectUserById(user.getUserId()));
|
||||
return Message.ok();
|
||||
}
|
||||
return Message.error();
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-user-edit">
|
||||
<input name="userId" type="hidden" th:value="${user.userId}" />
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">登录名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" readonly="true" th:value="${user.loginName}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">部门名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" readonly="true" th:value="${user.dept.deptName}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">用户名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="userName" id="userName" th:value="${user.userName}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="email" th:value="${user.email}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">手机:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="phonenumber" id="phonenumber" th:value="${user.phonenumber}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">性别:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio radio-info radio-inline">
|
||||
<input type="radio" id="radio1" th:field="*{user.sex}" name="sex" value="0">
|
||||
<label for="radio1">男</label>
|
||||
</div>
|
||||
<div class="radio radio-danger radio-inline">
|
||||
<input type="radio" id="radio2" th:field="*{user.sex}" name="sex" value="1">
|
||||
<label for="radio2">女</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-control-static col-sm-offset-9">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
<button th:onclick="'javascript:layer_close()'" class="btn btn-danger" type="button">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script>
|
||||
$("#form-user-edit").validate({
|
||||
rules:{
|
||||
userName:{
|
||||
required:true,
|
||||
},
|
||||
password:{
|
||||
required:true,
|
||||
minlength: 6
|
||||
},
|
||||
email:{
|
||||
required:true,
|
||||
email:true
|
||||
},
|
||||
phonenumber:{
|
||||
required:true,
|
||||
},
|
||||
},
|
||||
submitHandler:function(form){
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
function update() {
|
||||
_ajax_save(ctx + "system/user/profile/update", $("#form-user-edit").serialize());
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,113 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-user-resetPwd">
|
||||
<input name="userId" type="hidden" th:value="${user.userId}" />
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">登录名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" readonly="true" name="loginName" th:value="${user.loginName}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">旧密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="password" name="oldPassword" id="oldPassword">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">新密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="password" name="password" id="password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">再次确认:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="password" name="confirm" id="confirm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-control-static col-sm-offset-9">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
<button th:onclick="'javascript:layer_close()'" class="btn btn-danger" type="button">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include :: footer"></div>
|
||||
|
||||
<script>
|
||||
$("#form-user-resetPwd").validate({
|
||||
rules:{
|
||||
oldPassword:{
|
||||
required:true,
|
||||
minlength: 6,
|
||||
remote: {
|
||||
url: ctx + "system/user/profile/checkPassword",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
data: {
|
||||
password: function() {
|
||||
return $("input[name='oldPassword']").val();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
password: {
|
||||
required: true,
|
||||
minlength: 6
|
||||
},
|
||||
confirm: {
|
||||
required: true,
|
||||
equalTo: "#password"
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
oldPassword: {
|
||||
required: "请输入原密码",
|
||||
remote: "原密码错误"
|
||||
},
|
||||
password: {
|
||||
required: "请输入新密码",
|
||||
minlength: "密码不能小于6个字符"
|
||||
},
|
||||
confirm: {
|
||||
required: "请再次输入新密码",
|
||||
equalTo: "两次密码输入不一致"
|
||||
}
|
||||
|
||||
},
|
||||
submitHandler:function(form){
|
||||
resetPwd();
|
||||
}
|
||||
});
|
||||
|
||||
function resetPwd() {
|
||||
$.ajax({
|
||||
cache : true,
|
||||
type : "post",
|
||||
url : ctx + "system/user/profile/resetPwd",
|
||||
data : $('#form-user-resetPwd').serialize(),
|
||||
async : false,
|
||||
error : function(request) {
|
||||
parent.layer.alert("系统错误");
|
||||
},
|
||||
success : function(data) {
|
||||
if (data.code == 0) {
|
||||
parent.layer.msg("修改成功,正在刷新数据请稍后……",{icon:1,time: 500,shade: [0.1,'#fff']},function(){
|
||||
window.parent.location.reload();
|
||||
});
|
||||
} else {
|
||||
parent.layer.alert(data.m , {icon: 2,title:"系统提示"});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|