feat(training): 企业培训迭代:推送深链接与签名下载、课程管理修复与收集模板调整
推送域(000155):
- 广播通知支持 link_url:demand_collect 场景自动签发教育训练需求表模板
匿名下载直链(HMAC token,20 天有效,免登录路由),企微消息尾部拼
「下载模板 + 查看更多详情」链接;站内文本保持纯文本不受影响
- 配置中心新增「推送链接基址」(notify_link_base_url,多入口/内外网部署固定
权威地址,留空跟随推送人访问地址)与「年培训计划收集推送文案」
(demand_collect_*,{year} 渲染收集年度);空标题/内容按模板回落渲染
- 迁移 000155:tr_training_notifications 增 link_url/link_token 列
课程管理:
- 修复点【发布/下线】报「不支持的操作」:动作取值兼容字面量路由(FullPath
末段)与 :action 通配两种注册形态
- 列表新增「创建人」列:creator_id 联查 users 带出姓名,导出 Excel 同步;
新增课程「所属部门」默认当前登录用户所在部门
- 导入加固:表头归一化 + 别名模糊匹配(兼容内置模板/旧口径/自定义模板变体);
导入与新增行支持按部门名兜底解析为 id(前端名册未命中时传 owner_dept_name)
年培训计划:
- 需求列表新增「创建人/创建时间」列(submitter_id 联查 users 带出姓名)
- 收集模板调整:下载时动态删除「培训费用(RMB)」列(旧版自定义模板同步归一,
右侧列/合并/下拉随删列平移);备注右侧追加「调研维度/培训策划要求」说明列
(合并至数据区末行,自动换行带边框,已带说明的自定义模板不覆盖)
开发工具:
- air 热重载适配 Windows:构建收敛到 scripts/air_build.sh(规避 air 经
PowerShell 执行不支持 bash 命令替换),产物改 .exe 后缀;CGO_CFLAGS 取
持久化值并集追加,不覆盖 go env -w 的头文件包含路径
This commit is contained in:
1 parent
242dd7e1a6
commit
4e25fce9aa
30 files changed
+1150
-143
No files matched your search
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"academy/internal/types"
|
||||
"academy/internal/utils"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
@@ -18,9 +19,9 @@ import (
|
||||
// fakeWecomBackend serves a fake sender plus a userid mapping to the
|
||||
// scheduler under test.
|
||||
type fakeWecomBackend struct {
|
||||
sender *fakePushSender
|
||||
sender *fakePushSender
|
||||
clientErr error
|
||||
mapping map[string]string
|
||||
mapping map[string]string
|
||||
lookupErr error
|
||||
}
|
||||
|
||||
@@ -40,15 +41,17 @@ func (f *fakeWecomBackend) TenantWecomUserIDs(context.Context, *gorm.DB, uint64,
|
||||
|
||||
// fakePushSender records SendMarkdown calls for dispatcher assertions.
|
||||
type fakePushSender struct {
|
||||
sent [][]string
|
||||
err error
|
||||
sent [][]string
|
||||
contents []string
|
||||
err error
|
||||
}
|
||||
|
||||
func (f *fakePushSender) SendMarkdown(_ context.Context, userIDs []string, _ string) error {
|
||||
func (f *fakePushSender) SendMarkdown(_ context.Context, userIDs []string, content string) error {
|
||||
if f.err != nil {
|
||||
return f.err
|
||||
}
|
||||
f.sent = append(f.sent, userIDs)
|
||||
f.contents = append(f.contents, content)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -332,3 +335,54 @@ func TestRemindContent(t *testing.T) {
|
||||
require.Contains(t, maintain, "课程维护提醒")
|
||||
require.True(t, strings.Contains(maintain, "课件"), "maintain copy mentions materials")
|
||||
}
|
||||
|
||||
// [2026-11 需求] demand_collect 企微投递正文:行内带 link_url/link_token 时
|
||||
// 尾部拼「下载模板 + 查看详情」两行 markdown 链接;其他场景原样透传。
|
||||
func TestWecomDispatchContentDemandCollectFooter(t *testing.T) {
|
||||
token, err := utils.SignTrainingTemplateToken(&utils.TrainingTemplateTokenPayload{
|
||||
TenantID: 42, TemplateKey: types.TrainingTemplateDemandCollection,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("footer appended with download and details links", func(t *testing.T) {
|
||||
row := &claimedNotification{Scene: types.SceneDemandCollect,
|
||||
Content: "请于 2027-01-31 前提报需求。", LinkURL: "https://aido.example.com", LinkToken: token}
|
||||
got := wecomDispatchContent(row)
|
||||
require.True(t, strings.HasPrefix(got, "请于 2027-01-31 前提报需求。"))
|
||||
require.Contains(t, got,
|
||||
"[下载教育训练需求表模板](https://aido.example.com"+utils.TrainingTemplateSignedFilePath+"?token="+token+")")
|
||||
require.Contains(t, got, "[查看更多详情>>](https://aido.example.com/platform/training/plan)")
|
||||
})
|
||||
|
||||
t.Run("missing token keeps details link only", func(t *testing.T) {
|
||||
row := &claimedNotification{Scene: types.SceneDemandCollect,
|
||||
Content: "c", LinkURL: "https://aido.example.com"}
|
||||
got := wecomDispatchContent(row)
|
||||
require.NotContains(t, got, "signed-file")
|
||||
require.Contains(t, got, "[查看更多详情>>](https://aido.example.com/platform/training/plan)")
|
||||
})
|
||||
|
||||
t.Run("other scenes pass through untouched", func(t *testing.T) {
|
||||
row := &claimedNotification{Scene: types.SceneSessionNoticeStudent,
|
||||
Content: "markdown body", LinkURL: "https://aido.example.com", LinkToken: token}
|
||||
require.Equal(t, "markdown body", wecomDispatchContent(row))
|
||||
})
|
||||
|
||||
t.Run("dispatch end-to-end sends composed markdown", func(t *testing.T) {
|
||||
f := newTrainingPushFixture(t)
|
||||
f.backend.mapping["user-1"] = "wecom_u1"
|
||||
row := &types.TrainingNotification{ID: trainingNewID(), TenantID: f.tenantID,
|
||||
TargetUserID: "user-1", Scene: types.SceneDemandCollect, Content: "c",
|
||||
LinkURL: "https://aido.example.com", LinkToken: token, PushStatus: pushStatusSending}
|
||||
require.NoError(t, f.db.Create(row).Error)
|
||||
|
||||
f.sched.dispatchTenant(context.Background(), f.tenantID,
|
||||
[]*claimedNotification{{ID: row.ID, TenantID: f.tenantID, TargetUserID: "user-1",
|
||||
Scene: types.SceneDemandCollect, Content: "c",
|
||||
LinkURL: "https://aido.example.com", LinkToken: token}})
|
||||
|
||||
require.Len(t, f.backend.sender.contents, 1)
|
||||
require.Contains(t, f.backend.sender.contents[0], "[查看更多详情>>](https://aido.example.com/platform/training/plan)")
|
||||
require.Contains(t, f.backend.sender.contents[0], "signed-file?token=")
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user