wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package io.dataease.api.template.dto;
 
import io.dataease.api.template.vo.MarketCategoryVO;
import io.dataease.api.template.vo.MarketMetasVO;
import io.dataease.i18n.Translator;
import lombok.Data;
import lombok.NoArgsConstructor;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
@Data
@NoArgsConstructor
public class TemplateMarketDTO implements Comparable<TemplateMarketDTO> {
    private String id;
    private String title;
    private String status;
    private String slug;
    private String editorType;
    private String summary;
    private String thumbnail;
 
    private Boolean showFlag = true;
 
    private String suggest = "N";
 
    private Long recentUseTime = 0L;
 
    private String templateType;
 
    // 模板来源 market = 模板市场;manage=模板管理
    private String source = "market";
 
    // 模板分类 app = 应用模板;manage=样式模板
    private String classify = "template";
    private List<MarketCategoryVO> categories;
 
    private List<String> categoryNames;
 
    private String mainCategory;
    private MarketMetasVO metas;
 
 
    public TemplateMarketDTO(TemplateManageDTO manageDTO) {
        this.id = manageDTO.getId();
        this.title = manageDTO.getName();
        this.mainCategory = manageDTO.getCategoryName();
        this.categories = manageDTO.getCategoryNames().stream().map(category->new MarketCategoryVO(category)).collect(Collectors.toList());
        this.categoryNames = manageDTO.getCategoryNames();
        this.metas = new MarketMetasVO(manageDTO.getSnapshot());
        this.templateType = "dataV".equalsIgnoreCase(manageDTO.getDvType()) ? "SCREEN" : "PANEL";
        this.thumbnail = manageDTO.getSnapshot();
        this.source = "manage";
        this.classify = manageDTO.getNodeType();
        if (manageDTO.getRecentUseTime() != null) {
            this.recentUseTime = manageDTO.getRecentUseTime();
            String name = Translator.get("i18n_template_recent");
            this.categories.add(new MarketCategoryVO(name));
            this.categoryNames.add(name);
        }
    }
 
    public TemplateMarketDTO(String id, String title, String themeRepo, String templateUrl, String categoryName, String templateType, Long recentUseTime, String suggest, String classify) {
        this.id = id;
        this.title = title;
        this.metas = new MarketMetasVO(templateUrl);
        this.thumbnail = themeRepo;
        this.templateType = templateType;
        this.categories = new ArrayList<>(Arrays.asList(new MarketCategoryVO(categoryName))) ;
        this.categoryNames = new ArrayList<>(Arrays.asList(categoryName)) ;
        if("DATA".equals(classify)){
            this.classify = "app";
        }
        if (recentUseTime != null) {
            this.recentUseTime = recentUseTime;
            String name = Translator.get("i18n_template_recent");
            this.categories.add(new MarketCategoryVO(name));
            this.categoryNames.add(name);
        }
        if ("Y".equalsIgnoreCase(suggest)) {
            this.suggest = "Y";
            String name = Translator.get("i18n_template_recommend");
            this.categories.add(new MarketCategoryVO(name));
            this.categoryNames.add(name);
        }
    }
 
    @Override
    public int compareTo(TemplateMarketDTO other) {
        return Long.compare(other.recentUseTime, this.recentUseTime);
    }
}