-
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
Ryo Arima
committed
Sep 17, 2024
1 parent
13305e5
commit 0989b58
Showing
20 changed files
with
90 additions
and
72 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 @@ | ||
package main |
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 @@ | ||
package agent |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 controller |
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 repository |
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 usecase |
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 @@ | ||
package model |
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 request |
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 response |
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,73 @@ | ||
package controller | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/ryo-arima/mark1/pkg/entity/model" | ||
"github.com/ryo-arima/mark1/pkg/entity/request" | ||
"github.com/ryo-arima/mark1/pkg/entity/response" | ||
"github.com/ryo-arima/mark1/pkg/server/repository" | ||
) | ||
|
||
type GroupControllerForInternal interface { | ||
GetGroups(c *gin.Context) | ||
CreateGroup(c *gin.Context) | ||
UpdateGroup(c *gin.Context) | ||
DeleteGroup(c *gin.Context) | ||
} | ||
|
||
type groupControllerForInternal struct { | ||
GroupRepository repository.GroupRepository | ||
} | ||
|
||
func (groupController groupControllerForInternal) GetGroups(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_GET__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
res := groupController.GroupRepository.GetGroups() | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) CreateGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_CREATE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var groupModel model.Groups | ||
res := groupController.GroupRepository.CreateGroup(groupModel) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) UpdateGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_UPDATE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var groupModel model.Groups | ||
res := groupController.GroupRepository.UpdateGroup(groupModel) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) DeleteGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_DELETE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var uuid string | ||
res := groupController.GroupRepository.DeleteGroup(uuid) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func NewGroupControllerForInternal(groupRepository repository.GroupRepository) GroupControllerForInternal { | ||
return &groupControllerForInternal{GroupRepository: groupRepository} | ||
} |
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 controller |
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 |
---|---|---|
@@ -1,73 +1 @@ | ||
package controller | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/ryo-arima/mark1/pkg/entity/model" | ||
"github.com/ryo-arima/mark1/pkg/entity/request" | ||
"github.com/ryo-arima/mark1/pkg/entity/response" | ||
"github.com/ryo-arima/mark1/pkg/server/repository" | ||
) | ||
|
||
type GroupControllerForInternal interface { | ||
GetGroups(c *gin.Context) | ||
CreateGroup(c *gin.Context) | ||
UpdateGroup(c *gin.Context) | ||
DeleteGroup(c *gin.Context) | ||
} | ||
|
||
type groupControllerForInternal struct { | ||
GroupRepository repository.GroupRepository | ||
} | ||
|
||
func (groupController groupControllerForInternal) GetGroups(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_GET__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
res := groupController.GroupRepository.GetGroups() | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) CreateGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_CREATE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var groupModel model.Groups | ||
res := groupController.GroupRepository.CreateGroup(groupModel) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) UpdateGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_UPDATE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var groupModel model.Groups | ||
res := groupController.GroupRepository.UpdateGroup(groupModel) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func (groupController groupControllerForInternal) DeleteGroup(c *gin.Context) { | ||
var groupRequest request.GroupRequest | ||
if err := c.Bind(&groupRequest); err != nil { | ||
c.JSON(http.StatusBadRequest, &response.GroupResponse{Code: "SERVER_CONTROLLER_DELETE__FOR__001", Message: err.Error(), Groups: []response.Group{}}) | ||
return | ||
} | ||
var uuid string | ||
res := groupController.GroupRepository.DeleteGroup(uuid) | ||
c.JSON(http.StatusOK, res) | ||
return | ||
} | ||
|
||
func NewGroupControllerForInternal(groupRepository repository.GroupRepository) GroupControllerForInternal { | ||
return &groupControllerForInternal{GroupRepository: groupRepository} | ||
} |
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 repository |