Worked on anonymous access
This commit is contained in:
@@ -10,13 +10,14 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
bus.AddHandler("sql", GetAccount)
|
||||
bus.AddHandler("sql", GetAccountById)
|
||||
bus.AddHandler("sql", CreateAccount)
|
||||
bus.AddHandler("sql", SetUsingAccount)
|
||||
bus.AddHandler("sql", UpdateAccount)
|
||||
bus.AddHandler("sql", GetAccountByName)
|
||||
}
|
||||
|
||||
func GetAccount(query *m.GetAccountByIdQuery) error {
|
||||
func GetAccountById(query *m.GetAccountByIdQuery) error {
|
||||
var account m.Account
|
||||
exists, err := x.Id(query.Id).Get(&account)
|
||||
if err != nil {
|
||||
@@ -31,6 +32,21 @@ func GetAccount(query *m.GetAccountByIdQuery) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAccountByName(query *m.GetAccountByNameQuery) error {
|
||||
var account m.Account
|
||||
exists, err := x.Where("name=?", query.Name).Get(&account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return m.ErrAccountNotFound
|
||||
}
|
||||
|
||||
query.Result = &account
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateAccount(cmd *m.CreateAccountCommand) error {
|
||||
return inTransaction(func(sess *xorm.Session) error {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user