feat(*): go 后端项目脚手架
This commit is contained in:
19
internal/service/utils.go
Normal file
19
internal/service/utils.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zhilv666/navsite/pkg/config"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func columnName(name string) string {
|
||||
if config.GetConfig().Database.Driver == "postgres" {
|
||||
return fmt.Sprintf(`"%s"`, name)
|
||||
}
|
||||
return fmt.Sprintf("`%s`", name)
|
||||
}
|
||||
|
||||
func addStorageOrder(db *gorm.DB) *gorm.DB {
|
||||
return DB().Order(fmt.Sprintf("%s, %s", columnName("order"), columnName("id")))
|
||||
}
|
||||
Reference in New Issue
Block a user