fix(ticket): close final integration gaps
This commit is contained in:
@@ -101,6 +101,10 @@ func BuildTicketProgressWithContext(item *models.TicketProgress, ctx *TicketDeta
|
||||
return ret
|
||||
}
|
||||
|
||||
func BuildTicketProgressList(list []models.TicketProgress) []response.TicketProgressResponse {
|
||||
return BuildTicketProgressListWithContext(list, nil)
|
||||
}
|
||||
|
||||
func BuildTicketProgressListWithContext(list []models.TicketProgress, ctx *TicketDetailBuildContext) []response.TicketProgressResponse {
|
||||
if len(list) == 0 {
|
||||
return nil
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"cs-agent/internal/services"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/mlogclub/simple/sqls"
|
||||
"github.com/mlogclub/simple/web"
|
||||
"github.com/mlogclub/simple/web/params"
|
||||
)
|
||||
@@ -213,6 +214,29 @@ func (c *TicketController) PostChange_status() *web.JsonResult {
|
||||
}
|
||||
|
||||
func (c *TicketController) PostAdd_progress() *web.JsonResult {
|
||||
return c.createProgress()
|
||||
}
|
||||
|
||||
func (c *TicketController) AnyProgress_list() *web.JsonResult {
|
||||
if _, err := services.AuthService.RequirePermission(c.Ctx, constants.PermissionTicketView); err != nil {
|
||||
return web.JsonError(err)
|
||||
}
|
||||
ticketID, _ := params.GetInt64(c.Ctx, "ticketId")
|
||||
if ticketID <= 0 {
|
||||
return web.JsonErrorMsg("工单不存在")
|
||||
}
|
||||
if services.TicketService.Get(ticketID) == nil {
|
||||
return web.JsonErrorMsg("工单不存在")
|
||||
}
|
||||
progresses := services.TicketProgressService.Find(sqls.NewCnd().Eq("ticket_id", ticketID).Asc("id"))
|
||||
return web.JsonData(builders.BuildTicketProgressList(progresses))
|
||||
}
|
||||
|
||||
func (c *TicketController) PostProgress_create() *web.JsonResult {
|
||||
return c.createProgress()
|
||||
}
|
||||
|
||||
func (c *TicketController) createProgress() *web.JsonResult {
|
||||
operator, err := services.AuthService.RequirePermission(c.Ctx, constants.PermissionTicketProgress)
|
||||
if err != nil {
|
||||
return web.JsonError(err)
|
||||
|
||||
@@ -345,7 +345,7 @@ var RolePermissions = map[string][]Permission{
|
||||
PermissionRoleView,
|
||||
PermissionPermissionView,
|
||||
PermissionConversationView,
|
||||
PermissionTicketView, PermissionTicketCreate, PermissionTicketProgress,
|
||||
PermissionTicketView, PermissionTicketCreate, PermissionTicketAssign, PermissionTicketChangeStatus, PermissionTicketProgress,
|
||||
PermissionNotificationView, PermissionNotificationUpdate,
|
||||
PermissionQuickReplyView,
|
||||
PermissionTagView,
|
||||
|
||||
@@ -45,7 +45,7 @@ func handleTicketAssignedInAppNotification(ctx context.Context, event events.Tic
|
||||
NotificationType: "ticket_assigned",
|
||||
BizType: "ticket",
|
||||
BizID: ticket.ID,
|
||||
ActionURL: fmt.Sprintf("/dashboard/tickets/%d", ticket.ID),
|
||||
ActionURL: fmt.Sprintf("/dashboard/tickets?ticketId=%d", ticket.ID),
|
||||
})
|
||||
if err != nil {
|
||||
slog.Error("create ticket assigned in-app notification failed", "error", err, "ticketId", event.TicketID, "toUserId", event.ToUserID)
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestTicketAssignedInAppNotification(t *testing.T) {
|
||||
if got.NotificationType != "ticket_assigned" || got.BizType != "ticket" || got.BizID != ticket.ID {
|
||||
t.Fatalf("unexpected notification: %+v", got)
|
||||
}
|
||||
if got.ActionURL != "/dashboard/tickets/1" {
|
||||
if got.ActionURL != "/dashboard/tickets?ticketId=1" {
|
||||
t.Fatalf("unexpected action url: %q", got.ActionURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user