parent
4db28f5c0b
commit
6cc5e042d5
@ -1,32 +0,0 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
# goff-db:
|
||||
# image: postgres
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# volumes:
|
||||
# - "${PWD}/postgres.conf:/etc/postgresql/postgresql.conf"
|
||||
# - "goff-db:/var/lib/postgresql/data:rw"
|
||||
# env_file: ${PWD}/.env
|
||||
|
||||
goff:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: "${PWD}/Dockerfile"
|
||||
env_file: ${PWD}/.env
|
||||
logging:
|
||||
driver: awslogs
|
||||
options:
|
||||
awslogs-region: us-east-1
|
||||
awslogs-group: "/docker/goff/production"
|
||||
# depends_on:
|
||||
# - goff-db
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable
|
||||
# links:
|
||||
# - goff-db:goff.db
|
||||
|
||||
#volumes:
|
||||
# goff-db:
|
||||
# external: true
|
||||
@ -1,32 +0,0 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
# goff-db:
|
||||
# image: postgres
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# volumes:
|
||||
# - "${PWD}/postgres.conf:/etc/postgresql/postgresql.conf"
|
||||
# - "goff-db:/var/lib/postgresql/data:rw"
|
||||
# env_file: ${PWD}/.env
|
||||
|
||||
goff:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: "${PWD}/Dockerfile"
|
||||
env_file: ${PWD}/.env
|
||||
# logging:
|
||||
# driver: awslogs
|
||||
# options:
|
||||
# awslogs-region: us-east-1
|
||||
# awslogs-group: "/docker/goff/production"
|
||||
# depends_on:
|
||||
# - goff-db
|
||||
environment:
|
||||
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable
|
||||
# links:
|
||||
# - goff-db:goff.db
|
||||
|
||||
#volumes:
|
||||
# goff-db:
|
||||
# external: true
|
||||
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import "database/sql"
|
||||
|
||||
type Guild struct {
|
||||
ID string
|
||||
WelcomeMessage string
|
||||
GoodbyeMessage string
|
||||
LoggingChannel string
|
||||
WelcomeChannel string
|
||||
PuzzleChannel string
|
||||
PuzzleRole sql.NullString
|
||||
}
|
||||
|
||||
type GuildService interface {
|
||||
Guild(id string) (*Guild, error)
|
||||
Guilds() ([]*Guild, error)
|
||||
CreateGuild(g *Guild) error
|
||||
DeleteGuild(g *Guild) error
|
||||
GuildUsers(g *Guild) ([]*User, error)
|
||||
UpdateGuild(g *Guild) error
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package utils
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
@ -1,4 +1,4 @@
|
||||
package utils
|
||||
package postgres
|
||||
|
||||
import "log"
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/dustinpianalto/goff"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
DB *sql.DB
|
||||
}
|
||||
|
||||
func (s *UserService) User(id string) (*goff.User, error) {
|
||||
var u goff.User
|
||||
queryString := `SELECT id, banned, logging, steam_id, is_active, is_staff, is_admin
|
||||
FROM users WHERE id=$1`
|
||||
row := s.DB.QueryRow(queryString, id)
|
||||
if err := row.Scan(&u.ID, &u.Banned, &u.Logging, &u.SteamID, &u.IsActive, &u.IsStaff, &u.IsAdmin); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var guilds []string
|
||||
queryString = `SELECT guild_id from x_users_guilds WHERE user_id=$1`
|
||||
rows, err := s.DB.Query(queryString, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
var guildID string
|
||||
err = rows.Scan(&guildID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
guilds = append(guilds, guildID)
|
||||
}
|
||||
u.Guilds = guilds
|
||||
return &u, nil
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/local/bin/docker-compose build || exit
|
||||
/usr/local/bin/docker-compose up -d
|
||||
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Banned bool
|
||||
Logging bool
|
||||
SteamID string
|
||||
IsActive bool
|
||||
IsStaff bool
|
||||
IsAdmin bool
|
||||
Guilds []string
|
||||
}
|
||||
|
||||
type UserService interface {
|
||||
User(id string) (*User, error)
|
||||
CreateUser(u *User) error
|
||||
DeleteUser(u *User) error
|
||||
MarkUserInactive(u *User) error
|
||||
AddUserToGuild(u *User, g *Guild) error
|
||||
RemoveUserFromGuild(u *User, g *Guild) error
|
||||
UpdateUser(u *User) error
|
||||
}
|
||||
Loading…
Reference in new issue