You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
775 B
36 lines
775 B
package organization
|
|
|
|
import (
|
|
"net/http"
|
|
"task-track-backend/model"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *OrganizationHandler) CreateOrganization(c *gin.Context) {
|
|
var organization model.Organization
|
|
if err := c.ShouldBindJSON(&organization); err != nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{
|
|
"code": 400,
|
|
"message": "Invalid request data",
|
|
"error": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
// 创建机构
|
|
if err := h.db.Create(&organization).Error; err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{
|
|
"code": 500,
|
|
"message": "Failed to create organization",
|
|
"error": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusCreated, gin.H{
|
|
"code": 201,
|
|
"message": "Organization created successfully",
|
|
"data": organization,
|
|
})
|
|
}
|
|
|