enterprise/common/dao/dao.go

49 lines
666 B
Go
Raw Normal View History

2023-08-04 18:27:37 +08:00
package dao
import "gorm.io/gorm"
var (
2024-11-04 23:00:55 +08:00
db *gorm.DB
unifyDB *gorm.DB
2025-03-05 11:42:29 +08:00
corpDB *gorm.DB
2023-08-04 18:27:37 +08:00
)
2025-03-14 16:39:33 +08:00
type CountValue struct {
Key string `json:"key"`
Name string `json:"name"`
Value int64 `json:"value"`
}
type SortCountValue []*CountValue
func (a SortCountValue) Len() int {
return len(a)
}
func (a SortCountValue) len() int {
return len(a)
}
func (a SortCountValue) Swap(i, j int) {
a[i], a[j] = a[j], a[i]
}
func (a SortCountValue) Less(i, j int) bool {
return a[i].Value > a[j].Value
}
2023-08-04 18:27:37 +08:00
func SetDB(d *gorm.DB) {
db = d
}
2024-11-04 23:00:55 +08:00
func SetUnifyDB(d *gorm.DB) {
unifyDB = d
}
2025-03-05 11:42:29 +08:00
func SetCorpDB(d *gorm.DB) {
corpDB = d
}
2024-11-04 23:00:55 +08:00
2023-08-04 18:27:37 +08:00
func GetDB() *gorm.DB {
return db
}