作者 tangxuhui

Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…

…tion-gateway into test
@@ -103,6 +103,8 @@ spec: @@ -103,6 +103,8 @@ spec:
103 value: "false" 103 value: "false"
104 - name: HTTP_PORT 104 - name: HTTP_PORT
105 value: "8082" 105 value: "8082"
  106 + - name: ALLIED_CREATION_GATEWAY_HOST
  107 + value: "https://allied-creation-gateway-dev.fjmaimaimai.com"
106 - name: ALLIED_CREATION_USER_HOST 108 - name: ALLIED_CREATION_USER_HOST
107 value: "http://allied-creation-user-dev.fjmaimaimai.com" 109 value: "http://allied-creation-user-dev.fjmaimaimai.com"
108 - name: ALLIED_CREATION_COOPERATION_HOST 110 - name: ALLIED_CREATION_COOPERATION_HOST
@@ -107,6 +107,10 @@ spec: @@ -107,6 +107,10 @@ 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"
  112 + - name: ALLIED_CREATION_GATEWAY_HOST
  113 + value: "https://allied-creation-gateway-test.fjmaimaimai.com"
110 - name: ALLIED_CREATION_USER_HOST 114 - name: ALLIED_CREATION_USER_HOST
111 value: "https://allied-creation-user-test.fjmaimaimai.com" 115 value: "https://allied-creation-user-test.fjmaimaimai.com"
112 - name: ALLIED_CREATION_COOPERATION_HOST 116 - name: ALLIED_CREATION_COOPERATION_HOST
@@ -6,6 +6,7 @@ require ( @@ -6,6 +6,7 @@ require (
6 github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2 6 github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2
7 github.com/beego/beego/v2 v2.0.1 7 github.com/beego/beego/v2 v2.0.1
8 github.com/dgrijalva/jwt-go v3.2.0+incompatible 8 github.com/dgrijalva/jwt-go v3.2.0+incompatible
  9 + github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719 // indirect
9 github.com/go-pg/pg/v10 v10.10.1 10 github.com/go-pg/pg/v10 v10.10.1
10 github.com/go-redis/redis v6.14.2+incompatible 11 github.com/go-redis/redis v6.14.2+incompatible
11 github.com/google/uuid v1.1.1 12 github.com/google/uuid v1.1.1
@@ -54,6 +54,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3C @@ -54,6 +54,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3C
54 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= 54 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
55 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 55 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
56 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 56 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
  57 +github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719 h1:sBIoJbXC+QBD9kL00aAxi7dfJJ70YHhiKzSN9yeTjbU=
  58 +github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719/go.mod h1:NMVFOzYeLVR7UiGTxsa+A21nrERTZ3Rv2JHDPcJpDyI=
57 github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= 59 github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
58 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= 60 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
59 github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg= 61 github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg=
@@ -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 }
@@ -139,7 +139,7 @@ func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPer @@ -139,7 +139,7 @@ func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPer
139 // 分红支出 139 // 分红支出
140 DividendsIncome float64 `json:"dividendsIncome"` 140 DividendsIncome float64 `json:"dividendsIncome"`
141 // 企业信息 141 // 企业信息
142 - Company domain.CompanyData `json:"company"` 142 + Company domain.Company `json:"company"`
143 } 143 }
144 var cooperationCompanyStatisticsResponses []cooperationCompanyStatisticsResponse 144 var cooperationCompanyStatisticsResponses []cooperationCompanyStatisticsResponse
145 if err := json.UnmarshalFromString(json.MarshalToString(result), &cooperationCompanyStatisticsResponses); err != nil { 145 if err := json.UnmarshalFromString(json.MarshalToString(result), &cooperationCompanyStatisticsResponses); err != nil {
@@ -152,10 +152,10 @@ func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPer @@ -152,10 +152,10 @@ func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPer
152 var values = make([]interface{}, 0) 152 var values = make([]interface{}, 0)
153 for i := range users.Users { 153 for i := range users.Users {
154 user := users.Users[i] 154 user := users.Users[i]
155 - cooperationCompanyStatisticsResponses[i].Company = domain.CompanyData{ 155 + cooperationCompanyStatisticsResponses[i].Company = domain.Company{
156 CompanyID: user.Org.OrgId, 156 CompanyID: user.Org.OrgId,
157 CompanyName: user.Org.OrgName, 157 CompanyName: user.Org.OrgName,
158 - CompanyLogo: user.Company.Logo, 158 + Logo: user.Company.Logo,
159 } 159 }
160 values = append(values, cooperationCompanyStatisticsResponses[i]) 160 values = append(values, cooperationCompanyStatisticsResponses[i])
161 } 161 }
@@ -117,8 +117,8 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU @@ -117,8 +117,8 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU
117 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 117 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
118 } 118 }
119 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 119 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
120 - user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{  
121 - UserId: int(updateUserInfoCommand.Operator.UserId), 120 + user, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  121 + Account: updateUserInfoCommand.Operator.Phone,
122 }) 122 })
123 if err != nil { 123 if err != nil {
124 return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在") 124 return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
@@ -143,7 +143,7 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU @@ -143,7 +143,7 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU
143 } 143 }
144 } 144 }
145 _, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{ 145 _, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
146 - UserId: int64(user.UserId), 146 + UserBaseId: int64(user.UserBaseID),
147 UserName: updateUserInfoCommand.UserName, 147 UserName: updateUserInfoCommand.UserName,
148 Avatar: updateUserInfoCommand.Avatar, 148 Avatar: updateUserInfoCommand.Avatar,
149 Phone: updateUserInfoCommand.Phone, 149 Phone: updateUserInfoCommand.Phone,
@@ -75,7 +75,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -75,7 +75,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
75 PageSize: 0, 75 PageSize: 0,
76 CompanyId: resultProject.Company.CompanyId, 76 CompanyId: resultProject.Company.CompanyId,
77 OrgId: int64(resultProject.Org.OrgId), 77 OrgId: int64(resultProject.Org.OrgId),
78 - CooperationApplicationStatus: 2, //审核通过的 78 + //CooperationApplicationStatus: 2, //审核通过的
79 }) 79 })
80 if err != nil { 80 if err != nil {
81 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 81 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -8,12 +8,13 @@ import ( @@ -8,12 +8,13 @@ import (
8 const SERVICE_NAME = "allied-creation-gateway" 8 const SERVICE_NAME = "allied-creation-gateway"
9 9
10 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
11 -var LOG_TYPE = "console"// file, console, es 11 +var LOG_TYPE = "console" // file, console, es
12 var LOG_FRAMEWORK = "beego" // beego logrus 12 var LOG_FRAMEWORK = "beego" // beego logrus
13 var LOG_FILE = "app.log" 13 var LOG_FILE = "app.log"
14 var LOG_PREFIX = "[allied-creation-gateway]" 14 var LOG_PREFIX = "[allied-creation-gateway]"
15 15
16 var HTTP_PORT int = 8083 16 var HTTP_PORT int = 8083
  17 +var ALLIED_CREATION_GATEWAY_HOST = "https://allied-creation-gateway-dev.fjmaimaimai.com"
17 18
18 //天联共创基础模块 19 //天联共创基础模块
19 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com" 20 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"
@@ -24,6 +25,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio @@ -24,6 +25,9 @@ var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creatio
24 //天联共创业务模块 25 //天联共创业务模块
25 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"
26 27
  28 +// 版本更新模块
  29 +var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-test.fjmaimaimai.com"
  30 +
27 //通用模块短信服务 31 //通用模块短信服务
28 var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897" 32 var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897"
29 33
@@ -37,6 +41,12 @@ func init() { @@ -37,6 +41,12 @@ func init() {
37 if os.Getenv("LOG_TYPE") != "" { 41 if os.Getenv("LOG_TYPE") != "" {
38 LOG_TYPE = os.Getenv("LOG_TYPE") 42 LOG_TYPE = os.Getenv("LOG_TYPE")
39 } 43 }
  44 + if os.Getenv("SUPLUS_ADMIN_BASE_HOST") != "" {
  45 + ALLIED_CREATION_GATEWAY_HOST = os.Getenv("SUPLUS_ADMIN_BASE_HOST")
  46 + }
  47 + if os.Getenv("ALLIED_CREATION_GATEWAY_HOST") != "" {
  48 + ALLIED_CREATION_GATEWAY_HOST = os.Getenv("ALLIED_CREATION_GATEWAY_HOST")
  49 + }
40 if os.Getenv("ALLIED_CREATION_BASIC_HOST") != "" { 50 if os.Getenv("ALLIED_CREATION_BASIC_HOST") != "" {
41 ALLIED_CREATION_BASIC_HOST = os.Getenv("ALLIED_CREATION_BASIC_HOST") 51 ALLIED_CREATION_BASIC_HOST = os.Getenv("ALLIED_CREATION_BASIC_HOST")
42 } 52 }
@@ -6,3 +6,9 @@ type CompanyData struct { @@ -6,3 +6,9 @@ type CompanyData struct {
6 CompanyLogo string `json:"companyLogo"` 6 CompanyLogo string `json:"companyLogo"`
7 CompanyName string `json:"companyName"` 7 CompanyName string `json:"companyName"`
8 } 8 }
  9 +
  10 +type Company struct {
  11 + CompanyID int `json:"companyId"`
  12 + Logo string `json:"logo"`
  13 + CompanyName string `json:"companyName"`
  14 +}
@@ -3,8 +3,8 @@ package domain @@ -3,8 +3,8 @@ package domain
3 import ( 3 import (
4 "encoding/base64" 4 "encoding/base64"
5 "fmt" 5 "fmt"
6 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util"  
7 - "log" 6 + "github.com/forgoer/openssl"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
8 "time" 8 "time"
9 9
10 jwt "github.com/dgrijalva/jwt-go" 10 jwt "github.com/dgrijalva/jwt-go"
@@ -15,8 +15,8 @@ const ( @@ -15,8 +15,8 @@ const (
15 qrcodeCodeExpire int64 = 60 * 30 //15分钟过期 15 qrcodeCodeExpire int64 = 60 * 30 //15分钟过期
16 ) 16 )
17 17
18 -var aecSecret = []byte("mmm.qrcode.(%^&)")  
19 -var loginHost = "https://api.fjmaimaimai.com/app/auth/login/qrcode?key=" 18 +var aecSecret = []byte("mmm.qrcode.ecb.1")
  19 +var qrcodeLogin = "/v1/auth/login/qrcode?key="
20 20
21 type QrcodeMessage struct { 21 type QrcodeMessage struct {
22 jwt.StandardClaims 22 jwt.StandardClaims
@@ -48,34 +48,13 @@ func (qrmsg *QrcodeMessage) GenerateImageBase64() ([]byte, error) { @@ -48,34 +48,13 @@ func (qrmsg *QrcodeMessage) GenerateImageBase64() ([]byte, error) {
48 if err != nil { 48 if err != nil {
49 return nil, err 49 return nil, err
50 } 50 }
51 - key := loginHost + str  
52 - encryptedData, err := util.AesEncrypt([]byte(key), aecSecret) 51 + key := constant.ALLIED_CREATION_GATEWAY_HOST + qrcodeLogin + str
  52 + encryptedData, err := openssl.AesECBEncrypt([]byte(key), aecSecret, openssl.PKCS7_PADDING)
  53 + if err != nil {
  54 + return nil, err
  55 + }
53 qrmsg.Token = base64.StdEncoding.EncodeToString(encryptedData) 56 qrmsg.Token = base64.StdEncoding.EncodeToString(encryptedData)
54 - //初始化数据  
55 - //qrmsg.Token = string(encryptedData)  
56 qrmsg.IsLogin = false 57 qrmsg.IsLogin = false
57 -  
58 - // 输入日志  
59 - decrypted, _ := util.AesDecrypt(encryptedData, aecSecret)  
60 - if string(decrypted) == key {  
61 - log.Println("token:", str, "\n encrypt:", key, "\n decrypt:", string(decrypted))  
62 - }  
63 -  
64 - //qrCode, err := qr.Encode(str, qr.M, qr.Auto)  
65 - //if err != nil {  
66 - // return nil, err  
67 - //}  
68 - //qrCode, err = barcode.Scale(qrCode, 200, 200)  
69 - //if err != nil {  
70 - // return nil, err  
71 - //}  
72 - //var buf bytes.Buffer  
73 - //err = png.Encode(&buf, qrCode)  
74 - //if err != nil {  
75 - // return nil, err  
76 - //}  
77 - //var result []byte  
78 - //base64.StdEncoding.Encode(result, buf.Bytes())  
79 return encryptedData, err 58 return encryptedData, err
80 } 59 }
81 60
@@ -303,6 +303,8 @@ type ( @@ -303,6 +303,8 @@ type (
303 type ( 303 type (
304 ReqUserUpdateBaseInfo struct { 304 ReqUserUpdateBaseInfo struct {
305 UserId int64 `json:"userId"` 305 UserId int64 `json:"userId"`
  306 + // 用户基础Id 用户唯一标识
  307 + UserBaseId int64 `cname:"用户Id 用户唯一标识" json:"userBaseId" valid:"Required"`
306 // 用户姓名 308 // 用户姓名
307 UserName string `cname:"用户姓名" json:"userName" valid:"Required"` 309 UserName string `cname:"用户姓名" json:"userName" valid:"Required"`
308 // 头像 310 // 头像
  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
@@ -93,3 +93,30 @@ func AesDecrypt(crypted, key []byte) ([]byte, error) { @@ -93,3 +93,30 @@ func AesDecrypt(crypted, key []byte) ([]byte, error) {
93 origData = PKCS7UnPadding(origData, blockSize) 93 origData = PKCS7UnPadding(origData, blockSize)
94 return origData, nil 94 return origData, nil
95 } 95 }
  96 +
  97 +func ECBEncrypt(block cipher.Block, src, key []byte) ([]byte, error) {
  98 + blockSize := block.BlockSize()
  99 +
  100 + encryptData := make([]byte, len(src))
  101 + tmpData := make([]byte, blockSize)
  102 +
  103 + for index := 0; index < len(src); index += blockSize {
  104 + block.Encrypt(tmpData, src[index:index+blockSize])
  105 + copy(encryptData, tmpData)
  106 + }
  107 + return encryptData, nil
  108 +}
  109 +
  110 +func ECBDecrypt(block cipher.Block, src, key []byte) ([]byte, error) {
  111 + dst := make([]byte, len(src))
  112 +
  113 + blockSize := block.BlockSize()
  114 + tmpData := make([]byte, blockSize)
  115 +
  116 + for index := 0; index < len(src); index += blockSize {
  117 + block.Decrypt(tmpData, src[index:index+blockSize])
  118 + copy(dst, tmpData)
  119 + }
  120 +
  121 + return dst, nil
  122 +}
@@ -3,28 +3,34 @@ package util @@ -3,28 +3,34 @@ package util
3 import ( 3 import (
4 "encoding/base64" 4 "encoding/base64"
5 "fmt" 5 "fmt"
  6 + "github.com/forgoer/openssl"
6 "testing" 7 "testing"
7 ) 8 )
8 9
9 func Test_Aes(t *testing.T) { 10 func Test_Aes(t *testing.T) {
10 //key的长度必须是16、24或者32字节,分别用于选择AES-128, AES-192, or AES-256 11 //key的长度必须是16、24或者32字节,分别用于选择AES-128, AES-192, or AES-256
11 var aeskey = []byte("mmm.qrcode.(%^&)") 12 var aeskey = []byte("mmm.qrcode.(%^&)")
12 - pass := []byte("vdncloud123456") 13 + pass := []byte("https://www.baidu.com/")
13 xpass, err := AesEncrypt(pass, aeskey) 14 xpass, err := AesEncrypt(pass, aeskey)
14 if err != nil { 15 if err != nil {
15 fmt.Println(err) 16 fmt.Println(err)
16 return 17 return
17 } 18 }
18 - 19 + fmt.Printf("base64 加密前:%v\n", string(xpass))
19 pass64 := base64.StdEncoding.EncodeToString(xpass) 20 pass64 := base64.StdEncoding.EncodeToString(xpass)
20 - fmt.Printf("加密后:%v\n", pass64) 21 + fmt.Printf("base64 加密:%v\n", pass64)
  22 +
  23 + //pass64 ="qYy8JqxzYGkhmDCZ6581/Fg9LfcGGqlAVjCWHpSayNs="
21 24
22 bytesPass, err := base64.StdEncoding.DecodeString(pass64) 25 bytesPass, err := base64.StdEncoding.DecodeString(pass64)
  26 + fmt.Printf("base64 解密:%v\n", string(bytesPass))
23 if err != nil { 27 if err != nil {
24 fmt.Println(err) 28 fmt.Println(err)
25 return 29 return
26 } 30 }
27 31
  32 + //bytesPass:=xpass
  33 + //fmt.Println(string(bytesPass))
28 tpass, err := AesDecrypt(bytesPass, aeskey) 34 tpass, err := AesDecrypt(bytesPass, aeskey)
29 if err != nil { 35 if err != nil {
30 fmt.Println(err) 36 fmt.Println(err)
@@ -32,3 +38,38 @@ func Test_Aes(t *testing.T) { @@ -32,3 +38,38 @@ func Test_Aes(t *testing.T) {
32 } 38 }
33 fmt.Printf("解密后:%s\n", tpass) 39 fmt.Printf("解密后:%s\n", tpass)
34 } 40 }
  41 +
  42 +func Test_Base64(t *testing.T) {
  43 + xpass := []byte("123") //123
  44 + fmt.Printf("base64 加密前:%v\n", string(xpass))
  45 + pass64 := base64.StdEncoding.EncodeToString(xpass)
  46 + fmt.Printf("base64 加密:%v\n", pass64)
  47 +
  48 + bytesPass, err := base64.StdEncoding.DecodeString(pass64)
  49 + fmt.Printf("base64 解密:%v\n", string(bytesPass))
  50 + if err != nil {
  51 + fmt.Println(err)
  52 + return
  53 + }
  54 +}
  55 +
  56 +func Test_AES_ECB(t *testing.T) {
  57 + src := []byte("123456")
  58 + key := []byte("mmm.qrcode.ecb.1")
  59 + dst, _ := openssl.AesECBEncrypt(src, key, openssl.PKCS7_PADDING)
  60 + fmt.Println(base64.StdEncoding.EncodeToString(dst)) // 1jdzWuniG6UMtoa3T6uNLA==
  61 +
  62 + dst, _ = openssl.AesECBDecrypt(dst, key, openssl.PKCS7_PADDING)
  63 + fmt.Println(string(dst)) // 123456
  64 +}
  65 +
  66 +func Test_AES_CBC(t *testing.T) {
  67 + src := []byte("123456")
  68 + key := []byte("mmm.qrcode.ecb.1")
  69 + iv := []byte("mmm.qrcode.ecb.1")
  70 + dst, _ := openssl.AesCBCEncrypt(src, key, iv, openssl.PKCS7_PADDING)
  71 + fmt.Println(base64.StdEncoding.EncodeToString(dst)) // 1jdzWuniG6UMtoa3T6uNLA==
  72 +
  73 + dst, _ = openssl.AesCBCDecrypt(dst, key, iv, openssl.PKCS7_PADDING)
  74 + fmt.Println(string(dst)) // 123456
  75 +}