feat: swagger

This commit is contained in:
Blizzard
2025-09-16 14:27:32 +08:00
parent 79c19bc47c
commit 237ac665e6
19 changed files with 4690 additions and 91 deletions
+50 -9
View File
@@ -1,18 +1,28 @@
package system
import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"sundynix-go/global"
"sundynix-go/model/commom/request"
"sundynix-go/model/commom/response"
"sundynix-go/model/system"
systemReq "sundynix-go/model/system/request"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type ClientApi struct {
}
// SaveClient
// @Tags 客户端管理
// @Summary 创建client
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Client true "client"
// @Success 200 {object} response.Response{msg=string} "创建client"
// @Router /api/client/save [post]
func (s *ClientApi) SaveClient(c *gin.Context) {
var client system.Client
err := c.ShouldBindJSON(&client)
@@ -29,6 +39,15 @@ func (s *ClientApi) SaveClient(c *gin.Context) {
response.OkWithMsg("保存客户端成功!", c)
}
// UpdateClient
// @Tags 客户端管理
// @Summary 更新client
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Client true "client"
// @Success 200 {object} response.Response{msg=string} "更新client"
// @Router /api/client/update [post]
func (s *ClientApi) UpdateClient(c *gin.Context) {
var client system.Client
err := c.ShouldBindJSON(&client)
@@ -45,6 +64,15 @@ func (s *ClientApi) UpdateClient(c *gin.Context) {
response.OkWithMsg("更新客户端成功!", c)
}
// GetClientList
// @Tags 客户端管理
// @Summary 获取client列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body systemReq.GetClientList true "client"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取client列表"
// @Router /api/client/getClientList [post]
func (s *ClientApi) GetClientList(c *gin.Context) {
var pageInfo systemReq.GetClientList
err := c.ShouldBindJSON(&pageInfo)
@@ -66,6 +94,15 @@ func (s *ClientApi) GetClientList(c *gin.Context) {
}, c)
}
// Delete
// @Tags 客户端管理
// @Summary 删除client
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "ids"
// @Success 200 {object} response.Response{msg=string} "删除client"
// @Router /api/client/delete [post]
func (s *ClientApi) Delete(c *gin.Context) {
var ids request.IdsReq
err := c.ShouldBindJSON(&ids)
@@ -82,14 +119,18 @@ func (s *ClientApi) Delete(c *gin.Context) {
response.OkWithMsg("删除客户端成功!", c)
}
// Detail
// @Tags 客户端管理
// @Summary 获取client详情
// @Description id获取详情
// @Security ApiKeyAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.Client,msg=string} "获取client详情"
// @Router /api/client/detail [get]
func (s *ClientApi) Detail(c *gin.Context) {
var idInfo request.GetById
err := c.ShouldBindJSON(&idInfo)
if err != nil {
response.FailWithMsg(err.Error(), c)
return
}
client, err := clientService.GetClientById(idInfo.ID)
id := c.Query("id")
client, err := clientService.GetClientById(id)
if err != nil {
global.Logger.Error("获取客户端详情失败!", zap.Error(err))
response.FailWithMsg(err.Error(), c)