Skip to content

Commit

Permalink
[fix] #48
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Feb 27, 2021
1 parent 881913e commit 67c19e0
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 31 deletions.
10 changes: 7 additions & 3 deletions pkg/api/core/controller/v0/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func ReceiveChatUser(c *gin.Context) {
var input controller.Chat
log.Println(c.BindJSON(&input))

support.Broadcast <- support.WebSocketResult{CreatedAt: time.Now(),
UserID: input.UserID, GroupID: input.GroupID, Admin: input.Admin, Message: input.Message}

support.Broadcast <- support.WebSocketResult{
CreatedAt: time.Now(),
UserID: input.UserID,
GroupID: input.GroupID,
Admin: input.Admin,
Message: input.Message,
}
}
10 changes: 8 additions & 2 deletions pkg/api/core/group/connection/v0/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ func Add(c *gin.Context) {
}

_, err = dbConnection.Create(&connection.Connection{
GroupID: result.Group.ID, UserID: input.UserID, Service: input.Service, NTT: input.NTT, NOC: input.NOC,
TermIP: input.TermIP, Monitor: input.Monitor, Open: &[]bool{false}[0]})
GroupID: result.Group.ID,
UserID: input.UserID,
Service: input.Service,
NTT: input.NTT,
NOC: input.NOC,
TermIP: input.TermIP,
Monitor: input.Monitor,
Open: &[]bool{false}[0]})
if err != nil {
c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()})
return
Expand Down
19 changes: 15 additions & 4 deletions pkg/api/core/group/network/v0/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,21 @@ func AddAdmin(c *gin.Context) {

//db create for network
_, err = dbNetwork.Create(&network.Network{
GroupID: uint(id), Org: input.Org, OrgEn: input.OrgEn, Postcode: input.Postcode, Address: input.Address,
AddressEn: input.AddressEn, RouteV4: input.RouteV4, RouteV6: input.RouteV6, PI: &[]bool{input.PI}[0],
ASN: input.ASN, Open: &[]bool{false}[0], IP: *grpIP, JPNICAdmin: *jh.jpnicAdmin, JPNICTech: *jh.jpnicTech,
Lock: &[]bool{input.Lock}[0],
GroupID: uint(id),
Org: input.Org,
OrgEn: input.OrgEn,
Postcode: input.Postcode,
Address: input.Address,
AddressEn: input.AddressEn,
RouteV4: input.RouteV4,
RouteV6: input.RouteV6,
PI: &[]bool{input.PI}[0],
ASN: input.ASN,
Open: &[]bool{false}[0],
IP: *grpIP,
JPNICAdmin: *jh.jpnicAdmin,
JPNICTech: *jh.jpnicTech,
Lock: &[]bool{input.Lock}[0],
})
if err != nil {
c.JSON(http.StatusInternalServerError, common.Error{Error: err.Error()})
Expand Down
18 changes: 15 additions & 3 deletions pkg/api/store/group/connection/v0/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ func Update(base int, c connection.Connection) error {
result = db.Model(&connection.Connection{Model: gorm.Model{ID: c.ID}}).Update(connection.Connection{GroupID: c.GroupID})
} else if base == connection.UpdateAll {
result = db.Model(&connection.Connection{Model: gorm.Model{ID: c.ID}}).Update(connection.Connection{
GroupID: c.GroupID, ServiceID: c.ServiceID, UserID: c.UserID, Service: c.Service, NTT: c.NTT, NOC: c.NOC,
TermIP: c.TermIP, Monitor: c.Monitor, LinkV4Our: c.LinkV4Our, LinkV4Your: c.LinkV4Your,
LinkV6Our: c.LinkV6Our, LinkV6Your: c.LinkV6Your, Fee: c.Fee, Open: c.Open})
GroupID: c.GroupID,
ServiceID: c.ServiceID,
UserID: c.UserID,
Service: c.Service,
NTT: c.NTT,
NOC: c.NOC,
TermIP: c.TermIP,
Monitor: c.Monitor,
LinkV4Our: c.LinkV4Our,
LinkV4Your: c.LinkV4Your,
LinkV6Our: c.LinkV6Our,
LinkV6Your: c.LinkV6Your,
Fee: c.Fee,
Open: c.Open,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/store/group/network/jpnicAdmin/v0/jpnicAdmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func Update(base int, u jpnicAdmin.JpnicAdmin) error {

if base == jpnicAdmin.UpdateAll {
err = db.Model(&jpnicAdmin.JpnicAdmin{Model: gorm.Model{ID: u.ID}}).Update(jpnicAdmin.JpnicAdmin{
NetworkID: u.NetworkID, UserID: u.UserID, Lock: u.Lock}).Error
NetworkID: u.NetworkID,
UserID: u.UserID,
Lock: u.Lock,
}).Error
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/store/group/network/jpnicTech/v0/jpnicTech.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func Update(base int, u jpnicTech.JpnicTech) error {

if base == jpnicTech.UpdateAll {
err = db.Model(&jpnicTech.JpnicTech{Model: gorm.Model{ID: u.ID}}).Update(jpnicTech.JpnicTech{
NetworkID: u.NetworkID, UserID: u.UserID, Lock: u.Lock}).Error
NetworkID: u.NetworkID,
UserID: u.UserID,
Lock: u.Lock,
}).Error
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
19 changes: 16 additions & 3 deletions pkg/api/store/group/network/v0/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,22 @@ func Update(base int, c network.Network) error {
result = db.Model(&network.Network{Model: gorm.Model{ID: c.ID}}).Update(network.Network{GroupID: c.GroupID})
} else if network.UpdateAll == base {
result = db.Model(&network.Network{Model: gorm.Model{ID: c.ID}}).Update(network.Network{
GroupID: c.GroupID, Org: c.Org, OrgEn: c.Org, Postcode: c.Postcode, Address: c.Address, AddressEn: c.AddressEn,
PI: c.PI, ASN: c.ASN, RouteV4: c.RouteV4, RouteV6: c.RouteV6, IP: c.IP,
JPNICAdmin: c.JPNICAdmin, JPNICTech: c.JPNICTech, Open: c.Open, Lock: c.Lock})
GroupID: c.GroupID,
Org: c.Org,
OrgEn: c.Org,
Postcode: c.Postcode,
Address: c.Address,
AddressEn: c.AddressEn,
PI: c.PI,
ASN: c.ASN,
RouteV4: c.RouteV4,
RouteV6: c.RouteV6,
IP: c.IP,
JPNICAdmin: c.JPNICAdmin,
JPNICTech: c.JPNICTech,
Open: c.Open,
Lock: c.Lock,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
12 changes: 10 additions & 2 deletions pkg/api/store/notice/v0/notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ func Update(base int, data notice.Notice) error {

if notice.UpdateAll == base {
result = db.Model(&notice.Notice{Model: gorm.Model{ID: data.ID}}).Update(notice.Notice{
UserID: data.UserID, GroupID: data.GroupID, StartTime: data.StartTime, EndingTime: data.EndingTime,
Important: data.Important, Fault: data.Fault, Info: data.Info, Title: data.Title, Data: data.Data})
UserID: data.UserID,
GroupID: data.GroupID,
StartTime: data.StartTime,
EndingTime: data.EndingTime,
Important: data.Important,
Fault: data.Fault,
Info: data.Info,
Title: data.Title,
Data: data.Data,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/store/support/chat/v0/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func Update(base int, s chat.Chat) error {
result = db.Model(&chat.Chat{Model: gorm.Model{ID: s.ID}}).Update(chat.Chat{UserID: s.UserID})
} else if chat.UpdateAll == base {
result = db.Model(&chat.Chat{Model: gorm.Model{ID: s.ID}}).Update(chat.Chat{
TicketID: s.TicketID, UserID: s.UserID, Admin: s.Admin, Data: s.Data})
TicketID: s.TicketID,
UserID: s.UserID,
Admin: s.Admin,
Data: s.Data,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
7 changes: 6 additions & 1 deletion pkg/api/store/support/ticket/v0/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ func Update(base int, t ticket.Ticket) error {
//#4 Issue(解決済み)
if ticket.UpdateAll == base {
result = db.Model(&ticket.Ticket{Model: gorm.Model{ID: t.ID}}).Update(&ticket.Ticket{Title: t.Title,
GroupID: t.GroupID, UserID: t.UserID, ChatIDStart: t.ChatIDStart, ChatIDEnd: t.ChatIDEnd, Solved: t.Solved})
GroupID: t.GroupID,
UserID: t.UserID,
ChatIDStart: t.ChatIDStart,
ChatIDEnd: t.ChatIDEnd,
Solved: t.Solved,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down
10 changes: 8 additions & 2 deletions pkg/api/store/token/v0/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ func Update(base int, t *token.Token) error {
err = db.Model(&token.Token{Model: gorm.Model{ID: t.ID}}).Update("expired_at", t.ExpiredAt).Error
} else if token.UpdateAll == base {
err = db.Model(&token.Token{Model: gorm.Model{ID: t.ID}}).Update(token.Token{
ExpiredAt: t.ExpiredAt, UserID: t.UserID, Status: t.Status, UserToken: t.UserToken, TmpToken: t.TmpToken,
AccessToken: t.AccessToken, Debug: t.Debug}).Error
ExpiredAt: t.ExpiredAt,
UserID: t.UserID,
Status: t.Status,
UserToken: t.UserToken,
TmpToken: t.TmpToken,
AccessToken: t.AccessToken,
Debug: t.Debug,
}).Error
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n %s", time.Now(), err)
Expand Down
52 changes: 44 additions & 8 deletions pkg/api/store/user/v0/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,27 @@ func Update(base int, u *user.User) error {
result = db.Model(&user.User{Model: gorm.Model{ID: u.ID}}).Update(user.User{MailVerify: u.MailVerify})
} else if user.UpdateInfo == base {
result = db.Model(&user.User{Model: gorm.Model{ID: u.ID}}).Update(user.User{
Name: u.Name, NameEn: u.NameEn, Email: u.Email, Pass: u.Pass, Tech: u.Tech, Level: u.Level,
MailVerify: u.MailVerify, MailToken: u.MailToken, Org: u.Org, OrgEn: u.OrgEn, PostCode: u.PostCode,
Address: u.Address, AddressEn: u.AddressEn, Dept: u.Dept, DeptEn: u.DeptEn, Pos: u.Pos, PosEn: u.PosEn,
Tel: u.Tel, Fax: u.Fax, Country: u.Country})
Name: u.Name,
NameEn: u.NameEn,
Email: u.Email,
Pass: u.Pass,
Tech: u.Tech,
Level: u.Level,
MailVerify: u.MailVerify,
MailToken: u.MailToken,
Org: u.Org,
OrgEn: u.OrgEn,
PostCode: u.PostCode,
Address: u.Address,
AddressEn: u.AddressEn,
Dept: u.Dept,
DeptEn: u.DeptEn,
Pos: u.Pos,
PosEn: u.PosEn,
Tel: u.Tel,
Fax: u.Fax,
Country: u.Country,
})
} else if user.UpdateStatus == base {
result = db.Model(&user.User{Model: gorm.Model{ID: u.ID}}).Update(user.User{Status: u.Status})
} else if user.UpdateGID == base {
Expand All @@ -67,10 +84,29 @@ func Update(base int, u *user.User) error {
result = db.Model(&user.User{Model: gorm.Model{ID: u.ID}}).Update("level", u.Level)
} else if user.UpdateAll == base {
result = db.Model(&user.User{Model: gorm.Model{ID: u.ID}}).Update(user.User{
GroupID: u.GroupID, Name: u.Name, NameEn: u.NameEn, Email: u.Email, Pass: u.Pass, Tech: u.Tech, Level: u.Level,
MailVerify: u.MailVerify, MailToken: u.MailToken, Org: u.Org, OrgEn: u.OrgEn, PostCode: u.PostCode,
Address: u.Address, AddressEn: u.AddressEn, Dept: u.Dept, DeptEn: u.DeptEn, Pos: u.Pos, PosEn: u.PosEn,
Tel: u.Tel, Fax: u.Fax, Country: u.Country, Status: u.Status})
GroupID: u.GroupID,
Name: u.Name,
NameEn: u.NameEn,
Email: u.Email,
Pass: u.Pass,
Tech: u.Tech,
Level: u.Level,
MailVerify: u.MailVerify,
MailToken: u.MailToken,
Org: u.Org,
OrgEn: u.OrgEn,
PostCode: u.PostCode,
Address: u.Address,
AddressEn: u.AddressEn,
Dept: u.Dept,
DeptEn: u.DeptEn,
Pos: u.Pos,
PosEn: u.PosEn,
Tel: u.Tel,
Fax: u.Fax,
Country: u.Country,
Status: u.Status,
})
} else {
log.Println("base select error")
return fmt.Errorf("(%s)error: base select\n", time.Now())
Expand Down

0 comments on commit 67c19e0

Please sign in to comment.