Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide the share link created by schedule task #1715

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;