版本封存
This commit is contained in:
45
cmii-uav-watchdog-center/controllers/project_controller.go
Normal file
45
cmii-uav-watchdog-center/controllers/project_controller.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user