Skip to content

Commit

Permalink
Merge pull request #1715 from tianlu-root/master
Browse files Browse the repository at this point in the history
fix: hide the share link created by schedule task
  • Loading branch information
tianlu-root committed Jul 22, 2022
2 parents 4943fd3 + 88174fd commit 2dd5b38
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public interface ShareMapperExt extends ShareMapper {

@Select({"<script>",
"SELECT * FROM `share` where viz_id = #{vizId} ORDER BY create_time",
"SELECT * FROM `share` where viz_id = #{vizId} AND create_by &lt;&gt; 'SCHEDULER' ORDER BY create_time",
"</script>"})
List<Share> selectByViz(String vizId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

public interface AttachmentService {

String SHARE_USER = "SCHEDULER";

File getFile(DownloadCreateParam downloadCreateParam, String path, String fileName) throws Exception;

default String generateFileName(String path, String fileName, AttachmentType attachmentType) {
Expand All @@ -36,7 +38,7 @@ static AttachmentService matchAttachmentService(AttachmentType type) {
case PDF:
return Application.getBean(AttachmentPdfServiceImpl.class);
default:
Exceptions.msg("unsupported download type."+type);
Exceptions.msg("unsupported download type." + type);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public File getFile(DownloadCreateParam downloadCreateParam, String path, String
shareCreateParam.setExpiryDate(DateUtils.addHours(new Date(), 1));
shareCreateParam.setAuthenticationMode(ShareAuthenticationMode.NONE);
shareCreateParam.setRowPermissionBy(ShareRowPermissionBy.CREATOR);
ShareToken share = shareService.createShare(securityManager.getCurrentUser().getId(), shareCreateParam);
ShareToken share = shareService.createShare(SHARE_USER, shareCreateParam);

String url = Application.getWebRootURL()+"/"+shareCreateParam.getVizType().getShareRoute()+"/"+share.getId()+"?eager=true&type="+share.getAuthenticationMode();
String url = Application.getWebRootURL() + "/" + shareCreateParam.getVizType().getShareRoute() + "/" + share.getId() + "?eager=true&type=" + share.getAuthenticationMode();
log.info("created share url: {} ", url);
File target = WebUtils.screenShot2File(url, FileUtils.withBasePath(path), downloadCreateParam.getImageWidth());

path = generateFileName(path,fileName,attachmentType);
path = generateFileName(path, fileName, attachmentType);
File file = new File(path);
target.renameTo(file);
log.info("create image file complete.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public File getFile(DownloadCreateParam downloadCreateParam, String path, String
shareCreateParam.setExpiryDate(DateUtils.addHours(new Date(), 1));
shareCreateParam.setAuthenticationMode(ShareAuthenticationMode.NONE);
shareCreateParam.setRowPermissionBy(ShareRowPermissionBy.CREATOR);
ShareToken share = shareService.createShare(securityManager.getCurrentUser().getId(), shareCreateParam);
ShareToken share = shareService.createShare(SHARE_USER, shareCreateParam);

String url = Application.getWebRootURL()+"/"+shareCreateParam.getVizType().getShareRoute()+"/"+share.getId()+"?eager=true&type="+share.getAuthenticationMode();
String url = Application.getWebRootURL() + "/" + shareCreateParam.getVizType().getShareRoute() + "/" + share.getId() + "?eager=true&type=" + share.getAuthenticationMode();
log.info("share url {} ", url);

File imageFile = WebUtils.screenShot2File(url, FileUtils.withBasePath(path), downloadCreateParam.getImageWidth());
File file = new File(generateFileName(path,fileName,attachmentType));
File file = new File(generateFileName(path, fileName, attachmentType));
createPDFFromImage(file.getPath(), imageFile.getPath());

log.info("create pdf file complete.");
Expand All @@ -74,6 +74,7 @@ public File getFile(DownloadCreateParam downloadCreateParam, String path, String

/**
* 使用Apache pdfbox将图片生成pdf
*
* @param pdfPath
* @param imagePath
* @throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for source_schemas
-- ----------------------------
DROP TABLE IF EXISTS `source_schemas`;

ALTER TABLE `folder`
DROP COLUMN `sub_type`,
DROP COLUMN `avatar`;

SET FOREIGN_KEY_CHECKS = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for share
-- ----------------------------
DROP TABLE IF EXISTS `share`;

ALTER TABLE `source`
DROP COLUMN `parent_id` ,
DROP COLUMN `is_folder` ,
DROP COLUMN `index`;

DROP PROCEDURE IF EXISTS drop_source_prj_index;


ALTER TABLE `variable`
DROP COLUMN `source_id`,
DROP COLUMN `format`;
ALTER TABLE `variable`
DROP INDEX `source_id`;

SET FOREIGN_KEY_CHECKS = 1;

0 comments on commit 2dd5b38

Please sign in to comment.