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); + } + } + +}