FILE / Unmei/Backend
v1/club_sql.go
Исходный файл и его история в репозитории.
22 lines
727 B
Go
22 lines
727 B
Go
package v1
|
|
|
|
type Club struct {
|
|
ID uint16 `json:"id"`
|
|
Name string `json:"name"`
|
|
Avatar string `json:"avatar"`
|
|
Owner int `json:"-"`
|
|
IsPrivate bool `json:"is_private" db:"is_private"`
|
|
}
|
|
|
|
func GetClubs(userId uint64) ([]*Club, error) {
|
|
clubs := make([]*Club, 0)
|
|
err := database.Select(&clubs, "select clubs.* from clubs join club_member cm on clubs.id = cm.club_id where not is_private or cm.user_id=$1;", userId)
|
|
return clubs, err
|
|
}
|
|
|
|
func GetClub(id uint16, userId uint64) (*Club, error) {
|
|
club := new(Club)
|
|
err := database.Get(club, "select clubs.* from clubs join club_member cm on clubs.id = cm.club_id where club_id=$1 and (not is_private or cm.user_id=$2);", id, userId)
|
|
return club, err
|
|
}
|