voucher/internal/data
李子铭 107ed2cae0 notice 2025-03-14 14:36:27 +08:00
..
mixrepoimpl test 2025-03-13 18:59:30 +08:00
model test 2025-03-13 20:51:22 +08:00
repoimpl notice 2025-03-14 14:36:27 +08:00
wechatrepoimpl notice 2025-03-14 14:36:27 +08:00
README.md init 2025-03-03 14:49:28 +08:00
db.go init 2025-03-03 14:49:28 +08:00
gorm.go init 2025-03-03 14:49:28 +08:00
mq.go cmb 2025-03-07 16:28:59 +08:00
mq_test.go cmb 2025-03-08 14:20:19 +08:00
provider_set.go init 2025-03-03 14:49:28 +08:00
rds.go init 2025-03-03 14:49:28 +08:00
wechat.go add 查询回调地址接口,设置回调通知i接口 2025-03-13 16:42:20 +08:00
wechat_test.go cmb 2025-03-06 16:12:33 +08:00

README.md

Data

与外部交互的基础层:包含 数据库、Redis、MQ 等

如何编写数据库的dao

  1. 注入 data *Data
  2. 获取 Db 对象时,禁止直接取属性,必须使用 GetDb 方法,此方法解析了上下文 Context 中是否开启了事务

事务的使用

var err error
err = Exec(ctx, func(ctx context.Context) error {
    err = GoodsCreate(ctx)
    if err != nil {
        return err
    }
    return GoodsCashCreate(ctx)
})