jinlin
2023-12-13 b089cb398c59be1aa2c12c6b0be7652a9edb3612
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
package com.zt.life.modules.mainPart.utils;
 
import com.zt.core.sys.model.SysUser;
import com.zt.life.sys.dto.OssDto;
import com.zt.modules.oss.cloud.LocalStorageService;
import com.zt.modules.oss.model.SysOss;
import com.zt.modules.oss.service.SysOssService;
import com.zt.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
@Service
public class GetFilesPath {
    @Autowired
    private SysUserService sysUserService;
 
    @Autowired
    private SysOssService sysOssService;
 
    public String getSignPath(Long userId) {
        SysUser data = sysUserService.getUserInfo(userId);
        OssDto oss = data.getFiles2();
        return getFirstImagePath(oss);
    }
 
    public String getFirstImagePath(OssDto oss) {
        String filePath = "";
        if (oss != null) {
            if (oss.getGroups().size() > 0) {
                OssDto.OssFieldGroupDto group = oss.getGroups().get(0);
                if (group.getFields().size() > 0) {
                    OssDto.OssFieldDto field = group.getFields().get(0);
                    if (field.getFiles().size() > 0) {
                        com.zt.core.oss.dto.OssDto file = field.getFiles().get(0);
                        SysOss sysOss = sysOssService.get(file.getId());
                        filePath = sysOss.getPath();
                    }
                }
            }
        }
        return filePath;
    }
}