refactor: simplify route handlers by removing redundant ID parsing logic
This commit is contained in:
@@ -1,27 +1,13 @@
|
|||||||
package bootstrap
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"cs-agent/internal/controllers/api"
|
"cs-agent/internal/controllers/api"
|
||||||
"cs-agent/internal/controllers/dashboard"
|
"cs-agent/internal/controllers/dashboard"
|
||||||
"cs-agent/internal/controllers/third"
|
"cs-agent/internal/controllers/third"
|
||||||
"cs-agent/internal/pkg/httpx"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/mlogclub/simple/web"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func pathInt64(ctx *gin.Context, name string) (int64, bool) {
|
|
||||||
value, err := strconv.ParseInt(ctx.Param(name), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
httpx.WriteHttpStatusJSON(ctx, http.StatusBadRequest, web.JsonErrorMsg("路径参数错误"))
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
return value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func registerApiAuthRoutes(group *gin.RouterGroup) {
|
func registerApiAuthRoutes(group *gin.RouterGroup) {
|
||||||
group.POST("/login", api.Login)
|
group.POST("/login", api.Login)
|
||||||
group.POST("/logout", api.Logout)
|
group.POST("/logout", api.Logout)
|
||||||
@@ -41,13 +27,7 @@ func registerApiCustomerRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerApiConversationRoutes(group *gin.RouterGroup) {
|
func registerApiConversationRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", api.ConversationGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
api.ConversationGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/close", api.ConversationPostClose)
|
group.POST("/close", api.ConversationPostClose)
|
||||||
group.POST("/create_or_match", api.ConversationPostCreate_or_match)
|
group.POST("/create_or_match", api.ConversationPostCreate_or_match)
|
||||||
}
|
}
|
||||||
@@ -65,13 +45,7 @@ func registerDashboardDashboardRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardUserRoutes(group *gin.RouterGroup) {
|
func registerDashboardUserRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.UserGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.UserGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/assign_role", dashboard.UserPostAssign_role)
|
group.POST("/assign_role", dashboard.UserPostAssign_role)
|
||||||
group.POST("/change_password", dashboard.UserPostChange_password)
|
group.POST("/change_password", dashboard.UserPostChange_password)
|
||||||
group.POST("/create", dashboard.UserPostCreate)
|
group.POST("/create", dashboard.UserPostCreate)
|
||||||
@@ -84,13 +58,7 @@ func registerDashboardUserRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardCompanyRoutes(group *gin.RouterGroup) {
|
func registerDashboardCompanyRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.CompanyGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.CompanyGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.CompanyPostCreate)
|
group.POST("/create", dashboard.CompanyPostCreate)
|
||||||
group.POST("/delete", dashboard.CompanyPostDelete)
|
group.POST("/delete", dashboard.CompanyPostDelete)
|
||||||
group.Any("/list", dashboard.CompanyAnyList)
|
group.Any("/list", dashboard.CompanyAnyList)
|
||||||
@@ -99,13 +67,7 @@ func registerDashboardCompanyRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardCustomerRoutes(group *gin.RouterGroup) {
|
func registerDashboardCustomerRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.CustomerGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.CustomerGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.CustomerPostCreate)
|
group.POST("/create", dashboard.CustomerPostCreate)
|
||||||
group.POST("/delete", dashboard.CustomerPostDelete)
|
group.POST("/delete", dashboard.CustomerPostDelete)
|
||||||
group.POST("/list", dashboard.CustomerPostList)
|
group.POST("/list", dashboard.CustomerPostList)
|
||||||
@@ -122,13 +84,7 @@ func registerDashboardCustomerContactRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardRoleRoutes(group *gin.RouterGroup) {
|
func registerDashboardRoleRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.RoleGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.RoleGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/assign_permission", dashboard.RolePostAssign_permission)
|
group.POST("/assign_permission", dashboard.RolePostAssign_permission)
|
||||||
group.POST("/create", dashboard.RolePostCreate)
|
group.POST("/create", dashboard.RolePostCreate)
|
||||||
group.POST("/delete", dashboard.RolePostDelete)
|
group.POST("/delete", dashboard.RolePostDelete)
|
||||||
@@ -140,13 +96,7 @@ func registerDashboardRoleRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardPermissionRoutes(group *gin.RouterGroup) {
|
func registerDashboardPermissionRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.PermissionGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.PermissionGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.Any("/list", dashboard.PermissionAnyList)
|
group.Any("/list", dashboard.PermissionAnyList)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,13 +107,7 @@ func registerDashboardSessionRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardTagRoutes(group *gin.RouterGroup) {
|
func registerDashboardTagRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.TagGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.TagGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.TagPostCreate)
|
group.POST("/create", dashboard.TagPostCreate)
|
||||||
group.POST("/delete", dashboard.TagPostDelete)
|
group.POST("/delete", dashboard.TagPostDelete)
|
||||||
group.Any("/list", dashboard.TagAnyList)
|
group.Any("/list", dashboard.TagAnyList)
|
||||||
@@ -174,13 +118,7 @@ func registerDashboardTagRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardConversationRoutes(group *gin.RouterGroup) {
|
func registerDashboardConversationRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.ConversationGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.ConversationGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/add_tag", dashboard.ConversationPostAdd_tag)
|
group.POST("/add_tag", dashboard.ConversationPostAdd_tag)
|
||||||
group.POST("/assign", dashboard.ConversationPostAssign)
|
group.POST("/assign", dashboard.ConversationPostAssign)
|
||||||
group.POST("/close", dashboard.ConversationPostClose)
|
group.POST("/close", dashboard.ConversationPostClose)
|
||||||
@@ -199,13 +137,7 @@ func registerDashboardConversationRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardTicketRoutes(group *gin.RouterGroup) {
|
func registerDashboardTicketRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.TicketGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.TicketGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/assign", dashboard.TicketPostAssign)
|
group.POST("/assign", dashboard.TicketPostAssign)
|
||||||
group.POST("/change_status", dashboard.TicketPostChange_status)
|
group.POST("/change_status", dashboard.TicketPostChange_status)
|
||||||
group.POST("/create", dashboard.TicketPostCreate)
|
group.POST("/create", dashboard.TicketPostCreate)
|
||||||
@@ -237,13 +169,7 @@ func registerDashboardQuickReplyRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardChannelRoutes(group *gin.RouterGroup) {
|
func registerDashboardChannelRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.ChannelGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.ChannelGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.ChannelPostCreate)
|
group.POST("/create", dashboard.ChannelPostCreate)
|
||||||
group.POST("/delete", dashboard.ChannelPostDelete)
|
group.POST("/delete", dashboard.ChannelPostDelete)
|
||||||
group.Any("/list", dashboard.ChannelAnyList)
|
group.Any("/list", dashboard.ChannelAnyList)
|
||||||
@@ -254,13 +180,7 @@ func registerDashboardChannelRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAgentRoutes(group *gin.RouterGroup) {
|
func registerDashboardAgentRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AgentGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AgentGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.AgentPostCreate)
|
group.POST("/create", dashboard.AgentPostCreate)
|
||||||
group.POST("/delete", dashboard.AgentPostDelete)
|
group.POST("/delete", dashboard.AgentPostDelete)
|
||||||
group.Any("/list", dashboard.AgentAnyList)
|
group.Any("/list", dashboard.AgentAnyList)
|
||||||
@@ -269,13 +189,7 @@ func registerDashboardAgentRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAgentTeamRoutes(group *gin.RouterGroup) {
|
func registerDashboardAgentTeamRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AgentTeamGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AgentTeamGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.AgentTeamPostCreate)
|
group.POST("/create", dashboard.AgentTeamPostCreate)
|
||||||
group.POST("/delete", dashboard.AgentTeamPostDelete)
|
group.POST("/delete", dashboard.AgentTeamPostDelete)
|
||||||
group.Any("/list", dashboard.AgentTeamAnyList)
|
group.Any("/list", dashboard.AgentTeamAnyList)
|
||||||
@@ -284,13 +198,7 @@ func registerDashboardAgentTeamRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAgentTeamScheduleRoutes(group *gin.RouterGroup) {
|
func registerDashboardAgentTeamScheduleRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AgentTeamScheduleGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AgentTeamScheduleGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/batch_generate", dashboard.AgentTeamSchedulePostBatch_generate)
|
group.POST("/batch_generate", dashboard.AgentTeamSchedulePostBatch_generate)
|
||||||
group.POST("/batch_preview", dashboard.AgentTeamSchedulePostBatch_preview)
|
group.POST("/batch_preview", dashboard.AgentTeamSchedulePostBatch_preview)
|
||||||
group.Any("/calendar", dashboard.AgentTeamScheduleAnyCalendar)
|
group.Any("/calendar", dashboard.AgentTeamScheduleAnyCalendar)
|
||||||
@@ -301,13 +209,7 @@ func registerDashboardAgentTeamScheduleRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAIAgentRoutes(group *gin.RouterGroup) {
|
func registerDashboardAIAgentRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AIAgentGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AIAgentGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.AIAgentPostCreate)
|
group.POST("/create", dashboard.AIAgentPostCreate)
|
||||||
group.POST("/delete", dashboard.AIAgentPostDelete)
|
group.POST("/delete", dashboard.AIAgentPostDelete)
|
||||||
group.Any("/list", dashboard.AIAgentAnyList)
|
group.Any("/list", dashboard.AIAgentAnyList)
|
||||||
@@ -318,13 +220,7 @@ func registerDashboardAIAgentRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAIConfigRoutes(group *gin.RouterGroup) {
|
func registerDashboardAIConfigRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AIConfigGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AIConfigGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.AIConfigPostCreate)
|
group.POST("/create", dashboard.AIConfigPostCreate)
|
||||||
group.POST("/delete", dashboard.AIConfigPostDelete)
|
group.POST("/delete", dashboard.AIConfigPostDelete)
|
||||||
group.Any("/list", dashboard.AIConfigAnyList)
|
group.Any("/list", dashboard.AIConfigAnyList)
|
||||||
@@ -335,26 +231,14 @@ func registerDashboardAIConfigRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAssetRoutes(group *gin.RouterGroup) {
|
func registerDashboardAssetRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AssetGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AssetGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.AssetPostCreate)
|
group.POST("/create", dashboard.AssetPostCreate)
|
||||||
group.POST("/delete", dashboard.AssetPostDelete)
|
group.POST("/delete", dashboard.AssetPostDelete)
|
||||||
group.Any("/list", dashboard.AssetAnyList)
|
group.Any("/list", dashboard.AssetAnyList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardKnowledgeBaseRoutes(group *gin.RouterGroup) {
|
func registerDashboardKnowledgeBaseRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.KnowledgeBaseGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.KnowledgeBaseGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.KnowledgeBasePostCreate)
|
group.POST("/create", dashboard.KnowledgeBasePostCreate)
|
||||||
group.POST("/delete", dashboard.KnowledgeBasePostDelete)
|
group.POST("/delete", dashboard.KnowledgeBasePostDelete)
|
||||||
group.Any("/list", dashboard.KnowledgeBaseAnyList)
|
group.Any("/list", dashboard.KnowledgeBaseAnyList)
|
||||||
@@ -365,13 +249,7 @@ func registerDashboardKnowledgeBaseRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardKnowledgeDocumentRoutes(group *gin.RouterGroup) {
|
func registerDashboardKnowledgeDocumentRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.KnowledgeDocumentGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.KnowledgeDocumentGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.KnowledgeDocumentPostCreate)
|
group.POST("/create", dashboard.KnowledgeDocumentPostCreate)
|
||||||
group.POST("/delete", dashboard.KnowledgeDocumentPostDelete)
|
group.POST("/delete", dashboard.KnowledgeDocumentPostDelete)
|
||||||
group.Any("/list", dashboard.KnowledgeDocumentAnyList)
|
group.Any("/list", dashboard.KnowledgeDocumentAnyList)
|
||||||
@@ -379,13 +257,7 @@ func registerDashboardKnowledgeDocumentRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardKnowledgeFAQRoutes(group *gin.RouterGroup) {
|
func registerDashboardKnowledgeFAQRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.KnowledgeFAQGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.KnowledgeFAQGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.KnowledgeFAQPostCreate)
|
group.POST("/create", dashboard.KnowledgeFAQPostCreate)
|
||||||
group.POST("/delete", dashboard.KnowledgeFAQPostDelete)
|
group.POST("/delete", dashboard.KnowledgeFAQPostDelete)
|
||||||
group.Any("/list", dashboard.KnowledgeFAQAnyList)
|
group.Any("/list", dashboard.KnowledgeFAQAnyList)
|
||||||
@@ -399,35 +271,17 @@ func registerDashboardKnowledgeRetrieveRoutes(group *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardKnowledgeRetrieveLogRoutes(group *gin.RouterGroup) {
|
func registerDashboardKnowledgeRetrieveLogRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.KnowledgeRetrieveLogGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.KnowledgeRetrieveLogGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.Any("/list", dashboard.KnowledgeRetrieveLogAnyList)
|
group.Any("/list", dashboard.KnowledgeRetrieveLogAnyList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardAgentRunLogRoutes(group *gin.RouterGroup) {
|
func registerDashboardAgentRunLogRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.AgentRunLogGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.AgentRunLogGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.Any("/list", dashboard.AgentRunLogAnyList)
|
group.Any("/list", dashboard.AgentRunLogAnyList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerDashboardSkillDefinitionRoutes(group *gin.RouterGroup) {
|
func registerDashboardSkillDefinitionRoutes(group *gin.RouterGroup) {
|
||||||
group.GET("/:id", func(ctx *gin.Context) {
|
group.GET("/:id", dashboard.SkillDefinitionGetBy)
|
||||||
id, ok := pathInt64(ctx, "id")
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dashboard.SkillDefinitionGetBy(ctx, id)
|
|
||||||
})
|
|
||||||
group.POST("/create", dashboard.SkillDefinitionPostCreate)
|
group.POST("/create", dashboard.SkillDefinitionPostCreate)
|
||||||
group.POST("/debug_resume", dashboard.SkillDefinitionPostDebug_resume)
|
group.POST("/debug_resume", dashboard.SkillDefinitionPostDebug_resume)
|
||||||
group.POST("/debug_run", dashboard.SkillDefinitionPostDebug_run)
|
group.POST("/debug_run", dashboard.SkillDefinitionPostDebug_run)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func Login(ctx *gin.Context) {
|
|||||||
func WxWorkLogin(ctx *gin.Context) {
|
func WxWorkLogin(ctx *gin.Context) {
|
||||||
loginURL, err := services.WxWorkLoginService.BuildWxWorkLoginURL(ctx.Query("next"))
|
loginURL, err := services.WxWorkLoginService.BuildWxWorkLoginURL(ctx.Query("next"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
redirectWxWorkError(ctx, err.Error())
|
ctx.Redirect(http.StatusFound, "/login?wxworkError="+url.QueryEscape(wxWorkErrorMessage(err.Error())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Redirect(http.StatusFound, loginURL)
|
ctx.Redirect(http.StatusFound, loginURL)
|
||||||
@@ -41,7 +41,7 @@ func WxWorkLogin(ctx *gin.Context) {
|
|||||||
func WxWorkQRLogin(ctx *gin.Context) {
|
func WxWorkQRLogin(ctx *gin.Context) {
|
||||||
loginURL, err := services.WxWorkLoginService.BuildWxWorkQRCodeLoginURL(ctx.Query("next"))
|
loginURL, err := services.WxWorkLoginService.BuildWxWorkQRCodeLoginURL(ctx.Query("next"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
redirectWxWorkError(ctx, err.Error())
|
ctx.Redirect(http.StatusFound, "/login?wxworkError="+url.QueryEscape(wxWorkErrorMessage(err.Error())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Redirect(http.StatusFound, loginURL)
|
ctx.Redirect(http.StatusFound, loginURL)
|
||||||
@@ -57,7 +57,7 @@ func WxWorkCallback(ctx *gin.Context) {
|
|||||||
ctx.GetHeader("User-Agent"),
|
ctx.GetHeader("User-Agent"),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
redirectWxWorkError(ctx, err.Error())
|
ctx.Redirect(http.StatusFound, "/login?wxworkError="+url.QueryEscape(wxWorkErrorMessage(err.Error())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Redirect(http.StatusFound, "/dashboard/login/wxwork/callback?ticket="+url.QueryEscape(ticket)+"&next="+url.QueryEscape(next))
|
ctx.Redirect(http.StatusFound, "/dashboard/login/wxwork/callback?ticket="+url.QueryEscape(ticket)+"&next="+url.QueryEscape(next))
|
||||||
@@ -94,9 +94,9 @@ func Profile(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, ret)
|
httpx.WriteJSON(ctx, ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func redirectWxWorkError(ctx *gin.Context, message string) {
|
func wxWorkErrorMessage(message string) string {
|
||||||
if idx := strings.Index(message, ": "); idx >= 0 {
|
if idx := strings.Index(message, ": "); idx >= 0 {
|
||||||
message = message[idx+2:]
|
message = message[idx+2:]
|
||||||
}
|
}
|
||||||
ctx.Redirect(http.StatusFound, "/login?wxworkError="+url.QueryEscape(message))
|
return message
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import (
|
|||||||
"github.com/mlogclub/simple/web"
|
"github.com/mlogclub/simple/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ConversationGetBy(ctx *gin.Context, id int64) {
|
func ConversationGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if services.ChannelService.GetEnabledChannel(ctx) == nil {
|
if services.ChannelService.GetEnabledChannel(ctx) == nil {
|
||||||
httpx.WriteJSON(ctx, web.JsonErrorMsg("接入渠道未初始化"))
|
httpx.WriteJSON(ctx, web.JsonErrorMsg("接入渠道未初始化"))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ func AgentGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, builders.BuildAgentProfileList(list))
|
httpx.WriteJSON(ctx, builders.BuildAgentProfileList(list))
|
||||||
}
|
}
|
||||||
|
|
||||||
func AgentGetBy(ctx *gin.Context, id int64) {
|
func AgentGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -46,7 +46,11 @@ func AgentRunLogAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AgentRunLogGetBy(ctx *gin.Context, id int64) {
|
func AgentRunLogGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionConversationView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionConversationView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ func AgentTeamGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AgentTeamGetBy(ctx *gin.Context, id int64) {
|
func AgentTeamGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentTeamView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentTeamView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ func AgentTeamSchedulePostBatch_generate(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, builders.BuildAgentTeamScheduleBatchGenerateResponse(ret))
|
httpx.WriteJSON(ctx, builders.BuildAgentTeamScheduleBatchGenerateResponse(ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
func AgentTeamScheduleGetBy(ctx *gin.Context, id int64) {
|
func AgentTeamScheduleGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentTeamScheduleView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAgentTeamScheduleView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -52,7 +52,11 @@ func AIAgentGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AIAgentGetBy(ctx *gin.Context, id int64) {
|
func AIAgentGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAIAgentView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAIAgentView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ func AIConfigAnyList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AIConfigGetBy(ctx *gin.Context, id int64) {
|
func AIConfigGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAIConfigView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAIConfigView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -40,7 +40,11 @@ func AssetAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AssetGetBy(ctx *gin.Context, id int64) {
|
func AssetGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAssetView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAssetView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ func ChannelAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChannelGetBy(ctx *gin.Context, id int64) {
|
func ChannelGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionChannelView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionChannelView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ func CompanyAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func CompanyGetBy(ctx *gin.Context, id int64) {
|
func CompanyGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionCompanyView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionCompanyView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -99,7 +99,11 @@ func ConversationAnyConversations(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConversationGetBy(ctx *gin.Context, id int64) {
|
func ConversationGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionConversationView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionConversationView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ func CustomerPostList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: builders.BuildCustomerList(list), Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: builders.BuildCustomerList(list), Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func CustomerGetBy(ctx *gin.Context, id int64) {
|
func CustomerGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ func KnowledgeBaseAnyList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func KnowledgeBaseGetBy(ctx *gin.Context, id int64) {
|
func KnowledgeBaseGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeBaseView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeBaseView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ func KnowledgeDocumentAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func KnowledgeDocumentGetBy(ctx *gin.Context, id int64) {
|
func KnowledgeDocumentGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ func KnowledgeFAQAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func KnowledgeFAQGetBy(ctx *gin.Context, id int64) {
|
func KnowledgeFAQGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeFAQView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeFAQView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ func KnowledgeRetrieveLogAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func KnowledgeRetrieveLogGetBy(ctx *gin.Context, id int64) {
|
func KnowledgeRetrieveLogGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ func PermissionAnyList(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
httpx.WriteJSON(ctx, &web.PageResult{Results: results, Page: paging})
|
||||||
}
|
}
|
||||||
|
|
||||||
func PermissionGetBy(ctx *gin.Context, id int64) {
|
func PermissionGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionPermissionView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionPermissionView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -59,7 +59,11 @@ func RoleGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RoleGetBy(ctx *gin.Context, id int64) {
|
func RoleGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionRoleView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionRoleView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ func SkillDefinitionGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkillDefinitionGetBy(ctx *gin.Context, id int64) {
|
func SkillDefinitionGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionSkillDefinitionView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionSkillDefinitionView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ func TagGetList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TagGetBy(ctx *gin.Context, id int64) {
|
func TagGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionTagView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionTagView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -118,7 +118,11 @@ func TicketPostDelete_view(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, nil)
|
httpx.WriteJSON(ctx, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TicketGetBy(ctx *gin.Context, id int64) {
|
func TicketGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionTicketView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionTicketView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ func UserAnyList_all(ctx *gin.Context) {
|
|||||||
httpx.WriteJSON(ctx, results)
|
httpx.WriteJSON(ctx, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserGetBy(ctx *gin.Context, id int64) {
|
func UserGetBy(ctx *gin.Context) {
|
||||||
|
id, ok := httpx.GetPathInt64(ctx, "id")
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionUserView); err != nil {
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionUserView); err != nil {
|
||||||
httpx.WriteJSON(ctx, err)
|
httpx.WriteJSON(ctx, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package httpx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/mlogclub/simple/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetPathInt64(ctx *gin.Context, name string) (int64, bool) {
|
||||||
|
value, err := strconv.ParseInt(ctx.Param(name), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
WriteHttpStatusJSON(ctx, http.StatusBadRequest, web.JsonErrorMsg("路径参数错误"))
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
return value, true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user