voucher/internal/data
李子铭 77ed8f70cf 拓展参数字段 2025-03-17 11:11:57 +08:00
..
mixrepoimpl notice 2025-03-14 16:04:37 +08:00
model test 2025-03-13 20:51:22 +08:00
repoimpl 拓展参数字段 2025-03-17 09:14:59 +08:00
wechatrepoimpl 自定义错误 2025-03-15 13:52:48 +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 notice 2025-03-14 20:18:10 +08:00
wechat_test.go 拓展参数字段 2025-03-17 11:11:57 +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)
})