update
This commit is contained in:
@ -82,6 +82,8 @@ func NewBackstage(opt BackstageOptions) *gin.Engine {
|
||||
admin.POST("/api/articles/batch", opt.Backstage.ArticleBatch)
|
||||
admin.POST("/api/articles/:kind/:id/images/attach", opt.Backstage.ArticleAttachImagesAPI)
|
||||
admin.POST("/api/articles/:kind/:id/images/:img/detach", opt.Backstage.ArticleDetachImageAPI)
|
||||
// 编辑页实时翻译建议(已登录后台):英文标题 → 建议中文标题。
|
||||
admin.GET("/api/suggest-title-cn", opt.Backstage.SuggestTitleCn)
|
||||
|
||||
admin.GET("/", opt.Backstage.Dashboard)
|
||||
admin.GET("/brands", opt.Backstage.Brands)
|
||||
|
||||
@ -150,6 +150,9 @@ func (f *fakeArticle) PurgeGallery(ctx context.Context, id uint32) error {
|
||||
func (f *fakeArticle) GetRunwayDupSources(ctx context.Context, imageIDs []uint32) (map[uint32]dto.DupSource, error) {
|
||||
return map[uint32]dto.DupSource{}, nil
|
||||
}
|
||||
func (f *fakeArticle) SumImageSize(ctx context.Context, runwayID uint32) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
type fakeStreet struct{}
|
||||
|
||||
@ -210,10 +213,17 @@ func (f *fakeStreet) PurgeGallery(ctx context.Context, id uint32) error {
|
||||
func (f *fakeStreet) GetStreetSnapDupSources(ctx context.Context, imageIDs []uint32) (map[uint32]dto.DupSource, error) {
|
||||
return map[uint32]dto.DupSource{}, nil
|
||||
}
|
||||
func (f *fakeStreet) SumImageSize(ctx context.Context, snapID uint32) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// fakeAdminRepo 实现文章管理仓储接口;返回固定的混合列表示例,供路由/模板渲染测试。
|
||||
type fakeAdminRepo struct{}
|
||||
|
||||
func (f *fakeAdminRepo) ImageSizeByRecords(ctx context.Context, kind string, ids []uint32) (map[uint32]int64, error) {
|
||||
return map[uint32]int64{}, nil
|
||||
}
|
||||
|
||||
func (f *fakeAdminRepo) ListMixed(_ context.Context, status, kind string, page, size int) ([]repository.AdminRecordCard, int64, error) {
|
||||
all := []repository.AdminRecordCard{
|
||||
{Kind: "runway", ID: 1, Title: "Acne Studios Spring 2024", Subtitle: "Acne Studios", ImageCount: 12, Status: "published"},
|
||||
@ -270,7 +280,7 @@ func TestBackstage(t *testing.T) {
|
||||
m := jwt.NewManager("test-secret", 168)
|
||||
auth := &fakeAuth{jwt: m}
|
||||
brand := &fakeBrand{}
|
||||
h := handler.NewBackstageHandler(auth, brand, &fakeArticle{}, &fakeStreet{}, &fakeReview{attachOK: true}, nil, &fakeAdminRepo{})
|
||||
h := handler.NewBackstageHandler(auth, brand, &fakeArticle{}, &fakeStreet{}, &fakeReview{attachOK: true}, nil, &fakeAdminRepo{}, nil)
|
||||
r := NewBackstage(BackstageOptions{Config: &config.Config{}, JWT: m, Backstage: h})
|
||||
|
||||
// 1) 登录页可访问
|
||||
@ -478,7 +488,7 @@ func newReviewRouter(t *testing.T) (*gin.Engine, *fakeReview) {
|
||||
auth := &fakeAuth{jwt: m}
|
||||
brand := &fakeBrand{}
|
||||
rev := &fakeReview{attachOK: true}
|
||||
h := handler.NewBackstageHandler(auth, brand, &fakeArticle{}, &fakeStreet{}, rev, nil, &fakeAdminRepo{})
|
||||
h := handler.NewBackstageHandler(auth, brand, &fakeArticle{}, &fakeStreet{}, rev, nil, &fakeAdminRepo{}, nil)
|
||||
r := NewBackstage(BackstageOptions{Config: &config.Config{}, JWT: m, Backstage: h})
|
||||
return r, rev
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user