123456789101112131415161718192021222324252627 |
- package wechat_service
-
- import (
- "SCRM/models"
- "SCRM/service"
- )
-
- func SaveMaterial(m *models.WechatMedias) (err error) {
- err = service.PatientWriteDB().Save(m).Error
- return err
- }
-
- func FindMeterialsByMediaIDs(orgID int64, mediaType string, mediaIDs []string) (medias []models.WechatMedias, err error) {
- err = service.PatientReadDB().Model(&models.WechatMedias{}).Where("media_id IN (?) and user_org_id=? AND msgtype=? and media_status=1", mediaIDs, orgID, mediaType).Limit(len(mediaIDs)).Find(&medias).Error
- return
- }
-
- func GetPageMaterials(orgID, page, limit int64, mediaType string) (medias []*models.WechatMedias, total int64, err error) {
- db := service.PatientReadDB().Model(&models.WechatMedias{}).Where("user_org_id=? and msgtype=? and media_status=1", orgID, mediaType)
-
- offset := (page - 1) * limit
-
- err = db.Count(&total).Order("id desc").Offset(offset).Limit(limit).Find(&medias).Error
-
- return
- }
|