Skip to content

Commit

Permalink
[fix] #34 (User,GroupのJSONレスポンスの修正)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Mar 18, 2021
1 parent 646d3de commit eaa218c
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 44 deletions.
25 changes: 25 additions & 0 deletions pkg/api/core/group/connection/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ type Input struct {
Monitor *bool `json:"monitor"`
}

type Connection struct {
ID uint `json:"id"`
BGPRouterID *uint `json:"bgp_router_id"` //使用RouterのID
BGPRouterName string `json:"bgp_router_name"` //使用RouterのID
TunnelEndPointRouterIPID *uint `json:"tunnel_endpoint_router_ip_id"` //使用エンドポイントルータのID
TunnelEndPointRouterIPIDName string `json:"tunnel_endpoint_router_ip_name"`
ConnectionTemplateID *uint `json:"connection_template_id"`
ConnectionTemplateName string `json:"connection_template_name"`
ConnectionComment string `json:"connection_comment"` // ServiceがETCの時や補足説明で必要
ConnectionNumber uint `json:"connection_number"`
NTTTemplateID *uint `json:"ntt_template_id"`
NTTTemplateName string `json:"ntt_template_name"`
NOCID *uint `json:"noc_id"`
NOCName string `json:"noc_name"`
TermIP string `json:"term_ip"`
Monitor *bool `json:"monitor"`
Address string `json:"address"` //都道府県 市町村
LinkV4Our string `json:"link_v4_our"`
LinkV4Your string `json:"link_v4_your"`
LinkV6Our string `json:"link_v6_our"`
LinkV6Your string `json:"link_v6_your"`
Open *bool `json:"open"`
Lock *bool `json:"lock"`
}

type Result struct {
Connection []core.Connection `json:"connection"`
}
Expand Down
56 changes: 28 additions & 28 deletions pkg/api/core/group/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package group

import (
"github.com/homenoc/dsbd-backend/pkg/api/core"
"github.com/homenoc/dsbd-backend/pkg/api/core/group/service"
"github.com/homenoc/dsbd-backend/pkg/api/core/user"
)

const (
Expand Down Expand Up @@ -32,42 +34,40 @@ type Input struct {
StudentExpired *string `json:"student_expired"`
}

type Result struct {
type ResultAdmin struct {
Group core.Group `json:"group"`
}

type ResultAll struct {
type ResultAdminAll struct {
Group []core.Group `json:"group"`
}

type ResultOne struct {
ID uint `json:"id"`
Agree *bool `json:"agree"`
Question string `json:"question"`
Org string `json:"org"`
OrgEn string `json:"org_en"`
PostCode string `json:"postcode"`
Address string `json:"address"`
AddressEn string `json:"address_en"`
Tel string `json:"tel"`
Country string `json:"country"`
Status uint `json:"status"`
Bandwidth string `json:"bandwidth"`
Contract string `json:"contract"`
Student *bool `json:"student"`
Pass *bool `json:"pass"`
Lock *bool `json:"lock"`
ExpiredStatus uint `json:"expired_status"`
Open *bool `json:"open"`
type Group struct {
ID uint `json:"id"`
Agree *bool `json:"agree"`
Question string `json:"question"`
Org string `json:"org"`
OrgEn string `json:"org_en"`
PostCode string `json:"postcode"`
Address string `json:"address"`
AddressEn string `json:"address_en"`
Tel string `json:"tel"`
Country string `json:"country"`
Status uint `json:"status"`
Bandwidth string `json:"bandwidth"`
Contract string `json:"contract"`
Student *bool `json:"student"`
Pass *bool `json:"pass"`
Lock *bool `json:"lock"`
ExpiredStatus uint `json:"expired_status"`
Open *bool `json:"open"`
Service *[]service.Service `json:"service"`
User []user.User `json:"user"`
}

//type ResultAll struct {
// Group ResultOne `json:"group"`
// Network []core.Service `json:"network"`
// //Admin []core.Admin `json:"admin"`
// //Tech []core.Tech `json:"tech"`
// Connection []core.Connection `json:"connection"`
//}
type Result struct {
Group Group `json:"group"`
}

type ResultDatabase struct {
Err error
Expand Down
63 changes: 63 additions & 0 deletions pkg/api/core/group/service/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"github.com/homenoc/dsbd-backend/pkg/api/core"
"github.com/homenoc/dsbd-backend/pkg/api/core/group/connection"
)

const (
Expand Down Expand Up @@ -54,6 +55,68 @@ type Input struct {
Lock bool `json:"lock"`
}

type JPNIC struct {
ID uint `json:"id"`
JPNICHandle string `json:"jpnic_handle"`
Name string `json:"name"`
NameEn string `json:"name_en"`
Org string `json:"org"`
OrgEn string `json:"org_en"`
PostCode string `json:"postcode"`
Address string `json:"address"`
AddressEn string `json:"address_en"`
Dept string `json:"dept"`
DeptEn string `json:"dept_en"`
Tel string `json:"tel"`
Fax string `json:"fax"`
Country string `json:"country"`
}

type Service struct {
ID uint `json:"id"`
GroupID uint `json:"group_id"`
ServiceTemplateID *uint `json:"service_template_id"`
ServiceTemplateName string `json:"service_template_name"`
ServiceComment string `json:"service_comment"`
ServiceNumber uint `json:"service_number"`
Org string `json:"org"`
OrgEn string `json:"org_en"`
PostCode string `json:"postcode"`
Address string `json:"address"`
AddressEn string `json:"address_en"`
ASN *uint `json:"asn"`
RouteV4 string `json:"route_v4"`
RouteV6 string `json:"route_v6"`
V4Name string `json:"v4_name"`
V6Name string `json:"v6_name"`
AveUpstream uint `json:"avg_upstream"`
MaxUpstream uint `json:"max_upstream"`
AveDownstream uint `json:"avg_downstream"`
MaxDownstream uint `json:"max_downstream"`
MaxBandWidthAS uint `json:"max_bandwidth_as"`
Fee *uint `json:"fee"`
IP []core.IP `json:"ip"`
Connections *[]connection.Connection `json:"connections"`
JPNICAdminID uint `json:"jpnic_admin_id"`
JPNICAdmin *JPNIC `json:"jpnic_admin"`
JPNICTech *[]JPNIC `json:"jpnic_tech"`
Open *bool `json:"open"`
AddAllow *bool `json:"add_allow"`
Lock *bool `json:"lock"`
}

type IP struct {
ID uint `json:"id"`
Version uint `json:"version"`
Name string `json:"name"`
IP string `json:"ip"`
Plan []*core.Plan `json:"plan"`
StartDate string `json:"start_date"`
EndDate *string `json:"end_date"`
UseCase string `json:"use_case"`
Open *bool `json:"open"`
}

type IPInput struct {
Version uint `json:"version"`
Name string `json:"name"`
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/core/group/v0/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func AddAdmin(c *gin.Context) {
c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()})
return
}
c.JSON(http.StatusOK, group.Result{})
c.JSON(http.StatusOK, group.ResultAdmin{})
}

func DeleteAdmin(c *gin.Context) {
Expand All @@ -54,7 +54,7 @@ func DeleteAdmin(c *gin.Context) {
c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()})
return
}
c.JSON(http.StatusOK, group.Result{})
c.JSON(http.StatusOK, group.ResultAdmin{})
}

func UpdateAdmin(c *gin.Context) {
Expand Down Expand Up @@ -100,7 +100,7 @@ func UpdateAdmin(c *gin.Context) {
c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()})
return
}
c.JSON(http.StatusOK, group.Result{})
c.JSON(http.StatusOK, group.ResultAdmin{})
}

func GetAdmin(c *gin.Context) {
Expand All @@ -121,7 +121,7 @@ func GetAdmin(c *gin.Context) {
return
}

c.JSON(http.StatusOK, group.Result{
c.JSON(http.StatusOK, group.ResultAdmin{
Group: result.Group[0],
})
}
Expand All @@ -136,6 +136,6 @@ func GetAllAdmin(c *gin.Context) {
if result := dbGroup.GetAll(); result.Err != nil {
c.JSON(http.StatusInternalServerError, common.Error{Error: result.Err.Error()})
} else {
c.JSON(http.StatusOK, group.ResultAll{Group: result.Group})
c.JSON(http.StatusOK, group.ResultAdminAll{Group: result.Group})
}
}
Loading

0 comments on commit eaa218c

Please sign in to comment.