The Go Programming Language
› http://golang.org/
› Go Playground
Go Projects
› Revel Web Framework
mikurasa

想问问 gorm 的封装库有没有搞头

  •  
  •   mikurasa ·
    Germiniku · Sep 8, 2023 · 2361 views
    This topic created in 1151 days ago, the information mentioned may be changed or developed.
    gin 框架 controller 层总会定义个结构体去接收请求参数,把结构体透传到 dao 层,dao 层自己根据 tag 去过滤,免去写一堆垃圾 if
    type QueryFruits struct {
    Fruit string `json:"fruit" filter:"column:fruit;operator:like"`
    }
    d.Model(&Fruit{}).Scopes(func (db *gorm.DB) *gorm.DB){
    scope := xxxx()
    return db.Where(scope)
    }
    11 replies  •  2023-09-15 17:48:16 +08:00
    PiersSoCool
    PiersSoCool
    Sep 8, 2023
    1
    没有 gpt 会帮你写好
    vitoliu
    vitoliu
    Sep 9, 2023
    2
    go-mapper 不就完事儿了
    bianxiaoxian
    bianxiaoxian
    Sep 9, 2023
    3
    我自己项目就封装了一下,gorm 封装的像 MyBatisPlus 那样,根据泛型,组合,用起来挺爽的
    wheeler
    wheeler
    Sep 9, 2023 via iPhone
    4
    这样只适合简单的逻辑吧。explicit is better than implicit 。
    learningman
    learningman
    Sep 9, 2023 via Android
    5
    快进到被注入
    Nazz
    Nazz
    Sep 9, 2023 via Android
    6
    这个满足你需求吗

    https://github.com/lxzan/fi
    mikurasa
    mikurasa
    OP
    Sep 10, 2023
    7
    @Nazz 酷 我的想法也是和这个差不多
    flyv2x
    flyv2x
    Sep 12, 2023
    8
    ent 框架很好用
    mikurasa
    mikurasa
    OP
    Sep 12, 2023
    9
    Nazz
    Nazz
    Sep 12, 2023
    10
    @mikurasa 做完之后发现我更喜欢非反射的姿势
    ace12
    ace12
    Sep 15, 2023 via Android
    11
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5015 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 09:08 · PVG 17:08 · LAX 01:08 · JFK 04:08
    ♥ Do have faith in what you're doing.