Update clan.go
This commit is contained in:
parent
43bb674197
commit
d7d592a2bd
@ -2,10 +2,10 @@ package v1
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"github.com/osuyozora/api/common"
|
||||
"sort"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type singleClan struct {
|
||||
@ -53,11 +53,11 @@ func ClansGET(md common.MethodData) common.CodeMessager {
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
type clanMembersData struct {
|
||||
common.ResponseBase
|
||||
Members []userNotFullResponseLmao `json:"members"`
|
||||
}
|
||||
|
||||
// get total stats of clan. later.
|
||||
type totalStats struct {
|
||||
common.ResponseBase
|
||||
@ -86,7 +86,7 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
rows *sql.Rows
|
||||
err error
|
||||
)
|
||||
rows, err = md.DB.Query("SELECT id, name, description, tag, icon FROM clans")
|
||||
rows, err = md.DB.Query("SELECT id, name, description, icon FROM clans")
|
||||
|
||||
if err != nil {
|
||||
md.Err(err)
|
||||
@ -95,9 +95,7 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
nc := clanLbSingle{}
|
||||
err = rows.Scan(&nc.ID, &nc.Name, &nc.Description, &nc.Tag, &nc.Icon)
|
||||
fmt.Println(rows)
|
||||
fmt.Println(&nc.Tag)
|
||||
err = rows.Scan(&nc.ID, &nc.Name, &nc.Description, &nc.Icon)
|
||||
if err != nil {
|
||||
md.Err(err)
|
||||
}
|
||||
@ -109,8 +107,12 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
}
|
||||
r.ResponseBase.Code = 200
|
||||
// anyone who ever looks into this, yes, i need to kill myself. ~Flame
|
||||
m := strconv.ParseInt(string(md.Query("m")[19]), 10, 64)
|
||||
m, brr := strconv.ParseInt(string(md.Query("m")[19]), 10, 64)
|
||||
|
||||
if brr != nil {
|
||||
fmt.Println(brr)
|
||||
m = 0
|
||||
}
|
||||
n := "std"
|
||||
if m == 1 {
|
||||
n = "taiko"
|
||||
@ -123,6 +125,7 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
}
|
||||
fmt.Println(n)
|
||||
|
||||
|
||||
for i := 0; i < len(r.Clans); i++ {
|
||||
var members clanMembersData
|
||||
|
||||
@ -141,9 +144,13 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
INNER JOIN users
|
||||
ON users.id = uc.user
|
||||
INNER JOIN users_stats ON users_stats.id = uc.user
|
||||
WHERE clan = ? AND privileges > 2
|
||||
WHERE clan = ? AND privileges & 1 = 1
|
||||
`, rid)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
members.Code = 200
|
||||
|
||||
if n == "std" {
|
||||
@ -183,12 +190,14 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
})
|
||||
|
||||
for i := 0; i < len(r.Clans); i++ {
|
||||
r.Clans[i].Rank = i + 1
|
||||
r.Clans[i].Rank = i+1
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
|
||||
func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
var (
|
||||
r megaStats
|
||||
@ -238,6 +247,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
}
|
||||
fmt.Println(n)
|
||||
|
||||
|
||||
for i := 0; i < len(r.Clans); i++ {
|
||||
var members clanMembersData
|
||||
|
||||
@ -310,7 +320,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
|
||||
})
|
||||
|
||||
for i := 0; i < len(r.Clans); i++ {
|
||||
r.Clans[i].Rank = i + 1
|
||||
r.Clans[i].Rank = i+1
|
||||
}
|
||||
b := totalStats{}
|
||||
for i := 0; i < len(r.Clans); i++ {
|
||||
@ -376,23 +386,15 @@ type imRetarded struct {
|
||||
common.ResponseBase
|
||||
Invite string `json:"invite"`
|
||||
}
|
||||
type adminClan struct {
|
||||
Id int `json:"user"`
|
||||
Perms int `json:"perms"`
|
||||
}
|
||||
|
||||
func ClanInviteGET(md common.MethodData) common.CodeMessager {
|
||||
// big perms check lol ok
|
||||
n := common.Int(md.Query("id"))
|
||||
adminRetard := adminClan{}
|
||||
|
||||
var r imRetarded
|
||||
var clan int
|
||||
// get user clan, then get invite
|
||||
md.DB.QueryRow("SELECT user, clan, perms FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&adminRetard.Id, &clan, &adminRetard.Perms)
|
||||
if adminRetard.Perms < 8 || adminRetard.Id != md.ID() {
|
||||
return common.SimpleResponse(500, "You are not admin of there clan")
|
||||
}
|
||||
md.DB.QueryRow("SELECT clan FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&clan)
|
||||
row := md.DB.QueryRow("SELECT invite FROM clans_invites WHERE clan = ? LIMIT 1", clan).Scan(&r.Invite)
|
||||
if row != nil {
|
||||
fmt.Println(row)
|
||||
|
Loading…
Reference in New Issue
Block a user