A:添加 env 开发路由(有待调试)
This commit is contained in:
1 parent
77fb95b967
commit
a345134e04
7 files changed
+72
-70
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"rear/internal/container"
|
||||
"rear/internal/utils/tools"
|
||||
"rear/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type DevImageHandler struct {
|
||||
container *container.Container
|
||||
}
|
||||
|
||||
func NewDevImageHandler(container *container.Container) *DevImageHandler {
|
||||
return &DevImageHandler{container: container}
|
||||
}
|
||||
|
||||
// GetExif 获取图片的EXIF信息
|
||||
func (h *DevImageHandler) GetExif(c *gin.Context) {
|
||||
// 从 query 参数中获取图片路径
|
||||
logger.Warn("GetExif called, processing request...")
|
||||
imagePath := c.Query("image_path")
|
||||
|
||||
result := fmt.Sprintf("File generation done. %s\n", imagePath)
|
||||
logger.Warn(result)
|
||||
if imagePath == "" {
|
||||
c.JSON(400, gin.H{"error": "image_path query parameter is required"})
|
||||
return
|
||||
}
|
||||
// 调用工具函数获取 EXIF 数据
|
||||
exifData, err := tools.GetExifData(c, imagePath)
|
||||
if err != nil {
|
||||
c.JSON(500, gin.H{"error": "failed to get EXIF data"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{"exif_data": exifData})
|
||||
}
|
||||
@@ -11,16 +11,16 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
type LibraryHandler struct {
|
||||
container *container.Container
|
||||
}
|
||||
|
||||
func NewLibraryHandler(container *container.Container) *Handler {
|
||||
return &Handler{container: container}
|
||||
func NewLibraryHandler(container *container.Container) *LibraryHandler {
|
||||
return &LibraryHandler{container: container}
|
||||
}
|
||||
|
||||
// GetLibrary 获取存储
|
||||
func (h *Handler) GetLibrary(c *gin.Context) {
|
||||
func (h *LibraryHandler) GetLibrary(c *gin.Context) {
|
||||
libraries, err := h.container.LibraryRepo.GetAllLibrary()
|
||||
if err != nil {
|
||||
log.Printf("Failed to get all libraries: %v", err)
|
||||
@@ -39,7 +39,7 @@ func (h *Handler) GetLibrary(c *gin.Context) {
|
||||
Data: libraries,
|
||||
})
|
||||
}
|
||||
func (h *Handler) AddLibrary(c *gin.Context) {
|
||||
func (h *LibraryHandler) AddLibrary(c *gin.Context) {
|
||||
type AddLibraryRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (h *Handler) AddLibrary(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) UpdateLibrary(c *gin.Context) {
|
||||
func (h *LibraryHandler) UpdateLibrary(c *gin.Context) {
|
||||
type UpdateLibraryRequest struct {
|
||||
Path string `json:"path"`
|
||||
IsEnable bool `json:"is_enable"`
|
||||
@@ -116,7 +116,7 @@ func (h *Handler) UpdateLibrary(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) DeleteLibrary(c *gin.Context) {
|
||||
func (h *LibraryHandler) DeleteLibrary(c *gin.Context) {
|
||||
path := c.Query("path")
|
||||
if strings.TrimSpace(path) == "" {
|
||||
c.JSON(http.StatusBadRequest, model.Response{
|
||||
|
||||
Reference in new issue
Block a user