版本封存

This commit is contained in:
zeaslity
2025-12-06 11:26:05 +08:00
parent 13949e1ba8
commit c0ae5e30c4
57 changed files with 2443 additions and 1428 deletions

View File

@@ -0,0 +1,38 @@
package controllers
import (
"cmii-uav-watchdog-center/services"
"cmii-uav-watchdog-common/models"
"net/http"
"github.com/gin-gonic/gin"
)
// ProcessAuthorizationFile 处理授权文件
// @Summary 处理授权文件
// @Description 接收来自cmii-uav-watchdog的授权文件解码并生成授权码
// @Accept json
// @Produce json
// @Param authFile body models.AuthorizationFile true "授权文件"
// @Success 200 {object} models.AuthorizationCode "授权码"
// @Failure 400 {object} map[string]string "请求错误"
// @Failure 401 {object} map[string]string "未授权"
// @Router /api/v1/auth/process [post]
func ProcessAuthorizationFile(c *gin.Context) {
var authFile models.AuthorizationFile
// 解析请求体
if err := c.ShouldBindJSON(&authFile); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "无效的请求体"})
return
}
authCode, err := services.ProcessAuthorizationFile(authFile)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "生成授权码失败"})
return
}
// 返回授权码
c.JSON(http.StatusOK, authCode)
}

View File

@@ -0,0 +1,45 @@
package controllers
import (
"cmii-uav-watchdog-center/services"
"cmii-uav-watchdog-common/models"
"cmii-uav-watchdog-common/wdd_log"
"net/http"
"github.com/gin-gonic/gin"
)
// GetProjectList 获取项目列表
func GetProjectList(c *gin.Context) {
// 获取项目列表
projectList, err := services.GetProjectList()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, projectList)
}
// CreateProject 创建项目
func CreateProject(c *gin.Context) {
// 绑定 Project
var project models.Project
if err := c.ShouldBindJSON(&project); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 创建项目
authFilePath, err := services.CreateProject(&project)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
wdd_log.Info("创建项目成功: %s", authFilePath)
c.JSON(http.StatusOK, project)
}