update
parent
940cdfc0e7
commit
69868b476a
@ -0,0 +1,15 @@
|
||||
package models
|
||||
|
||||
import "goqs/global"
|
||||
|
||||
type AppPage struct {
|
||||
global.MODEL
|
||||
PkgName string `json:"pkg_name" gorm:"column:pkg_name;type:varchar(255);not null;comment:应用包名"`
|
||||
PageName string `json:"page_name" gorm:"column:page_name;type:varchar(255);not null;comment:应用页面名称"`
|
||||
Pf string `json:"pf" gorm:"column:pf;type:varchar(255);not null;comment:应用包名"`
|
||||
Count int `json:"count" gorm:"column:is_del;type:int(13);not null;comment:计数"`
|
||||
}
|
||||
|
||||
func (t *AppPage) TableName() string {
|
||||
return "app_pages"
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package monkey
|
||||
|
||||
import (
|
||||
"goqs/controllers"
|
||||
"goqs/dbsql"
|
||||
"goqs/models"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
// @Tags Monkey相关 /api/monkey/v1/
|
||||
// @Summary 上报Monkey应用页
|
||||
// @Description Android上报activity名
|
||||
// @accept x-www-form-urlencoded
|
||||
// @Param task_id formData int true "任务id"
|
||||
// @Param device_name formData string false "设备id"
|
||||
// @Param activity_name formData string false "页面名称"
|
||||
// @Success 200 {object} models.Response "返回更新后的任务信息"
|
||||
// @Router /api/monkey/v1/task/activity [post]
|
||||
func UploadPage(c *gin.Context) {
|
||||
rsp := controllers.NewResponse()
|
||||
|
||||
var res models.MonkeyActivity
|
||||
res.TaskId = cast.ToInt(c.PostForm("task_id"))
|
||||
if res.TaskId < 1 {
|
||||
rsp.Error("task_id error:" + c.PostForm("task_id"))
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
res.DeviceName = c.PostForm("device_name")
|
||||
if res.DeviceName == "" {
|
||||
rsp.Error("device_name不能为空")
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
res.ActivityName = c.PostForm("activity_name")
|
||||
if res.ActivityName == "" {
|
||||
rsp.Error("activity_name不能为空")
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
|
||||
db, err := dbsql.GetConn(dbsql.DSN)
|
||||
if err != nil {
|
||||
rsp.Error(err.Error())
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
return
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
db.Create(&res)
|
||||
if res.ID < 1 {
|
||||
rsp.Error("记录activity应用页失败")
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
return
|
||||
}
|
||||
|
||||
rsp.Success()
|
||||
rsp.Data = res
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
|
||||
// @Tags Monkey相关 /api/monkey/v1/
|
||||
// @Summary 获取覆盖页面列表
|
||||
// @Description 通过monkey任务id获取覆盖的活动页面
|
||||
// @accept x-www-form-urlencoded
|
||||
// @Param task_id query int true "任务id"
|
||||
// @Success 200 {object} models.Response "返回任务覆盖的活动页"
|
||||
// @Router /api/monkey/v1/task/activity [get]
|
||||
func GetPages(c *gin.Context) {
|
||||
rsp := controllers.NewResponse()
|
||||
|
||||
var list []models.MonkeyActivity
|
||||
db, err := dbsql.GetConn(dbsql.DSN)
|
||||
if err != nil {
|
||||
rsp.Error(err.Error())
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
return
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
db.Where("task_id = ?", c.Query("task_id")).Find(&list)
|
||||
|
||||
rsp.Success()
|
||||
rsp.Data = list
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
Loading…
Reference in New Issue