-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65e8f5e
commit 693c74a
Showing
20 changed files
with
184 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package box | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
// GetMyBox ... | ||
func GetMyBox(ctx context.Context, uid *uuid.UUID) (res *MyBoxesRes, err error) { | ||
res = new(MyBoxesRes) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package box | ||
|
||
// MyBoxesRes ... | ||
type MyBoxesRes struct { | ||
Boxes []*Box `json:"boxes,omitempty"` | ||
} | ||
|
||
// Box ... | ||
type Box struct { | ||
Id *string `json:"id,omitempty"` | ||
Name *string `json:"name" binding:"required,min=3,max=30"` | ||
Desc *string `json:"desc,omitempty"` | ||
CreatedByID *string `json:"created_by_id,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package permission | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
"github.com/isaqueveras/powersso/utils" | ||
) | ||
|
||
// GetPermissions ... | ||
func GetPermissions(ctx context.Context, pid *uuid.UUID) (res *PermissionsRes, err error) { | ||
res = new(PermissionsRes) | ||
res.ProjectID = pid | ||
res.DateCache = utils.Pointer(time.Now()) | ||
res.Permission = utils.Pointer(uint64(9003840938243279983)) | ||
return res, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package permission | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
// PermissionsRes models ... | ||
type PermissionsRes struct { | ||
ProjectID *uuid.UUID `json:"pid"` | ||
Permission *uint64 `json:"permission"` | ||
DateCache *time.Time `json:"date_cache,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package box | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/google/uuid" | ||
"github.com/isaqueveras/powersso/application/box" | ||
"github.com/isaqueveras/powersso/middleware" | ||
"github.com/isaqueveras/powersso/oops" | ||
"github.com/isaqueveras/powersso/utils" | ||
) | ||
|
||
func getMyBoxes(ctx *gin.Context) { | ||
uid, err := uuid.Parse(middleware.GetSession(ctx).UserID) | ||
if err != nil { | ||
oops.Handling(ctx, err) | ||
return | ||
} | ||
|
||
boxes, err := box.GetMyBox(ctx, utils.Pointer(uid)) | ||
if err != nil { | ||
oops.Handling(ctx, err) | ||
return | ||
} | ||
|
||
ctx.JSON(http.StatusOK, boxes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package box | ||
|
||
import "github.com/gin-gonic/gin" | ||
|
||
// Router ... | ||
func Router(r *gin.RouterGroup) { | ||
r.GET("/my", getMyBoxes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Copyright (c) 2023 Isaque Veras | ||
-- Use of this source code is governed by MIT style | ||
-- license that can be found in the LICENSE file. | ||
|
||
DROP TABLE IF EXISTS "boxes" CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- Copyright (c) 2023 Isaque Veras | ||
-- Use of this source code is governed by MIT style | ||
-- license that can be found in the LICENSE file. | ||
|
||
CREATE TABLE boxes ( | ||
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), | ||
"name" VARCHAR(30) NOT NULL, | ||
"desc" VARCHAR(50), | ||
"project_id" UUID NOT NULL REFERENCES projects (id), | ||
"flag" BIGINT NOT NULL DEFAULT 0, | ||
"created_by" UUID NOT NULL REFERENCES users (id), | ||
"created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Copyright (c) 2023 Isaque Veras | ||
-- Use of this source code is governed by MIT style | ||
-- license that can be found in the LICENSE file. | ||
|
||
DROP TABLE IF EXISTS "users_boxes" CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Copyright (c) 2023 Isaque Veras | ||
-- Use of this source code is governed by MIT style | ||
-- license that can be found in the LICENSE file. | ||
|
||
CREATE TABLE users_boxes ( | ||
id UUID DEFAULT uuid_generate_v4(), | ||
user_id UUID NOT NULL REFERENCES users (id), | ||
box_id UUID NOT NULL REFERENCES boxes (id), | ||
created_by UUID NOT NULL REFERENCES users (id), | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters