Merge pull request #125 from Eric-Guo/doc_update

Document update
This commit is contained in:
zhuyasen
2025-08-08 21:20:26 +08:00
committed by GitHub
9 changed files with 34 additions and 31 deletions

View File

@@ -176,7 +176,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExa
}
// GetByColumns get a paginated list of userExamples by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
queryStr, args, err := params.ConvertToGormConditions(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {

View File

@@ -182,7 +182,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExa
}
// GetByColumns get a paginated list of userExamples by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
queryStr, args, err := params.ConvertToGormConditions(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {
@@ -226,7 +226,7 @@ func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []uint64) error {
}
// GetByCondition get a userExample by custom condition
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html#_2-condition-parameters-optional
func (d *userExampleDao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.UserExample, error) {
queryStr, args, err := c.ConvertToGorm(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {

View File

@@ -188,7 +188,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Contex
}
// GetByColumns get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *{{.TableNameCamelFCL}}Dao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.{{.TableNameCamel}}, int64, error) {
if params.Sort == "" {
params.Sort = "-{{.ColumnName}}"
@@ -235,7 +235,7 @@ func (d *{{.TableNameCamelFCL}}Dao) DeleteBy{{.ColumnNamePluralCamel}}(ctx conte
}
// GetByCondition get a {{.TableNameCamelFCL}} by custom condition
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html#_2-condition-parameters-optional
func (d *{{.TableNameCamelFCL}}Dao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.{{.TableNameCamel}}, error) {
queryStr, args, err := c.ConvertToGorm(query.WithWhitelistNames(model.{{.TableNameCamel}}ColumnNames))
if err != nil {

View File

@@ -194,7 +194,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExa
}
// GetByColumns get a paginated list of userExamples by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
filter, err := params.ConvertToMongoFilter(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {

View File

@@ -199,7 +199,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExa
}
// GetByColumns get a paginated list of userExamples by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
filter, err := params.ConvertToMongoFilter(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {
@@ -252,7 +252,7 @@ func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []string) error {
}
// GetByCondition get a userExample by custom condition.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html#_2-condition-parameters-optional
func (d *userExampleDao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.UserExample, error) {
filter, err := c.ConvertToMongo(query.WithWhitelistNames(model.UserExampleColumnNames))
if err != nil {

View File

@@ -182,7 +182,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Contex
}
// GetByColumns get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions.
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
func (d *{{.TableNameCamelFCL}}Dao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.{{.TableNameCamel}}, int64, error) {
if params.Sort == "" {
params.Sort = "-{{.ColumnName}}"

View File

@@ -204,6 +204,7 @@ func (h *{{.TableNameCamelFCL}}Handler) GetBy{{.ColumnNameCamel}}(c *gin.Context
}
// List get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
// @Summary Get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions
// @Description Returns a paginated list of {{.TableNamePluralCamelFCL}} based on query filters, including page number and size.
// @Tags {{.TableNameCamelFCL}}

View File

@@ -198,6 +198,7 @@ func (h *{{.TableNameCamelFCL}}Handler) GetBy{{.ColumnNameCamel}}(c *gin.Context
}
// List get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions
// For more details, please refer to https://go-sponge.com/component/data/custom-page-query.html
// @Summary Get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions
// @Description Returns a paginated list of {{.TableNamePluralCamelFCL}} based on query filters, including page number and size.
// @Tags {{.TableNameCamelFCL}}

View File

@@ -11,10 +11,10 @@ import "github.com/go-dev-frame/sponge/pkg/app"
func main() {
initApp()
servers := registerServers()
closes := registerCloses(servers)
services := CreateServices()
closes := Close(services)
a := app.New(servers, closes)
a := app.New(services, closes)
a.Run()
}
@@ -28,39 +28,40 @@ func initApp() {
// ......
}
func registerServers() []app.IServer {
func CreateServices() []app.IServer {
var servers []app.IServer
// create a http service
servers = append(servers, server.NewHTTPServer(
// create an HTTP service
httpAddr := ":8080" // or get from configuration
httpServer := server.NewHTTPServer(
httpAddr,
server.WithHTTPIsProd(true), // run in release mode
)
servers = append(servers, httpServer)
))
// create a grpc service
servers = append(servers, server.NewGRPCServer(
))
// ......
// create a gRPC service (optional)
// grpcServer := server.NewGRPCServer(
//
// )
// servers = append(servers, grpcServer)
return servers
}
func registerCloses(servers []app.IServer) []app.Close {
func Close(servers []app.IServer) []app.Close {
var closes []app.Close
// close server
for _, server := range servers {
closes = append(closes, server.Stop)
// close servers
for _, s := range servers {
closes = append(closes, s.Stop)
}
// close other resource
// close other resources (database, logger, tracing, etc.)
closes = append(closes, func() error {
// TODO: call db.Close()
return nil
})
// ......
return closes
}
```