Refactor import paths to use internal/pkg/httpx/params

- Updated multiple repository and service files to replace imports from "github.com/mlogclub/simple/web/params" with "cs-agent/internal/pkg/httpx/params".
- Adjusted context handling in auth_service and ws_service to use gin.Context instead of iris.Context.
- Ensured consistent usage of HTTP status responses across websocket handlers.
This commit is contained in:
mlogclub
2026-05-23 22:10:20 +08:00
parent f8b1ed42fa
commit 79614b2d07
140 changed files with 1117 additions and 595 deletions
@@ -6,13 +6,13 @@ import (
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AgentController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AgentController) AnyList() *web.JsonResult {
@@ -6,13 +6,13 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AgentRunLogController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AgentRunLogController) AnyList() *web.JsonResult {
@@ -8,14 +8,14 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AgentTeamController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AgentTeamController) AnyList() *web.JsonResult {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AgentTeamScheduleController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AgentTeamScheduleController) AnyList() *web.JsonResult {
@@ -13,14 +13,14 @@ import (
"cs-agent/internal/pkg/utils"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AIAgentController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AIAgentController) AnyList() *web.JsonResult {
@@ -114,7 +114,7 @@ func (c *AIAgentController) PostUpdate_sort() *web.JsonResult {
return web.JsonError(err)
}
var ids []int64
if err := c.Ctx.ReadJSON(&ids); err != nil {
if err := params.ReadJSON(c.Ctx, &ids); err != nil {
return web.JsonError(err)
}
if err := services.AIAgentService.UpdateSort(ids); err != nil {
@@ -7,13 +7,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AIConfigController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AIConfigController) AnyList() *web.JsonResult {
@@ -133,7 +133,7 @@ func (c *AIConfigController) PostUpdate_sort() *web.JsonResult {
}
var ids []int64
if err := c.Ctx.ReadJSON(&ids); err != nil {
if err := params.ReadJSON(c.Ctx, &ids); err != nil {
return web.JsonError(err)
}
if err := services.AIConfigService.UpdateSort(ids); err != nil {
@@ -9,13 +9,13 @@ import (
"cs-agent/internal/services"
"strings"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type AssetController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *AssetController) AnyList() *web.JsonResult {
@@ -29,7 +29,7 @@ func (c *AssetController) AnyList() *web.JsonResult {
params.QueryFilter{ParamName: "createUserId"},
params.QueryFilter{ParamName: "filename", Op: params.Like},
).Desc("id")
if strings.TrimSpace(c.Ctx.URLParam("status")) == "" {
if strings.TrimSpace(c.Ctx.Query("status")) == "" {
cnd = cnd.Eq("status", enums.AssetStatusSuccess)
}
@@ -62,12 +62,10 @@ func (c *AssetController) PostCreate() *web.JsonResult {
if err := params.ReadForm(c.Ctx, &req); err != nil {
return web.JsonError(err)
}
f, header, err := c.Ctx.FormFile("file")
header, err := c.Ctx.FormFile("file")
if err != nil {
return web.JsonErrorMsg("请选择上传文件")
}
_ = f.Close()
item, err := services.AssetService.UploadFile(header, req.Prefix, operator)
if err != nil {
return web.JsonError(err)
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type ChannelController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *ChannelController) AnyList() *web.JsonResult {
@@ -7,13 +7,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type CompanyController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *CompanyController) AnyList() *web.JsonResult {
@@ -10,15 +10,15 @@ import (
"strconv"
"strings"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/common/strs"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
"github.com/spf13/cast"
)
type ConversationController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *ConversationController) AnyList() *web.JsonResult {
@@ -272,7 +272,7 @@ func (c *ConversationController) PostUpload_image() *web.JsonResult {
return web.JsonError(err)
}
rawConv := strings.TrimSpace(c.Ctx.FormValue("conversationId"))
rawConv := strings.TrimSpace(params.FormValue(c.Ctx, "conversationId"))
if rawConv == "" {
return web.JsonErrorMsg("conversationId不能为空")
}
@@ -284,12 +284,10 @@ func (c *ConversationController) PostUpload_image() *web.JsonResult {
return web.JsonError(err)
}
f, header, err := c.Ctx.FormFile("file")
header, err := c.Ctx.FormFile("file")
if err != nil {
return web.JsonErrorMsg("请选择上传图片")
}
_ = f.Close()
if !strings.HasPrefix(strings.ToLower(header.Header.Get("Content-Type")), "image/") {
return web.JsonErrorMsg("仅支持上传图片文件")
}
@@ -307,7 +305,7 @@ func (c *ConversationController) PostUpload_attachment() *web.JsonResult {
return web.JsonError(err)
}
rawConv := strings.TrimSpace(c.Ctx.FormValue("conversationId"))
rawConv := strings.TrimSpace(params.FormValue(c.Ctx, "conversationId"))
if rawConv == "" {
return web.JsonErrorMsg("conversationId不能为空")
}
@@ -319,12 +317,10 @@ func (c *ConversationController) PostUpload_attachment() *web.JsonResult {
return web.JsonError(err)
}
f, header, err := c.Ctx.FormFile("file")
header, err := c.Ctx.FormFile("file")
if err != nil {
return web.JsonErrorMsg("请选择上传附件")
}
_ = f.Close()
item, err := services.AssetService.UploadFile(header, "attachments", operator)
if err != nil {
return web.JsonError(err)
@@ -6,13 +6,13 @@ import (
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type CustomerContactController struct {
Ctx iris.Context
Ctx *gin.Context
}
// AnyList GET/POST /customer-contact/list?customerId=
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type CustomerController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *CustomerController) PostList() *web.JsonResult {
@@ -3,13 +3,13 @@ package dashboard
import (
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type DashboardController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *DashboardController) GetOverview() *web.JsonResult {
@@ -12,14 +12,14 @@ import (
"cs-agent/internal/repositories"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type KnowledgeBaseController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *KnowledgeBaseController) AnyList() *web.JsonResult {
@@ -127,7 +127,7 @@ func (c *KnowledgeBaseController) PostDelete() *web.JsonResult {
func (c *KnowledgeBaseController) PostUpdate_sort() *web.JsonResult {
var ids []int64
if err := c.Ctx.ReadJSON(&ids); err != nil {
if err := params.ReadJSON(c.Ctx, &ids); err != nil {
return web.JsonError(err)
}
if err := services.KnowledgeBaseService.UpdateSort(ids); err != nil {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type KnowledgeDocumentController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *KnowledgeDocumentController) AnyList() *web.JsonResult {
@@ -7,13 +7,13 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type KnowledgeFAQController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *KnowledgeFAQController) AnyList() *web.JsonResult {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type KnowledgeRetrieveController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *KnowledgeRetrieveController) PostDebugSearch() *web.JsonResult {
@@ -6,13 +6,13 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type KnowledgeRetrieveLogController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *KnowledgeRetrieveLogController) AnyList() *web.JsonResult {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type MCPController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *MCPController) AnyList_servers() *web.JsonResult {
@@ -10,13 +10,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type NotificationController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *NotificationController) AnyList() *web.JsonResult {
@@ -31,7 +31,7 @@ func (c *NotificationController) AnyList() *web.JsonResult {
Eq("status", enums.StatusOk).
Desc("id")
switch strings.TrimSpace(c.Ctx.URLParam("readStatus")) {
switch strings.TrimSpace(c.Ctx.Query("readStatus")) {
case "unread":
cnd.Where("read_at IS NULL")
case "read":
@@ -5,14 +5,14 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/common/strs"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type PermissionController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *PermissionController) AnyList() *web.JsonResult {
@@ -7,14 +7,14 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type QuickReplyController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *QuickReplyController) AnyList() *web.JsonResult {
@@ -6,14 +6,14 @@ import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type RoleController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *RoleController) AnyList() *web.JsonResult {
@@ -177,7 +177,7 @@ func (c *RoleController) PostAssign_permission() *web.JsonResult {
func (c *RoleController) PostUpdate_sort() *web.JsonResult {
var ids []int64
if err := c.Ctx.ReadJSON(&ids); err != nil {
if err := params.ReadJSON(c.Ctx, &ids); err != nil {
return web.JsonError(err)
}
if err := services.RoleService.UpdateSort(ids); err != nil {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/services"
"time"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type SessionController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *SessionController) AnyList() *web.JsonResult {
@@ -12,13 +12,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type SkillDefinitionController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *SkillDefinitionController) AnyList() *web.JsonResult {
@@ -6,13 +6,13 @@ import (
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type TagController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *TagController) AnyList() *web.JsonResult {
@@ -101,7 +101,7 @@ func (c *TagController) PostDelete() *web.JsonResult {
func (c *TagController) PostUpdate_sort() *web.JsonResult {
var ids []int64
if err := c.Ctx.ReadJSON(&ids); err != nil {
if err := params.ReadJSON(c.Ctx, &ids); err != nil {
return web.JsonError(err)
}
if err := services.TagService.UpdateSort(ids); err != nil {
@@ -8,14 +8,14 @@ import (
"cs-agent/internal/pkg/dto/request"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/sqls"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type TicketController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *TicketController) AnyList() *web.JsonResult {
@@ -8,13 +8,13 @@ import (
"cs-agent/internal/pkg/enums"
"cs-agent/internal/services"
"github.com/kataras/iris/v12"
"cs-agent/internal/pkg/httpx/params"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
"github.com/mlogclub/simple/web/params"
)
type UserController struct {
Ctx iris.Context
Ctx *gin.Context
}
func (c *UserController) AnyList() *web.JsonResult {