Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
[需求] 企业CLA签署管理平台优化-2(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)
改动内容
feat(app-cla-server, app-cla-webui): 新增已申请企业名单 CSV 导出功能
改动概述
基于 issue #1975 和 design.md,在既有企业签署名单查询链路上新增只读 CSV 导出能力。app-cla-server 新增
GET /v1/corporation-signing/export/:link_id接口,复用现有鉴权与查询逻辑;app-cla-webui 名单页面新增「导出名单」按钮完成浏览器文件下载。改动文件清单
app-cla-server(6 个修改文件 + 1 个新增测试文件)
signing/app/corp_signing.go — 核心实现
CorpSigningService接口新增Export(userId, linkId string, adminAdded bool, searchQuery string) ([]byte, error)方法Export方法实现:复用checkIfCommunityManager权限校验 → 循环FindPage(pageSize=200, maxPages=500)全量收集 DTO → 调 CSV 纯函数生成字节流corpListToCSV(rows []CorpSigningDTO) []byte:使用encoding/csv标准库生成,前置 UTF-8 BOM 保证 Excel 中文不乱码;表头序号,企业名称,申请状态,CLA语言,申请时间;申请状态由HasAdminAdded判定(已完成/未完成);空列表仅输出表头escapeCSVCell(s string) string:单元格以=/+/-/@开头时前缀'防公式注入admin_email、admin_name等个人敏感字段(内容红线 D1)signing/adapter/corp_signing.go — 适配层
ExportCorpSigningList(userId, linkId string, adminAdded bool, searchQuery string) ([]byte, models.IModelError),透传 service 层 Export 方法models/adapter.go — 模型层入口
ExportCorpSigningList(userId, linkID string, adminAdded bool, searchQuery string) ([]byte, IModelError)透传函数models/init.go — 接口定义
corpSigningAdapter接口新增ExportCorpSigningList方法签名controllers/corp_signing.go — 控制器
Export()方法(仿GetPage),带@router /export/:link_id [get]注解Prepare()(GET 且非/cla/diff、/cla/agree→apiPrepare(PermissionOwnerOfOrg))Content-Type: text/csv; charset=utf-8、Content-Disposition: attachment; filename=...,以ctl.Ctx.Output.Body()输出内存字节流GetPage完全一致(401 missing_token 等)routers/commentsRouter.go — 路由注册
Export路由注册项(/export/:link_id, GET),与 GetPage 注册项同款signing/app/corp_signing_export_test.go(新增)— 单元测试
TestCorpListToCSVBOM:BOM 存在性TestCorpListToCSVEmpty:空列表仅表头TestCorpListToCSVNormal:正常多行输出,含序号/企业名称/状态/语言/时间校验TestCorpListToCSVFormulaInjection:=/+/-/@开头单元格转义TestCorpListToCSVSpecialChars:含逗号/引号/中文企业名转义与编码TestEscapeCSVCell:escapeCSVCell 函数各分支(表驱动)TestExportSuccess:正常路径(权限校验通过 + 数据收集 + CSV 生成)TestExportEmptyResult:空名单路径TestExportLinkNotFound:link 不存在异常路径TestExportNoPermission:无权限异常路径TestExportMultiPage:多页分页收集(200+5 条跨 2 页)app-cla-webui(4 个修改文件)
exportCorporationSigningList = '/v1/corporation-signing/export'el-button size="small" :loading="exportLoading")exportCorpList()方法:空名单时ElMessage.info(t('corp.no_data'))不发请求;否则http(responseType: 'blob')请求导出接口 →saveAs下载已申请企业名单_<状态>_<时间戳>.csv;失败走util.catchErr(401 自动弹 ReLoginDialog);下载期间按钮 loading 防重复exportLoadingref +.searchBarflex 布局样式export_list: '导出名单'export_list: 'Export List'需求对应
相关 Issue
resolve https://github.com/opensourceways/backlog/issues/1975
AI 使用声明
当前 PR 是否有 AI 参与:
/ai-develop-preview