附近小店
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

db_cloud_bundle.go 2.6 KiB

2ヶ月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/md"
  5. "errors"
  6. "fmt"
  7. "github.com/gin-gonic/gin"
  8. "xorm.io/xorm"
  9. )
  10. // GetCloudBundleByVersion is 根据版本 获取打包记录
  11. func GetCloudBundleByVersion(Db *xorm.Engine, appverison string, os, ep int) (*model.CloudBundle, error) {
  12. m := new(model.CloudBundle)
  13. has, err := Db.Where("version = ? and os = ? and template_during_audit<>'' and ep=?", appverison, os, ep).Get(m)
  14. if err != nil {
  15. return nil, err
  16. }
  17. if !has {
  18. return nil, errors.New("not Found")
  19. }
  20. return m, nil
  21. }
  22. // GetCloudBundleByVersionPlatform is 根据版本\os 获取打包记录
  23. func GetCloudBundleByVersionPlatform(Db *xorm.Engine, appverison string, platform string, appType string) (*model.CloudBundle, error) {
  24. m := new(model.CloudBundle)
  25. var tag int
  26. var ep = 0
  27. if platform == "ios" {
  28. tag = 2
  29. } else {
  30. tag = 1
  31. }
  32. if appType == "daogou" || appType == "" {
  33. ep = 0
  34. } else {
  35. ep = 1
  36. }
  37. has, err := Db.Where("version = ? and os=? and ep=?", appverison, tag, ep).Desc("build_number").Get(m)
  38. if err != nil {
  39. return nil, err
  40. }
  41. if !has {
  42. return nil, errors.New("not Found")
  43. }
  44. return m, nil
  45. }
  46. // GetCloudBundleByVersionPlatformWithAudit is 根据版本\os 获取打包记录
  47. func GetCloudBundleByVersionPlatformWithAudit(Db *xorm.Engine, appverison string, platform string, appType string) (*model.CloudBundle, error) {
  48. m := new(model.CloudBundle)
  49. var tag int
  50. var ep = 0
  51. if platform == "ios" {
  52. tag = 2
  53. } else {
  54. tag = 1
  55. }
  56. if appType == "daogou" || appType == "" {
  57. ep = 0
  58. } else {
  59. ep = 1
  60. }
  61. has, err := Db.Where("version = ? and os=? and ep=? and template_during_audit<>''", appverison, tag, ep).Desc("build_number").Get(m)
  62. if err != nil {
  63. return nil, err
  64. }
  65. if !has {
  66. return nil, errors.New("not Found")
  67. }
  68. return m, nil
  69. }
  70. func GetCloudBuild(c *gin.Context, platform string) string {
  71. appVersion := c.GetHeader("app_version_name")
  72. ep := 0
  73. if c.GetString("app_type") != "" && c.GetString("app_type") != "daogou" {
  74. ep = 1
  75. }
  76. if platform == "" {
  77. platform = c.GetHeader("platform")
  78. }
  79. version := ""
  80. os := 0
  81. switch platform {
  82. case md.PLATFORM_ANDROID:
  83. if ep == 1 {
  84. version = SysCfgGet(c, "biz_android_audit_version")
  85. } else {
  86. version = SysCfgGet(c, "android_audit_version")
  87. }
  88. os = 1
  89. case md.PLATFORM_IOS:
  90. if ep == 1 {
  91. version = SysCfgGet(c, "biz_ios_audit_version")
  92. } else {
  93. version = SysCfgGet(c, "ios_audit_version")
  94. }
  95. os = 2
  96. }
  97. var data model.CloudBundle
  98. get, err := DBs[c.GetString("mid")].Where("is_auditing=1 and os=? and ep=? and version=?", os, ep, appVersion).Get(&data)
  99. fmt.Println(get)
  100. fmt.Println(err)
  101. if data.Version != "" {
  102. version = data.Version
  103. }
  104. return version
  105. }