作者 yangfu

版本更新修改

@@ -107,6 +107,8 @@ spec: @@ -107,6 +107,8 @@ spec:
107 value: "false" 107 value: "false"
108 - name: HTTP_PORT 108 - name: HTTP_PORT
109 value: "8082" 109 value: "8082"
  110 + - name: SUPLUS_ADMIN_BASE_HOST
  111 + value: "http://suplus-admin-base-test.fjmaimaimai.com"
110 - name: ALLIED_CREATION_GATEWAY_HOST 112 - name: ALLIED_CREATION_GATEWAY_HOST
111 value: "https://allied-creation-gateway-test.fjmaimaimai.com" 113 value: "https://allied-creation-gateway-test.fjmaimaimai.com"
112 - name: ALLIED_CREATION_USER_HOST 114 - name: ALLIED_CREATION_USER_HOST
@@ -369,7 +369,7 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in @@ -369,7 +369,7 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
369 loginToken := domain.LoginToken{} 369 loginToken := domain.LoginToken{}
370 err := loginToken.ParseToken(switchOrgCommand.Operator.Token) 370 err := loginToken.ParseToken(switchOrgCommand.Operator.Token)
371 if err != nil { 371 if err != nil {
372 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error()) 372 + return nil, domain.NewApplicationError(domain.InvalidAccessToken)
373 } 373 }
374 loginToken.OrgId = switchOrgCommand.OrgId 374 loginToken.OrgId = switchOrgCommand.OrgId
375 token, err := svr.getToken(loginToken) 375 token, err := svr.getToken(loginToken)
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "net/http"
  7 +)
  8 +
  9 +type GetLatestVersionQuery struct {
  10 + //操作人
  11 + //操作人
  12 + //Operator domain.Operator `json:"-"`
  13 + DeviceType string `json:"-"`
  14 + VersionNo int `json:"versionNo"`
  15 + Channel int `json:"channel"`
  16 + Request *http.Request `json:"-"`
  17 +}
  18 +
  19 +func (departmentsUsersQuery *GetLatestVersionQuery) Valid(validation *validation.Validation) {
  20 +
  21 +}
  22 +
  23 +func (departmentsUsersQuery *GetLatestVersionQuery) ValidateQuery() error {
  24 + valid := validation.Validation{}
  25 + b, err := valid.Valid(departmentsUsersQuery)
  26 + if err != nil {
  27 + return err
  28 + }
  29 + if !b {
  30 + for _, validErr := range valid.Errors {
  31 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  32 + }
  33 + }
  34 + return nil
  35 +}
@@ -4,6 +4,9 @@ import ( @@ -4,6 +4,9 @@ import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
5 ) 5 )
6 6
  7 +const IOSPage = "http://fir.fjmaimaimai.com/pdvn"
  8 +const ANDPage = "http://fir.fjmaimaimai.com/ben1"
  9 +
7 type CommonService struct { 10 type CommonService struct {
8 } 11 }
9 12
@@ -67,22 +70,48 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti @@ -67,22 +70,48 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
67 } 70 }
68 71
69 //LatestVersionInfo 版本升级 72 //LatestVersionInfo 版本升级
70 -func (srv *CommonService) LatestVersionInfo() (interface{}, error) { 73 +func (srv *CommonService) LatestVersionInfo(q *query.GetLatestVersionQuery) (interface{}, error) {
  74 + page := IOSPage
  75 + if q.DeviceType == "1" { // 安卓
  76 + page = ANDPage
  77 + }
71 return map[string]interface{}{ 78 return map[string]interface{}{
72 "version": map[string]interface{}{ 79 "version": map[string]interface{}{
73 - "downloadPage": "www.baidu.com",  
74 - "downloadFile": "test.iso", 80 + "downloadPage": page,
  81 + "downloadFile": "",
75 "updateType": 0, 82 "updateType": 0,
76 }, 83 },
77 }, nil 84 }, nil
  85 + //vs:= version_server.NewHttpLibVersionServer()
  86 + //data,err:= vs.GetLatestVersion(q.Request,version_server.ReqLatestVersion{
  87 + // VersionNo: q.VersionNo,
  88 + // Channel: q.Channel,
  89 + //})
  90 + //if err != nil {
  91 + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  92 + //}
  93 + //return data, nil
78 } 94 }
79 95
80 //AppSharing 获取分享链接地址 96 //AppSharing 获取分享链接地址
81 -func (srv *CommonService) AppSharing() (interface{}, error) { 97 +func (srv *CommonService) AppSharing(q *query.GetLatestVersionQuery) (interface{}, error) {
  98 + page := IOSPage
  99 + if q.DeviceType == "1" { // 安卓
  100 + page = ANDPage
  101 + }
82 return map[string]interface{}{ 102 return map[string]interface{}{
83 "version": map[string]interface{}{ 103 "version": map[string]interface{}{
84 - "downloadPage": "www.baidu.com",  
85 - "downloadFile": "test.iso", 104 + "downloadPage": page,
  105 + "downloadFile": "",
86 }, 106 },
87 }, nil 107 }, nil
  108 + //vs:= version_server.NewHttpLibVersionServer()
  109 + //data,err:= vs.GetLatestVersion(q.Request,version_server.ReqLatestVersion{
  110 + // VersionNo: q.VersionNo,
  111 + // Channel: q.Channel,
  112 + //})
  113 + //if err != nil {
  114 + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  115 + //}
  116 + //return data, nil
88 } 117 }
@@ -25,6 +25,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio @@ -25,6 +25,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio
25 //天联共创业务模块 25 //天联共创业务模块
26 var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com" 26 var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"
27 27
  28 +// 版本更新模块
  29 +var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-test.fjmaimaimai.com"
  30 +
28 //通用模块短信服务 31 //通用模块短信服务
29 var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897" 32 var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897"
30 33
@@ -38,6 +41,9 @@ func init() { @@ -38,6 +41,9 @@ func init() {
38 if os.Getenv("LOG_TYPE") != "" { 41 if os.Getenv("LOG_TYPE") != "" {
39 LOG_TYPE = os.Getenv("LOG_TYPE") 42 LOG_TYPE = os.Getenv("LOG_TYPE")
40 } 43 }
  44 + if os.Getenv("SUPLUS_ADMIN_BASE_HOST") != "" {
  45 + ALLIED_CREATION_GATEWAY_HOST = os.Getenv("SUPLUS_ADMIN_BASE_HOST")
  46 + }
41 if os.Getenv("ALLIED_CREATION_GATEWAY_HOST") != "" { 47 if os.Getenv("ALLIED_CREATION_GATEWAY_HOST") != "" {
42 ALLIED_CREATION_GATEWAY_HOST = os.Getenv("ALLIED_CREATION_GATEWAY_HOST") 48 ALLIED_CREATION_GATEWAY_HOST = os.Getenv("ALLIED_CREATION_GATEWAY_HOST")
43 } 49 }
  1 +package version_server
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "net/http"
  7 + "time"
  8 +
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
  10 +
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
  12 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  13 +)
  14 +
  15 +//公共短信服务模块
  16 +type HttpLibVersionServer struct {
  17 + service_gateway.BaseServiceGateway
  18 + baseUrL string
  19 +}
  20 +
  21 +func NewHttpLibVersionServer() *HttpLibVersionServer {
  22 + return &HttpLibVersionServer{
  23 + BaseServiceGateway: service_gateway.BaseServiceGateway{
  24 + ConnectTimeout: 100 * time.Second,
  25 + ReadWriteTimeout: 30 * time.Second,
  26 + },
  27 + baseUrL: constant.SUPLUS_ADMIN_BASE_HOST,
  28 + }
  29 +
  30 +}
  31 +
  32 +//SendSms 公共短信验证码服务 发送验证码
  33 +func (gateway HttpLibVersionServer) GetLatestVersion(rc *http.Request, param ReqLatestVersion) (*DataLatestVersion, error) {
  34 + url := gateway.baseUrL + "/version/getLatestVersionInfo"
  35 + method := "post"
  36 + req := gateway.CreateRequest(url, method)
  37 + //TODO traceID
  38 + log.Logger.Debug("向版本管理请求数据:搜索用户列表。", map[string]interface{}{
  39 + "api": method + ":" + url,
  40 + "param": param,
  41 + })
  42 + req, err := req.JSONBody(param)
  43 + if err != nil {
  44 + return nil, fmt.Errorf("搜索版本失败:%w", err)
  45 + }
  46 + for k, vs := range rc.Header {
  47 + for i := range vs {
  48 + req.Header(k, vs[i])
  49 + }
  50 + }
  51 +
  52 + byteResult, err := req.Bytes()
  53 + if err != nil {
  54 + return nil, fmt.Errorf("获取版本失败:%w", err)
  55 + }
  56 +
  57 + fmt.Println(string(byteResult))
  58 + var result service_gateway.GatewayResponse
  59 + err = json.Unmarshal(byteResult, &result)
  60 + if err != nil {
  61 + return nil, fmt.Errorf("解析版本:%w", err)
  62 + }
  63 + var data DataLatestVersion
  64 + err = gateway.GetResponseData(result, &data)
  65 + return &data, err
  66 +}
  1 +package version_server
  2 +
  3 +type (
  4 + ReqLatestVersion struct {
  5 + VersionNo int `json:"versionNo"`
  6 + Channel int `json:"channel"`
  7 + }
  8 +
  9 + DataLatestVersion map[string]interface{}
  10 +)
@@ -2,9 +2,6 @@ package controllers @@ -2,9 +2,6 @@ package controllers
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "io"  
6 - "path/filepath"  
7 -  
8 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
9 "github.com/linmadan/egglib-go/utils/json" 6 "github.com/linmadan/egglib-go/utils/json"
10 "github.com/linmadan/egglib-go/web/beego" 7 "github.com/linmadan/egglib-go/web/beego"
@@ -12,6 +9,8 @@ import ( @@ -12,6 +9,8 @@ import (
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
  12 + "io"
  13 + "path/filepath"
15 ) 14 )
16 15
17 type BaseController struct { 16 type BaseController struct {
@@ -3,13 +3,13 @@ package controllers @@ -3,13 +3,13 @@ package controllers
3 import ( 3 import (
4 "io/ioutil" 4 "io/ioutil"
5 5
6 - "github.com/linmadan/egglib-go/web/beego" 6 + //"github.com/linmadan/egglib-go/web/beego"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
9 ) 9 )
10 10
11 type CommonController struct { 11 type CommonController struct {
12 - beego.BaseController 12 + BaseController
13 } 13 }
14 14
15 func (controller *CommonController) GetDictionaryByCode() { 15 func (controller *CommonController) GetDictionaryByCode() {
@@ -22,17 +22,21 @@ func (controller *CommonController) GetDictionaryByCode() { @@ -22,17 +22,21 @@ func (controller *CommonController) GetDictionaryByCode() {
22 22
23 func (controller *CommonController) LatestVersionInfo() { 23 func (controller *CommonController) LatestVersionInfo() {
24 commonService := service.NewCommonService(nil) 24 commonService := service.NewCommonService(nil)
25 - queryParam := &query.GetDictionaryByCodeQuery{} 25 + queryParam := &query.GetLatestVersionQuery{}
26 _ = controller.Unmarshal(queryParam) 26 _ = controller.Unmarshal(queryParam)
27 - data, err := commonService.LatestVersionInfo() 27 + queryParam.Request = controller.Ctx.Request
  28 + queryParam.DeviceType = controller.GetDeviceType()
  29 + data, err := commonService.LatestVersionInfo(queryParam)
28 controller.Response(data, err) 30 controller.Response(data, err)
29 } 31 }
30 32
31 func (controller *CommonController) AppSharing() { 33 func (controller *CommonController) AppSharing() {
32 commonService := service.NewCommonService(nil) 34 commonService := service.NewCommonService(nil)
33 - queryParam := &query.GetDictionaryByCodeQuery{} 35 + queryParam := &query.GetLatestVersionQuery{}
34 _ = controller.Unmarshal(queryParam) 36 _ = controller.Unmarshal(queryParam)
35 - data, err := commonService.AppSharing() 37 + queryParam.Request = controller.Ctx.Request
  38 + queryParam.DeviceType = controller.GetDeviceType()
  39 + data, err := commonService.AppSharing(queryParam)
36 controller.Response(data, err) 40 controller.Response(data, err)
37 } 41 }
38 42