提交代码
parent
b6c4b380ab
commit
f0c9416033
|
@ -0,0 +1,91 @@
|
|||
package com.ruoyi.common.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* ////////////////////////////////////////////////////////////////////
|
||||
* // _ooOoo_
|
||||
* // o8888888o
|
||||
* // 88" . "88
|
||||
* // (| ^_^ |)
|
||||
* // O\ = /O
|
||||
* // ____/`---'\____
|
||||
* // .' \\| |// `.
|
||||
* // / \\||| : |||// \
|
||||
* // / _||||| -:- |||||- \
|
||||
* // | | \\\ - /// | |
|
||||
* // | \_| ''\---/'' | |
|
||||
* // \ .-\__ `-` ___/-. /
|
||||
* // ___`. .' /--.--\ `. . ___
|
||||
* // ."" '< `.___\_<|>_/___.' >'"".
|
||||
* // | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
* // \ \ `-. \_ __\ /__ _/ .-` / /
|
||||
* // ========`-.____`-.___\_____/___.-`____.-'========
|
||||
* // `=---='
|
||||
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
* // 佛祖保佑 永无BUG 永不修改
|
||||
* ////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* @ClassName SmsConfig
|
||||
* @Description TODO
|
||||
* @Author QiangZi
|
||||
* @DateTime 2022/3/31 18:15
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
@PropertySource(value = "classpath:message.properties",encoding = "UTF-8")
|
||||
@ConfigurationProperties(prefix = "sms.jiuwei")
|
||||
public class SmsConfig {
|
||||
|
||||
/**
|
||||
* 企信通平台url
|
||||
**/
|
||||
private String url;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
private String productid;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getProductid() {
|
||||
return productid;
|
||||
}
|
||||
|
||||
public void setProductid(String productid) {
|
||||
this.productid = productid;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.ruoyi.common.config.SmsConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* ////////////////////////////////////////////////////////////////////
|
||||
* // _ooOoo_
|
||||
* // o8888888o
|
||||
* // 88" . "88
|
||||
* // (| ^_^ |)
|
||||
* // O\ = /O
|
||||
* // ____/`---'\____
|
||||
* // .' \\| |// `.
|
||||
* // / \\||| : |||// \
|
||||
* // / _||||| -:- |||||- \
|
||||
* // | | \\\ - /// | |
|
||||
* // | \_| ''\---/'' | |
|
||||
* // \ .-\__ `-` ___/-. /
|
||||
* // ___`. .' /--.--\ `. . ___
|
||||
* // ."" '< `.___\_<|>_/___.' >'"".
|
||||
* // | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
* // \ \ `-. \_ __\ /__ _/ .-` / /
|
||||
* // ========`-.____`-.___\_____/___.-`____.-'========
|
||||
* // `=---='
|
||||
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
* // 佛祖保佑 永无BUG 永不修改
|
||||
* ////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* @ClassName SMSUtils
|
||||
* @Description 短信发送工具类
|
||||
* @Author QiangZi
|
||||
* @DateTime 2022/3/10 17:51
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class SmsUtils {
|
||||
|
||||
private static SmsConfig smsConfig;
|
||||
|
||||
/**
|
||||
* @param phoneNumber 手机号码
|
||||
* @param message 消息内容
|
||||
* @return boolean
|
||||
* @throws
|
||||
* @Author QiangZi
|
||||
* @Description 发送短信消息
|
||||
* @Date 2022/3/10 17:53
|
||||
**/
|
||||
public static boolean sendMsg(String phoneNumber, String message) {
|
||||
|
||||
boolean result = false;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer(smsConfig.getUrl());
|
||||
sb.append("?username=").append(smsConfig.getUsername());
|
||||
sb.append("&password=").append(smsConfig.getPassword());
|
||||
sb.append("&productid=").append(smsConfig.getProductid());
|
||||
sb.append("&mobile=" + phoneNumber);
|
||||
//sb.append("&dstime="+URLEncoder.encode("2015-01-01 14:41:00", "utf-8"));
|
||||
sb.append("&content=" + URLEncoder.encode(message, "utf-8"));
|
||||
URL url = new URL(sb.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");//or set POST
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
String inputline = in.readLine();
|
||||
System.out.println("SEND_MSG_XSMS===" + inputline);
|
||||
String code = inputline.split(",")[0];
|
||||
result = code.equals("1");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSmsConfig(SmsConfig smsConfig) {
|
||||
SmsUtils.smsConfig = smsConfig;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
# sms短信平台配置 企信通--九维
|
||||
sms.jiuwei.url=http://123.206.19.78:9001/sendXSms.do
|
||||
sms.jiuwei.username=gwzdyjc
|
||||
sms.jiuwei.password=308517
|
||||
sms.jiuwei.productid=621215
|
|
@ -2,9 +2,6 @@ package com.ruoyi.framework.web.service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -12,6 +9,8 @@ import org.springframework.security.authentication.AuthenticationManager;
|
|||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
|
@ -57,9 +56,6 @@ public class SysLoginService
|
|||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
|
@ -159,54 +155,23 @@ public class SysLoginService
|
|||
return tokenService.createWxToken(loginUser,openId);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
* 小程序免密登录
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param openId 微信openId
|
||||
* @return 结果
|
||||
*/
|
||||
public String login(String username,String openId)
|
||||
public String wxLogin(String username,String openId)
|
||||
{
|
||||
//进入这里先把用户的密码修改,登录成功后在修改回去
|
||||
SysUser sysUser = sysUserMapper.selectUserByUserName(username);
|
||||
String userAuth = sysUser.getPassword();
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try
|
||||
{
|
||||
String password = Convert.toStr(System.currentTimeMillis());
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
sysUserMapper.updateUser(sysUser);
|
||||
log.info("【password】...密文==>{}",sysUser.getPassword());
|
||||
log.info("【"+username+"】...临时登录密码是==>{},旧密码是==>{}",password,userAuth);
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
|
||||
AuthenticationContextHolder.setContext(authenticationToken);
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager.authenticate(authenticationToken);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e instanceof BadCredentialsException)
|
||||
{
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||
throw new UserPasswordNotMatchException();
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
sysUser.setPassword(userAuth);
|
||||
sysUserMapper.updateUser(sysUser);
|
||||
log.info("【"+username+"】...密码已更新==>{}",userAuth);
|
||||
AuthenticationContextHolder.clearContext();
|
||||
}
|
||||
log.info("【"+username+"】免密登录...openId==>{}",openId);
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
LoginUser loginUser = new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
recordLoginInfo(loginUser.getUserId());
|
||||
// 生成token
|
||||
return tokenService.createWxToken(loginUser,openId);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
@ -28,6 +31,8 @@ public class SysPasswordService
|
|||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
public static final String defaultNoSecurityPassWord = "??????????????????????";
|
||||
|
||||
@Value(value = "${user.password.maxRetryCount}")
|
||||
private int maxRetryCount;
|
||||
|
||||
|
@ -65,7 +70,7 @@ public class SysPasswordService
|
|||
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
|
||||
}
|
||||
|
||||
if (!matches(user, password))
|
||||
if (!Objects.equals(password,defaultNoSecurityPassWord) && !matches(user, password))
|
||||
{
|
||||
retryCount = retryCount + 1;
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@Data
|
||||
public class AlertUserPassVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 手机号码格式限制
|
||||
*/
|
||||
public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$";
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
@NotBlank(message = "登录账号不能为空")
|
||||
@Pattern(regexp = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$", message = "手机号格式异常")
|
||||
private String loginName;
|
||||
|
||||
@NotBlank(message = "登录密码不能为空")
|
||||
@Size(min = 6, max = 20, message = "登录密码格式异常")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "确认密码不能为空")
|
||||
@Size(min = 6, max = 20, message = "确认密码格式异常")
|
||||
private String confPass;
|
||||
|
||||
@Size(min = 6, max = 20, message = "旧密码格式异常")
|
||||
private String oldPass;
|
||||
|
||||
@Pattern(regexp = "^[0-9]{6}$", message = "验证码格式异常")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
@NotBlank(message = "来源不能为空")
|
||||
@Pattern(regexp = "r|u", message = "来源异常")
|
||||
private String source;
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.system.domain.vo.AlertUserPassVo;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
|
@ -212,4 +215,18 @@ public interface ISysUserService
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* @param phoneNumber 电话号码
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult sendPhoneMessage(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
* @param alertUserPassVo
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult updataUserPassWord(AlertUserPassVo alertUserPassVo);
|
||||
}
|
||||
|
|
|
@ -1,40 +1,39 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.system.domain.SysApplyConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.SmsUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.domain.SysUserPost;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.mapper.SysPostMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.domain.vo.AlertUserPassVo;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.Validator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
|
@ -46,6 +45,12 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
|
@ -64,9 +69,6 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -556,8 +558,88 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
* @param phonenumber 用户手机
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectUserRoles(String phonenumber) {
|
||||
return userRoleMapper.selectUserRoles(phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult sendPhoneMessage(String phoneNumber){
|
||||
String key = "YANZHU.sendPhoneMessage."+phoneNumber;
|
||||
String obj = redisCache.getCacheObject(key);
|
||||
if(obj!=null){
|
||||
return AjaxResult.success(false);
|
||||
}
|
||||
SysUser sysUser = userMapper.selectUserByUserName(phoneNumber);
|
||||
if(sysUser==null){
|
||||
return AjaxResult.success(false);
|
||||
}
|
||||
String yangZhengMa = RandomUtil.randomNumbers(6);
|
||||
String content = "您正在修改密码,本次验证码为:" + yangZhengMa + ",有效期5分钟。请勿转发或泄漏,如果不是您的操作请忽略。";
|
||||
// 发送短信
|
||||
boolean result = SmsUtils.sendMsg(phoneNumber, content);
|
||||
if(result){
|
||||
redisCache.setCacheObject(key,yangZhengMa,2, TimeUnit.MINUTES);
|
||||
redisCache.setCacheObject(key+".VERIFY",yangZhengMa,5,TimeUnit.MINUTES);
|
||||
}
|
||||
return AjaxResult.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
* @param alertUserPassVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult updataUserPassWord(AlertUserPassVo alertUserPassVo){
|
||||
SysUser sysUser = userMapper.selectUserByUserName(alertUserPassVo.getLoginName());
|
||||
if(sysUser==null){
|
||||
throw new ServiceException("修改的登录账号不存在");
|
||||
}
|
||||
if(Objects.equals("u",alertUserPassVo.getSource())){
|
||||
if(StringUtils.isEmpty(alertUserPassVo.getOldPass())){
|
||||
throw new ServiceException("旧密码不能为空!");
|
||||
}
|
||||
if(!SecurityUtils.matchesPassword(alertUserPassVo.getOldPass(),sysUser.getPassword())) {
|
||||
throw new ServiceException("旧密码错误,请重新输入!");
|
||||
}
|
||||
if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
throw new ServiceException("两次密码不一致,请重新输入!");
|
||||
}
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(alertUserPassVo.getPassword()));
|
||||
int res = userMapper.updateUser(sysUser);
|
||||
if(res>0){
|
||||
return AjaxResult.success();
|
||||
}else{
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isEmpty(alertUserPassVo.getCode())){
|
||||
throw new ServiceException("验证码不能为空!");
|
||||
}
|
||||
if(Objects.equals(alertUserPassVo.getPassword(),alertUserPassVo.getConfPass())){
|
||||
throw new ServiceException("两次密码不一致,请重新输入!");
|
||||
}
|
||||
String key = "YANZHU.sendPhoneMessage."+alertUserPassVo.getLoginName()+".VERIFY";
|
||||
String code = redisCache.getCacheObject(key);
|
||||
if(StringUtils.isNotEmpty(code) && Objects.equals(code,alertUserPassVo.getCode())){
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(alertUserPassVo.getPassword()));
|
||||
int res = userMapper.updateUser(sysUser);
|
||||
if(res>0){
|
||||
return AjaxResult.success();
|
||||
}else{
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}else{
|
||||
throw new ServiceException("验证码输入错误,请重新输入!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
package com.ruoyi.web.userLogin.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.SmsUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.SysUserOpenid;
|
||||
import com.ruoyi.system.domain.vo.AlertUserPassVo;
|
||||
import com.ruoyi.system.service.ISysUserOpenidService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.web.userLogin.service.IWechatUserLoginService;
|
||||
import liquibase.pro.packaged.S;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -40,6 +46,9 @@ public class WechatUserLoginController extends BaseController {
|
|||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private IWechatUserLoginService wechatUserLoginService;
|
||||
|
||||
|
@ -83,7 +92,7 @@ public class WechatUserLoginController extends BaseController {
|
|||
return ajax;
|
||||
}
|
||||
data = wechatUserLoginService.getLoginUserByOpenId(loginBody.getOpenId());
|
||||
String token = loginService.login(Convert.toStr(data.get("userName")),loginBody.getOpenId());
|
||||
String token = loginService.wxLogin(Convert.toStr(data.get("userName")),loginBody.getOpenId());
|
||||
// 移动端这里刷新token有效期为长期
|
||||
tokenService.refreshMobileToken(token);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
|
@ -146,18 +155,6 @@ public class WechatUserLoginController extends BaseController {
|
|||
return success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 修改密码
|
||||
* @Param: [map]
|
||||
* @return: java.lang.Object
|
||||
* @Author: wxw
|
||||
* @Date: 2020/7/7 19:15
|
||||
*/
|
||||
@RequestMapping(value = "updatePassword",method = RequestMethod.POST)
|
||||
public Object updatePassword(@RequestParam Map<String,Object> map){
|
||||
return wechatUserLoginService.updataUser(map);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ISysUserOpenidService sysUserOpenidService;
|
||||
|
||||
|
@ -184,6 +181,28 @@ public class WechatUserLoginController extends BaseController {
|
|||
return success(sysUserOpenidService.updateSysUserOpenid(sysUserOpenid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码修改密码
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/sendPhoneMessage/{phoneNumber}")
|
||||
public AjaxResult sendPhoneMessage(@PathVariable("phoneNumber") String phoneNumber){
|
||||
return sysUserService.sendPhoneMessage(phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 修改密码
|
||||
* @Param: [map]
|
||||
* @return: java.lang.Object
|
||||
* @Author: wxw
|
||||
* @Date: 2020/7/7 19:15
|
||||
*/
|
||||
@PostMapping(value = "/v1/updatePassword")
|
||||
public AjaxResult updatePassword(@RequestBody @Valid AlertUserPassVo alertUserPassVo){
|
||||
return sysUserService.updataUserPassWord(alertUserPassVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param request
|
||||
|
|
|
@ -19,13 +19,6 @@ public interface IWechatUserLoginService {
|
|||
*/
|
||||
public Map<String,Object> findUserInfo(String loginName,String openId);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> updataUser(Map<String,Object> map);
|
||||
|
||||
/**
|
||||
* 获取openId
|
||||
* @param code
|
||||
|
|
|
@ -267,29 +267,4 @@ public class WechatUserLoginServiceImpl implements IWechatUserLoginService {
|
|||
return dataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> updataUser(Map<String, Object> map) {
|
||||
Map<String,Object> infoMap = new HashMap<>();
|
||||
String oldPws = Convert.toStr(map.get("oldPsw"));
|
||||
SysUser sysUser = sysUserMapper.selectUserByUserName(Convert.toStr(map.get("loginName")));
|
||||
if(!SecurityUtils.matchesPassword(oldPws,sysUser.getPassword())) {
|
||||
infoMap.put("data","-1");
|
||||
infoMap.put("info","旧密码错误,请重新输入!");
|
||||
return infoMap;
|
||||
}
|
||||
if(!Convert.toStr(map.get("newPsw")).equals(Convert.toStr(map.get("password")))){
|
||||
infoMap.put("data","-2");
|
||||
infoMap.put("info","两次密码不一致,请重新输入!");
|
||||
return infoMap;
|
||||
}
|
||||
map.put("password",SecurityUtils.encryptPassword(Convert.toStr(map.get("password"))));
|
||||
if(wechatUserLoginMapper.updataUser(map) > 0){
|
||||
infoMap.put("data","200");
|
||||
infoMap.put("info","操作成功");
|
||||
}else {
|
||||
infoMap.put("data","-3");
|
||||
infoMap.put("info","操作失败!");
|
||||
}
|
||||
return infoMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
SELECT sps.id, sps.project_id, sps.dept_id, sd.dept_name, sps.image_file, sps.standard_desc, sps.ord, sps.standard_type,
|
||||
sp.projectName remark,
|
||||
sps.is_del, sps.create_by, sps.create_time, sps.update_by, sps.update_time
|
||||
|
||||
FROM sur_project_standard sps
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = sps.dept_id
|
||||
LEFT JOIN sur_project sp ON sp.id = sps.project_id
|
||||
|
@ -40,24 +39,21 @@
|
|||
<if test="activeName != null and activeName != ''"> and sp.progressVisible = 0</if>
|
||||
<if test="deptId != null "> and sps.dept_id = #{deptId}</if>
|
||||
<if test="standardDesc != null and standardDesc != ''"> and sps.standard_desc like concat('%', #{standardDesc}, '%')</if>
|
||||
<if test="ord != null "> and sps.ord = #{ord}</if>
|
||||
<if test="standardType != null and standardType != ''"> and sps.standard_type like concat('', #{standardType}, '%')</if>
|
||||
<if test="standardType != null and standardType != ''"> and sps.standard_type like concat('', #{standardType}, '%')</if>
|
||||
<if test="isDel != null "> and sps.is_del = #{isDel}</if>
|
||||
</where>
|
||||
order by sps.ord,sps.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSurProjectStandardGroupByType" parameterType="SurProjectStandard" resultType="map">
|
||||
select sps.standard_type as standardType, count(1) as total from sur_project_standard sps
|
||||
select left(sps.standard_type,1) as standardType, count(1) as total from sur_project_standard sps
|
||||
<where>
|
||||
<if test="projectId != null "> and sps.project_id = #{projectId}</if>
|
||||
<if test="deptId != null "> and sps.dept_id = #{deptId}</if>
|
||||
<if test="imageFile != null and imageFile != ''"> and sps.image_file = #{imageFile}</if>
|
||||
<if test="standardDesc != null and standardDesc != ''"> and sps.standard_desc = #{standardDesc}</if>
|
||||
<if test="ord != null "> and sps.ord = #{ord}</if>
|
||||
<if test="isDel != null "> and sps.is_del = #{isDel}</if>
|
||||
</where>
|
||||
group by sps.standard_type
|
||||
group by left(sps.standard_type,1)
|
||||
</select>
|
||||
|
||||
<select id="selectSurProjectStandardById" parameterType="Long" resultMap="SurProjectStandardResult">
|
||||
|
@ -153,6 +149,7 @@
|
|||
sur_project b where a.project_id=b.id and b.progressVisible=0
|
||||
order by a.cnt desc
|
||||
</select>
|
||||
|
||||
<select id="selectList" parameterType="SurProjectStandard" resultMap="SurProjectStandardResult">
|
||||
<include refid="selectSurProjectStandardVo"/>
|
||||
where sps.is_del =0
|
||||
|
|
Loading…
Reference in New Issue