Skip to content

Commit a5ba45e

Browse files
committed
feat(ideas-plaza): 有个想法板块上线 + 模型目录统一 Sprint 1/2 + 发布 1.2.53
- 新增「有个想法」经验分享板块全模块:内容发布/版本留痕/点赞收藏/标签/举报/AI 审核/打赏/私有 OSS 附件/前端页面。 - 模型目录统一改造(Sprint 1/2):账号测试连接、模型白名单、渠道定价与调度校验统一到同一份目录口径,管理员端与用户端模型候选一致。 - 新增迁移 279_ideas_plaza 并已在生产应用:创建 idea_* 系列 12 张业务表,均为幂等 DDL,不改动既有余额/账本表。 - 版本号升至 1.2.53,更新文档站 changelog。
1 parent 4dfabba commit a5ba45e

80 files changed

Lines changed: 9061 additions & 1109 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎backend/cmd/server/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.52
1+
1.2.53

‎backend/cmd/server/wire.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func provideCleanup(
109109
paymentOrderExpiry *service.PaymentOrderExpiryService,
110110
channelMonitorRunner *service.ChannelMonitorRunner,
111111
contentModeration *service.ContentModerationService,
112+
ideasService *service.IdeasService,
112113
clusterRuntime *service.ClusterRuntime,
113114
) func(context.Context) error {
114115
return func(ctx context.Context) error {
@@ -323,6 +324,12 @@ func provideCleanup(
323324
}
324325
return nil
325326
}},
327+
{"IdeasModeration", func() error {
328+
if ideasService != nil {
329+
ideasService.StopModerationWorker()
330+
}
331+
return nil
332+
}},
326333
}
327334

328335
infraSteps := []cleanupStep{

‎backend/cmd/server/wire_gen.go‎

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎backend/internal/handler/admin/account_handler.go‎

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ const (
350350
adminOwnedPublicShareValidationWorkers = 2
351351
adminOwnedPublicShareValidationTestTimeout = 30 * time.Second
352352
adminAccountBatchConnectionTestTimeout = 90 * time.Second
353+
adminBatchTestModelOptionsMaxAccounts = 100
353354
)
354355

355356
type ownedPublicShareValidationJob struct {
@@ -1749,6 +1750,66 @@ func (h *AccountHandler) CreateBatchRefreshTask(c *gin.Context) {
17491750
response.Accepted(c, task)
17501751
}
17511752

1753+
// GetBatchTestModelOptions returns the models common to all target accounts for batch testing.
1754+
// POST /api/v1/admin/accounts/batch-test/model-options
1755+
func (h *AccountHandler) GetBatchTestModelOptions(c *gin.Context) {
1756+
if h.accountTestService == nil {
1757+
response.Error(c, http.StatusServiceUnavailable, "Account test service is unavailable")
1758+
return
1759+
}
1760+
var req struct {
1761+
AccountIDs []int64 `json:"account_ids"`
1762+
}
1763+
if err := c.ShouldBindJSON(&req); err != nil {
1764+
response.BadRequest(c, "Invalid request: "+err.Error())
1765+
return
1766+
}
1767+
accountIDs := normalizeInt64IDList(req.AccountIDs)
1768+
if len(accountIDs) == 0 {
1769+
response.BadRequest(c, "account_ids is required")
1770+
return
1771+
}
1772+
if len(accountIDs) > adminBatchTestModelOptionsMaxAccounts {
1773+
response.BadRequest(c, fmt.Sprintf("account_ids exceeds the maximum of %d", adminBatchTestModelOptionsMaxAccounts))
1774+
return
1775+
}
1776+
1777+
accounts, err := h.adminService.GetAccountsByIDs(c.Request.Context(), accountIDs)
1778+
if err != nil {
1779+
response.ErrorFrom(c, err)
1780+
return
1781+
}
1782+
accountsByID := make(map[int64]*service.Account, len(accounts))
1783+
for _, account := range accounts {
1784+
if account != nil {
1785+
accountsByID[account.ID] = account
1786+
}
1787+
}
1788+
ordered := make([]*service.Account, 0, len(accountIDs))
1789+
for _, accountID := range accountIDs {
1790+
account, ok := accountsByID[accountID]
1791+
if !ok {
1792+
response.BadRequest(c, fmt.Sprintf("account not found: %d", accountID))
1793+
return
1794+
}
1795+
ordered = append(ordered, account)
1796+
}
1797+
platform := ordered[0].Platform
1798+
for _, account := range ordered[1:] {
1799+
if account.Platform != platform {
1800+
response.BadRequest(c, "all accounts must use the same platform")
1801+
return
1802+
}
1803+
}
1804+
1805+
models, err := h.accountTestService.ResolveBatchTestModels(c.Request.Context(), ordered)
1806+
if err != nil {
1807+
response.ErrorFrom(c, err)
1808+
return
1809+
}
1810+
response.Success(c, models)
1811+
}
1812+
17521813
// CreateBatchTestConnectionTask creates an async account connection test task.
17531814
// POST /api/v1/admin/accounts/batch-test/async
17541815
func (h *AccountHandler) CreateBatchTestConnectionTask(c *gin.Context) {
@@ -1804,6 +1865,28 @@ func (h *AccountHandler) CreateBatchTestConnectionTask(c *gin.Context) {
18041865
}
18051866
}
18061867

1868+
// 服务端校验:model_id 必须属于所有目标账号的共同可测试模型,不信任前端下拉值。
1869+
ordered := make([]*service.Account, 0, len(accountIDs))
1870+
for _, accountID := range accountIDs {
1871+
ordered = append(ordered, accountsByID[accountID])
1872+
}
1873+
testableModels, err := h.accountTestService.ResolveBatchTestModels(c.Request.Context(), ordered)
1874+
if err != nil {
1875+
response.ErrorFrom(c, err)
1876+
return
1877+
}
1878+
modelAllowed := false
1879+
for _, m := range testableModels {
1880+
if m.ID == modelID {
1881+
modelAllowed = true
1882+
break
1883+
}
1884+
}
1885+
if !modelAllowed {
1886+
response.BadRequest(c, "model_id is not available for all selected accounts")
1887+
return
1888+
}
1889+
18071890
createdBy, ok := currentAdminUserID(c)
18081891
if !ok {
18091892
response.Error(c, http.StatusUnauthorized, "Invalid admin identity")
@@ -2604,9 +2687,9 @@ func (h *AccountHandler) GetAvailableModels(c *gin.Context) {
26042687
return
26052688
}
26062689

2607-
models, ok := service.AvailableTestModels(account)
2608-
if !ok {
2609-
response.BadRequest(c, "Unsupported account platform: "+account.Platform)
2690+
models, err := h.accountTestService.ResolveAvailableTestModels(c.Request.Context(), account)
2691+
if err != nil {
2692+
response.ErrorFrom(c, err)
26102693
return
26112694
}
26122695
response.Success(c, models)

0 commit comments

Comments
 (0)