|
|
|
|
@ -4,17 +4,48 @@ import (
|
|
|
|
|
"autogo/dbsql"
|
|
|
|
|
"autogo/models"
|
|
|
|
|
"net/http"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// @Tags 设置相关 /api/setting/v2/
|
|
|
|
|
// @Summary 新建设备
|
|
|
|
|
// @Description 新建设备,UDID唯一
|
|
|
|
|
// @Summary 获取bugly凭据
|
|
|
|
|
// @Description 获取bugly凭据
|
|
|
|
|
// @accept x-www-form-urlencoded
|
|
|
|
|
// @Success 200 {object} models.Response "返回存储的bugly凭据"
|
|
|
|
|
// @Router /api/setting/v2/get_bugly_token [get]
|
|
|
|
|
func GetBuglyToken(c *gin.Context) {
|
|
|
|
|
rsp := NewResponse()
|
|
|
|
|
|
|
|
|
|
db, err := dbsql.GetConn(dbsql.DSN)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.JSON(http.StatusOK, rsp.Error(err.Error()))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
defer dbsql.Close(db)
|
|
|
|
|
|
|
|
|
|
var m1, m2 models.SysMap
|
|
|
|
|
db.Model(models.SysMap{}).Where("name = ? AND `key` = ?", "bugly-login", "xtoken").Last(&m1)
|
|
|
|
|
db.Model(models.SysMap{}).Where("name = ? AND `key` = ?", "bugly-login", "session").Last(&m2)
|
|
|
|
|
|
|
|
|
|
m := make(map[string]string)
|
|
|
|
|
m["xtoken"] = m1.Value
|
|
|
|
|
m["session"] = m2.Value
|
|
|
|
|
location, _ := time.LoadLocation("Asia/Shanghai")
|
|
|
|
|
m["update_time"] = m1.UpdateTime.Local().In(location).Format("2006-01-02 15:04:05")
|
|
|
|
|
|
|
|
|
|
rsp.Data = m
|
|
|
|
|
c.JSON(http.StatusOK, rsp.Success())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Tags 设置相关 /api/setting/v2/
|
|
|
|
|
// @Summary 更新Bugly凭据
|
|
|
|
|
// @Description 更新Bugly凭据
|
|
|
|
|
// @accept x-www-form-urlencoded
|
|
|
|
|
// @Param xtoken formData string true "bugly请求header:XToken"
|
|
|
|
|
// @Param session formData string true "bugly请求cookies:bugly-session"
|
|
|
|
|
// @Success 200 {object} models.Response "返回创建后的设备信息"
|
|
|
|
|
// @Success 200 {object} models.Response "返回接收的凭据"
|
|
|
|
|
// @Router /api/setting/v2/update_bugly_token [post]
|
|
|
|
|
func UpdateBuglyToken(c *gin.Context) {
|
|
|
|
|
rsp := NewResponse()
|
|
|
|
|
|