派生自 projectDept/qhighschool

yn147
2023-04-13 e10efae34a92fdcb6451f1a6a823a72b8c394d43
src/main/java/com/qxueyou/scc/sys/action/LoginController.java
@@ -24,6 +24,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;
import com.qxueyou.scc.admin.teacher.service.ITeacherService;
@@ -183,8 +184,8 @@
      // 查询用户信息
      String uuNumber=null;
      String uuReNumber=null;
      String hql = "from User where deleteFlag is false and account = ? and password = ? ";
      List<Object> params =  CollectionUtils.newList(account,password);
      String hql = "from User where deleteFlag is false and account = ?";
      List<Object> params =  CollectionUtils.newList(account);
      User user = commonDAO.findUnique(hql,params, User.class);
      if (user == null ) {
         return new Result(false, "用户账户、密码错误");
@@ -213,6 +214,12 @@
      }
      // 插入日志
      insertLoginLog(request, user, account, "SYS-LOGIN");
      String salt = user.getSalt();
      String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes());
      //比较用户输入的密码加密后的字符串是否跟注册时填写的加密密码相同
      if (!newPassword.equals(user.getPassword())) {
         return new Result(false, "用户账户、密码错误或缺少凭证");
      }
      // 返回
      return new Result(true, "验证成功",CollectionUtils.newObjectMap("uuNumber",uuNumber,"uuReNumber",uuReNumber));
   }
@@ -374,16 +381,16 @@
      List<Object> params = null;
//        boolean flag=true;
      if ("study".equals(logType)) {
         hql = "from User where deleteFlag is false and account = ? and password = ? ";
         params = CollectionUtils.newList(account, password);
         hql = "from User where deleteFlag is false and account = ?";
         params = CollectionUtils.newList(account);
      }else if("portal".equals(logType)){
         hql = "from User where deleteFlag is false and mobilePhone = ? and password = ? ";
         params = CollectionUtils.newList(account, password);
         hql = "from User where deleteFlag is false and mobilePhone = ?";
         params = CollectionUtils.newList(account);
      }else{
            if(StringUtils.isEmpty(password)) {
            return new Result(false, "用户密码不能为空");
         }
            hql = "from User where deleteFlag is false and account = ? and password = ? ";
            hql = "from User where deleteFlag is false and account = ? and password = ?";
            params =  CollectionUtils.newList(account,password);
        }
@@ -406,13 +413,19 @@
//         request.getSession().removeAttribute("uuReNumber");
//      }
      if (user == null) {
         return new Result(false, "用户账户不存在");
      }
        // 插入日志
        insertLoginLog(request, user, account, "SYS-LOGIN");
        //考试登录会控制flag变量 其他登录不会 默认true
        if (user == null) {
            return new Result(false, "用户账户、密码错误或缺少凭证");
        }
      String salt = user.getSalt();
      String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes());
      //比较用户输入的密码加密后的字符串是否跟注册时填写的加密密码相同
      if("study".equals(logType) || "portal".equals(logType)){
         if (!newPassword.equals(user.getPassword())) {
            return new Result(false, "用户账户、密码错误或缺少凭证");
         }
      }
        // 返回用户基本信息
        return this.loginValidate(user, 1, request, response, logType, platForm, organizationId);