update
parent
69868b476a
commit
1090ed797a
@ -0,0 +1,53 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"goqs/dbsql"
|
||||
"goqs/models"
|
||||
"strings"
|
||||
|
||||
"github.com/imroc/req/v3"
|
||||
)
|
||||
|
||||
var ACCRSS_KEY = "muZd08g0_A4ucMCz"
|
||||
|
||||
func GetProduct(product_name string, pf string) (models.Product, error) {
|
||||
var p models.Product
|
||||
db, err := dbsql.GetConn(dbsql.DSN)
|
||||
if err != nil {
|
||||
return p, err
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
|
||||
db.Model(models.Product{}).Where("name = ? AND platform = ?", product_name, pf).Last(&p)
|
||||
if db.Error != nil {
|
||||
return p, db.Error
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func GetBranch(pkg_name string, pkg_url string) (ApkInfo, error) {
|
||||
var _app ApkInfo
|
||||
_strs := strings.Split(pkg_url, "/")
|
||||
filename := _strs[len(_strs)-1]
|
||||
var rsp RespGetApkInfo
|
||||
client := req.C()
|
||||
_, err := client.R().
|
||||
SetSuccessResult(&rsp).
|
||||
SetQueryParam("access_key", ACCRSS_KEY).
|
||||
SetQueryParam("pkg_name", pkg_name).
|
||||
SetQueryParam("pageIndex", "1").
|
||||
SetQueryParam("pageSize", "200").
|
||||
SetQueryParam("sortBy", "utime").
|
||||
SetQueryParam("orderBy", "DESC").
|
||||
Get("http://8.214.100.26:8048/api/app-version/get-apk-list")
|
||||
if err != nil {
|
||||
return _app, err
|
||||
}
|
||||
for _, v := range rsp.Data {
|
||||
if v.Name == filename {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
return _app, errors.New("没有匹配到对应的包信息")
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package common
|
||||
|
||||
type RespGetApkInfo struct {
|
||||
IsSuccess bool `json:"isSuccess"`
|
||||
Data []ApkInfo `json:"data"`
|
||||
PageIndex int `json:"pageIndex"`
|
||||
PageSize int `json:"pageSize"`
|
||||
Total int `json:"total"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
type ApkInfo struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PkgName string `json:"pkg_name"`
|
||||
Version string `json:"version"`
|
||||
Pf string `json:"pf"`
|
||||
Title string `json:"title"`
|
||||
Status int `json:"status"`
|
||||
ChangeLog interface{} `json:"change_log"`
|
||||
PromotionTitle interface{} `json:"promotion_title"`
|
||||
PromotionBanner interface{} `json:"promotion_banner"`
|
||||
Ctime int `json:"ctime"`
|
||||
Utime int `json:"utime"`
|
||||
BuildNum int `json:"build_num"`
|
||||
AttachmentOld string `json:"attachment_old"`
|
||||
AppLog interface{} `json:"app_log"`
|
||||
Branch string `json:"branch"`
|
||||
VirusLink string `json:"virus_link"`
|
||||
Size string `json:"size"`
|
||||
SizeLink string `json:"size_link"`
|
||||
DefaultPub interface{} `json:"default_pub"`
|
||||
Rabit interface{} `json:"rabit"`
|
||||
ButtonAction int `json:"button_action"`
|
||||
ButtonText string `json:"button_text"`
|
||||
Offset int `json:"offset"`
|
||||
Len int `json:"len"`
|
||||
Md5 string `json:"md5"`
|
||||
PkgType string `json:"pkg_type"`
|
||||
PkgSubType string `json:"pkg_sub_type"`
|
||||
HostVer interface{} `json:"host_ver"`
|
||||
LastHostVer interface{} `json:"last_host_ver"`
|
||||
SignVer int `json:"sign_ver"`
|
||||
IsLite int `json:"is_lite"`
|
||||
Attachment string `json:"attachment"`
|
||||
VersionCode string `json:"version_code"`
|
||||
Anm string `json:"anm"`
|
||||
Extra string `json:"extra"`
|
||||
OriginalApk string `json:"original_apk"`
|
||||
Abi string `json:"abi"`
|
||||
IsPressureTag int `json:"is_pressure_tag"`
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"goqs/dbsql"
|
||||
)
|
||||
|
||||
type notify struct {
|
||||
ID int `json:"id" gorm:"column:id"`
|
||||
Section string `json:"section" gorm:"column:section"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
Token string `json:"token" gorm:"column:token"`
|
||||
Secret string `json:"secret" gorm:"column:secret"`
|
||||
IsDel int `json:"-" gorm:"column:is_del"`
|
||||
}
|
||||
|
||||
func (t *notify) TableName() string {
|
||||
return "notify"
|
||||
}
|
||||
|
||||
func GetNotifyConfig(section, name string) (notify, error) {
|
||||
db, err := dbsql.GetConn(dbsql.DSN)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
var n notify
|
||||
db.Model(notify{}).Where("section = ? AND name = ?", section, name).Last(&n)
|
||||
if n.ID < 1 {
|
||||
return n, errors.New("没找到对应的通知设置")
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
type App struct {
|
||||
Id int `json:"id" gorm:"column:id;type:int(11);primary_key;not null;autoIncrement;comment:主键"`
|
||||
AppName string `json:"app_name" gorm:"column:app_name"`
|
||||
Project string `json:"project" gorm:"column:project;type:varchar(255);not null;comment:项目名"`
|
||||
Product string `json:"product" gorm:"column:product"`
|
||||
PackageName string `json:"package_name" gorm:"column:package_name;type:varchar(255);not null;comment:应用包名"`
|
||||
LaunchActivity string `json:"launch_activity" gorm:"column:launch_activity;type:varchar(255);comment:启动Activity页"`
|
||||
Platform string `json:"platform" gorm:"column:platform"`
|
||||
CreateTime int `json:"create_time" gorm:"column:create_time;type:int(11);not null;autoCreateTime;comment:创建时间"`
|
||||
UpdateTime int `json:"update_time" gorm:"column:update_time;type:int(11);not null;autoUpdateTime;comment:更新时间"`
|
||||
IsDel int `json:"is_del" gorm:"column:is_del;type:int(1);not null;comment:是否已删除"`
|
||||
}
|
||||
|
||||
func (t *App) TableName() string {
|
||||
return "app"
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Product struct {
|
||||
Id int `json:"id" gorm:"column:id;type:int(11);primary_key;not null;autoIncrement;comment:主键"`
|
||||
ProjectId int `json:"product_id" gorm:"column:product_id"`
|
||||
ProductLine string `json:"product_line" gorm:"column:product_line"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
PackageName string `json:"package_name" gorm:"column:package_name;type:varchar(255);not null;comment:应用包名"`
|
||||
LaunchActivity string `json:"launch_activity" gorm:"column:launch_activity;type:varchar(255);comment:启动Activity页"`
|
||||
Platform string `json:"platform" gorm:"column:platform"`
|
||||
CreateTime time.Time `json:"create_time" gorm:"column:create_time;not null;autoCreateTime;comment:创建时间"`
|
||||
UpdateTime time.Time `json:"update_time" gorm:"column:update_time;not null;autoUpdateTime;comment:更新时间"`
|
||||
IsDel int `json:"is_del" gorm:"column:is_del;type:int(1);not null;comment:是否已删除"`
|
||||
}
|
||||
|
||||
func (t *Product) TableName() string {
|
||||
return "products"
|
||||
}
|
||||
@ -1,84 +1,28 @@
|
||||
package monkey
|
||||
|
||||
import (
|
||||
"goqs/controllers"
|
||||
"goqs/dbsql"
|
||||
"goqs/models"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// @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
|
||||
func countPage(p models.AppPage, db *gorm.DB) error {
|
||||
if db == nil {
|
||||
db, err := dbsql.GetConn(dbsql.DSN)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
}
|
||||
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
|
||||
db.Table(p.TableName()).Model(models.AppPage{}).Where("product = ? AND page_name = ?", p.Product, p.PageName).Last(&p)
|
||||
if p.ID == 0 {
|
||||
p.Count = 1
|
||||
db.Create(&p)
|
||||
return nil
|
||||
}
|
||||
defer dbsql.Close(db)
|
||||
db.Where("task_id = ?", c.Query("task_id")).Find(&list)
|
||||
p.Count += 1
|
||||
db.Where("id = ?", p.ID).Update("count", p.Count)
|
||||
|
||||
rsp.Success()
|
||||
rsp.Data = list
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue