futian.liu
2023-12-22 fd95223d9703b9c038ed3c782474c885052dda08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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;
    }
 
}