You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.5 KiB
78 lines
1.5 KiB
package handler |
|
|
|
import ( |
|
"server/call" |
|
"server/common" |
|
"server/modules/backend/app" |
|
"server/modules/backend/bdb" |
|
"server/modules/backend/values" |
|
"server/util" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
func ProductList(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
products := call.GetConfigPayProduct() |
|
resp := &values.ProductListResp{List: products} |
|
a.Data = resp |
|
} |
|
|
|
func ChannelList(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
ret := call.GetChannelList() |
|
if ret == nil { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
resp := values.ChannelListResp{} |
|
resp.List = make([]*common.Channel, 0) |
|
for _, v := range ret { |
|
if len(a.User.SChannels) > 0 { |
|
if !util.SliceContain(a.User.SChannels, v.ChannelID) { |
|
continue |
|
} |
|
} |
|
resp.List = append(resp.List, v) |
|
} |
|
a.Data = resp |
|
} |
|
|
|
func UserInfo(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
resp := values.UserInfoResp{Name: a.User.Name, Role: a.User.Role, Power: a.User.Power} |
|
a.Data = resp |
|
} |
|
|
|
func AccountList(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
ret := call.GetChannelList() |
|
if ret == nil { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
resp := &values.AccountListResp{} |
|
a.Data = resp |
|
list := []values.User{} |
|
if err := bdb.BackDB.C().Find(&list).Error; err != nil { |
|
log.Error("err:%v", err) |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
for _, v := range list { |
|
resp.List = append(resp.List, v.Account) |
|
} |
|
}
|
|
|