Bläddra i källkod

fix 注册登录

tjf 8 månader sedan
förälder
incheckning
57fc1e4f04

+ 3 - 3
ruoyi-admin/src/main/resources/application-dev.yml

@@ -59,7 +59,7 @@ spring:
           driverClassName: com.mysql.cj.jdbc.Driver
           # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
           # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
-          url: jdbc:mysql://192.168.101.10:3306/zhihuixiaoyuan2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
+          url: jdbc:mysql://60.171.161.56:25143/zhihuixiaoyuan2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
           username: root
           password: Boman123
         # 从库数据源
@@ -93,9 +93,9 @@ spring:
 spring.data:
   redis:
     # 地址
-    host: 192.168.101.10
+    host: 60.171.161.56
     # 端口,默认为6379
-    port: 6379
+    port: 20001
     # 数据库索引
     database: 13
     # 密码(如没有密码请注释掉)

+ 1 - 1
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/domain/model/LoginBody.java

@@ -42,7 +42,7 @@ public class LoginBody {
     /**
      * 租户ID
      */
-    @NotBlank(message = "{tenant.number.not.blank}")
+    //@NotBlank(message = "{tenant.number.not.blank}")
     private String tenantId;
 
     /**

+ 12 - 0
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/UserType.java

@@ -18,6 +18,18 @@ public enum UserType {
      * pc端
      */
     SYS_USER("sys_user"),
+    /**
+     * 注册用户
+     */
+    REGISTER("register"),
+    /**
+     * 申请用户
+     */
+    APPLY("apply"),
+    /**
+     * 正式用户
+     */
+    FORMAL("formal"),
 
     /**
      * app端

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/common/RegisterCommonController.java

@@ -40,6 +40,7 @@ public class RegisterCommonController extends BaseController {
             return R.fail("密码必须包含数字、大小写字母、特殊符号且大于8位");
         }
         user.setPassword(BCrypt.hashpw(user.getPassword()));
+        user.setUserType("register");
         return toAjax(userService.insertUserCommon(user));
     }
 }

+ 4 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java

@@ -124,7 +124,10 @@ public class SysUserController extends BaseController {
             TenantHelper.clearDynamic();
         }
 
-        SysUserVo user = userService.selectUserByUserName(loginUser.getUsername());
+        SysUserVo user = userService.selectUserByUserName(LoginHelper.getUsername());
+        if (user == null){
+            return R.fail("请重新登录");
+        }
         SysDeptVo dept = new SysDeptVo();
         dept.setDeptId(loginUser.getDeptId());
         dept.setDeptName(loginUser.getDeptName());

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysUserBo.java

@@ -48,7 +48,7 @@ public class SysUserBo extends BaseEntity {
      * 用户昵称
      */
     @Xss(message = "用户昵称不能包含脚本字符")
-    @NotBlank(message = "用户昵称不能为空")
+    //@NotBlank(message = "用户昵称不能为空")
     @Size(min = 0, max = 30, message = "用户昵称长度不能超过{max}个字符")
     private String nickName;
 

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysUserMapper.java

@@ -128,6 +128,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
         @DataColumn(key = "userName", value = "u.user_id")
     })
     SysUserVo selectUserById(Long userId);
+    int updateByUserName(SysUser user);
 
     @Override
     @DataPermission({

+ 24 - 15
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RegisterParentsServiceImpl.java

@@ -1,36 +1,39 @@
 package org.dromara.system.service.impl;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.ClassUtils;
 import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import lombok.RequiredArgsConstructor;
-import org.dromara.system.domain.OrientationInfo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.system.domain.RegisterParents;
 import org.dromara.system.domain.RegisterParentsStudent;
+import org.dromara.system.domain.SysUser;
+import org.dromara.system.domain.bo.RegisterParentsBo;
 import org.dromara.system.domain.bo.RegisterParentsStudentBo;
-import org.dromara.system.domain.bo.RegisterTeacherClassBo;
 import org.dromara.system.domain.vo.RegisterParentsStudentVo;
-import org.dromara.system.mapper.RegisterParentsStudentMapper;
-import org.dromara.system.service.IRegisterParentsStudentService;
-import org.springframework.stereotype.Service;
-import org.dromara.system.domain.bo.RegisterParentsBo;
 import org.dromara.system.domain.vo.RegisterParentsVo;
-import org.dromara.system.domain.RegisterParents;
 import org.dromara.system.mapper.RegisterParentsMapper;
+import org.dromara.system.mapper.RegisterParentsStudentMapper;
+import org.dromara.system.mapper.SysUserMapper;
 import org.dromara.system.service.IRegisterParentsService;
+import org.dromara.system.service.IRegisterParentsStudentService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
+
+import static org.dromara.system.constent.Constants.ONE;
+import static org.dromara.system.constent.Constants.TWO;
 
 /**
  * 注册-家长Service业务层处理
@@ -47,6 +50,7 @@ public class RegisterParentsServiceImpl implements IRegisterParentsService {
     private final RegisterParentsStudentMapper registerParentsStudentMapper;
 
     private final IRegisterParentsStudentService registerParentsStudentService;
+    private final SysUserMapper sysUserMapper;
 
     /**
      * 查询注册-家长
@@ -98,9 +102,9 @@ public class RegisterParentsServiceImpl implements IRegisterParentsService {
         //查询是否已经注册过
         RegisterParentsVo registerParentsOld = baseMapper.selectRegisterParentsByPhonenumber(bo.getUserPhone());
         if(registerParentsOld!=null){
-            if(registerParentsOld.getIsPass().equals("1")){
+            if(registerParentsOld.getIsPass().equals(ONE)){
                 return R.fail("该手机号已注册当前身份,信息正在审核中。",registerParentsOld);
-            }else if(registerParentsOld.getIsPass().equals("2")){
+            }else if(registerParentsOld.getIsPass().equals(TWO)){
                 return R.fail("该手机号已注册当前身份,审核已通过,请登录。",registerParentsOld);
             }else{
                 return R.fail("该手机号已注册当前身份,审核未通过。",registerParentsOld);
@@ -131,6 +135,11 @@ public class RegisterParentsServiceImpl implements IRegisterParentsService {
 
         if (flag) {
             bo.setId(add.getId());
+            //更新用户为apply申请用户
+            SysUser sysUser = new SysUser();
+            sysUser.setUserName(bo.getUserPhone());
+            sysUser.setUserType("apply");
+            sysUserMapper.updateByUserName(sysUser);
             return R.ok();
         }
         return R.fail();

+ 27 - 17
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RegisterSchoolServiceImpl.java

@@ -1,5 +1,9 @@
 package org.dromara.system.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import org.dromara.common.core.domain.R;
 import org.dromara.common.core.exception.ServiceException;
@@ -7,30 +11,30 @@ import org.dromara.common.core.utils.ClassUtils;
 import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import lombok.RequiredArgsConstructor;
-import org.dromara.system.domain.RegisterParentsStudent;
-import org.dromara.system.domain.RegisterSchoolFile;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.system.domain.RegisterSchool;
+import org.dromara.system.domain.SysUser;
 import org.dromara.system.domain.bo.RegisterParentsStudentBo;
+import org.dromara.system.domain.bo.RegisterSchoolBo;
 import org.dromara.system.domain.bo.RegisterSchoolFileBo;
 import org.dromara.system.domain.bo.RegisterTeacherClassBo;
 import org.dromara.system.domain.vo.*;
 import org.dromara.system.mapper.*;
 import org.dromara.system.service.IRegisterParentsStudentService;
 import org.dromara.system.service.IRegisterSchoolFileService;
+import org.dromara.system.service.IRegisterSchoolService;
 import org.dromara.system.service.IRegisterTeacherClassService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.dromara.system.domain.bo.RegisterSchoolBo;
-import org.dromara.system.domain.RegisterSchool;
-import org.dromara.system.service.IRegisterSchoolService;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.dromara.system.constent.Constants.ONE;
+import static org.dromara.system.constent.Constants.TWO;
 
 /**
  * 注册-学校Service业务层处理
@@ -52,10 +56,11 @@ public class RegisterSchoolServiceImpl implements IRegisterSchoolService {
     private final RegisterParentsMapper registerParentsMapper;
 
     private final IRegisterTeacherClassService registerTeacherClassService;
-    private final RegisterTeacherClassMapper registerTeacherClassMapper;
+
 
     private final IRegisterParentsStudentService registerParentsStudentService;
-    private final RegisterParentsStudentMapper registerParentsStudentMapper;
+    private final SysUserMapper sysUserMapper;
+
 
     /**
      * 查询注册-学校
@@ -125,9 +130,9 @@ public class RegisterSchoolServiceImpl implements IRegisterSchoolService {
         //查询是否已经注册过
         RegisterSchoolVo registerSchoolOld = baseMapper.selectRegisterSchooByPhonenumber(bo.getUserPhone());
         if(registerSchoolOld!=null){
-            if(registerSchoolOld.getIsPass().equals("1")){
+            if(registerSchoolOld.getIsPass().equals(ONE)){
                 return R.fail("该手机号已注册当前身份,信息正在审核中。",registerSchoolOld);
-            }else if(registerSchoolOld.getIsPass().equals("2")){
+            }else if(registerSchoolOld.getIsPass().equals(TWO)){
                 return R.fail("该手机号已注册当前身份,审核已通过,请登录。",registerSchoolOld);
             }else{
                 return R.fail("该手机号已注册当前身份,审核未通过。",registerSchoolOld);
@@ -136,7 +141,7 @@ public class RegisterSchoolServiceImpl implements IRegisterSchoolService {
 
         bo.setCreateTime(DateUtils.getNowDate());
         bo.setUpdateTime(DateUtils.getNowDate());
-        bo.setIsPass("1");
+        bo.setIsPass(ONE);
         RegisterSchool add = MapstructUtils.convert(bo, RegisterSchool.class);
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
@@ -155,6 +160,11 @@ public class RegisterSchoolServiceImpl implements IRegisterSchoolService {
 
         if (flag) {
             bo.setId(add.getId());
+            //更新用户为apply申请用户
+            SysUser sysUser = new SysUser();
+            sysUser.setUserName(bo.getUserPhone());
+            sysUser.setUserType("apply");
+            sysUserMapper.updateByUserName(sysUser);
             return R.ok();
         }
         return R.fail();

+ 24 - 27
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RegisterTeacherServiceImpl.java

@@ -1,45 +1,36 @@
 package org.dromara.system.service.impl;
 
-import cn.hutool.core.collection.CollUtil;
-import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
-import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.ClassUtils;
 import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import lombok.RequiredArgsConstructor;
-import org.dromara.common.mybatis.helper.DataPermissionHelper;
-import org.dromara.system.domain.RegisterSchool;
-import org.dromara.system.domain.RegisterTeacherClass;
-import org.dromara.system.domain.SysTenant;
-import org.dromara.system.domain.bo.RegisterSchoolFileBo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.system.domain.RegisterTeacher;
+import org.dromara.system.domain.SysUser;
+import org.dromara.system.domain.bo.RegisterTeacherBo;
 import org.dromara.system.domain.bo.RegisterTeacherClassBo;
 import org.dromara.system.domain.vo.RegisterTeacherClassVo;
-import org.dromara.system.mapper.RegisterTeacherClassMapper;
-import org.dromara.system.service.IRegisterTeacherClassService;
-import org.springframework.stereotype.Service;
-import org.dromara.system.domain.bo.RegisterTeacherBo;
 import org.dromara.system.domain.vo.RegisterTeacherVo;
-import org.dromara.system.domain.RegisterTeacher;
+import org.dromara.system.mapper.RegisterTeacherClassMapper;
 import org.dromara.system.mapper.RegisterTeacherMapper;
+import org.dromara.system.mapper.SysUserMapper;
+import org.dromara.system.service.IRegisterTeacherClassService;
 import org.dromara.system.service.IRegisterTeacherService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Collection;
+
+import static org.dromara.system.constent.Constants.ONE;
+import static org.dromara.system.constent.Constants.TWO;
 
 /**
  * 注册-老师Service业务层处理
@@ -56,6 +47,7 @@ public class RegisterTeacherServiceImpl implements IRegisterTeacherService {
     private final IRegisterTeacherClassService registerTeacherClassService;
 
     private final RegisterTeacherClassMapper registerTeacherClassMapper;
+    private final SysUserMapper sysUserMapper;
 
     /**
      * 查询注册-老师
@@ -129,9 +121,9 @@ public class RegisterTeacherServiceImpl implements IRegisterTeacherService {
         //查询是否已经注册过
         RegisterTeacherVo registerTeacherOld = baseMapper.selectRegisterTeacherByPhonenumber(bo.getUserPhone());
         if (registerTeacherOld != null) {
-            if (registerTeacherOld.getIsPass().equals("1")) {
+            if (registerTeacherOld.getIsPass().equals(ONE)) {
                 return R.fail("该微信已注册当前身份,信息正在审核中。", registerTeacherOld);
-            } else if (registerTeacherOld.getIsPass().equals("2")) {
+            } else if (registerTeacherOld.getIsPass().equals(TWO)) {
                 return R.fail("该微信已注册当前身份,审核已通过,请登录。", registerTeacherOld);
             } else {
                 return R.fail("该微信已注册当前身份,审核未通过。", registerTeacherOld);
@@ -163,6 +155,11 @@ public class RegisterTeacherServiceImpl implements IRegisterTeacherService {
 
         if (flag) {
             bo.setId(add.getId());
+            //更新用户为apply申请用户
+            SysUser sysUser = new SysUser();
+            sysUser.setUserName(bo.getUserPhone());
+            sysUser.setUserType("apply");
+            sysUserMapper.updateByUserName(sysUser);
             return R.ok();
         }
         return R.fail();
@@ -191,7 +188,7 @@ public class RegisterTeacherServiceImpl implements IRegisterTeacherService {
                 registerTeacherClassService.insertByBo(registerTeacherClassBo);
             }
         }
-        bo.setIsPass("1");
+        bo.setIsPass(ONE);
         bo.setUpdateTime(DateUtils.getNowDate());
 
         RegisterTeacher update = MapstructUtils.convert(bo, RegisterTeacher.class);

+ 7 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ZhxyShyjServiceImpl.java

@@ -201,8 +201,9 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
                 }else{
                     use.setDeptId(dept.getDeptId());
                     use.setTenantId(sysTenant.getTenantId());
+                    use.setUserType("formal");
                     SysUser sysUser = MapstructUtils.convert(use, SysUser.class);
-                    userMapper.insert(sysUser);
+                    userMapper.updateById(sysUser);
                 }
                 //新增用户与角色管理
                 //查询当前租户下的学校角色
@@ -266,6 +267,7 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
                 }else{
                     use.setDeptId(registerTeacher.getSchoolId());
                     use.setTenantId(sysDept.getTenantId());
+                    use.setUserType("formal");
                     SysUser sysUser = MapstructUtils.convert(use, SysUser.class);
                     userMapper.updateById(sysUser);
                 }
@@ -345,6 +347,9 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
                     Long[] roleIds = {5L};
                     sysUserServiceImpl.insertUserRoleNoTenantId(sysUser.getUserId(), roleIds,false);
                 } else {
+                    sysUser.setUserType("formal");
+                    SysUser user = MapstructUtils.convert(sysUser, SysUser.class);
+                    userMapper.updateById(user);
                     //账号存在
                     SysUserRole userRole = userRoleMapper.selectUserRole(sysUser.getUserId(),5);
                     if(userRole==null){
@@ -352,6 +357,7 @@ public class ZhxyShyjServiceImpl implements IZhxyShyjService {
                         Long[] roleIds = {5L};
                         sysUserServiceImpl.insertUserRoleNoTenantId(sysUser.getUserId(), roleIds,false);
                     }
+
                 }
 
                 //新增家长-学生(审核通过之后数据)

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -67,6 +67,9 @@
     <update id="resetUserPwdByUserName" parameterType = "string">
         update sys_user set password = #{password} where user_name = #{userName}
     </update>
+    <update id="updateByUserName" parameterType="SysUser">
+        update sys_user set user_type = #{userType} where user_name = #{userName}
+    </update>
 
     <select id="selectPageUserList" resultMap="SysUserResult">
         select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,