add new uuid for workspace and create uuid folder
This commit is contained in:
@@ -3,11 +3,13 @@ package handlers
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"gitea.tecamino.com/paadi/access-handler/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (aH *AccessHandler) AddWorkspaceTable() error {
|
||||
@@ -30,10 +32,26 @@ func (aH *AccessHandler) AddWorkspace(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
uid, err := uuid.NewUUID()
|
||||
if err != nil {
|
||||
aH.logger.Error("AddWorkspace", err)
|
||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||
return
|
||||
}
|
||||
|
||||
// create new folder
|
||||
err = os.MkdirAll(uid.String(), 0644)
|
||||
if err != nil {
|
||||
aH.logger.Error("AddWorkspace", err)
|
||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||
return
|
||||
}
|
||||
|
||||
// Insert new workspace with provided permissions
|
||||
aH.dbHandler.AddNewColum(&models.Workspace{
|
||||
Name: workspace.Name,
|
||||
Description: workspace.Description,
|
||||
Uuid: uid,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user