package com.consum.base;
|
|
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayOutputStream;
|
import java.io.InputStream;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import com.consum.model.po.FinSysTenantUser;
|
import com.iplatform.base.PlatformAdapterController;
|
import com.iplatform.base.util.UserUtils;
|
import com.iplatform.core.BeanContextAware;
|
import com.iplatform.model.po.S_user_core;
|
import com.walker.file.FileInfo;
|
|
public abstract class BaseController extends PlatformAdapterController {
|
|
protected TokenCacheProvider getTokenCache() {
|
return BeanContextAware.getBeanByType(TokenCacheProvider.class);
|
}
|
|
protected FinOrgCacheProvider getFinOrgCache() {
|
return BeanContextAware.getBeanByType(FinOrgCacheProvider.class);
|
}
|
|
protected FinSysTenantUserCacheProvider getFinSysTenantUserCache() {
|
return BeanContextAware.getBeanByType(FinSysTenantUserCacheProvider.class);
|
}
|
|
protected FinSysTenantCacheProvider getFinSysTenantCache() {
|
return BeanContextAware.getBeanByType(FinSysTenantCacheProvider.class);
|
}
|
|
/**
|
* @Description 获取后台登录用户信息
|
* @Author wh
|
* @Date 2023/7/25 9:59
|
*/
|
protected FinSysTenantUser getSysInfo() {
|
S_user_core userInfo = UserUtils.getUserInfo();
|
FinSysTenantUser finSysTenantUser = new FinSysTenantUser();
|
if (userInfo.getId() == null) {
|
return finSysTenantUser;
|
}
|
// 从缓存中取出用户,如果没有则新增
|
return this.getFinSysTenantUserCache().get(String.valueOf(userInfo.getId()));
|
}
|
|
protected String downLoadExcel(String fileName, Workbook workbook) throws Exception {
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
workbook.write(byteArrayOutputStream);
|
|
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
FileInfo fileInfo = this.uploadFileToLocal(byteArrayInputStream, fileName + ".xls", "-1",
|
byteArrayOutputStream.size(), 0, "-1");
|
String fileUrl = fileInfo.getUrl();
|
|
return "/file/" + fileUrl;
|
}
|
|
}
|