home_service.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 GetCreator(id int64, orgid int64) (models.SgjUserAdminRole, error) {
  15. role := models.SgjUserAdminRole{}
  16. err := UserReadDB().Model(&role).Where("admin_user_id = ? and org_id = ? and status =1", id, orgid).Find(&role).Error
  17. return role, err
  18. }
  19. func GetSuperAdmin(id int64) (models.SgjUserAdmin, error) {
  20. admin := models.SgjUserAdmin{}
  21. err := UserReadDB().Model(&admin).Where("id=? and status =1", id).Find(&admin).Error
  22. return admin, err
  23. }
  24. func GetAllApp(org_id int64) (apps []*models.OrgApp, err error) {
  25. err = readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND pid > 0 AND org_id = ?", org_id).Order("number asc").Find(&apps).Error
  26. return
  27. }
  28. func GetSystemBanner() (banners []*models.VMAdminBanner, err error) {
  29. err = readUserDb.Model(&models.VMAdminBanner{}).Where("status = 1 ").Find(&banners).Error
  30. return
  31. }