c6c1c00141
- Implement role management endpoints including listing, creating, updating, and deleting roles. - Add session management endpoints for viewing and revoking sessions. - Create skill definition management endpoints for CRUD operations and status updates. - Introduce tag management endpoints for handling tags with sorting and status updates. - Develop ticket management endpoints for viewing, creating, updating, and managing ticket progress. - Implement user management endpoints for CRUD operations, role assignments, and password resets. - Add WeChat callback handlers for verifying and processing messages.
86 lines
2.3 KiB
Go
86 lines
2.3 KiB
Go
package dashboard
|
|
|
|
import (
|
|
"cs-agent/internal/builders"
|
|
"cs-agent/internal/pkg/constants"
|
|
"cs-agent/internal/pkg/dto/request"
|
|
"cs-agent/internal/pkg/httpx"
|
|
"cs-agent/internal/services"
|
|
|
|
"cs-agent/internal/pkg/httpx/params"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/mlogclub/simple/web"
|
|
)
|
|
|
|
// AnyList GET/POST /customer-contact/list?customerId=
|
|
func CustomerContactAnyList(ctx *gin.Context) {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerView); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
customerID, _ := params.GetInt64(ctx, "customerId")
|
|
if customerID <= 0 {
|
|
httpx.WriteJSON(ctx, web.JsonErrorMsg("customerId 必填"))
|
|
return
|
|
}
|
|
list := services.CustomerContactService.FindActiveByCustomerID(customerID)
|
|
httpx.WriteJSON(ctx, builders.BuildCustomerContactList(list))
|
|
}
|
|
|
|
func CustomerContactPostCreate(ctx *gin.Context) {
|
|
user, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
req := request.CreateCustomerContactRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
item, err := services.CustomerContactService.CreateCustomerContact(req, user)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
ret := builders.BuildCustomerContactResponse(item)
|
|
httpx.WriteJSON(ctx, &ret)
|
|
}
|
|
|
|
func CustomerContactPostUpdate(ctx *gin.Context) {
|
|
user, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
req := request.UpdateCustomerContactRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.CustomerContactService.UpdateCustomerContact(req, user); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|
|
|
|
func CustomerContactPostDelete(ctx *gin.Context) {
|
|
user, err := services.AuthService.RequirePermission(ctx, constants.PermissionCustomerUpdate)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
req := request.DeleteCustomerContactRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := services.CustomerContactService.DeleteCustomerContact(req.ID, user); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
}
|