提交代码
parent
f0c9416033
commit
1c107346dc
|
@ -1,9 +1,11 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.system.domain.vo.AlertUserPassVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -19,6 +21,8 @@ import com.ruoyi.framework.web.service.SysLoginService;
|
|||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.system.domain.vo.AlertUserPassVo;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -248,4 +253,26 @@ public class SysUserController extends BaseController
|
|||
{
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码修改密码
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Anonymous
|
||||
@PostMapping("/v1/sendPhoneMessage")
|
||||
public AjaxResult sendPhoneMessage(@RequestBody Map<String,String> data){
|
||||
return userService.sendPhoneMessage(data.get("phoneNumber"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户修改密码&【不需要token】
|
||||
* @param alertUserPassVo
|
||||
* @return
|
||||
*/
|
||||
@Anonymous
|
||||
@PostMapping(value = "/v1/codeUpdatePwd")
|
||||
public AjaxResult codeUpdatePwd(@RequestBody @Valid AlertUserPassVo alertUserPassVo){
|
||||
return userService.updataUserPassWord(alertUserPassVo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -570,6 +570,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult sendPhoneMessage(String phoneNumber){
|
||||
if(StringUtils.isEmpty(phoneNumber)){
|
||||
throw new ServiceException("手机号码不能为空!");
|
||||
}
|
||||
String key = "YANZHU.sendPhoneMessage."+phoneNumber;
|
||||
String obj = redisCache.getCacheObject(key);
|
||||
if(obj!=null){
|
||||
|
@ -577,7 +580,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
}
|
||||
SysUser sysUser = userMapper.selectUserByUserName(phoneNumber);
|
||||
if(sysUser==null){
|
||||
return AjaxResult.success(false);
|
||||
throw new ServiceException("账号"+phoneNumber+"不存在,请重新输入!");
|
||||
}
|
||||
String yangZhengMa = RandomUtil.randomNumbers(6);
|
||||
String content = "您正在修改密码,本次验证码为:" + yangZhengMa + ",有效期5分钟。请勿转发或泄漏,如果不是您的操作请忽略。";
|
||||
|
@ -609,7 +612,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
if(!SecurityUtils.matchesPassword(alertUserPassVo.getOldPass(),sysUser.getPassword())) {
|
||||
throw new ServiceException("旧密码错误,请重新输入!");
|
||||
}
|
||||
if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
if(!Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
throw new ServiceException("两次密码不一致,请重新输入!");
|
||||
}
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(alertUserPassVo.getPassword()));
|
||||
|
@ -623,7 +626,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
if(StringUtils.isEmpty(alertUserPassVo.getCode())){
|
||||
throw new ServiceException("验证码不能为空!");
|
||||
}
|
||||
if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
if(!Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
throw new ServiceException("两次密码不一致,请重新输入!");
|
||||
}
|
||||
String key = "YANZHU.sendPhoneMessage."+alertUserPassVo.getLoginName()+".VERIFY";
|
||||
|
|
|
@ -133,3 +133,21 @@ export function deptTreeSelect() {
|
|||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 发送短信验证码
|
||||
export function sendPhoneMessage(data) {
|
||||
return request({
|
||||
url: '/system/user/v1/sendPhoneMessage',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 用户修改密码
|
||||
export function codeUpdatePwd(data) {
|
||||
return request({
|
||||
url: '/system/user/v1/codeUpdatePwd',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
|
@ -173,7 +173,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="投诉时间" align="center" prop="createTime">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.checkTime, "{y}-{m}-{d} {h}:{i}") }}</span>
|
||||
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}") }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div class="login">
|
||||
<div class="login-bg"></div>
|
||||
<div v-if="isLogin">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">产发工程数字管理平台</h3>
|
||||
<el-form-item prop="username">
|
||||
|
@ -46,9 +47,18 @@
|
|||
<img :src="codeUrl" @click="getCode" class="login-code-img" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin: 0px 0px 25px 0px"
|
||||
>记住密码</el-checkbox
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="12" style="text-align: right; font-size: 14px">
|
||||
<el-link type="primary" icon="el-icon-warning" @click="isLogin = false"
|
||||
>忘记密码?立即修改</el-link
|
||||
>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
|
@ -65,6 +75,79 @@
|
|||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div v-if="!isLogin">
|
||||
<el-form ref="passForm" :model="passForm" :rules="passRules" class="login-form">
|
||||
<h3 class="title">产发工程数字管理平台</h3>
|
||||
<el-form-item prop="loginName">
|
||||
<el-input v-model="passForm.loginName" type="text" placeholder="手机账号">
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="pCode">
|
||||
<el-input v-model="passForm.pCode" placeholder="验证码" style="width: 68%">
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="validCode"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<el-button
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width: 100%"
|
||||
@click="sendPhoneMsg"
|
||||
:disabled="disabled"
|
||||
>
|
||||
{{ buttonText }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item prop="pw">
|
||||
<el-input v-model="passForm.pw" type="password" placeholder="登录密码">
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="password"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="cpw">
|
||||
<el-input v-model="passForm.cpw" type="password" placeholder="确认密码">
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="password"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width: 100%"
|
||||
@click="codeUpdatePwd"
|
||||
>
|
||||
<span v-if="!loading">修 改 密 码</span>
|
||||
<span v-else>修 改 中...</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button
|
||||
plain
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="info"
|
||||
style="width: 100%"
|
||||
@click="isLogin = true"
|
||||
>
|
||||
<span>返 回 登 录</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
<span>Copyright © 2023 西咸新区泾河新城产业发展集团 All Rights Reserved.</span>
|
||||
|
@ -74,6 +157,7 @@
|
|||
|
||||
<script>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import { codeUpdatePwd, sendPhoneMessage } from "@/api/system/user";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from "@/utils/jsencrypt";
|
||||
|
||||
|
@ -89,17 +173,35 @@ export default {
|
|||
code: "",
|
||||
uuid: "",
|
||||
},
|
||||
passForm: {
|
||||
loginName: "",
|
||||
pw: "",
|
||||
cpw: "",
|
||||
pCode: "",
|
||||
source: "r",
|
||||
},
|
||||
loginRules: {
|
||||
username: [{ required: true, trigger: "blur", message: "请输入您的账号" }],
|
||||
password: [{ required: true, trigger: "blur", message: "请输入您的密码" }],
|
||||
username: [{ required: true, trigger: "change", message: "请输入您的账号" }],
|
||||
password: [{ required: true, trigger: "change", message: "请输入您的密码" }],
|
||||
code: [{ required: true, trigger: "change", message: "请输入验证码" }],
|
||||
},
|
||||
passRules: {
|
||||
loginName: [{ required: true, trigger: "change", message: "请输入您的账号" }],
|
||||
pw: [{ required: true, trigger: "change", message: "请输入您的密码" }],
|
||||
cpw: [{ required: true, trigger: "change", message: "请输入确认密码" }],
|
||||
pCode: [{ required: true, trigger: "change", message: "请输入验证码" }],
|
||||
},
|
||||
loading: false,
|
||||
// 验证码开关
|
||||
captchaEnabled: true,
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined,
|
||||
isLogin: true,
|
||||
timer: null,
|
||||
count: 30,
|
||||
buttonText: "发送验证码",
|
||||
disabled: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
@ -134,6 +236,7 @@ export default {
|
|||
password: password === undefined ? this.loginForm.password : decrypt(password),
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
||||
};
|
||||
this.passForm.loginName = "";
|
||||
},
|
||||
handleLogin() {
|
||||
this.redirect = this.$route.query.redirect;
|
||||
|
@ -152,7 +255,7 @@ export default {
|
|||
this.$store
|
||||
.dispatch("Login", this.loginForm)
|
||||
.then(() => {
|
||||
window.open( this.redirect || "#/index",'_self');
|
||||
window.open(this.redirect || "#/index", "_self");
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
|
@ -163,6 +266,61 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
resetCountdown() {
|
||||
this.count = 30;
|
||||
this.buttonText = "发送验证码";
|
||||
this.disabled = false; // 恢复按钮可点击
|
||||
},
|
||||
startCountdown() {
|
||||
this.disabled = true; // 禁用按钮
|
||||
this.buttonText = `${this.count}秒后发送`;
|
||||
this.timer = setInterval(() => {
|
||||
this.count--;
|
||||
this.buttonText = `${this.count}秒后发送`;
|
||||
if (this.count <= 0) {
|
||||
clearInterval(this.timer);
|
||||
this.resetCountdown();
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
//发送验证码
|
||||
sendPhoneMsg() {
|
||||
if (this.passForm.loginName) {
|
||||
sendPhoneMessage({ phoneNumber: this.passForm.loginName }).then((res) => {
|
||||
if (res.code == 200 && res.data) {
|
||||
this.$modal.msgSuccess(`已发送验证码,请注意查收。5分钟内有效!`);
|
||||
this.startCountdown();
|
||||
} else {
|
||||
this.$modal.msgError(`请稍后再试!`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$modal.msgError(`请输入正确的登录账号/手机号!`);
|
||||
}
|
||||
},
|
||||
codeUpdatePwd() {
|
||||
this.$refs.passForm.validate((valid) => {
|
||||
if (valid) {
|
||||
if(this.passForm.pw!=this.passForm.cpw){
|
||||
this.$modal.msgError(`两次输入的密码不一致,请重新输入!`);
|
||||
return false;
|
||||
}
|
||||
this.loading = true;
|
||||
this.passForm.password = this.passForm.pw;
|
||||
this.passForm.confPass = this.passForm.cpw;
|
||||
this.passForm.code = this.passForm.pCode;
|
||||
codeUpdatePwd(this.passForm).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.$modal.msgSuccess(`密码修改成功!`);
|
||||
this.loading = false;
|
||||
this.isLogin = true;
|
||||
}
|
||||
}).catch((err) => {
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -183,26 +183,34 @@ public class WechatUserLoginController extends BaseController {
|
|||
|
||||
/**
|
||||
* 发送短信验证码修改密码
|
||||
* @param phoneNumber
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/sendPhoneMessage/{phoneNumber}")
|
||||
public AjaxResult sendPhoneMessage(@PathVariable("phoneNumber") String phoneNumber){
|
||||
return sysUserService.sendPhoneMessage(phoneNumber);
|
||||
@PostMapping("/v1/sendPhoneMessage")
|
||||
public AjaxResult sendPhoneMessage(@RequestBody Map<String,String> data){
|
||||
return sysUserService.sendPhoneMessage(data.get("phoneNumber"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 修改密码
|
||||
* @Param: [map]
|
||||
* @return: java.lang.Object
|
||||
* @Author: wxw
|
||||
* @Date: 2020/7/7 19:15
|
||||
* 用户修改密码&需要token
|
||||
* @param alertUserPassVo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/v1/updatePassword")
|
||||
public AjaxResult updatePassword(@RequestBody @Valid AlertUserPassVo alertUserPassVo){
|
||||
return sysUserService.updataUserPassWord(alertUserPassVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户修改密码&【不需要token】
|
||||
* @param alertUserPassVo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/v1/codeUpdatePwd")
|
||||
public AjaxResult codeUpdatePwd(@RequestBody @Valid AlertUserPassVo alertUserPassVo){
|
||||
return sysUserService.updataUserPassWord(alertUserPassVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param request
|
||||
|
|
Loading…
Reference in New Issue