Browse Source

一些修改

master
cgx 2 months ago
parent
commit
f5dca9f82f
4 changed files with 88 additions and 28 deletions
  1. +64
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java
  2. +10
    -0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  3. +0
    -23
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java
  4. +14
    -5
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java

+ 64
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java View File

@ -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<SimpleDateFormat> date_sdf = new ThreadLocal<SimpleDateFormat>() {
@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;
}
/**
* 解析字符串为日期
* <p>
* 说明
* 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()));
}


+ 10
- 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java View File

@ -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验证登录


+ 0
- 23
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/bean/LoginReq.java View File

@ -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;
}

+ 14
- 5
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/userRole/service/impl/TbUserRoleServiceImpl.java View File

@ -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<TbUserRoleMapper, TbUserRole> implements ITbUserRoleService {
@Override
public Map getRoleInfo(String userId) {
public Map<String, TbUserRole> getRoleInfo(String userId, boolean status) {
//.eq(TbUserRole::getAuditStatus, 1)
LambdaQueryWrapper<TbUserRole> 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<TbUserRole> 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<TbUserRole> 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<String, TbUserRole> map = new HashMap<>();


Loading…
Cancel
Save