From ee059ea10644d23d107cae7a70c5fc0962753c50 Mon Sep 17 00:00:00 2001 From: chen <1251790704@qq.com> Date: Fri, 4 Jun 2021 15:46:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AF=86=E7=A0=81=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liuwanr/service/UserInfoService.java | 13 +++++--- src/main/java/com/yipin/liuwanr/util/MD5.java | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/yipin/liuwanr/util/MD5.java diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index fa1c87f..977d0d9 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -1,7 +1,6 @@ package com.yipin.liuwanr.service; import com.aliyun.oss.OSSClient; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.yipin.liuwanr.AliyunOssConfig; @@ -12,8 +11,8 @@ import com.yipin.liuwanr.mapper.OrganizationRelationshipMapper; import com.yipin.liuwanr.mapper.StaffMapper; import com.yipin.liuwanr.mapper.StudentMapper; import com.yipin.liuwanr.mapper.UserInfoMapper; +import com.yipin.liuwanr.util.MD5; import com.yipin.liuwanr.vo.UserInfoReceiveVo; -import org.apache.poi.ss.formula.functions.T; import org.jboss.logging.Logger; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +25,10 @@ import redis.clients.jedis.JedisCluster; import javax.annotation.Resource; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -426,10 +428,11 @@ public class UserInfoService { //区分密码大小写 boolean num = false; if (user != null){ - num = password.equals(user.getPassword()); + //校验密码 + num = MD5.encrypt(password).equals(user.getPassword()); } - if(user!=null && num == true) { + if(user!=null && num) { Integer userId = user.getUserId(); List staffList = userInfoMapper.loginsGetStaffSchoolInfo(userId,schoolId); diff --git a/src/main/java/com/yipin/liuwanr/util/MD5.java b/src/main/java/com/yipin/liuwanr/util/MD5.java new file mode 100644 index 0000000..5cfce04 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/util/MD5.java @@ -0,0 +1,31 @@ +package com.yipin.liuwanr.util; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public final class MD5 { + + public static String encrypt(String strSrc) { + try { + char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + byte[] bytes = strSrc.getBytes(); + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(bytes); + bytes = md.digest(); + int j = bytes.length; + char[] chars = new char[j * 2]; + int k = 0; + for (int i = 0; i < bytes.length; i++) { + byte b = bytes[i]; + chars[k++] = hexChars[b >>> 4 & 0xf]; + chars[k++] = hexChars[b & 0xf]; + } + return new String(chars); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + throw new RuntimeException("MD5加密出错!!+" + e); + } + } + +}