作者 yangfu

版本更新修改

... ... @@ -107,6 +107,8 @@ spec:
value: "false"
- name: HTTP_PORT
value: "8082"
- name: SUPLUS_ADMIN_BASE_HOST
value: "http://suplus-admin-base-test.fjmaimaimai.com"
- name: ALLIED_CREATION_GATEWAY_HOST
value: "https://allied-creation-gateway-test.fjmaimaimai.com"
- name: ALLIED_CREATION_USER_HOST
... ...
... ... @@ -369,7 +369,7 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
loginToken := domain.LoginToken{}
err := loginToken.ParseToken(switchOrgCommand.Operator.Token)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error())
return nil, domain.NewApplicationError(domain.InvalidAccessToken)
}
loginToken.OrgId = switchOrgCommand.OrgId
token, err := svr.getToken(loginToken)
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"net/http"
)
type GetLatestVersionQuery struct {
//操作人
//操作人
//Operator domain.Operator `json:"-"`
DeviceType string `json:"-"`
VersionNo int `json:"versionNo"`
Channel int `json:"channel"`
Request *http.Request `json:"-"`
}
func (departmentsUsersQuery *GetLatestVersionQuery) Valid(validation *validation.Validation) {
}
func (departmentsUsersQuery *GetLatestVersionQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(departmentsUsersQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -4,6 +4,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
)
const IOSPage = "http://fir.fjmaimaimai.com/pdvn"
const ANDPage = "http://fir.fjmaimaimai.com/ben1"
type CommonService struct {
}
... ... @@ -67,22 +70,48 @@ func (srv *CommonService) GetDictionaryByCode(getDictionaryQuery *query.GetDicti
}
//LatestVersionInfo 版本升级
func (srv *CommonService) LatestVersionInfo() (interface{}, error) {
func (srv *CommonService) LatestVersionInfo(q *query.GetLatestVersionQuery) (interface{}, error) {
page := IOSPage
if q.DeviceType == "1" { // 安卓
page = ANDPage
}
return map[string]interface{}{
"version": map[string]interface{}{
"downloadPage": "www.baidu.com",
"downloadFile": "test.iso",
"downloadPage": page,
"downloadFile": "",
"updateType": 0,
},
}, nil
//vs:= version_server.NewHttpLibVersionServer()
//data,err:= vs.GetLatestVersion(q.Request,version_server.ReqLatestVersion{
// VersionNo: q.VersionNo,
// Channel: q.Channel,
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//return data, nil
}
//AppSharing 获取分享链接地址
func (srv *CommonService) AppSharing() (interface{}, error) {
func (srv *CommonService) AppSharing(q *query.GetLatestVersionQuery) (interface{}, error) {
page := IOSPage
if q.DeviceType == "1" { // 安卓
page = ANDPage
}
return map[string]interface{}{
"version": map[string]interface{}{
"downloadPage": "www.baidu.com",
"downloadFile": "test.iso",
"downloadPage": page,
"downloadFile": "",
},
}, nil
//vs:= version_server.NewHttpLibVersionServer()
//data,err:= vs.GetLatestVersion(q.Request,version_server.ReqLatestVersion{
// VersionNo: q.VersionNo,
// Channel: q.Channel,
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
//return data, nil
}
... ...
... ... @@ -25,6 +25,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio
//天联共创业务模块
var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"
// 版本更新模块
var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-test.fjmaimaimai.com"
//通用模块短信服务
var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897"
... ... @@ -38,6 +41,9 @@ func init() {
if os.Getenv("LOG_TYPE") != "" {
LOG_TYPE = os.Getenv("LOG_TYPE")
}
if os.Getenv("SUPLUS_ADMIN_BASE_HOST") != "" {
ALLIED_CREATION_GATEWAY_HOST = os.Getenv("SUPLUS_ADMIN_BASE_HOST")
}
if os.Getenv("ALLIED_CREATION_GATEWAY_HOST") != "" {
ALLIED_CREATION_GATEWAY_HOST = os.Getenv("ALLIED_CREATION_GATEWAY_HOST")
}
... ...
package version_server
import (
"encoding/json"
"fmt"
"net/http"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)
//公共短信服务模块
type HttpLibVersionServer struct {
service_gateway.BaseServiceGateway
baseUrL string
}
func NewHttpLibVersionServer() *HttpLibVersionServer {
return &HttpLibVersionServer{
BaseServiceGateway: service_gateway.BaseServiceGateway{
ConnectTimeout: 100 * time.Second,
ReadWriteTimeout: 30 * time.Second,
},
baseUrL: constant.SUPLUS_ADMIN_BASE_HOST,
}
}
//SendSms 公共短信验证码服务 发送验证码
func (gateway HttpLibVersionServer) GetLatestVersion(rc *http.Request, param ReqLatestVersion) (*DataLatestVersion, error) {
url := gateway.baseUrL + "/version/getLatestVersionInfo"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向版本管理请求数据:搜索用户列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("搜索版本失败:%w", err)
}
for k, vs := range rc.Header {
for i := range vs {
req.Header(k, vs[i])
}
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取版本失败:%w", err)
}
fmt.Println(string(byteResult))
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析版本:%w", err)
}
var data DataLatestVersion
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package version_server
type (
ReqLatestVersion struct {
VersionNo int `json:"versionNo"`
Channel int `json:"channel"`
}
DataLatestVersion map[string]interface{}
)
... ...
... ... @@ -2,9 +2,6 @@ package controllers
import (
"fmt"
"io"
"path/filepath"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/json"
"github.com/linmadan/egglib-go/web/beego"
... ... @@ -12,6 +9,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
"io"
"path/filepath"
)
type BaseController struct {
... ...
... ... @@ -3,13 +3,13 @@ package controllers
import (
"io/ioutil"
"github.com/linmadan/egglib-go/web/beego"
//"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
)
type CommonController struct {
beego.BaseController
BaseController
}
func (controller *CommonController) GetDictionaryByCode() {
... ... @@ -22,17 +22,21 @@ func (controller *CommonController) GetDictionaryByCode() {
func (controller *CommonController) LatestVersionInfo() {
commonService := service.NewCommonService(nil)
queryParam := &query.GetDictionaryByCodeQuery{}
queryParam := &query.GetLatestVersionQuery{}
_ = controller.Unmarshal(queryParam)
data, err := commonService.LatestVersionInfo()
queryParam.Request = controller.Ctx.Request
queryParam.DeviceType = controller.GetDeviceType()
data, err := commonService.LatestVersionInfo(queryParam)
controller.Response(data, err)
}
func (controller *CommonController) AppSharing() {
commonService := service.NewCommonService(nil)
queryParam := &query.GetDictionaryByCodeQuery{}
queryParam := &query.GetLatestVersionQuery{}
_ = controller.Unmarshal(queryParam)
data, err := commonService.AppSharing()
queryParam.Request = controller.Ctx.Request
queryParam.DeviceType = controller.GetDeviceType()
data, err := commonService.AppSharing(queryParam)
controller.Response(data, err)
}
... ...