add new uuid for workspace and create uuid folder

This commit is contained in:
Adrian Zürcher
2026-02-17 07:30:10 +01:00
parent 7d604189af
commit 38a7660d41
3 changed files with 26 additions and 5 deletions

View File

@@ -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{