123456789101112131415161718192021222324252627282930313233343536373839 |
- package article_service
-
- import (
- "SCRM/models"
- "SCRM/service"
- )
-
- func FindArticleCategoryType (userOrgId int64)(*[]models.ArticleCategory,error){
- cartegory := &[]models.ArticleCategory{}
- err := service.PatientReadDB().Where("status = ? AND user_org_id = ? ", 1, userOrgId).Find(cartegory).Error
- return cartegory,err
- }
-
- func AddAritcle(articles models.Articles) error {
- err := service.PatientWriteDB().Create(&articles).Error
- return err
- }
-
- func FindAllArticle(orgID int64, page int, count int, searchKey string, classId int64) (articles *[]models.Articles,total int64, err error) {
-
- db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
- if(orgID>0){
- db.Where("a.user_org_id = ?" ,orgID)
- }
-
- if(classId>0){
- db = db.Joins("JOIN sgj_patient_articles_menu as s ON s.id = a.class_id AND s.status=1 AND user_org_id = ?")
- }
-
- if len(searchKey) > 0 {
- searchKey = "%" + searchKey + "%"
- db = db.Where("a.title LIKE ?", searchKey)
- }
-
- //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" +
- // "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
-
- return
- }
|