1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ad2info.go 708 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2024-04-30 10:12 . 调整xcron和xcache的目录结构
package xtype
import (
"errors"
"gitee.com/xiaoyutab/xgotool/individual/xcache"
)
// Adcode换取分类的详细信息
//
// type_code 分类的TypeCode值【五~六位数字】
func Code2info(type_code uint) (*Types, error) {
cache_key := xcache.Key("xtype.code2info", type_code)
cit := Types{}
if xcache.Exists(cache_key) {
if err := xcache.GetStruct(cache_key, &cit); err == nil {
return &cit, nil
}
}
if _default.DB == nil {
return nil, errors.New("数据库未连接")
}
cit.TypeCode = type_code
// 从数据库中进行读取
err := _default.DB.Table(_default.TypeName).Find(&cit).Error
if err != nil {
return nil, err
}
xcache.SetStruct(cache_key, cit)
return &cit, nil
}
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.13

搜索帮助