From f5dca9f82f0152e35e9343adf8a52fc540a03c70 Mon Sep 17 00:00:00 2001 From: cgx <2606784146@qq.com> Date: Thu, 12 Dec 2024 22:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/common/util/DateUtils.java | 64 ++++++++++++++++++++++ .../java/org/jeecg/config/shiro/ShiroConfig.java | 10 ++++ .../main/java/org/jeecg/modules/bean/LoginReq.java | 23 -------- .../service/impl/TbUserRoleServiceImpl.java | 19 +++++-- 4 files changed, 88 insertions(+), 28 deletions(-) diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java index 291b508..f18aade 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java @@ -1,10 +1,15 @@ package org.jeecg.common.util; import java.beans.PropertyEditorSupport; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -21,6 +26,11 @@ import org.springframework.util.StringUtils; */ public class DateUtils extends PropertyEditorSupport { + + private static String YYYYMMDDHHMMSS = "yyyy-MM-dd HH:mm:ss"; + + + public static ThreadLocal date_sdf = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { @@ -634,6 +644,60 @@ public class DateUtils extends PropertyEditorSupport { return 0; } + + public static LocalDateTime dateToDateTime(Date date) { + Instant instant = date.toInstant(); + return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); + } + public static float getUntilHours(Date date1, Date date2) { + LocalDateTime localDate1 = dateToDateTime(date1); + LocalDateTime localDate2 = dateToDateTime(date2); + float senonds = Duration.between(localDate1, localDate2).get(ChronoUnit.SECONDS); + return senonds / 3600; + } + + + + /** + * 解析字符串为日期 + *

+ * 说明: + * 1. 该方法主要解决yyyy-MM-dd格式文本字符串无法直接转换为LocalDateTime的问题 + * + * @param source 需要解析的日期字符串 + * @param formatPattern 日期格式化模式 + * @return 格式化后的日期 + */ + public static Date parseStringToLocalDateTime(String source, String formatPattern) { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(formatPattern); + LocalDate localDate = LocalDate.parse(source, dateTimeFormatter); + LocalDateTime localDateTime = localDate.atStartOfDay(); + return dateTimeToDate(localDateTime); + } + public static Date dateTimeToDate(LocalDateTime localDateTime) { + Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + return date; + } + /** + + 将字符串转为日期 + @param date + @return + */ + public static Date getDateymdhms(String date) { + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(YYYYMMDDHHMMSS); + LocalDateTime localDateTime = LocalDateTime.parse(date, dateTimeFormatter); + return dateTimeToDate(localDateTime); + } + + public static void main(String[] args) { + Date date1 = getDateymdhms("2024-12-12 12:00:00"); + Date date2 = getDateymdhms("2024-12-12 09:20:30"); + float untilHours = getUntilHours(date2, date1); + BigDecimal bigDecimal = new BigDecimal(String.valueOf(untilHours)); + System.out.println(bigDecimal.setScale(2, RoundingMode.HALF_UP)); + } + public static Long getCurrentTimestamp() { return Long.valueOf(DateUtils.yyyymmddhhmmss.get().format(new Date())); } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index ac70b7f..3d353af 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -72,6 +72,16 @@ public class ShiroConfig { } } + filterChainDefinitionMap.put("/index/index", "anon"); //登录接口排除 + filterChainDefinitionMap.put("/index/bannerList", "anon"); + filterChainDefinitionMap.put("/index/industryList", "anon"); + filterChainDefinitionMap.put("/index/getIndustryById", "anon"); + filterChainDefinitionMap.put("/index/rolelist1", "anon"); + filterChainDefinitionMap.put("/index/taskList", "anon"); + filterChainDefinitionMap.put("/user/login", "anon"); + filterChainDefinitionMap.put("/index//bannerList", "anon"); + + filterChainDefinitionMap.put("/sys/oss/file/upload", "anon"); //图片上传验证放开 filterChainDefinitionMap.put("/sys/common/upload", "anon"); //图片上传验证放开 filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录 diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java index baf11ba..3723337 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java @@ -13,12 +13,6 @@ public class LoginReq { @ApiModelProperty(value = "参数信息") private String code; - /** - * 参数信息 - */ - @ApiModelProperty(value = "参数信息") - private String vid; - /** * 用户唯一标识 */ @@ -40,22 +34,5 @@ public class LoginReq { @ApiModelProperty(value = "用户头像") private String headimgurl; - /** - * 解密标签 - */ - @ApiModelProperty(value = "解密标签") - private String iv; - /** - * 解密 - */ - @ApiModelProperty(value = "解密") - private String encryptedData; - - - /** - * 邀请者标识 - */ - @ApiModelProperty(value = "邀请者销售标识") - private String shareId; } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java index bec35f1..e5afc6c 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java @@ -14,26 +14,35 @@ import java.util.Map; /** * @Description: tb_user_role * @Author: jeecg-boot - * @Date: 2024-12-07 + * @Date: 2024-12-07 * @Version: V1.0 */ @Service public class TbUserRoleServiceImpl extends ServiceImpl implements ITbUserRoleService { @Override - public Map getRoleInfo(String userId) { + public Map getRoleInfo(String userId, boolean status) { //.eq(TbUserRole::getAuditStatus, 1) LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(TbUserRole::getUserId, userId). - eq(TbUserRole::getRole, 0); + eq(TbUserRole::getRole, 0).ne(TbUserRole::getAuditStatus, 2); + if (status) { + queryWrapper1.eq(TbUserRole::getAuditStatus, 1); + } TbUserRole boss = this.getOne(queryWrapper1); LambdaQueryWrapper queryWrapper2 = new LambdaQueryWrapper<>(); queryWrapper2.eq(TbUserRole::getUserId, userId). - eq(TbUserRole::getRole, 1); + eq(TbUserRole::getRole, 1).ne(TbUserRole::getAuditStatus, 2); + if (status) { + queryWrapper2.eq(TbUserRole::getAuditStatus, 1); + } TbUserRole company = this.getOne(queryWrapper2); LambdaQueryWrapper queryWrapper3 = new LambdaQueryWrapper<>(); queryWrapper3.eq(TbUserRole::getUserId, userId). - eq(TbUserRole::getRole, 2); + eq(TbUserRole::getRole, 2).ne(TbUserRole::getAuditStatus, 2); + if (status) { + queryWrapper3.eq(TbUserRole::getAuditStatus, 1); + } TbUserRole worker = this.getOne(queryWrapper3); Map map = new HashMap<>();