Compare commits

...

3 Commits

2 changed files with 32 additions and 1 deletions

View File

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

View File

@ -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
*