mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
applying go fmt
This commit is contained in:
parent
97f7239be1
commit
ffb0d1b8a5
@ -111,14 +111,14 @@ func ParamAgentToken(r *http.Request, detail bool) (*store.Account, int, error)
|
|||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if app.Account.Disabled {
|
if app.Account.Disabled {
|
||||||
@ -146,14 +146,14 @@ func BearerAppToken(r *http.Request, detail bool) (*store.Account, int, error) {
|
|||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
if err := store.DB.Preload("Account").Where("account_id = ? AND token = ?", target, access).First(&app).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if app.Account.Disabled {
|
if app.Account.Disabled {
|
||||||
@ -209,14 +209,14 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
|
|||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := store.DB.Preload("CardSlot").Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
if err := store.DB.Preload("CardSlot").Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if card.Account.Disabled {
|
if card.Account.Disabled {
|
||||||
@ -247,14 +247,14 @@ func BearerContactToken(r *http.Request, detail bool) (*store.Card, int, error)
|
|||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := store.DB.Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
if err := store.DB.Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
}
|
}
|
||||||
return nil, http.StatusInternalServerError, err
|
return nil, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if card.Account.Disabled {
|
if card.Account.Disabled {
|
||||||
|
@ -64,4 +64,3 @@ func ParseRequest(r *http.Request, w http.ResponseWriter, obj interface{}) error
|
|||||||
dec.DisallowUnknownFields()
|
dec.DisallowUnknownFields()
|
||||||
return dec.Decode(&obj)
|
return dec.Decode(&obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ func ErrMsg(err error) {
|
|||||||
|
|
||||||
//LogMsg prints detailed error string
|
//LogMsg prints detailed error string
|
||||||
func LogMsg(msg string) {
|
func LogMsg(msg string) {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
p, _ := os.Getwd()
|
p, _ := os.Getwd()
|
||||||
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
log.Printf("%s:%d %s", strings.TrimPrefix(file, p), line, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
//PrintMsg prints debug message
|
//PrintMsg prints debug message
|
||||||
|
@ -445,4 +445,3 @@ type TopicDetail struct {
|
|||||||
|
|
||||||
Transform string `json:"transform,omitempty"`
|
Transform string `json:"transform,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user