scrm-go

article_category_service.go 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package article_service
  2. import (
  3. "SCRM/models"
  4. "SCRM/service"
  5. )
  6. func FindArticleCategoryType (userOrgId int64)(*[]models.ArticleCategory,error){
  7. cartegory := &[]models.ArticleCategory{}
  8. err := service.PatientReadDB().Where("status = ? AND user_org_id = ? ", 1, userOrgId).Find(cartegory).Error
  9. return cartegory,err
  10. }
  11. func AddAritcle(articles models.Articles) error {
  12. err := service.PatientWriteDB().Create(&articles).Error
  13. return err
  14. }
  15. func FindAllArticle(orgID int64, page int, count int, searchKey string, classId int64) (articles *[]models.Articles,total int64, err error) {
  16. db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
  17. if(orgID>0){
  18. db.Where("a.user_org_id = ?" ,orgID)
  19. }
  20. if(classId>0){
  21. db = db.Joins("JOIN sgj_patient_articles_menu as s ON s.id = a.class_id AND s.status=1 AND user_org_id = ?")
  22. }
  23. if len(searchKey) > 0 {
  24. searchKey = "%" + searchKey + "%"
  25. db = db.Where("a.title LIKE ?", searchKey)
  26. }
  27. //err = db.Select("a.id,a.title,a.summary,a.content,a.type,a.num,a.mtime,a.real_read_num,a.ctime,a.class_id,a.author,a.status,a.reason" +
  28. // "a.star_num,a.comment_num,a.user_org_id,a.article_status,a.imgs,a.video_url,a.source,a.category_id,a.ttid,a.ttype,a.toid").Count(&total).Find(&articles).Error
  29. return
  30. }