新增书签设置星标功能 ,新增redis工具类规定时间内请求限制次数,新增阿里大鱼手机号发送验证码功能
This commit is contained in:
		| @@ -0,0 +1,58 @@ | ||||
| package com.ruoyi.web.controller.common; | ||||
|  | ||||
|  | ||||
| import com.ruoyi.bookmark.service.ISqMenuService; | ||||
| import com.ruoyi.common.constant.Constants; | ||||
| import com.ruoyi.common.constant.HttpStatus; | ||||
| import com.ruoyi.common.core.controller.BaseController; | ||||
| import com.ruoyi.common.core.domain.AjaxResult; | ||||
| import com.ruoyi.common.core.redis.RedisCache; | ||||
| import com.ruoyi.common.utils.PhoneCode; | ||||
| import com.ruoyi.common.utils.bookmarkhtml.Const; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * 验证码操作处理 | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @RestController | ||||
| public class RegisterPhoneController extends BaseController | ||||
| { | ||||
|  | ||||
|     @Autowired | ||||
|     private ISqMenuService iSqMenuService; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 发送注册验证码 | ||||
|      */ | ||||
|     @GetMapping("/registerPhoneCode") | ||||
|     public AjaxResult registerPhoneCode(String phone) | ||||
|     { | ||||
|         AjaxResult ajaxResult = new AjaxResult(); | ||||
|         ajaxResult.put("code", HttpStatus.SUCCESS); | ||||
|         //防止重复点击 | ||||
|         boolean phoneCodelFlag = iSqMenuService.countRepetition(Const.PHONE_REGISTER,getAuthUser().getUserId(),3600L,10); //3600秒 最多请求10次验证码 | ||||
|  | ||||
|         if(!phoneCodelFlag){ | ||||
|             ajaxResult.put("msg","短时间内发送频繁,请稍后再操作!"); | ||||
|             return ajaxResult; | ||||
|         } | ||||
|  | ||||
|         //通过手机号发送短信 | ||||
|         Boolean flag =  PhoneCode.getPhonemsg(phone); | ||||
|  | ||||
|         if (flag){ | ||||
|             ajaxResult.put("msg","短信发送成功,请在"+Constants.CAPTCHA_PHONE_EXPIRATION+"分钟内验证。"); | ||||
|             return ajaxResult; | ||||
|         }else { | ||||
|             ajaxResult.put("msg","短信发送失败"); | ||||
|             return ajaxResult; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -39,6 +39,25 @@ public class SysLoginController | ||||
|     @Autowired | ||||
|     private TokenService tokenService; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 注册方法 | ||||
|      * | ||||
|      * @param loginBody 注册信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @PostMapping("/registerUser") | ||||
|     public AjaxResult registerUser(@RequestBody LoginBody loginBody) | ||||
|     { | ||||
|         AjaxResult ajax = AjaxResult.success(); | ||||
|         // 生成令牌 | ||||
|         String token = loginService.registerUser(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), | ||||
|                 loginBody.getUuid(),loginBody.getEmail(),loginBody.getPhone()); | ||||
|         ajax.put(Constants.TOKEN, token); | ||||
|         return ajax; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 登录方法 | ||||
|      * | ||||
|   | ||||
| @@ -76,9 +76,8 @@ public class SqBookmarkController extends BaseController | ||||
|      * 书签设置星标 取消星标 | ||||
|      */ | ||||
|     @GetMapping("/updateBookmarkStarById") | ||||
|     public AjaxResult updateBookmarkStarById(String bookmarkId,int bookmarkStr) { | ||||
|     public AjaxResult updateBookmarkStarById(Long bookmarkId,Integer bookmarkStr) { | ||||
|         return toAjax(sqBookmarkService.updateBookmarkStarById(getAuthUser().getUserId(),bookmarkId,bookmarkStr)); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import com.ruoyi.bookmark.mapper.SqMenuMapper; | ||||
| import com.ruoyi.bookmark.service.ISqBookmarkService; | ||||
| import com.ruoyi.bookmark.service.ISqMenuService; | ||||
| import com.ruoyi.bookmark.service.impl.SqMenuServiceImpl; | ||||
| import com.ruoyi.common.utils.bookmarkhtml.Const; | ||||
| import org.apache.ibatis.session.ExecutorType; | ||||
| import org.apache.ibatis.session.SqlSession; | ||||
| import org.apache.velocity.runtime.directive.Foreach; | ||||
| @@ -162,4 +163,7 @@ public class SqMenuTest extends BaseSpringBootTest{ | ||||
|         long end = System.currentTimeMillis(); | ||||
|         System.out.println("---------------" + (start - end) + "---------------"); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,9 +1,15 @@ | ||||
| package com.ruoyi.web.test.controller; | ||||
|  | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import com.github.wujun234.uid.UidGenerator; | ||||
| import com.ruoyi.bookmark.service.ISqMenuService; | ||||
| import com.ruoyi.common.core.redis.RedisUtil; | ||||
| import com.ruoyi.common.utils.bookmarkhtml.Const; | ||||
| import org.junit.Test; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
|  * @Auther: Wang | ||||
| @@ -17,6 +23,10 @@ public class UIDTest extends BaseSpringBootTest{ | ||||
|     private UidGenerator defaultUidGenerator; | ||||
|     @Resource | ||||
|     private UidGenerator cachedUidGenerator; | ||||
|     @Autowired | ||||
|     private ISqMenuService iSqMenuService; | ||||
|     @Autowired | ||||
|     private RedisUtil redisUtil; | ||||
|  | ||||
|     @Test | ||||
|     public void testSerialGenerate() { | ||||
| @@ -34,4 +44,25 @@ public class UIDTest extends BaseSpringBootTest{ | ||||
| //        System.out.println(cachedUidGenerator.parseUID(uid)); | ||||
|  | ||||
|     } | ||||
|     @Test | ||||
|     public void dateTest(){ | ||||
|         //当前时间 | ||||
|         Date date3 = DateUtil.date(System.currentTimeMillis()); | ||||
|         System.out.println(date3); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     //测试规定时间内 禁能访问次数 | ||||
|     @Test | ||||
|     public void rest2(){ | ||||
|         boolean phoneCodelFlag = iSqMenuService.countRepetition(Const.PHONE_REGISTER,1L,600L,3); | ||||
|         if (phoneCodelFlag){ | ||||
|             System.out.println("可以访问请求!"); | ||||
|         }else{ | ||||
|             System.out.println("访问请求失败了!"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -15,6 +15,8 @@ ruoyi: | ||||
|   # 验证码类型 math 数组计算 char 字符验证 | ||||
|   captchaType: math | ||||
|  | ||||
|  | ||||
|  | ||||
| # 开发环境配置 | ||||
| server: | ||||
|   # 服务器的HTTP端口,默认为8080 | ||||
|   | ||||
| @@ -167,6 +167,17 @@ | ||||
| <!--            <artifactId>spring-boot-starter-data-mongodb</artifactId>--> | ||||
| <!--            <version>2.3.4.RELEASE</version>--> | ||||
| <!--        </dependency>--> | ||||
|         <!-- 阿里云验证码使用SDK --> | ||||
|         <dependency> | ||||
|             <groupId>com.aliyun</groupId> | ||||
|             <artifactId>aliyun-java-sdk-core</artifactId> | ||||
|             <version>4.5.18</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.aliyun</groupId> | ||||
|             <artifactId>aliyun-java-sdk-dysmsapi</artifactId> | ||||
|             <version>2.1.0</version> | ||||
|         </dependency> | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -66,6 +66,10 @@ public class Constants | ||||
|      * 验证码有效期(分钟) | ||||
|      */ | ||||
|     public static final Integer CAPTCHA_EXPIRATION = 2; | ||||
|     /** | ||||
|      * 手机号验证码有效期(分钟) | ||||
|      */ | ||||
|     public static final Integer CAPTCHA_PHONE_EXPIRATION = 2; | ||||
|  | ||||
|     /** | ||||
|      * 令牌 | ||||
|   | ||||
| @@ -2,7 +2,7 @@ package com.ruoyi.common.core.domain.model; | ||||
|  | ||||
| /** | ||||
|  * 用户登录对象 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| public class LoginBody | ||||
| @@ -17,6 +17,19 @@ public class LoginBody | ||||
|      */ | ||||
|     private String password; | ||||
|  | ||||
|     /** | ||||
|      * 邮箱 | ||||
|      */ | ||||
|     private String email; | ||||
|     /** | ||||
|      * 手机号 | ||||
|      */ | ||||
|     private String phone; | ||||
|     /** | ||||
|      * 手机号验证码 | ||||
|      */ | ||||
|     private String phoneCode; | ||||
|  | ||||
|     /** | ||||
|      * 验证码 | ||||
|      */ | ||||
| @@ -66,4 +79,28 @@ public class LoginBody | ||||
|     { | ||||
|         this.uuid = uuid; | ||||
|     } | ||||
|  | ||||
|     public String getEmail() { | ||||
|         return email; | ||||
|     } | ||||
|  | ||||
|     public void setEmail(String email) { | ||||
|         this.email = email; | ||||
|     } | ||||
|  | ||||
|     public String getPhone() { | ||||
|         return phone; | ||||
|     } | ||||
|  | ||||
|     public void setPhone(String phone) { | ||||
|         this.phone = phone; | ||||
|     } | ||||
|  | ||||
|     public String getPhoneCode() { | ||||
|         return phoneCode; | ||||
|     } | ||||
|  | ||||
|     public void setPhoneCode(String phoneCode) { | ||||
|         this.phoneCode = phoneCode; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -8,4 +8,8 @@ package com.ruoyi.common.core.redis; | ||||
| public class RedisKey { | ||||
|  | ||||
|     public static final String USER_FOLLOW ="USER:FOLLOW:"; | ||||
|  | ||||
|     public static final String BOOKMARK ="bookMark:"; | ||||
|  | ||||
|     public static final String CONNECTOR =":"; | ||||
| } | ||||
|   | ||||
							
								
								
									
										112
									
								
								ruoyi-common/src/main/java/com/ruoyi/common/utils/PhoneCode.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								ruoyi-common/src/main/java/com/ruoyi/common/utils/PhoneCode.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,112 @@ | ||||
| package com.ruoyi.common.utils; | ||||
|  | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import com.aliyuncs.DefaultAcsClient; | ||||
| import com.aliyuncs.IAcsClient; | ||||
| import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; | ||||
| import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; | ||||
| import com.aliyuncs.exceptions.ClientException; | ||||
| import com.aliyuncs.http.MethodType; | ||||
| import com.aliyuncs.profile.DefaultProfile; | ||||
| import com.aliyuncs.profile.IClientProfile; | ||||
| import com.ruoyi.common.constant.Constants; | ||||
| import com.ruoyi.common.core.redis.RedisUtil; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * 通过手机号发送短信 | ||||
|  * | ||||
|  * @Auther: Wang | ||||
|  */ | ||||
| public class PhoneCode { | ||||
|  | ||||
|     private static final Logger logger = LoggerFactory.getLogger(PhoneCode.class); | ||||
|  | ||||
|     private static String code; | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 阿里云短信服务配置 | ||||
|      * | ||||
|      * @param phone | ||||
|      * @return | ||||
|      */ | ||||
|     public static Boolean getPhonemsg(String phone) { | ||||
|  | ||||
|         // 短信验证---阿里 | ||||
|         // 设置超时时间-可自行调整 | ||||
|         System.setProperty(PhoneDeploy.defaultConnectTimeout, PhoneDeploy.Timeout); | ||||
|         System.setProperty(PhoneDeploy.defaultReadTimeout, PhoneDeploy.Timeout); | ||||
|         // 初始化ascClient需要的几个参数 | ||||
|         final String product = PhoneDeploy.product;// 短信API产品名称(短信产品名固定,无需修改) | ||||
|         final String domain = PhoneDeploy.domain;// 短信API产品域名(接口地址固定,无需修改) | ||||
|         // 替换成你的AK | ||||
|         final String accessKeyId = PhoneDeploy.accessKeyId;// 你的accessKeyId | ||||
|         final String accessKeySecret = PhoneDeploy.accessKeySecret;// 你的accessKeySecret | ||||
|         // 初始化ascClient,暂时不支持多region | ||||
|         IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); | ||||
|         try { | ||||
|             DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); | ||||
|         } catch (ClientException e1) { | ||||
|             e1.printStackTrace(); | ||||
|         } | ||||
|  | ||||
|         //获取验证码 | ||||
|         code = vcode(); | ||||
|  | ||||
|         IAcsClient acsClient = new DefaultAcsClient(profile); | ||||
|         // 组装请求对象 | ||||
|         SendSmsRequest request = new SendSmsRequest(); | ||||
|         // 使用post提交 | ||||
|         request.setMethod(MethodType.POST); | ||||
|         // 必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式 | ||||
|         request.setPhoneNumbers(phone); | ||||
|         // 必填:短信签名-可在短信控制台中找到 | ||||
|         request.setSignName(PhoneDeploy.SignName); | ||||
|         // 必填:短信模板-可在短信控制台中找到 | ||||
|         request.setTemplateCode(PhoneDeploy.TemplateCode); | ||||
|         // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 | ||||
|         // 友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败 | ||||
|         request.setTemplateParam("{ \"code\":\"" + code + "\"}");  //此处的code和短信模板中的${code}对应 | ||||
|         // 可选-上行短信扩展码(无特殊需求用户请忽略此字段) | ||||
|         // request.setSmsUpExtendCode("90997"); | ||||
|         // 可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 | ||||
|         request.setOutId("yourOutId"); | ||||
|         // 请求失败这里会抛ClientException异常 | ||||
|         SendSmsResponse sendSmsResponse; | ||||
|         try { | ||||
|             sendSmsResponse = acsClient.getAcsResponse(request); | ||||
|             if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) { | ||||
|                 // 请求成功 | ||||
|                 RedisUtil redisUtil =   new RedisUtil(); | ||||
|                 redisUtil.setEx(phone,code,Constants.CAPTCHA_PHONE_EXPIRATION, TimeUnit.MINUTES); | ||||
|                 return true; | ||||
|             } else { | ||||
|                 // 验证码失败 如果验证码出错,会输出错误码告诉你具体原因 | ||||
|                 logger.info("手机号:" + code + " 时间"+DateUtil.now()+" 发送失败!!错误日志:"+sendSmsResponse.getCode()); | ||||
|                 return false; | ||||
|             } | ||||
|         } catch (ClientException e) { | ||||
|             e.printStackTrace(); | ||||
|             logger.info("手机号:" + code + " 时间"+DateUtil.now()+" 发送失败!!"); | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 生成4位随机数验证码 | ||||
|      * | ||||
|      * @return 验证码 | ||||
|      */ | ||||
|     public static String vcode(){ | ||||
|         StringBuilder vcode = new StringBuilder(); | ||||
|         for (int i = 0; i < 4; i++) { | ||||
|             vcode.append((int)(Math.random() * 9)); | ||||
|         } | ||||
|         return vcode.toString(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,34 @@ | ||||
| package com.ruoyi.common.utils; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * 手机号获取验证码 | ||||
|  * | ||||
|  * @Auther: Wang | ||||
|  * | ||||
|  */ | ||||
| public class PhoneDeploy { | ||||
|  | ||||
|     // 设置超时时间-可自行调整 | ||||
|     final static String defaultConnectTimeout = "sun.net.client.defaultConnectTimeout"; | ||||
|  | ||||
|     final static String defaultReadTimeout = "sun.net.client.defaultReadTimeout"; | ||||
|  | ||||
|     final static String Timeout = "20000"; | ||||
|  | ||||
|     // 初始化ascClient需要的几个参数 | ||||
|     final static String product = "Dysmsapi";// 短信API产品名称(短信产品名固定,无需修改) | ||||
|     final static String domain = "dysmsapi.aliyuncs.com";// 短信API产品域名(接口地址固定,无需修改) | ||||
|  | ||||
|     // 替换成你的AK (产品密) | ||||
|     final static String accessKeyId = "。。。。。。。。。。。";// 你的accessKeyId,填你自己的 上文配置所得  自行配置 | ||||
|  | ||||
|     final static String accessKeySecret = "。。。。。。。。。。。。。。";// 你的accessKeySecret,填你自己的 上文配置所得 自行配置 | ||||
|  | ||||
|     // 必填:短信签名-可在短信控制台中找到 | ||||
|     final static String SignName = "【藏趣云】";// 阿里云配置你自己的短信签名填入 | ||||
|  | ||||
|     // 必填:短信模板-可在短信控制台中找到 | ||||
|     final static String TemplateCode = "SMS_........."; // 阿里云配置你自己的短信模板填入 | ||||
|  | ||||
| } | ||||
| @@ -3,9 +3,7 @@ package com.ruoyi.common.utils.bookmarkhtml; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| /** | ||||
|  * @Auther: Wang | ||||
|  * @Date: 2020/08/22 23:03 | ||||
|  * 功能描述: | ||||
|  * 常量类 | ||||
|  */ | ||||
| @Component | ||||
| public class Const { | ||||
| @@ -35,13 +33,10 @@ public class Const { | ||||
|     //导入书签html功能 | ||||
|     public static String IMPORTHTML= "IMPORT_HTML"; | ||||
|  | ||||
|     //手机号发送验证码 | ||||
|     public static String PHONE_REGISTER= "phone_register"; | ||||
|  | ||||
|  | ||||
|  | ||||
| //	  @Autowired(required = true) | ||||
| //	  public void setBasePath(@Value("${favorites.base.path}")String basePath) { | ||||
| //		  Const.BASE_PATH = basePath; | ||||
| //	  } | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,11 +1,16 @@ | ||||
| package com.ruoyi.framework.web.service; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
|  | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import com.ruoyi.common.core.domain.entity.SysUser; | ||||
| import com.ruoyi.system.service.ISysUserService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.authentication.AuthenticationManager; | ||||
| import org.springframework.security.authentication.BadCredentialsException; | ||||
| import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||||
| import org.springframework.security.core.Authentication; | ||||
| import org.springframework.security.core.userdetails.User; | ||||
| import org.springframework.stereotype.Component; | ||||
| import com.ruoyi.common.constant.Constants; | ||||
| import com.ruoyi.common.core.domain.model.LoginUser; | ||||
| @@ -35,9 +40,14 @@ public class SysLoginService | ||||
|     @Autowired | ||||
|     private RedisCache redisCache; | ||||
|  | ||||
|     @Autowired | ||||
|     private ISysUserService sysUserService; | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 登录验证 | ||||
|      *  | ||||
|      * | ||||
|      * @param username 用户名 | ||||
|      * @param password 密码 | ||||
|      * @param code 验证码 | ||||
| @@ -85,4 +95,44 @@ public class SysLoginService | ||||
|         // 生成token | ||||
|         return tokenService.createToken(loginUser); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 注册账号 | ||||
|      * | ||||
|      * @param username 用户名 | ||||
|      * @param password 密码 | ||||
|      * @param code 验证码 | ||||
|      * @param uuid 唯一标识 | ||||
|      * @param email 邮箱 | ||||
|      * @param phone 手机号 | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public String registerUser(String username, String password, String code, String uuid, String email, String phone) { | ||||
|  | ||||
|         int usernameCount = sysUserService.countUserByUserName(username); | ||||
|         if (usernameCount != 0) { | ||||
|             return username + "登陆账号已经存在,请更换!"; | ||||
|         } | ||||
|         int phoneCount = sysUserService.countUserByPhone(phone); | ||||
|         if (phoneCount != 0) { | ||||
|             return phone + "手机账号已经存在,请更换!"; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         //验证传入的手机号和验证码是否匹配 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|         //加密信息存入数据库 | ||||
|         SysUser user = new SysUser(); | ||||
|         user.setUserName(username); | ||||
|         user.setPassword(password); | ||||
|         user.setDeptId(100L); | ||||
|         user.setNickName(username); | ||||
|         user.setCreateTime(DateUtil.date(System.currentTimeMillis())); | ||||
|         user.setUpdateBy("admin"); | ||||
|         return sysUserService.insertUser(user)!=0?Constants.LOGIN_SUCCESS:Constants.LOGIN_FAIL; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -6,14 +6,14 @@ import com.ruoyi.common.core.domain.entity.SysUser; | ||||
|  | ||||
| /** | ||||
|  * 用户表 数据层 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| public interface SysUserMapper | ||||
| { | ||||
|     /** | ||||
|      * 根据条件分页查询用户列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysUser 用户信息 | ||||
|      * @return 用户信息集合信息 | ||||
|      */ | ||||
| @@ -21,7 +21,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 通过用户名查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
| @@ -29,7 +29,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
| @@ -37,7 +37,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 新增用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -45,7 +45,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 修改用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -53,7 +53,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 修改用户头像 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param avatar 头像地址 | ||||
|      * @return 结果 | ||||
| @@ -62,7 +62,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 重置用户密码 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param password 密码 | ||||
|      * @return 结果 | ||||
| @@ -71,7 +71,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID删除用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -79,7 +79,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 批量删除用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param userIds 需要删除的用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -87,7 +87,7 @@ public interface SysUserMapper | ||||
|  | ||||
|     /** | ||||
|      * 校验用户名称是否唯一 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名称 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -108,4 +108,28 @@ public interface SysUserMapper | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public SysUser checkEmailUnique(String email); | ||||
|  | ||||
|     /** | ||||
|      * 查询邮箱是否唯一 | ||||
|      * | ||||
|      * @param email 邮箱 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int selectUserByEmail(String email); | ||||
|     /** | ||||
|      * 查询登陆名称是否唯一 | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int countUserByUserName(String userName); | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 查询手机号是否唯一 | ||||
|      * | ||||
|      * @param phone 手机号 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int countUserByPhone(String phone); | ||||
| } | ||||
|   | ||||
| @@ -5,14 +5,14 @@ import com.ruoyi.common.core.domain.entity.SysUser; | ||||
|  | ||||
| /** | ||||
|  * 用户 业务层 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| public interface ISysUserService | ||||
| { | ||||
|     /** | ||||
|      * 根据条件分页查询用户列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 用户信息集合信息 | ||||
|      */ | ||||
| @@ -20,15 +20,36 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 通过用户名查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public SysUser selectUserByUserName(String userName); | ||||
|     /** | ||||
|      * 查询邮箱是否唯一 | ||||
|      * | ||||
|      * @param email 邮箱 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int selectUserByEmail(String email); | ||||
|     /** | ||||
|      * 查询登陆名称是否唯一 | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int countUserByUserName(String userName); | ||||
|     /** | ||||
|      * 查询手机号是否唯一 | ||||
|      * | ||||
|      * @param phone 手机号 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     public int countUserByPhone(String phone); | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
| @@ -36,7 +57,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 根据用户ID查询用户所属角色组 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -44,7 +65,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 根据用户ID查询用户所属岗位组 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -52,7 +73,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 校验用户名称是否唯一 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名称 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -76,14 +97,14 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 校验用户是否允许操作 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      */ | ||||
|     public void checkUserAllowed(SysUser user); | ||||
|  | ||||
|     /** | ||||
|      * 新增用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -91,7 +112,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -99,7 +120,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户状态 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -107,7 +128,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户基本信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -115,7 +136,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户头像 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param avatar 头像地址 | ||||
|      * @return 结果 | ||||
| @@ -124,7 +145,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 重置用户密码 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -132,7 +153,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 重置用户密码 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param password 密码 | ||||
|      * @return 结果 | ||||
| @@ -141,7 +162,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID删除用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -149,7 +170,7 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 批量删除用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param userIds 需要删除的用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -157,11 +178,15 @@ public interface ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 导入用户数据 | ||||
|      *  | ||||
|      * | ||||
|      * @param userList 用户数据列表 | ||||
|      * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 | ||||
|      * @param operName 操作用户 | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysUserService; | ||||
|  | ||||
| /** | ||||
|  * 用户 业务层处理 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @Service | ||||
| @@ -55,7 +55,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 根据条件分页查询用户列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 用户信息集合信息 | ||||
|      */ | ||||
| @@ -68,7 +68,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 通过用户名查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
| @@ -78,9 +78,47 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|         return userMapper.selectUserByUserName(userName); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询邮箱是否唯一 | ||||
|      * | ||||
|      * @param email 邮箱 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     @Override | ||||
|     public int selectUserByEmail(String email) { | ||||
|         return userMapper.selectUserByEmail(email); | ||||
|     } | ||||
|     /** | ||||
|      * 查询登陆名称是否唯一 | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     @Override | ||||
|     public int countUserByUserName(String userName) { | ||||
|         return userMapper.countUserByUserName(userName); | ||||
|     } | ||||
|     /** | ||||
|      * 查询手机号是否唯一 | ||||
|      * | ||||
|      * @param phone 手机号 | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
|     @Override | ||||
|     public int countUserByPhone(String phone) { | ||||
|         return userMapper.countUserByPhone(phone); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID查询用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 用户对象信息 | ||||
|      */ | ||||
| @@ -92,7 +130,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 查询用户所属角色组 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -114,7 +152,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 查询用户所属岗位组 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -136,7 +174,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 校验用户名称是否唯一 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名称 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -189,7 +227,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 校验用户是否允许操作 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      */ | ||||
|     @Override | ||||
| @@ -203,7 +241,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 新增保存用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -222,7 +260,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改保存用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -244,7 +282,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户状态 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -256,7 +294,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户基本信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -268,7 +306,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 修改用户头像 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param avatar 头像地址 | ||||
|      * @return 结果 | ||||
| @@ -281,7 +319,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 重置用户密码 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户信息 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -293,7 +331,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 重置用户密码 | ||||
|      *  | ||||
|      * | ||||
|      * @param userName 用户名 | ||||
|      * @param password 密码 | ||||
|      * @return 结果 | ||||
| @@ -306,7 +344,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 新增用户角色信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户对象 | ||||
|      */ | ||||
|     public void insertUserRole(SysUser user) | ||||
| @@ -332,7 +370,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 新增用户岗位信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param user 用户对象 | ||||
|      */ | ||||
|     public void insertUserPost(SysUser user) | ||||
| @@ -358,7 +396,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 通过用户ID删除用户 | ||||
|      *  | ||||
|      * | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -374,7 +412,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 批量删除用户信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param userIds 需要删除的用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -390,7 +428,7 @@ public class SysUserServiceImpl implements ISysUserService | ||||
|  | ||||
|     /** | ||||
|      * 导入用户数据 | ||||
|      *  | ||||
|      * | ||||
|      * @param userList 用户数据列表 | ||||
|      * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 | ||||
|      * @param operName 操作用户 | ||||
|   | ||||
| @@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| 		<association property="dept"    column="dept_id" javaType="SysDept" resultMap="deptResult" /> | ||||
| 		<collection  property="roles"   javaType="java.util.List"        resultMap="RoleResult" /> | ||||
| 	</resultMap> | ||||
| 	 | ||||
|  | ||||
| 	<resultMap id="deptResult" type="SysDept"> | ||||
| 		<id     property="deptId"   column="dept_id"     /> | ||||
| 		<result property="parentId" column="parent_id"   /> | ||||
| @@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| 		<result property="leader"   column="leader"      /> | ||||
| 		<result property="status"   column="dept_status" /> | ||||
| 	</resultMap> | ||||
| 	 | ||||
|  | ||||
| 	<resultMap id="RoleResult" type="SysRole"> | ||||
| 		<id     property="roleId"       column="role_id"        /> | ||||
| 		<result property="roleName"     column="role_name"      /> | ||||
| @@ -44,9 +44,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| 		<result property="dataScope"     column="data_scope"    /> | ||||
| 		<result property="status"       column="role_status"    /> | ||||
| 	</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.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 | ||||
| @@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| 		    left join sys_user_role ur on u.user_id = ur.user_id | ||||
| 		    left join sys_role r on r.role_id = ur.role_id | ||||
|     </sql> | ||||
|      | ||||
|  | ||||
|     <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> | ||||
| 		select u.user_id, u.dept_id, u.nick_name, u.user_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, d.dept_name, d.leader from sys_user u | ||||
| 		left join sys_dept d on u.dept_id = d.dept_id | ||||
| @@ -80,29 +80,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| 		<!-- 数据范围过滤 --> | ||||
| 		${params.dataScope} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> | ||||
| 	    <include refid="selectUserVo"/> | ||||
| 		where u.user_name = #{userName} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<select id="selectUserByEmail" parameterType="String" resultType="int"> | ||||
| 		SELECT count(*) where email = #{email} | ||||
| 	</select> | ||||
|  | ||||
|  | ||||
| 	<select id="countUserByUserName" parameterType="String" resultType="int"> | ||||
| 		SELECT count(*) where user_name = #{userName} | ||||
| 	</select> | ||||
|  | ||||
| 	<select id="countUserByPhone" parameterType="String" resultType="int"> | ||||
| 		SELECT count(*) where phonenumber = #{phone} | ||||
| 	</select> | ||||
|  | ||||
|  | ||||
|  | ||||
| 	<select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> | ||||
| 		<include refid="selectUserVo"/> | ||||
| 		where u.user_id = #{userId} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<select id="checkUserNameUnique" parameterType="String" resultType="int"> | ||||
| 		select count(1) from sys_user where user_name = #{userName} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> | ||||
| 		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> | ||||
| 		select user_id, email from sys_user where email = #{email} | ||||
| 	</select> | ||||
| 	 | ||||
|  | ||||
| 	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> | ||||
|  		insert into sys_user( | ||||
|  			<if test="userId != null and userId != 0">user_id,</if> | ||||
| @@ -134,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|  			sysdate() | ||||
|  		) | ||||
| 	</insert> | ||||
| 	 | ||||
|  | ||||
| 	<update id="updateUser" parameterType="SysUser"> | ||||
|  		update sys_user | ||||
|  		<set> | ||||
| @@ -155,28 +170,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|  		</set> | ||||
|  		where user_id = #{userId} | ||||
| 	</update> | ||||
| 	 | ||||
|  | ||||
| 	<update id="updateUserStatus" parameterType="SysUser"> | ||||
|  		update sys_user set status = #{status} where user_id = #{userId} | ||||
| 	</update> | ||||
| 	 | ||||
|  | ||||
| 	<update id="updateUserAvatar" parameterType="SysUser"> | ||||
|  		update sys_user set avatar = #{avatar} where user_name = #{userName} | ||||
| 	</update> | ||||
| 	 | ||||
|  | ||||
| 	<update id="resetUserPwd" parameterType="SysUser"> | ||||
|  		update sys_user set password = #{password} where user_name = #{userName} | ||||
| 	</update> | ||||
| 	 | ||||
|  | ||||
| 	<delete id="deleteUserById" parameterType="Long"> | ||||
|  		delete from sys_user where user_id = #{userId} | ||||
|  	</delete> | ||||
|  	 | ||||
|  | ||||
|  	<delete id="deleteUserByIds" parameterType="Long"> | ||||
|  		update sys_user set del_flag = '2' where user_id in | ||||
|  		<foreach collection="array" item="userId" open="(" separator="," close=")"> | ||||
|  			#{userId} | ||||
|         </foreach>  | ||||
|         </foreach> | ||||
|  	</delete> | ||||
| 	 | ||||
| </mapper>  | ||||
|  | ||||
| </mapper> | ||||
|   | ||||
| @@ -1,6 +1,17 @@ | ||||
| import request from '@/utils/request' | ||||
|  | ||||
|  | ||||
|  | ||||
| //书签设置星标 取消星标 | ||||
| export function updateBookmarkStarById(query) { | ||||
|   return request({ | ||||
|     url: '/bookmark/bookmark/updateBookmarkStarById', | ||||
|     method: 'get', | ||||
|     params: query | ||||
|   }) | ||||
| } | ||||
|  | ||||
|  | ||||
| export function selectBymenuIdUserID(query) { | ||||
|   return request({ | ||||
|     url: '/bookmark/bookmark/selectBymenuIdUserID', | ||||
|   | ||||
| @@ -30,22 +30,22 @@ | ||||
|           </div> | ||||
|           <div class="bookmark-official">{{bm.urls}} · </div> | ||||
|           <div class="bookmark-time">{{bm.createTime|changeTime}}</div> | ||||
|           <div class="bookmark-time">{{bm.bookmarkStar}}</div> | ||||
|           <div class="bookmark-time" v-for="t in bm.sqTags" v-if="false"> | ||||
|             <el-tag class="bookmark-list-tag" data-bookmarkId="t.bookmarkId" data-tagId="t.tagId" | ||||
|                     size="mini"> | ||||
|               {{t.name}} | ||||
|             </el-tag> | ||||
| <!--            <el-tag class="bookmark-list-tag" data-bookmarkId="t.bookmarkId" data-tagId="t.tagId"--> | ||||
| <!--                    size="mini">--> | ||||
| <!--              {{t.name}}--> | ||||
| <!--            </el-tag>--> | ||||
|           </div> | ||||
|         </div> | ||||
|       </div> | ||||
|  | ||||
|       <!--编辑  --> | ||||
|       <div class="editAllBookMark"  v-show="seen&&bm.bookmarkId==current"> | ||||
|           <el-button type="info" style="color: #1112ff" plain size="mini" icon="el-icon-star-off" ></el-button> | ||||
|           <el-button slot="reference" @click.stop="updateStarById(bm.bookmarkId,bm.bookmarkStar)"  type="info" v-bind:class="{ activeClass: bm.bookmarkStar ==1  }"   plain size="mini" icon="el-icon-star-off"></el-button> | ||||
|           <el-button type="info" plain size="mini" icon="el-icon-share" ></el-button> | ||||
|           <el-button type="info" plain size="mini" icon="el-icon-edit" @click.stop="handleUpdate(bm.bookmarkId)"></el-button> | ||||
|           <el-button type="danger" plain size="mini" icon="el-icon-delete" @click.stop="handleDelete(bm.bookmarkId)"></el-button> | ||||
|  | ||||
|           <div style="width: 10px"></div> | ||||
|       </div> | ||||
|     </div> | ||||
| @@ -54,9 +54,10 @@ | ||||
| </template> | ||||
| <script> | ||||
|   import {format} from 'timeago.js'; | ||||
|   import {updateBookmarkStarById} from '@/api/bookmark/bookmark'; | ||||
|  | ||||
|   export default { | ||||
|     components: {format}, | ||||
|     components: {format,updateBookmarkStarById}, | ||||
|     props: { | ||||
|       bookmarkList: Array, | ||||
|       property: null, | ||||
| @@ -85,6 +86,7 @@ | ||||
|       // that.Ueditor = that.$route.query.Ueditor; | ||||
|  | ||||
|     }, | ||||
|  | ||||
|     filters: { | ||||
|       //timeago.js插件 | ||||
|       //计算时间,类似于几分钟前,几小时前,几天前等 | ||||
| @@ -107,6 +109,20 @@ | ||||
|       handleDelete:function(bookmarkId) { | ||||
|       this.$emit('on-handleDelete', bookmarkId); | ||||
|       }, | ||||
|       /** 星标 **/ | ||||
|       updateStarById:function(bookmarkId,bookmarkStar){ | ||||
|         console.log("bookmarkStar:"+bookmarkStar) | ||||
|         var param={ | ||||
|           bookmarkId:bookmarkId, | ||||
|           bookmarkStr:bookmarkStar==0?1:0 | ||||
|         } | ||||
|         console.log("bookmarkStar2:"+param.bookmarkStar) | ||||
|         updateBookmarkStarById(param).then(response => { | ||||
|           if (response.code === 200) { | ||||
|             this.msgSuccess("设置成功"); | ||||
|           } | ||||
|         }); | ||||
|       }, | ||||
|       /**渲染模式**/ | ||||
|       showView(e) { | ||||
|         var that=this; | ||||
| @@ -199,6 +215,9 @@ | ||||
|   } | ||||
| </script> | ||||
| <style scoped> | ||||
|   .activeClass{ | ||||
|     color: red; | ||||
|   } | ||||
|  | ||||
|   .bookmark-item { | ||||
|     display: flex; | ||||
|   | ||||
| @@ -2,16 +2,34 @@ | ||||
|   <div class="app-container "> | ||||
|     <el-row :gutter="20" > | ||||
|       <el-col :xs="24" :sm="{span: 16, push: 4}" :md="{span: 14, push: 5}"  :xl="{span: 10, push: 7}"  > | ||||
|         <el-card class="box-card"> | ||||
|           <div slot="header" class="clearfix"> | ||||
|             <span>系统设置</span> | ||||
|           </div> | ||||
|           <div> | ||||
|             <ul class="list-group list-group-striped"> | ||||
|  | ||||
|             </ul> | ||||
|  | ||||
|  | ||||
|         <el-card class="box-card"> | ||||
|  | ||||
|           <div style="height: 600px"> | ||||
|             <el-tabs tab-position="left" style="height: 200px;" > | ||||
|               <el-tab-pane style="margin-bottom: 110px"> | ||||
|                 <span slot="label"><i class="el-icon-date"></i> 用户管理</span> | ||||
|                 用户管理 | ||||
|               </el-tab-pane> | ||||
|               <el-tab-pane > | ||||
|                 <span slot="label"><i class="el-icon-coin"></i> 配置管理</span> | ||||
|                 配置管理 | ||||
|               </el-tab-pane> | ||||
|               <el-tab-pane > | ||||
|                 <span slot="label"><i class="el-icon-set-up"></i> 角色管理</span> | ||||
|                 角色管理 | ||||
|               </el-tab-pane> | ||||
|               <el-tab-pane > | ||||
|                 <span slot="label"><i class="el-icon-turn-off"></i> 定时任务</span> | ||||
|                 定时任务 | ||||
|               </el-tab-pane> | ||||
|             </el-tabs> | ||||
|           </div> | ||||
|         </el-card> | ||||
|  | ||||
|  | ||||
|       </el-col> | ||||
|  | ||||
|     </el-row> | ||||
|   | ||||
| @@ -17,8 +17,8 @@ | ||||
|         </div> | ||||
|  | ||||
|         <div class="sousouright-icon"> | ||||
|           <el-badge :value="5" :max="99" class="item"><i class="el-icon-message-solid" style="font-size: 17px;"></i> | ||||
|           </el-badge> | ||||
|           <inform></inform> | ||||
|  | ||||
|         </div> | ||||
|  | ||||
|         <div class="sousouright-iconadd"> | ||||
| @@ -224,7 +224,7 @@ | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|  | ||||
|   import inform from '../common/inform.vue' | ||||
|   import {listMenuByUserId} from "@/api/bookmark/menu"; | ||||
|   import { getUserProfile } from "@/api/system/user"; | ||||
|   import Treeselect from "@riophae/vue-treeselect"; | ||||
| @@ -250,7 +250,7 @@ | ||||
|  | ||||
|   export default { | ||||
|     components: { | ||||
|       format, Treeselect,BookmarkOne,TinyMceEdit | ||||
|       format, Treeselect,BookmarkOne,TinyMceEdit,inform | ||||
|     }, | ||||
|  | ||||
|     data: function () { | ||||
|   | ||||
							
								
								
									
										190
									
								
								ruoyi-ui/src/views/bookmark/common/inform.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										190
									
								
								ruoyi-ui/src/views/bookmark/common/inform.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,190 @@ | ||||
| <template> | ||||
|   <div> | ||||
|  | ||||
|     <el-badge :value="5" :max="99" class="item"><i class="el-icon-bell badgeiocn" @click="dialogVisible = true"></i> | ||||
|     </el-badge> | ||||
|  | ||||
|  | ||||
|     <el-dialog | ||||
|       title="通知信息" | ||||
|       :visible.sync="dialogVisible" | ||||
|       width="35%" | ||||
|       :before-close="handleClose"> | ||||
|  | ||||
|       <!--  tabs--> | ||||
|       <el-tabs :stretch="true" v-model="activeNameTabs" @tab-click="handleClick" accordion class="tabsList"> | ||||
|  | ||||
|         <el-tab-pane name="first"> | ||||
|           <span slot="label"><i class="el-icon-message tabFont"></i> </span> | ||||
|  | ||||
|  | ||||
|           <!--  collapse 消息列表--> | ||||
|           <el-collapse v-model="activeName" accordion @change="handleChange" | ||||
|                        v-if="informList !==undefined && informList.length > 0"> | ||||
|             <el-collapse-item name="1111"> | ||||
|               <template slot="title"> 一致性 Consistency 20201-10-10 20:22:22 ....</template> | ||||
|               <div>20201-10-10 20:22:22</div> | ||||
|               <div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||||
|               <div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||||
|             </el-collapse-item> | ||||
|           </el-collapse> | ||||
|  | ||||
|  | ||||
|           <!-- 空 --> | ||||
|           <div v-if="informList == undefined || informList.length <= 0"> | ||||
|             <div class="emptyList"> | ||||
|               <i class="el-icon-bell"></i> | ||||
|             </div> | ||||
|             <div class="emptytext"> | ||||
|               <span>你还没有消息</span> | ||||
|             </div> | ||||
|           </div> | ||||
|  | ||||
|  | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane name="second"> | ||||
|           <span slot="label"><i class="el-icon-chat-round tabFont"></i> </span> | ||||
|  | ||||
|           <!--  collapse 消息列表--> | ||||
|           <el-collapse v-model="activeName" accordion @change="handleChange" | ||||
|                        v-if="systemInformList !==undefined && systemInformList.length > 0"> | ||||
|             <el-collapse-item name="1111"> | ||||
|               <template slot="title"> 一致性 Consistency 20201-10-10 20:22:22 ....</template> | ||||
|               <div>20201-10-10 20:22:22</div> | ||||
|               <div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||||
|               <div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||||
|             </el-collapse-item> | ||||
|           </el-collapse> | ||||
|  | ||||
|  | ||||
|           <!-- 空 --> | ||||
|           <div v-if="systemInformList == undefined || systemInformList.length <= 0"> | ||||
|             <div class="emptyList"> | ||||
|               <i class="el-icon-bell"></i> | ||||
|             </div> | ||||
|             <div class="emptytext"> | ||||
|               <span>你还没有消息</span> | ||||
|             </div> | ||||
|           </div> | ||||
|  | ||||
|  | ||||
|         </el-tab-pane> | ||||
|  | ||||
|         <el-tab-pane name="second2"> | ||||
|           <span slot="label"><i class="el-icon-document tabFont"></i> </span> | ||||
|  | ||||
|           <!--  collapse 消息列表--> | ||||
|           <el-collapse v-model="activeName" accordion @change="handleChange" | ||||
|                        v-if="significanceInformList !==undefined && significanceInformList.length > 0"> | ||||
|             <el-collapse-item name="1111"> | ||||
|               <template slot="title"> 一致性 Consistency 20201-10-10 20:22:22 ....</template> | ||||
|               <div>20201-10-10 20:22:22</div> | ||||
|               <div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||||
|               <div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||||
|             </el-collapse-item> | ||||
|           </el-collapse> | ||||
|  | ||||
|  | ||||
|           <!-- 空 --> | ||||
|           <div v-if="significanceInformList == undefined || significanceInformList.length <= 0"> | ||||
|             <div class="emptyList"> | ||||
|               <i class="el-icon-bell"></i> | ||||
|             </div> | ||||
|             <div class="emptytext"> | ||||
|               <span>你还没有消息</span> | ||||
|             </div> | ||||
|           </div> | ||||
|  | ||||
|  | ||||
|         </el-tab-pane> | ||||
|       </el-tabs> | ||||
|  | ||||
|       <span slot="footer" class="dialog-footer"> | ||||
|         <el-button @click="dialogVisible = false">取 消</el-button> | ||||
|         <el-button type="primary" @click="dialogVisible = false">确 定</el-button> | ||||
|       </span> | ||||
|  | ||||
|  | ||||
|  | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
| <script> | ||||
|   export default { | ||||
|     name: 'areaTree', | ||||
|     components: {}, | ||||
|     props: {}, | ||||
|     data: function () { | ||||
|       return { | ||||
|         activeName: '1', | ||||
|         dialogVisible: false, | ||||
|         activeNameTabs: 'first', | ||||
|         userInformList: [], | ||||
|         systemInformList: [], | ||||
|         significanceInformList: [], | ||||
|         informList:[] | ||||
|       } | ||||
|     }, | ||||
|     methods: { | ||||
|  | ||||
|       handleClose(done) { | ||||
|         this.$confirm('确认关闭?') | ||||
|           .then(_ => { | ||||
|             done(); | ||||
|           }) | ||||
|           .catch(_ => { | ||||
|           }); | ||||
|       }, | ||||
|       handleClick(tab, event) { | ||||
|         console.log(tab, event); | ||||
|       }, | ||||
|       handleChange(val) { | ||||
|         console.log(val); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| </script> | ||||
| <style scoped> | ||||
|  | ||||
|   .emptyList { | ||||
|     width: 100%; | ||||
|     height: 180px; | ||||
|     display: flex; | ||||
|     justify-items: center; | ||||
|     align-items: center; | ||||
|   } | ||||
|  | ||||
|   .emptyList i { | ||||
|     font-size: 120px; | ||||
|     margin: 0 auto; | ||||
|     color: #D4D4D4; | ||||
|   } | ||||
|  | ||||
|   .emptytext { | ||||
|     width: 100%; | ||||
|     display: flex; | ||||
|     justify-items: center; | ||||
|     align-items: center; | ||||
|     font-size: 17px; | ||||
|     color: #D4D4D4; | ||||
|   } | ||||
|  | ||||
|   .emptytext span { | ||||
|     margin: 0 auto; | ||||
|   } | ||||
|  | ||||
|   .badgeiocn { | ||||
|     font-size: 17px; | ||||
|   } | ||||
|  | ||||
|   .tabsList { | ||||
|     margin-top: -30px; | ||||
|     min-height: 100px | ||||
|   } | ||||
|  | ||||
|   .tabFont { | ||||
|     font-size: 22px; | ||||
|   } | ||||
|  | ||||
|  | ||||
| </style> | ||||
| @@ -80,18 +80,21 @@ | ||||
|     </div> | ||||
| </template> | ||||
| <script> | ||||
|  | ||||
|     export default { | ||||
|         name: 'areaTree', | ||||
|         components: {}, | ||||
|         components: { | ||||
|         }, | ||||
|  | ||||
|         data: function () { | ||||
|             return {} | ||||
|             return { | ||||
|             } | ||||
|         }, | ||||
|         methods: { | ||||
|  | ||||
|         }, | ||||
|       mounted() { | ||||
|         document.querySelector('body').setAttribute('style', 'background-color:#f6f5f4') | ||||
|         document.querySelector('body').setAttribute('style', 'background-color:#f4f5f9') | ||||
|       }, | ||||
|       beforeDestroy() { | ||||
|         document.querySelector('body').removeAttribute('style') | ||||
|   | ||||
| @@ -21,9 +21,10 @@ | ||||
|           <div class="main-right"> | ||||
| <!--            <svg-icon icon-class="tool" class="svgicon"/>--> | ||||
| <!--             <div class="aside-title"><i class="el-icon-s-management"></i><span>发现</span></div>--> | ||||
|             <div class="aside-title" @click="goRouter(8)"><i class="el-icon-s-tools"></i><span>最新</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-star-on"></i><span>星标</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-help"></i><span>稍后看</span></div> | ||||
|             <div class="aside-title" @click="goRouter(8)"><i class="el-icon-folder"></i><span>最新</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-star-off"></i><span>星标</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-reading"></i><span>稍后看</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-view"></i><span>发现</span></div> | ||||
| <!--            <div class="aside-title"><i class="el-icon-s-platform"></i><span>任意门</span></div>--> | ||||
| <!--            <div class="aside-title"><i class="el-icon-message-solid"></i><span>收件箱</span></div>--> | ||||
|             <div class="reminder">我的收藏 <svg-icon icon-class="sx" style="margin-left:5px" @click="refreshNode"/></div> | ||||
| @@ -32,13 +33,13 @@ | ||||
|             </div> | ||||
|             <div class="reminder" >工具箱</div> | ||||
| <!--            <div class="aside-title"><i class="el-icon-s-flag" style="color: #569cd5"></i><span>RSS订阅</span></div>--> | ||||
|             <div class="aside-title" @click="goRouter(7)"><i class="el-icon-s-management"></i><span>标签管理</span></div> | ||||
|             <div class="aside-title" @click="goRouter(6)"><i class="el-icon-delete-solid" style="color: red"></i><span>垃圾桶</span></div> | ||||
|             <div class="aside-title" @click="goRouter(7)"><i class="el-icon-collection"></i><span>标签管理</span></div> | ||||
|             <div class="aside-title" @click="goRouter(6)"><i class="el-icon-delete" ></i><span>垃圾桶</span></div> | ||||
| <!--            <div class="aside-title" @click="goRouter(5)"><i class="el-icon-s-platform"></i><span>导入书签</span></div>--> | ||||
|             <div class="aside-title"><i class="el-icon-s-comment"></i><span>意见反馈</span></div> | ||||
|             <div class="aside-title"><i class="el-icon-chat-dot-square"></i><span>意见反馈</span></div> | ||||
| <!--            <div class="aside-title" @click="ceshi"><i class="el-icon-s-comment"></i><span>测试页面</span></div>--> | ||||
|             <div class="aside-title" @click="goRouter(2)"><i class="el-icon-s-platform"></i><span>小工具</span></div> | ||||
|             <div class="aside-title " style="margin-bottom: 100px"  @click="goRouter(9)"><i class="el-icon-s-grid"></i><span>更多设置</span></div> | ||||
|             <div class="aside-title" @click="goRouter(2)"><i class="el-icon-suitcase"></i><span>小工具</span></div> | ||||
|             <div class="aside-title " style="margin-bottom: 100px"  @click="goRouter(9)"><i class="el-icon-setting"></i><span>更多设置</span></div> | ||||
|  | ||||
|           </div> | ||||
|  | ||||
| @@ -74,7 +75,7 @@ | ||||
|     </el-container> | ||||
|     <!--  编辑弹窗--> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="500px" class="menuedit" append-to-body> | ||||
|       <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||||
|       <el-form ref="form" :model="form" :rules="rules" > | ||||
|         <el-form-item prop="menuName"> | ||||
|           <div class="labelname">菜单名称</div> | ||||
|           <el-input class="custom-input" v-model="form.menuName" placeholder="请输入菜单名称"/> | ||||
|   | ||||
| @@ -56,6 +56,15 @@ public interface SqBookmarkMapper extends MyMapper<SqBookmark> | ||||
|      */ | ||||
|     public int updateSqBookmark(SqBookmark sqBookmark); | ||||
|  | ||||
|     /** | ||||
|      * 设置书签的星标 | ||||
|      * | ||||
|      * @param bookmarkId | ||||
|      * @param userId | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int updateSqBookmarkByStar(@Param("bookmarkId") Long bookmarkId,@Param("userId")Long userId,@Param("bookmarkStar") Integer bookmarkStar); | ||||
|  | ||||
|     /** | ||||
|      * 删除书签管理 | ||||
|      * | ||||
|   | ||||
| @@ -132,7 +132,7 @@ public interface ISqBookmarkService | ||||
|      * @param userId | ||||
|      * @return | ||||
|      */ | ||||
|     int updateBookmarkStarById(Long userId, String bookmarkId, int bookmarkStr); | ||||
|     int updateBookmarkStarById(Long userId, Long bookmarkId, Integer bookmarkStr); | ||||
|     /** | ||||
|      * 删除重复的书签 | ||||
|      * | ||||
|   | ||||
| @@ -127,7 +127,7 @@ public interface ISqMenuService | ||||
|  | ||||
|  | ||||
|    /** | ||||
|     *防止重复点击上传文件 | ||||
|     *防止重复点击 | ||||
|     * | ||||
|     * @param  state 表示某个功能 | ||||
|     * @param  userID 用户ID | ||||
| @@ -183,4 +183,16 @@ public interface ISqMenuService | ||||
|      * @return | ||||
|      */ | ||||
|     List<SqMenu> listByMenuId(Long userId, Long menuId); | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * 显示l时间内 只能访问i次 | ||||
|      * | ||||
|      * @param phoneRegister 功能标识符 | ||||
|      * @param userId 用户id | ||||
|      * @param time 时间单位秒 | ||||
|      * @param i 次数 | ||||
|      * @return | ||||
|      */ | ||||
|     Boolean countRepetition(String phoneRegister, Long userId, long time, int i); | ||||
| } | ||||
|   | ||||
| @@ -375,12 +375,8 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int updateBookmarkStarById(Long userId, String bookmarkId, int bookmarkStr) { | ||||
|         SqBookmark sqBookmark =new SqBookmark(); | ||||
|         sqBookmark.setBookmarkId(Long.valueOf(bookmarkId)); | ||||
|         sqBookmark.setUserid(userId); | ||||
|         sqBookmark.setBookmarkStar(bookmarkStr==1?1:0); | ||||
|         return sqBookmarkMapper.updateSqBookmark(sqBookmark); | ||||
|     public int updateBookmarkStarById(Long userId, Long bookmarkId, Integer bookmarkStr) { | ||||
|         return sqBookmarkMapper.updateSqBookmarkByStar(bookmarkId,userId,bookmarkStr==1?1:0); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -2,11 +2,14 @@ package com.ruoyi.bookmark.service.impl; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
|  | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import com.ruoyi.common.core.redis.RedisKey; | ||||
| import com.ruoyi.common.core.redis.RedisUtil; | ||||
| import com.ruoyi.common.utils.DateUtils; | ||||
| import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; | ||||
| @@ -221,14 +224,14 @@ public class SqMenuServiceImpl implements ISqMenuService | ||||
|      */ | ||||
|     @Override | ||||
|     public Long noRepetition(String state, Long userID, Long time) { | ||||
|       String key = "BookMark:"+state+":"+userID.toString(); | ||||
|       String str = redisUtil.get(key); | ||||
|       if (str==null){ | ||||
|           redisUtil.setEx(key,"0",time,TimeUnit.SECONDS); | ||||
|           return 0L; | ||||
|       }else{ | ||||
|           return  redisUtil.getExpire(key); | ||||
|       } | ||||
|         String key = RedisKey.BOOKMARK + state + RedisKey.CONNECTOR + userID.toString(); | ||||
|         String str = redisUtil.get(key); | ||||
|         if (str == null) { | ||||
|             redisUtil.setEx(key, "0", time, TimeUnit.SECONDS);//秒 | ||||
|             return 0L; | ||||
|         } else { | ||||
|             return redisUtil.getExpire(key); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -330,4 +333,31 @@ public class SqMenuServiceImpl implements ISqMenuService | ||||
|         return sqMenuMapper.selectSqMenuList(new SqMenu(parentId,userId)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     public Boolean countRepetition(String state, Long userId, long time, int i) { | ||||
|  | ||||
|         String key = RedisKey.BOOKMARK + state + RedisKey.CONNECTOR + userId.toString(); | ||||
|         Long count = redisUtil.lLen(key); | ||||
|         if (count.intValue() < i) { | ||||
|             //插入到尾部 | ||||
|             redisUtil.lRightPush(key, String.valueOf(DateUtil.date(System.currentTimeMillis()).getTime())); | ||||
|             redisUtil.expire(key, time, TimeUnit.SECONDS); //设置过期时间(秒) | ||||
|         } else { | ||||
|             //获取最新第一条 判断是否满足规定时间内的访问次数 | ||||
|             String indexTime = redisUtil.lIndex(key, 0); | ||||
|  | ||||
|             if (TimeUnit.MILLISECONDS.toSeconds(DateUtil.date(System.currentTimeMillis()).getTime() - Long.valueOf(indexTime)) < time) // 触发10min内请求大于3次,提醒,“请求过多,请稍后再试。” | ||||
|             { | ||||
|                 return false; | ||||
|             } else { | ||||
|                 //将当前时间戳插入List头部 | ||||
|                 redisUtil.lLeftPush(key, String.valueOf(DateUtil.date(System.currentTimeMillis()).getTime())); | ||||
|                 redisUtil.lTrim(key, 0, i - 1); //剪切 0 到i个数 | ||||
|                 redisUtil.expire(key, time, TimeUnit.SECONDS); //设置过期时间(秒) | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -102,15 +102,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|             <if test="zcount != null">zcount = #{zcount},</if> | ||||
|             <if test="idelete != null">idelete = #{idelete},</if> | ||||
|             <if test="start != null">start = #{start},</if> | ||||
|             <if test="bookmarkStar != null">bookmark_star = #{bookmarkStar},</if> | ||||
|             <if test="createTime != null">create_time = #{createTime},</if> | ||||
|         </trim> | ||||
|         where bookmark_id = #{bookmarkId} | ||||
|     </update> | ||||
|  | ||||
|     <update id="updateSqBookmarkByStar" parameterType="SqBookmark"> | ||||
|        update sq_bookmark SET bookmark_star = #{bookmarkStar} where bookmark_id = #{bookmarkId} and userid = #{userId} | ||||
|     </update> | ||||
|  | ||||
|     <update id="updateSqBookmarkBymenuId" parameterType="Long"> | ||||
|         update sq_bookmark set IDelete = 1 where menu_id = #{menuId} | ||||
|     </update> | ||||
|  | ||||
|  | ||||
|     <delete id="deleteSqBookmarkById" parameterType="Long"> | ||||
|         delete from sq_bookmark where bookmark_id = #{bookmarkId} | ||||
|     </delete> | ||||
| @@ -145,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|         <include refid="selectSqBookmarkVo"/> | ||||
|         where   userid=#{userID} | ||||
|         <if test="sousuo == null  or sousuo == ''"> and menu_id = #{menuID}</if> | ||||
|         <if test="bookmarkStar != null  and bookmarkStar != ''"> and bookmark_star = #{bookmarkStar}</if> | ||||
|  | ||||
|         <if test="start != null  and start != ''"> and start = #{start}</if> | ||||
|         <if test="sousuo != null  and sousuo != ''"> and title like concat('%', #{sousuo}, '%')</if> | ||||
|         order by | ||||
|   | ||||
		Reference in New Issue
	
	Block a user