2 Star 0 Fork 1

taotechip/modules

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
repo.go 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
kyugao 提交于 2025-04-02 17:36 +08:00 . 2.0_alpha
package wxapp
import (
"errors"
"gitee.com/taotechip/modules/database"
"gorm.io/gorm"
)
type wxappRepo struct {
database.GeneralRepo
}
func WxappRepo(transactionalConn *gorm.DB) (repo *wxappRepo) {
repo = database.NewRepo(transactionalConn, &wxappRepo{})
return
}
func (repo *wxappRepo) FindWechatAccountByOpenId(openId string) (account *WechatAccount, err error) {
account = &WechatAccount{}
err = repo.GetConn().Where("open_id = ?", openId).First(account).Error
return
}
func (repo *wxappRepo) FindWechatAccountByUnionId(unionId string) (account *WechatAccount, err error) {
account = &WechatAccount{}
err = repo.GetConn().Where("union_id = ?", unionId).First(account).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, nil
}
return
}
func (repo *wxappRepo) FindWechatAccountByAccountId(accountId string) (account *WechatAccount, err error) {
account = &WechatAccount{}
err = repo.GetConn().Where("account_id = ?", accountId).First(account).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, nil
}
return
}
func (repo *wxappRepo) CreateWechatAccount(account *WechatAccount) error {
return repo.GetConn().Create(account).Error
}
func (repo *wxappRepo) UpdateWechatAccount(account *WechatAccount, columns ...string) error {
return repo.GetConn().Model(account).Select(columns).Updates(account).Error
}
func (repo *wxappRepo) DeleteWechatAccount(id string) error {
return repo.GetConn().Delete(&WechatAccount{}, id).Error
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/taotechip/modules.git
git@gitee.com:taotechip/modules.git
taotechip
modules
modules
v1.10.5

搜索帮助