Compare commits
3 Commits
61e58d52b3
...
1d1f7667bf
| Author | SHA1 | Date |
|---|---|---|
|
|
1d1f7667bf | |
|
|
1f2f11f80f | |
|
|
8506f4a55e |
|
|
@ -3,7 +3,11 @@ package com.ruoyi.common.utils;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
|
|
@ -185,4 +189,16 @@ public class SecurityUtils
|
|||
.anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 委派用户
|
||||
* 模拟其他用户登录或是在定时任务等无登录用户环境下填充默认用户,确保可正常获取用户信息。
|
||||
*/
|
||||
public static void delegatingUser(SysUser user) {
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUser(user);
|
||||
context.setAuthentication(new UsernamePasswordAuthenticationToken(loginUser, null));
|
||||
SecurityContextHolder.setContext(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@ public class ExcelUtil<T>
|
|||
String dictType = attr.dictType();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
|
||||
cell.setCellStyle(createCellStyle(cell.getCellStyle(), dateFormat));
|
||||
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
|
|
@ -1192,6 +1192,21 @@ public class ExcelUtil<T>
|
|||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用自定义格式,同时避免样式污染
|
||||
*
|
||||
* @param cellStyle 从此样式复制
|
||||
* @param format 格式匹配的字符串
|
||||
* @return 格式化后CellStyle对象
|
||||
*/
|
||||
private CellStyle createCellStyle(CellStyle cellStyle, String format)
|
||||
{
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(cellStyle);
|
||||
style.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat(format));
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 POI XSSFSheet 单元格提示或选择框
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue