12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package wechat_service
-
- import (
- "SCRM/models"
- "SCRM/service"
-
- "github.com/jinzhu/gorm"
- )
-
- //GetAuthorizationByOnlyAppID 通过appid取信息
- func GetAuthorizationByOnlyAppID(appid string) (*models.PatientAuthorizations, error) {
- var authorizationinfo models.PatientAuthorizations
- var err error
- err = service.PatientReadDB().Model(&models.PatientAuthorizations{}).Where("authorizer_appid=? and authorizer_status=1", appid).First(&authorizationinfo).Error
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- }
- if err != nil {
- return nil, err
- }
- return &authorizationinfo, nil
- }
-
- //GetAuthorizationByAppID 通过appid取信息
- func GetAuthorizationByAppID(orgID int64, appid string) (*models.PatientAuthorizations, error) {
- var authorizationinfo models.PatientAuthorizations
- var err error
- err = service.PatientReadDB().Model(&models.PatientAuthorizations{}).Where(" user_org_id=? and authorizer_appid=? and authorizer_status=1", orgID, appid).First(&authorizationinfo).Error
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- }
- if err != nil {
- return nil, err
- }
- return &authorizationinfo, nil
- }
-
- //GetAuthorizationByOrgID 通过orgid取信息
- func GetAuthorizationByOrgID(orgID int64) (*models.PatientAuthorizations, error) {
- var authorizationinfo models.PatientAuthorizations
- var err error
- err = service.PatientReadDB().Model(&models.PatientAuthorizations{}).Where("user_org_id=?", orgID).First(&authorizationinfo).Error
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- }
- if err != nil {
- return nil, err
- }
- return &authorizationinfo, nil
- }
-
- func SaveWechatComponentVerifyTicket(id int64, componentVerifyTicket string) (err error) {
- err = service.PatientWriteDB().Model(&models.WechatComponents{}).Where("id=?", id).Update(map[string]interface{}{"ComponentVerifyTicket": componentVerifyTicket}).Error
- return
- }
-
- func SaveWechatComponentInfoByMap(id int64, info map[string]interface{}) (err error) {
- err = service.PatientWriteDB().Model(&models.WechatComponents{}).Where("id=?", id).Update(info).Error
- return
- }
-
- func SaveAuthorizerStatusByAppID(appID string, status int64) (err error) {
- err = service.PatientWriteDB().Model(&models.PatientAuthorizations{}).Where("authorizer_appid=?", appID).Update(map[string]interface{}{"AuthorizerStatus": status}).Error
- return
- }
-
- func SaveAuthorizationInfo(authorization *models.PatientAuthorizations) (err error) {
- err = service.PatientWriteDB().Model(&models.PatientAuthorizations{}).Save(&authorization).Error
- return
- }
-
- func GetAuthorizations() (mps []*models.PatientAuthorizations, err error) {
- err = service.PatientReadDB().Where("authorizer_status = 1").Find(&mps).Error
- return
- }
|