1 Star 0 Fork 0

小鱼儿小董子/dongli-platform

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dao.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
小鱼儿小董子 提交于 1个月前 . 1111
package model
import (
"gitee.com/wanjimao/dongli-kit/orm/nosql"
"gitee.com/wanjimao/dongli-kit/orm/nosql/diface"
"google.golang.org/protobuf/proto"
pb "gitee.com/wanjimao/dongli-platform/api/gen/profile/api"
)
type Dao struct {
nosql.DocumentBase `bson:"-"`
Data *pb.Profile `bson:"data"`
}
func (d *Dao) Init(id string, doc diface.ICollection, cache diface.ICache) error {
key, e := NewProfileKey(id)
if e != nil {
return e
}
d.initData()
d.DocumentBase.InitWithCache(&d.Data, d.clear, doc, key, cache)
return nil
}
func (d *Dao) ToProto() *pb.Profile {
return proto.Clone(d.Data).(*pb.Profile)
}
func (d *Dao) UpdateData(profile *pb.Profile) bool {
if profile.Nickname != "" {
d.Data.Nickname = profile.Nickname
}
if profile.Avatar != "" {
d.Data.Avatar = profile.Avatar
}
if profile.Phone != "" {
d.Data.Phone = profile.Phone
}
if profile.Email != "" {
d.Data.Email = profile.Email
}
if profile.RechargeAmount > 0 {
d.Data.RechargeAmount += profile.RechargeAmount
}
return true
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wanjimao/dongli-platform.git
git@gitee.com:wanjimao/dongli-platform.git
wanjimao
dongli-platform
dongli-platform
v0.0.13

搜索帮助