代码拉取完成,页面将自动刷新
package controllers
import (
"fmt"
"gitee.com/aywc_1/aywc_judge/src/configuration"
"gitee.com/aywc_1/aywc_judge/src/models"
"gitee.com/aywc_1/aywc_judge/src/services"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/shenyisyn/goft-gin/goft"
log "github.com/sirupsen/logrus"
)
type RongCloudController struct {
Db *gorm.DB `inject:"-"`
RongCloudService *services.RongCloudService `inject:"-"`
//DeviceWarmService *services.DeviceWarmService `inject:"-"`
}
func (this *RongCloudController) Name() string {
return "RongCloudController"
}
func NewRongCloudController() *RongCloudController {
return &RongCloudController{}
}
func (this *RongCloudController) UploadRongcloudInfo(ctx *gin.Context) goft.Json {
form := &models.RongCloundAccountModel{}
if err := ctx.BindJSON(&form); err == nil {
if form.RcId == "" || form.RcName == "" || form.RcToken == "" {
panic(fmt.Sprintf("param lack "))
}
err := this.RongCloudService.RongCloudInfoUpload(form)
if err != nil {
log.Errorf("Failed err:%s\n", err.Error())
panic(fmt.Sprintf("Failed ,err:%s\n", err.Error()))
}
} else {
log.Errorf("Failed err:%s\n", err.Error())
panic(fmt.Sprintf("Failed ,err:%s\n", err.Error()))
}
return gin.H{"result": "success", "code": 200}
}
/**
1,融云的通讯token获取接口,YYD上传数据:设备id。A55下发数据:融云的通讯token
*/
func (this *RongCloudController) GetRongcloudTokenByDeviceId(ctx *gin.Context) goft.Json {
deviceId := ""
if deviceId = ctx.Query("device_id"); deviceId == "" {
panic(" params not find device_id")
}
appKey := configuration.GetYamlValue([]string{"config", "rongcloud", "web", "app-key"}, 0, "").(string)
appSecret := configuration.GetYamlValue([]string{"config", "rongcloud", "web", "app-secret"}, 0, "").(string)
token := this.RongCloudService.GetRongcloudTokenByDeviceId(deviceId, appKey, appSecret)
ret := gin.H{"result": "success", "code": 200, "data": token}
return ret
}
/**
2, APP扫码绑定设备接口,YYD上传数据:设备id,手机id。A55下发数据:是否绑定成功,手机端需要的融云通讯token等
*/
func (this *RongCloudController) GetRongcloudTokenByPhoneDeviceId(ctx *gin.Context) goft.Json {
deviceId := ""
phone := ""
if deviceId = ctx.Query("device_id"); deviceId == "" {
panic(" params not find device_id")
}
if phone = ctx.Query("phone"); phone == "" {
panic(" params not find phone")
}
appKey := configuration.GetYamlValue([]string{"config", "rongcloud", "web", "app-key"}, 0, "").(string)
appSecret := configuration.GetYamlValue([]string{"config", "rongcloud", "web", "app-secret"}, 0, "").(string)
token := this.RongCloudService.GetRongcloudTokenByPhoneDeviceId(deviceId, phone, appKey, appSecret)
ret := gin.H{"result": "success", "code": 200, "data": token}
return ret
}
func (this *RongCloudController) Build(goft *goft.Goft) {
goft.
Handle("POST", "/uploadRongcloudInfo", this.UploadRongcloudInfo).
Handle("GET", "/getRongcloudTokenByDeviceId", this.GetRongcloudTokenByDeviceId).
Handle("GET", "/getRongcloudTokenByPhoneDeviceId", this.GetRongcloudTokenByPhoneDeviceId)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。