Categorygithub.com/uozi-tech/cosy
modulepackage
1.14.2
Repository: https://github.com/uozi-tech/cosy.git
Documentation: pkg.go.dev

# README

Cosy - Golang Web API 框架助手

a Comfortable Object-oriented Simplified framework for You

Designed by @0xJacky 2024

Cosy 是一个方便的工具,基于泛型,面相对象,旨在简化基于 Gin 框架并使用 Gorm 作为 ORM 的 Web API 的创建、更新和列出数据库记录的过程。

目标是简化繁琐重复的 CURD 过程,并且对 ChatGPT 友好。

特点

  1. 链式方法: 为 CRUD 操作轻松设置各种查询条件和配置
  2. 基本生命周期: BeforeDecode, BeforeExecute, GormAction, Executed
  3. 钩子: 提供在主要 CRUD 操作之前和之后执行函数的能力
    • map 转换为 struct 前的钩子 BeforeDecodeHook(hook ...func(ctx *Ctx[T]) *Ctx[T]
    • 数据库操作执行前的钩子 BeforeExecuteHook(hook ...func(ctx *Ctx[T]) *Ctx[T]
    • 数据库执行时的钩子 GormScope(hook func(tx *gorm.DB) *gorm.DB) *Ctx[T]
    • 数据库执行后的钩子 ExecutedHook(hook ...func(ctx *Ctx[T])) *Ctx[T]
    • 钩子的设置函数可以被多次调用,将会按照调用顺序执行
  4. 性能:尽最大努力优化,减少反射使用

数据库驱动支持

文档

https://cosy.uozi.org/

在项目中使用

go get -u github.com/uozi-tech/cosy

版权

Copyright © 2024 UoziTech

Cosy 版权属于柚子星云科技(深圳)有限公司,并已取得软件著作权。

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Api returns a new instance of Curd.
No description provided by the author
Boot the server.
No description provided by the author
ErrHandler error handler for external use.
GetEngine returns the gin engine.
GetPagingParams get paging params.
GetValidator returns the validator instance.
InitDB init db.
NewError create a new error.
No description provided by the author
NewErrorWithParams create a new error with params.
No description provided by the author
RegisterCronJob registers a cron job.
RegisterGoroutine Register syncs functions, this function should be called before kernel boot.
RegisterInitFunc Register init functions, this function should be called before kernel boot.
RegisterMigration Register a migration.
RegisterModels register models.
SetListener Set the listener.
UseDB return the ptr of gorm.DB.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author