moved accounts to MVC directories
This commit is contained in:
parent
819ec891e7
commit
34dd280fba
|
@ -1,8 +1,8 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"arimelody-web/account/controller"
|
"arimelody-web/controller"
|
||||||
"arimelody-web/account/model"
|
"arimelody-web/model"
|
||||||
"arimelody-web/global"
|
"arimelody-web/global"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"arimelody-web/account/model"
|
"arimelody-web/model"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
@ -58,3 +59,13 @@ func DeleteAccount(db *sqlx.DB, accountID string) error {
|
||||||
_, err := db.Exec("DELETE FROM account WHERE id=$1", accountID)
|
_, err := db.Exec("DELETE FROM account WHERE id=$1", accountID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var inviteChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||||
|
|
||||||
|
func GenerateInviteCode(length int) []byte {
|
||||||
|
code := []byte{}
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
code = append(code, inviteChars[rand.Intn(len(inviteChars) - 1)])
|
||||||
|
}
|
||||||
|
return code
|
||||||
|
}
|
4
main.go
4
main.go
|
@ -9,11 +9,11 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"arimelody-web/account/model"
|
|
||||||
"arimelody-web/admin"
|
"arimelody-web/admin"
|
||||||
"arimelody-web/api"
|
"arimelody-web/api"
|
||||||
"arimelody-web/global"
|
"arimelody-web/global"
|
||||||
"arimelody-web/view"
|
"arimelody-web/view"
|
||||||
|
"arimelody-web/controller"
|
||||||
"arimelody-web/templates"
|
"arimelody-web/templates"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
@ -47,7 +47,7 @@ func main() {
|
||||||
accountsCount := 0
|
accountsCount := 0
|
||||||
global.DB.Get(&accountsCount, "SELECT count(*) FROM account")
|
global.DB.Get(&accountsCount, "SELECT count(*) FROM account")
|
||||||
if accountsCount == 0 {
|
if accountsCount == 0 {
|
||||||
code := model.GenerateInviteCode(8)
|
code := controller.GenerateInviteCode(8)
|
||||||
|
|
||||||
tx, err := global.DB.Begin()
|
tx, err := global.DB.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -42,13 +41,3 @@ const (
|
||||||
ReadArtists AccountPrivilege = "read_artists"
|
ReadArtists AccountPrivilege = "read_artists"
|
||||||
EditArtists AccountPrivilege = "edit_artists"
|
EditArtists AccountPrivilege = "edit_artists"
|
||||||
)
|
)
|
||||||
|
|
||||||
var inviteChars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
||||||
|
|
||||||
func GenerateInviteCode(length int) []byte {
|
|
||||||
code := []byte{}
|
|
||||||
for i := 0; i < length; i++ {
|
|
||||||
code = append(code, inviteChars[rand.Intn(len(inviteChars) - 1)])
|
|
||||||
}
|
|
||||||
return code
|
|
||||||
}
|
|
Loading…
Reference in a new issue