feat(publish): add tenant publish management with desktop deep-link
Expose tenant-authenticated publish task list and retry endpoints so the admin web can show desktop publish state without an Electron bridge, and register a `shengxintui://` deep-link so the page can hand off to the desktop client workbench. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -65,34 +65,10 @@ func (h *DesktopTaskHandler) Lease(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) ListPublish(c *gin.Context) {
|
||||
req := app.ListPublishTasksRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
Title: strings.TrimSpace(c.Query("title")),
|
||||
req, ok := parseListPublishTasksRequest(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if rawPage := c.Query("page"); rawPage != "" {
|
||||
parsed, err := strconv.Atoi(rawPage)
|
||||
if err != nil || parsed <= 0 {
|
||||
response.Error(c, response.ErrBadRequest(40001, "invalid_params", "page must be a positive integer"))
|
||||
return
|
||||
}
|
||||
req.Page = parsed
|
||||
}
|
||||
|
||||
rawPageSize := c.Query("page_size")
|
||||
if rawPageSize == "" {
|
||||
rawPageSize = c.Query("limit")
|
||||
}
|
||||
if rawPageSize != "" {
|
||||
parsed, err := strconv.Atoi(rawPageSize)
|
||||
if err != nil || parsed <= 0 {
|
||||
response.Error(c, response.ErrBadRequest(40001, "invalid_params", "page_size must be a positive integer"))
|
||||
return
|
||||
}
|
||||
req.PageSize = parsed
|
||||
}
|
||||
|
||||
data, err := h.svc.ListPublishTasks(c.Request.Context(), MustDesktopClient(c.Request.Context()), req)
|
||||
if err != nil {
|
||||
response.Error(c, err)
|
||||
@@ -101,6 +77,19 @@ func (h *DesktopTaskHandler) ListPublish(c *gin.Context) {
|
||||
response.Success(c, data)
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) TenantListPublish(c *gin.Context) {
|
||||
req, ok := parseListPublishTasksRequest(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
data, err := h.svc.ListTenantPublishTasks(c.Request.Context(), auth.MustActor(c.Request.Context()), req)
|
||||
if err != nil {
|
||||
response.Error(c, err)
|
||||
return
|
||||
}
|
||||
response.Success(c, data)
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) Extend(c *gin.Context) {
|
||||
desktopID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
@@ -158,6 +147,21 @@ func (h *DesktopTaskHandler) RetryPublish(c *gin.Context) {
|
||||
response.Success(c, data)
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) TenantRetryPublish(c *gin.Context) {
|
||||
desktopID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
response.Error(c, response.ErrBadRequest(40084, "invalid_desktop_task_id", "task id must be a uuid"))
|
||||
return
|
||||
}
|
||||
|
||||
data, err := h.publishSvc.RetryTenantDesktopTask(c.Request.Context(), auth.MustActor(c.Request.Context()), desktopID)
|
||||
if err != nil {
|
||||
response.Error(c, err)
|
||||
return
|
||||
}
|
||||
response.Success(c, data)
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) Cancel(c *gin.Context) {
|
||||
desktopID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
@@ -179,6 +183,38 @@ func (h *DesktopTaskHandler) Cancel(c *gin.Context) {
|
||||
response.Success(c, data)
|
||||
}
|
||||
|
||||
func parseListPublishTasksRequest(c *gin.Context) (app.ListPublishTasksRequest, bool) {
|
||||
req := app.ListPublishTasksRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
Title: strings.TrimSpace(c.Query("title")),
|
||||
}
|
||||
|
||||
if rawPage := c.Query("page"); rawPage != "" {
|
||||
parsed, err := strconv.Atoi(rawPage)
|
||||
if err != nil || parsed <= 0 {
|
||||
response.Error(c, response.ErrBadRequest(40001, "invalid_params", "page must be a positive integer"))
|
||||
return req, false
|
||||
}
|
||||
req.Page = parsed
|
||||
}
|
||||
|
||||
rawPageSize := c.Query("page_size")
|
||||
if rawPageSize == "" {
|
||||
rawPageSize = c.Query("limit")
|
||||
}
|
||||
if rawPageSize != "" {
|
||||
parsed, err := strconv.Atoi(rawPageSize)
|
||||
if err != nil || parsed <= 0 {
|
||||
response.Error(c, response.ErrBadRequest(40001, "invalid_params", "page_size must be a positive integer"))
|
||||
return req, false
|
||||
}
|
||||
req.PageSize = parsed
|
||||
}
|
||||
|
||||
return req, true
|
||||
}
|
||||
|
||||
func (h *DesktopTaskHandler) TenantCancel(c *gin.Context) {
|
||||
desktopID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
|
||||
@@ -74,6 +74,8 @@ func RegisterRoutes(app *bootstrap.App) {
|
||||
tenantProtected.POST("/accounts/:id/request-delete", desktopAccountHandler.RequestDelete)
|
||||
tenantProtected.POST("/tasks/:id/reconcile", desktopTaskHandler.Reconcile)
|
||||
tenantProtected.POST("/tasks/:id/cancel", desktopTaskHandler.TenantCancel)
|
||||
tenantProtected.GET("/publish-tasks", desktopTaskHandler.TenantListPublish)
|
||||
tenantProtected.POST("/publish-tasks/:id/retry", desktopTaskHandler.TenantRetryPublish)
|
||||
tenantProtected.POST("/publish-jobs", publishJobHandler.Create)
|
||||
|
||||
complianceHandler := NewComplianceHandler(app)
|
||||
|
||||
@@ -30,6 +30,8 @@ func TestProtectedRoutes_RequireAuth(t *testing.T) {
|
||||
{http.MethodPost, "/api/tenant/accounts/:id/request-delete"},
|
||||
{http.MethodPost, "/api/tenant/tasks/:id/reconcile"},
|
||||
{http.MethodPost, "/api/tenant/tasks/:id/cancel"},
|
||||
{http.MethodGet, "/api/tenant/publish-tasks"},
|
||||
{http.MethodPost, "/api/tenant/publish-tasks/:id/retry"},
|
||||
{http.MethodPost, "/api/tenant/publish-jobs"},
|
||||
{http.MethodGet, "/api/tenant/media/platforms"},
|
||||
{http.MethodGet, "/api/tenant/workspace/overview"},
|
||||
@@ -77,10 +79,12 @@ func TestDesktopClientRoutes_ClientTokenAuth(t *testing.T) {
|
||||
}{
|
||||
{http.MethodGet, "/api/desktop/dispatch"},
|
||||
{http.MethodGet, "/api/desktop/accounts"},
|
||||
{http.MethodGet, "/api/desktop/publish-tasks"},
|
||||
{http.MethodGet, "/api/desktop/content/assets/:token"},
|
||||
{http.MethodPost, "/api/desktop/clients/offline"},
|
||||
{http.MethodPost, "/api/desktop/tasks/lease"},
|
||||
{http.MethodPost, "/api/desktop/tasks/:id/result"},
|
||||
{http.MethodPost, "/api/desktop/publish-tasks/:id/retry"},
|
||||
{http.MethodPost, "/api/desktop/monitoring/tasks/lease"},
|
||||
{http.MethodPost, "/api/desktop/monitoring/tasks/resume"},
|
||||
{http.MethodPost, "/api/desktop/monitoring/tasks/:id/result"},
|
||||
|
||||
Reference in New Issue
Block a user