Merge pull request #7000 from dataease/pr@dev-v2@refactor_template-manage

refactor: 优化最近使用查询逻辑
This commit is contained in:
王嘉豪 2023-12-05 10:47:33 +08:00 committed by GitHub
commit 3733fe16e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -20,6 +20,7 @@
<resultMap id="BaseResultMapDTO" type="io.dataease.api.template.dto.TemplateManageDTO"
extends="BaseResultMap">
<result column="recent_use_time" jdbcType="BIGINT" property="recentUseTime" />
<result column="label" jdbcType="VARCHAR" property="label"/>
<result column="childrenCount" jdbcType="VARCHAR" property="childrenCount"/>
</resultMap>
@ -50,10 +51,12 @@
vt.create_time,
vt.template_type,
vt.SNAPSHOT,
vtcm.category_id
vtcm.category_id,
cor.time as 'recent_use_time'
FROM
visualization_template vt
LEFT JOIN visualization_template_category_map vtcm ON vt.id = vtcm.template_id
left JOIN core_opt_recent cor on cor.resource_type=6 and vt.id= cor.resource_name
ORDER BY
vt.create_time DESC
</select>

View File

@ -405,6 +405,7 @@ const apply = () => {
decompression(state.dvCreateForm)
.then(response => {
state.curApplyTemplate.recentUseTime = Date.now()
state.curApplyTemplate.categoryNames.push('最近使用')
state.loading = false
const templateData = response.data
// do create

View File

@ -46,11 +46,13 @@ public class TemplateMarketDTO implements Comparable<TemplateMarketDTO> {
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.getTemplateType()) ? "SCREEN" : "PANEL";
this.templateType = "dataV".equalsIgnoreCase(manageDTO.getDvType()) ? "SCREEN" : "PANEL";
this.thumbnail = manageDTO.getSnapshot();
this.source = "manage";
if (manageDTO.getRecentUseTime() != null) {
this.recentUseTime = manageDTO.getRecentUseTime();
this.categories.add(new MarketCategoryVO("最近使用"));
this.categoryNames.add("最近使用");
}
}