本文整理汇总了Golang中github.com/ctripcorp/nephele/imgws/models.Config类的典型用法代码示例。如果您正苦于以下问题:Golang Config类的具体用法?Golang Config怎么用?Golang Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initFdfsClient
func (this *FdfsStorage) initFdfsClient() util.Error {
if fdfsClient == nil {
lock <- 1
defer func() {
<-lock
}()
if fdfsClient != nil {
return util.Error{}
}
config := models.Config{Cat: this.Cat}
fdfsdomain, e := config.GetFdfsDomain()
if e.Err != nil {
return e
}
fdfsport, e := config.GetFdfsPort()
if e.Err != nil {
return e
}
var err error
fdfsClient, err = fdfs.NewFdfsClient([]string{fdfsdomain}, fdfsport)
if err != nil {
util.LogErrorEvent(this.Cat, ERRORTYPE_FDFSCONNECTIONERR, err.Error())
return util.Error{IsNormal: false, Err: err, Type: ERRORTYPE_FDFSCONNECTIONERR}
}
}
return util.Error{}
}
开发者ID:chenbk85,项目名称:nephele,代码行数:27,代码来源:storage.go
示例2: Get
// @router /config/get/ [get]
func (this *ConfigController) Get() {
channel := this.GetString("channel")
key := this.GetString("key")
config := models.Config{}
m, e := config.GetConfigs()
if e.Err != nil {
this.Ctx.WriteString(fmt.Sprintf("%v", e.Err))
}
var result interface{}
if channel != "" {
m1, exists := m[channel]
if !exists {
this.Ctx.WriteString("No record")
return
}
if key != "" {
m2, exists := m1[key]
if !exists {
this.Ctx.WriteString("No record")
return
}
result = m2
} else {
result = m1
}
} else {
result = m
}
bts, err := json.Marshal(result)
if err != nil {
this.Ctx.WriteString(err.Error())
} else {
this.Ctx.WriteString(string(bts))
}
}
开发者ID:chenbk85,项目名称:nephele,代码行数:36,代码来源:configcontroller.go
示例3: Add
// @router /config/add/ [get]
func (this *ConfigController) Add() {
channel := this.GetString("channel")
key := this.GetString("key")
value := this.GetString("value")
config := models.Config{ChannelCode: channel, Key: key, Value: value}
err := config.Insert()
if err != nil {
this.Ctx.WriteString(err.Error())
} else {
this.Ctx.WriteString("sucess")
}
}
开发者ID:chenbk85,项目名称:nephele,代码行数:13,代码来源:configcontroller.go
示例4: Update
// @router /config/update/ [get]
func (this *ConfigController) Update() {
channel := this.GetString("channel")
key := this.GetString("key")
value := this.GetString("value")
if channel == "" || key == "" {
this.Ctx.WriteString("params is invalid")
return
}
config := models.Config{ChannelCode: channel, Key: key, Value: value}
err := config.UpdateValue()
if err != nil {
this.Ctx.WriteString(err.Error())
} else {
this.Ctx.WriteString("sucess")
}
}
开发者ID:chenbk85,项目名称:nephele,代码行数:17,代码来源:configcontroller.go
示例5: Add
// @router /whitelist/add/ [get]
func (c *WhitelistController) Add() {
channel := c.GetString("channel")
isMatch, err := regexp.Match(TgPattern, []byte(channel))
if err != nil {
//err
c.Ctx.WriteString(err.Error())
return
}
if !isMatch {
//ErrIllegalChannel
c.Ctx.WriteString(ErrIllegalChannel.Error())
return
}
size := c.GetString("size")
isMatch, err = regexp.Match(SizePattern, []byte(size))
if err != nil {
//err
c.Ctx.WriteString(err.Error())
return
}
if !isMatch {
//ErrIllegalSize
c.Ctx.WriteString(ErrIllegalSize.Error())
return
}
var conf models.Config = models.Config{
ChannelCode: channel,
Key: "sizes",
}
err = conf.AddSize(size)
if err != nil {
//err
c.Ctx.WriteString(conf.Value)
c.Ctx.WriteString(err.Error())
return
}
c.Ctx.WriteString(conf.Value)
}
开发者ID:chenbk85,项目名称:nephele,代码行数:40,代码来源:whitelistcontroller.go
示例6: Upload
func (this *FdfsStorage) Upload(bts []byte, fileExt string) (string, util.Error) {
if e := this.initFdfsClient(); e.Err != nil {
return "", e
}
config := models.Config{Cat: this.Cat}
groups, e := config.GetGroups()
if e.Err != nil {
return "", e
}
if uploadcount == 99999999 {
uploadcount = 0
}
i := uploadcount % len(groups)
uploadcount = 0
g := groups[i]
var result util.Error = util.Error{}
if this.Cat != nil {
tran := this.Cat.NewTransaction(CATTITLE, "Fdfs.Upload")
util.LogEvent(this.Cat, "Size", util.GetImageSizeDistribution(len(bts)), map[string]string{"size": strconv.Itoa(len(bts))})
defer func() {
if result.Err != nil && result.IsNormal {
tran.SetStatus(result.Err)
} else {
tran.SetStatus("0")
}
tran.Complete()
}()
}
path, err := fdfsClient.UploadByBuffer(g, bts, fileExt)
if err != nil {
util.LogErrorEvent(this.Cat, ERRORTYPE_FDFSUPLOADERR, err.Error())
result = util.Error{IsNormal: false, Err: err, Type: ERRORTYPE_FDFSUPLOADERR}
return "", result
}
return path, result
}
开发者ID:chenbk85,项目名称:nephele,代码行数:38,代码来源:storage.go
示例7: GetSizes
// @router /whitelist/getsizes/ [get]
func (c *WhitelistController) GetSizes() {
channel := c.GetString("channel")
isMatch, err := regexp.Match(TgPattern, []byte(channel))
if err != nil {
c.Ctx.WriteString(err.Error())
return
}
if !isMatch {
//ErrIllegalChannel
c.Ctx.WriteString(ErrIllegalChannel.Error())
return
}
var conf models.Config = models.Config{
ChannelCode: channel,
Key: "sizes",
}
sizes, err := conf.GetSizes()
if err != nil {
c.Ctx.WriteString(err.Error())
return
}
c.Ctx.WriteString(sizes)
}
开发者ID:chenbk85,项目名称:nephele,代码行数:24,代码来源:whitelistcontroller.go
注:本文中的github.com/ctripcorp/nephele/imgws/models.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论