Переглянути джерело

新增用户保存明文密码,取消定时任务模块

Administrator 4 роки тому
батько
коміт
ec7022a419

+ 6 - 6
pom.xml

@@ -87,7 +87,7 @@
                 <version>${jna.version}</version>
             </dependency>
 			
-            <!-- swagger2-->
+<!--            &lt;!&ndash; swagger2&ndash;&gt;
             <dependency>
                 <groupId>io.springfox</groupId>
                 <artifactId>springfox-swagger2</artifactId>
@@ -104,12 +104,12 @@
                 </exclusions>
             </dependency>
 			
-            <!-- swagger2-UI-->
+            &lt;!&ndash; swagger2-UI&ndash;&gt;
             <dependency>
                 <groupId>io.springfox</groupId>
                 <artifactId>springfox-swagger-ui</artifactId>
                 <version>${swagger.version}</version>
-            </dependency>
+            </dependency>-->
             
             <!--io常用工具类 -->
             <dependency>
@@ -160,12 +160,12 @@
                 <version>${kaptcha.version}</version>
             </dependency>
             
-            <!-- 定时任务-->
+<!--            &lt;!&ndash; 定时任务&ndash;&gt;
             <dependency>
                 <groupId>com.ruoyi</groupId>
                 <artifactId>ruoyi-quartz</artifactId>
                 <version>${ruoyi.version}</version>
-            </dependency>
+            </dependency>-->
 	
             <!-- 代码生成-->
             <dependency>
@@ -202,7 +202,7 @@
         <module>ruoyi-admin</module>
         <module>ruoyi-framework</module>
         <module>ruoyi-system</module>
-        <module>ruoyi-quartz</module>
+    <!--    <module>ruoyi-quartz</module>-->
         <module>ruoyi-generator</module>
         <module>ruoyi-common</module>
     </modules>

+ 2 - 2
ruoyi-admin/pom.xml

@@ -61,11 +61,11 @@
             <artifactId>ruoyi-framework</artifactId>
         </dependency>
 
-        <!-- 定时任务-->
+<!--        &lt;!&ndash; 定时任务&ndash;&gt;
         <dependency>
             <groupId>com.ruoyi</groupId>
             <artifactId>ruoyi-quartz</artifactId>
-        </dependency>
+        </dependency>-->
 
         <!-- 代码生成-->
         <dependency>

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;

+ 6 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -132,12 +132,13 @@ public class SysUserController extends BaseController
         {
             return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
         }
-        else if (StringUtils.isNotEmpty(user.getEmail())
+/*        else if (StringUtils.isNotEmpty(user.getEmail())
                 && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
         {
             return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
-        }
+        }*/
         user.setCreateBy(SecurityUtils.getUsername());
+        user.setClearTextPasswords(user.getPassword());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         return toAjax(userService.insertUser(user));
     }
@@ -156,11 +157,11 @@ public class SysUserController extends BaseController
         {
             return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
         }
-        else if (StringUtils.isNotEmpty(user.getEmail())
+/*        else if (StringUtils.isNotEmpty(user.getEmail())
                 && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
         {
             return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
-        }
+        }*/
         user.setUpdateBy(SecurityUtils.getUsername());
         return toAjax(userService.updateUser(user));
     }
@@ -185,6 +186,7 @@ public class SysUserController extends BaseController
     public AjaxResult resetPwd(@RequestBody SysUser user)
     {
         userService.checkUserAllowed(user);
+        user.setClearTextPasswords(user.getPassword());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         user.setUpdateBy(SecurityUtils.getUsername());
         return toAjax(userService.resetPwd(user));

+ 37 - 15
ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.web.core.config;
 
 import java.util.ArrayList;
@@ -21,30 +22,40 @@ import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
+*/
 /**
  * Swagger2的接口配置
  * 
  * @author ruoyi
- */
+ *//*
+
 @Configuration
 @EnableSwagger2
 public class SwaggerConfig
 {
-    /** 系统基础配置 */
+    */
+/** 系统基础配置 *//*
+
     @Autowired
     private RuoYiConfig ruoyiConfig;
 
-    /** 是否开启swagger */
+    */
+/** 是否开启swagger *//*
+
     @Value("${swagger.enabled}")
     private boolean enabled;
 
-    /** 设置请求的统一前缀 */
+    */
+/** 设置请求的统一前缀 *//*
+
     @Value("${swagger.pathMapping}")
     private String pathMapping;
 
-    /**
+    */
+/**
      * 创建API
-     */
+     *//*
+
     @Bean
     public Docket createRestApi()
     {
@@ -62,15 +73,19 @@ public class SwaggerConfig
                 // 扫描所有 .apis(RequestHandlerSelectors.any())
                 .paths(PathSelectors.any())
                 .build()
-                /* 设置安全模式,swagger可以设置访问token */
+                */
+/* 设置安全模式,swagger可以设置访问token *//*
+
                 .securitySchemes(securitySchemes())
                 .securityContexts(securityContexts())
                 .pathMapping(pathMapping);
     }
 
-    /**
+    */
+/**
      * 安全模式,这里指定token通过Authorization头请求头传递
-     */
+     *//*
+
     private List<ApiKey> securitySchemes()
     {
         List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
@@ -78,9 +93,11 @@ public class SwaggerConfig
         return apiKeyList;
     }
 
-    /**
+    */
+/**
      * 安全上下文
-     */
+     *//*
+
     private List<SecurityContext> securityContexts()
     {
         List<SecurityContext> securityContexts = new ArrayList<>();
@@ -92,9 +109,11 @@ public class SwaggerConfig
         return securityContexts;
     }
 
-    /**
+    */
+/**
      * 默认的安全上引用
-     */
+     *//*
+
     private List<SecurityReference> defaultAuth()
     {
         AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
@@ -105,9 +124,11 @@ public class SwaggerConfig
         return securityReferences;
     }
 
-    /**
+    */
+/**
      * 添加摘要信息
-     */
+     *//*
+
     private ApiInfo apiInfo()
     {
         // 用ApiInfoBuilder进行定制
@@ -123,3 +144,4 @@ public class SwaggerConfig
                 .build();
     }
 }
+*/

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -107,7 +107,7 @@ pagehelper:
 # Swagger配置
 swagger:
   # 是否开启swagger
-  enabled: true
+  enabled: false
   # 请求前缀
   pathMapping: /dev-api
 

+ 35 - 22
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -1,5 +1,6 @@
 package com.ruoyi.common.core.domain.entity;
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import javax.validation.constraints.Email;
@@ -58,6 +59,11 @@ public class SysUser extends BaseEntity
     /** 密码 */
     private String password;
 
+    /**
+     * 明文密码
+     */
+    private String clearTextPasswords;
+
     /** 盐加密 */
     private String salt;
 
@@ -300,29 +306,36 @@ public class SysUser extends BaseEntity
         this.postIds = postIds;
     }
 
+    public String getClearTextPasswords() {
+        return clearTextPasswords;
+    }
+
+    public void setClearTextPasswords(String clearTextPasswords) {
+        this.clearTextPasswords = clearTextPasswords;
+    }
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("userId", getUserId())
-            .append("deptId", getDeptId())
-            .append("userName", getUserName())
-            .append("nickName", getNickName())
-            .append("email", getEmail())
-            .append("phonenumber", getPhonenumber())
-            .append("sex", getSex())
-            .append("avatar", getAvatar())
-            .append("password", getPassword())
-            .append("salt", getSalt())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("loginIp", getLoginIp())
-            .append("loginDate", getLoginDate())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .append("dept", getDept())
-            .toString();
+        return "SysUser{" +
+                "userId=" + userId +
+                ", deptId=" + deptId +
+                ", userName='" + userName + '\'' +
+                ", nickName='" + nickName + '\'' +
+                ", email='" + email + '\'' +
+                ", phonenumber='" + phonenumber + '\'' +
+                ", sex='" + sex + '\'' +
+                ", avatar='" + avatar + '\'' +
+                ", password='" + password + '\'' +
+                ", clearTextPasswords='" + clearTextPasswords + '\'' +
+                ", salt='" + salt + '\'' +
+                ", status='" + status + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", loginIp='" + loginIp + '\'' +
+                ", loginDate=" + loginDate +
+                ", dept=" + dept +
+                ", roles=" + roles +
+                ", roleIds=" + Arrays.toString(roleIds) +
+                ", postIds=" + Arrays.toString(postIds) +
+                '}';
     }
 }

+ 6 - 2
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.quartz.config;
 
 import org.springframework.context.annotation.Bean;
@@ -6,11 +7,13 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 import javax.sql.DataSource;
 import java.util.Properties;
 
+*/
 /**
  * 定时任务配置
  * 
  * @author ruoyi
- */
+ *//*
+
 @Configuration
 public class ScheduleConfig
 {
@@ -50,8 +53,9 @@ public class ScheduleConfig
         // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
         factory.setOverwriteExistingJobs(true);
         // 设置自动启动,默认为true
-        factory.setAutoStartup(true);
+        factory.setAutoStartup(false);
 
         return factory;
     }
 }
+*/

+ 3 - 3
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java

@@ -31,9 +31,9 @@ public class SysJobServiceImpl implements ISysJobService
     @Autowired
     private SysJobMapper jobMapper;
 
-    /**
+/*    *//**
      * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
-     */
+     *//*
     @PostConstruct
     public void init() throws SchedulerException, TaskException
     {
@@ -43,7 +43,7 @@ public class SysJobServiceImpl implements ISysJobService
         {
             ScheduleUtils.createScheduleJob(scheduler, job);
         }
-    }
+    }*/
 
     /**
      * 获取quartz调度器的计划任务列表

+ 5 - 1
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java

@@ -1,13 +1,16 @@
+/*
 package com.ruoyi.quartz.task;
 
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.utils.StringUtils;
 
+*/
 /**
  * 定时任务调度测试
  * 
  * @author ruoyi
- */
+ *//*
+
 @Component("ryTask")
 public class RyTask
 {
@@ -26,3 +29,4 @@ public class RyTask
         System.out.println("执行无参方法");
     }
 }
+*/

+ 11 - 7
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="sex"          column="sex"          />
 		<result property="avatar"       column="avatar"       />
 		<result property="password"     column="password"     />
+		<result property="clearTextPasswords"     column="clear_text_passwords"     />
 		<result property="status"       column="status"       />
 		<result property="delFlag"      column="del_flag"     />
 		<result property="loginIp"      column="login_ip"     />
@@ -46,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</resultMap>
 	
 	<sql id="selectUserVo">
-        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, 
+        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber,u.clear_text_passwords, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
         d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
         from sys_user u
@@ -83,24 +84,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
 	    <include refid="selectUserVo"/>
-		where u.user_name = #{userName}
+		where u.user_name = #{userName} and u.del_flag = '0'
 	</select>
 	
 	<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
 		<include refid="selectUserVo"/>
-		where u.user_id = #{userId}
+		where u.user_id = #{userId} and u.del_flag = '0'
 	</select>
 	
 	<select id="checkUserNameUnique" parameterType="String" resultType="int">
-		select count(1) from sys_user where user_name = #{userName} limit 1
+		select count(1) from sys_user where user_name = #{userName} and del_flag = '0' limit 1
 	</select>
 	
 	<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
-		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} limit 1
+		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
 	</select>
 	
 	<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
-		select user_id, email from sys_user where email = #{email} limit 1
+		select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
 	</select>
 	
 	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
@@ -114,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
  			<if test="sex != null and sex != ''">sex,</if>
  			<if test="password != null and password != ''">password,</if>
+ 			<if test="clearTextPasswords != null and clearTextPasswords != ''">clear_text_passwords,</if>
  			<if test="status != null and status != ''">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			<if test="remark != null and remark != ''">remark,</if>
@@ -128,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
  			<if test="sex != null and sex != ''">#{sex},</if>
  			<if test="password != null and password != ''">#{password},</if>
+ 			<if test="clearTextPasswords != null and clearTextPasswords != ''">#{clearTextPasswords},</if>
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
@@ -146,6 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="sex != null and sex != ''">sex = #{sex},</if>
  			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  			<if test="password != null and password != ''">password = #{password},</if>
+ 			<if test="clearTextPasswords != null and clearTextPasswords != ''">clear_text_passwords = #{clearTextPasswords},</if>
  			<if test="status != null and status != ''">status = #{status},</if>
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  			<if test="loginDate != null">login_date = #{loginDate},</if>
@@ -165,7 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</update>
 	
 	<update id="resetUserPwd" parameterType="SysUser">
- 		update sys_user set password = #{password} where user_name = #{userName}
+ 		update sys_user set password = #{password}, clear_text_passwords = #{clearTextPasswords} where user_name = #{userName}
 	</update>
 	
 	<delete id="deleteUserById" parameterType="Long">