parent
1b59a2a042
commit
8a1905c362
@ -0,0 +1,15 @@
|
||||
package com.gccloud.dataroom.core.module.basic.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gccloud.dataroom.core.module.basic.entity.PagePreviewEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author gcpaas
|
||||
* @Date 2022/06/07
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataRoomPagePreviewDao extends BaseMapper<PagePreviewEntity> {
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.gccloud.dataroom.core.module.basic.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.gccloud.common.entity.SuperEntity;
|
||||
import com.gccloud.dataroom.core.module.basic.dto.BasePageDTO;
|
||||
import com.gccloud.dataroom.core.module.basic.entity.type.BasePageDTOTypeHandler;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 预览缓存临时表
|
||||
*
|
||||
* @Author qianxing
|
||||
* @Date 2022/06/07
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "big_screen_page_preview", autoResultMap = true)
|
||||
@ApiModel
|
||||
public class PagePreviewEntity extends SuperEntity implements Serializable {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty(notes = "主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(notes = "页面编码,页面唯一标识符")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(notes = "具体组件配置、JSON格式")
|
||||
@TableField(typeHandler = BasePageDTOTypeHandler.class)
|
||||
private BasePageDTO config;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
|
||||
@ApiModelProperty(notes = "创建时间")
|
||||
private Date createDate;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.gccloud.dataroom.core.module.manage.service;
|
||||
|
||||
import com.gccloud.common.service.ISuperService;
|
||||
import com.gccloud.dataroom.core.module.basic.entity.PagePreviewEntity;
|
||||
import com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO;
|
||||
|
||||
/**
|
||||
* @author hongyang
|
||||
* @version 1.0
|
||||
* @date 2023/9/13 10:10
|
||||
*/
|
||||
public interface IDataRoomPagePreviewService extends ISuperService<PagePreviewEntity> {
|
||||
|
||||
String PREVIEW_KEY = "preview";
|
||||
|
||||
/**
|
||||
* 保存大屏预览数据
|
||||
* @param bigScreenPageDTO
|
||||
* @return
|
||||
*/
|
||||
String add(DataRoomPageDTO bigScreenPageDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据code获取大屏预览数据
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
PagePreviewEntity getByCode(String code);
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.gccloud.dataroom.core.module.manage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gccloud.common.exception.GlobalException;
|
||||
import com.gccloud.common.utils.BeanConvertUtils;
|
||||
import com.gccloud.dataroom.core.module.basic.dao.DataRoomPagePreviewDao;
|
||||
import com.gccloud.dataroom.core.module.basic.entity.PagePreviewEntity;
|
||||
import com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO;
|
||||
import com.gccloud.dataroom.core.module.manage.service.IDataRoomPagePreviewService;
|
||||
import com.gccloud.dataroom.core.utils.CodeGenerateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongyang
|
||||
* @version 1.0
|
||||
* @date 2023/9/13 10:11
|
||||
*/
|
||||
@Service
|
||||
public class DataRoomPagePreviewServiceImpl extends ServiceImpl<DataRoomPagePreviewDao, PagePreviewEntity> implements IDataRoomPagePreviewService {
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String add(DataRoomPageDTO bigScreenPageDTO) {
|
||||
String code = CodeGenerateUtils.generate(PREVIEW_KEY);
|
||||
bigScreenPageDTO.setCode(code);
|
||||
PagePreviewEntity pagePreviewEntity = BeanConvertUtils.convert(bigScreenPageDTO, PagePreviewEntity.class);
|
||||
this.save(pagePreviewEntity);
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagePreviewEntity getByCode(String code) {
|
||||
LambdaQueryWrapper<PagePreviewEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PagePreviewEntity::getCode, code);
|
||||
List<PagePreviewEntity> list = this.list(queryWrapper);
|
||||
if (list == null || list.isEmpty()) {
|
||||
throw new GlobalException("大屏预览数据不存在,可能已过期");
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue