home_service.go 813B

1234567891011121314151617181920212223242526
  1. package service
  2. import (
  3. "XT_New/models"
  4. "github.com/jinzhu/gorm"
  5. )
  6. func GetHomeData(adminUserId int64) (adminUser models.VMAdminUser, err error) {
  7. err = readUserDb.Model(&models.VMAdminUser{}).Where("status = 1 AND id = ?", adminUserId).
  8. Preload("Org", "status = 1").
  9. Preload("VMApp_Role", func(db *gorm.DB) *gorm.DB {
  10. return db.Preload("Org", "status = 1").Where("status = 1")
  11. }).Find(&adminUser).Error
  12. return
  13. }
  14. func GetAllApp(org_id int64) (apps []*models.OrgApp, err error) {
  15. err = readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND pid > 0 AND org_id = ?", org_id).Order("number asc").Find(&apps).Error
  16. return
  17. }
  18. func GetSystemBanner() (banners []*models.VMAdminBanner, err error) {
  19. err = readUserDb.Model(&models.VMAdminBanner{}).Where("status = 1 ").Find(&banners).Error
  20. return
  21. }