This commit is contained in:
Yvan
2026-08-17 07:44:52 +08:00
parent d09e6b42bd
commit 9715b2ef1a
28 changed files with 1586 additions and 326 deletions
-39
View File
@@ -25,45 +25,6 @@ func NewAudit(service *service.AuditService, recorder *service.AuditRecorder, lo
return &Audit{service: service, recorder: recorder, logs: logs, logger: logger}
}
func page(c *gin.Context) (int, int, error) {
var value, size int
if raw, exists := c.GetQuery("page"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
value = parsed
}
if raw, exists := c.GetQuery("pageSize"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
size = parsed
}
return value, size, nil
}
func queryUintValue(c *gin.Context, key string) (uint, bool, error) {
raw, ok := c.GetQuery(key)
if !ok || raw == "" {
return 0, false, nil
}
value, err := strconv.ParseUint(raw, 10, 0)
return uint(value), true, err
}
func IDsFromQuery(c *gin.Context) []uint {
values := c.QueryArray("IDs[]")
ids := make([]uint, 0, len(values))
for _, value := range values {
id, _ := strconv.ParseUint(value, 10, 64)
if id > 0 {
ids = append(ids, uint(id))
}
}
return ids
}
func (h *Audit) Operations(c *gin.Context) {
var req dto.OperationRecordSearchRequest
if err := c.ShouldBindQuery(&req); err != nil {
+2 -3
View File
@@ -3,7 +3,6 @@ package handler
import (
"strconv"
"kra/internal/biz"
"kra/internal/server/httpx"
"kra/internal/service"
"kra/internal/service/dto"
@@ -175,7 +174,7 @@ func (h *Dictionary) Details(c *gin.Context) {
return
}
}
filter := biz.DictionaryDetailFilter{DictionaryID: uint(dictionaryID), Label: c.Query("label"), Value: c.Query("value")}
filter := dto.DictionaryDetailListRequest{DictionaryID: uint(dictionaryID), Label: c.Query("label"), Value: c.Query("value")}
if raw, exists := c.GetQuery("status"); exists {
value, parseErr := strconv.ParseBool(raw)
if parseErr != nil {
@@ -201,7 +200,7 @@ func (h *Dictionary) Details(c *gin.Context) {
}
filter.Level = &value
}
items, total, err := h.service.DictionaryDetails(c.Request.Context(), p, size, filter)
items, total, err := h.service.DictionaryDetailsRequest(c.Request.Context(), p, size, filter)
if err != nil {
httpx.Fail(c, "获取失败")
return
+1 -2
View File
@@ -3,7 +3,6 @@ package handler
import (
"strconv"
"kra/internal/biz"
"kra/internal/server/httpx"
servermiddleware "kra/internal/server/middleware"
"kra/internal/service"
@@ -47,7 +46,7 @@ func (h *Media) List(c *gin.Context) {
httpx.Fail(c, err.Error())
return
}
items, total, err := h.service.MediaList(c.Request.Context(), biz.MediaFilter{Page: req.Page, PageSize: req.PageSize, Keyword: req.Keyword, CategoryID: req.ClassID, Tag: req.Tag, UserID: req.UserID, StartCreatedAt: req.StartCreatedAt, EndCreatedAt: req.EndCreatedAt, OrderKey: req.OrderKey, Desc: req.Desc})
items, total, err := h.service.MediaListRequest(c.Request.Context(), &req)
if err != nil {
httpx.Fail(c, "获取失败")
return
+1 -1
View File
@@ -120,7 +120,7 @@ func (h *Public) InitializeDatabase(engine *gin.Engine) gin.HandlerFunc {
httpx.Fail(c, "已存在数据库配置")
return
}
var input service.DatabaseInit
var input dto.DatabaseInitRequest
if c.ShouldBindJSON(&input) != nil {
httpx.Fail(c, "参数校验不通过")
return
+38
View File
@@ -0,0 +1,38 @@
package handler
import (
"strconv"
"github.com/gin-gonic/gin"
)
func page(c *gin.Context) (int, int, error) {
var value, size int
if raw, exists := c.GetQuery("page"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
value = parsed
}
if raw, exists := c.GetQuery("pageSize"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
size = parsed
}
return value, size, nil
}
func IDsFromQuery(c *gin.Context) []uint {
values := c.QueryArray("IDs[]")
ids := make([]uint, 0, len(values))
for _, value := range values {
id, _ := strconv.ParseUint(value, 10, 64)
if id > 0 {
ids = append(ids, uint(id))
}
}
return ids
}
+1 -2
View File
@@ -108,8 +108,7 @@ func (h *User) UpdateSelf(c *gin.Context) {
httpx.Fail(c, err.Error())
return
}
value := service.UserInput{ID: claims.ID, NickName: req.NickName, HeaderImg: req.HeaderImg, Phone: req.Phone, Email: req.Email, Enable: req.Enable}
if err := h.service.UpdateSelfUser(c.Request.Context(), value); err != nil {
if err := h.service.UpdateSelfUserRequest(c.Request.Context(), claims.ID, &req); err != nil {
httpx.Fail(c, "修改失败")
return
}
+2 -2
View File
@@ -8,7 +8,7 @@ import (
"strings"
"sync"
"kra/internal/service"
"kra/internal/routeinfo"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
@@ -83,7 +83,7 @@ func buildSwaggerDocument(routes []gin.RouteInfo, prefix, version string) string
apiPath = "/"
}
documentPath := swaggerPathParameter.ReplaceAllString(apiPath, `{$1}`)
group, description := service.RouteMetadata(route.Method, apiPath)
group, description := routeinfo.Metadata(route.Method, apiPath)
if description == "" {
description = route.Method + " " + apiPath
}