fix: 导出链接走下载端点;文件记录切到 core 库

This commit is contained in:
2026-10-31 02:42:41 +08:00
parent 8953fc3088
commit 47b55bad04
4 changed files with 16 additions and 6 deletions
@@ -103,7 +103,8 @@ public class ApprovalExportService {
record.setLength(target.length()); record.setLength(target.length());
record.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); record.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
record.setCreateUserId(user.getUserId()); record.setCreateUserId(user.getUserId());
record.setUrl(config.getServerUrl() + "/file/" + filename); record.setUrl(config.getServerUrl() + "/file/download/" + filename);
record.setDownloadUrl(record.getUrl());
fileService.save(record); fileService.save(record);
return new ApprovalExportResult(record, rows.size()); return new ApprovalExportResult(record, rows.size());
} }
@@ -1,5 +1,6 @@
package com.gxwebsoft.common.system.service.impl; package com.gxwebsoft.common.system.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.utils.CommonUtil; import com.gxwebsoft.common.core.utils.CommonUtil;
import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageParam;
@@ -21,6 +22,7 @@ import java.util.List;
* @since 2021-08-30 11:21:01 * @since 2021-08-30 11:21:01
*/ */
@Service @Service
@DS("server")
public class FileRecordServiceImpl extends ServiceImpl<FileRecordMapper, FileRecord> implements FileRecordService { public class FileRecordServiceImpl extends ServiceImpl<FileRecordMapper, FileRecord> implements FileRecordService {
@Override @Override
@@ -169,12 +169,19 @@ class ApprovalCompletionDraftIT {
@Test @Test
void rejectsSubmitWhenArchivistRoleMissing() throws Exception { void rejectsSubmitWhenArchivistRoleMissing() throws Exception {
grantDepartmentLeader(organizationId, TENANT); int tenant = 10023;
long instanceId = createCompletion(reporter, organizationId, TENANT, "缺收文员"); Integer orgId = data.createOrganization("缺收文员部门" + data.uniqueSuffix(), 136, tenant);
uploadAttachment(instanceId, reporter, organizationId, "image/png"); ApprovalTestData.TestUser submitter =
data.createUser("缺收文员报送人" + data.uniqueSuffix(), orgId, tenant);
ApprovalTestData.TestRole leaderRole =
data.createRole(data.leaderRoleCode(orgId), "部门负责人", tenant);
ApprovalTestData.TestUser leader = data.createUser("缺收文员负责人" + data.uniqueSuffix(), orgId, tenant);
data.bindTenant(leader.userId, leaderRole.roleId, tenant);
long instanceId = createCompletion(submitter, orgId, tenant, "缺收文员");
uploadAttachment(instanceId, submitter, orgId, tenant, "image/png");
mockMvc.perform(authed(post("/api/approval/instance/" + instanceId + "/submit"), mockMvc.perform(authed(post("/api/approval/instance/" + instanceId + "/submit"),
reporter, organizationId, TENANT, SUBMIT)) submitter, orgId, tenant, SUBMIT))
.andExpect(jsonPath("$.code").value(1)) .andExpect(jsonPath("$.code").value(1))
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("收文员角色缺配"))); .andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("收文员角色缺配")));
@@ -172,7 +172,7 @@ class ApprovalExportIT {
assertThat(node.path("id").asInt()).isPositive(); assertThat(node.path("id").asInt()).isPositive();
String name = node.path("name").asText(); String name = node.path("name").asText();
assertThat(name).startsWith("excel/审批单据-").endsWith(".xlsx"); assertThat(name).startsWith("excel/审批单据-").endsWith(".xlsx");
assertThat(node.path("url").asText()).contains("/file/excel/审批单据-"); assertThat(node.path("url").asText()).contains("/file/download/excel/审批单据-");
File file = new File(node.path("path").asText()); File file = new File(node.path("path").asText());
assertThat(file).exists(); assertThat(file).exists();
exportedFiles.add(file.toPath()); exportedFiles.add(file.toPath());