作者 tangxvhui

调整根据环境变量 设置是否发送短信和检查短信验证码

@@ -6,7 +6,7 @@ COPY ./pkg pkg @@ -6,7 +6,7 @@ COPY ./pkg pkg
6 COPY ./conf conf 6 COPY ./conf conf
7 COPY ./go.mod go.mod 7 COPY ./go.mod go.mod
8 COPY ./main.go main.go 8 COPY ./main.go main.go
9 -# RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] 9 +RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
10 ENV GO111MODULE on 10 ENV GO111MODULE on
11 ENV GOPROXY https://goproxy.cn,direct 11 ENV GOPROXY https://goproxy.cn,direct
12 RUN ["go","mod","tidy"] 12 RUN ["go","mod","tidy"]
1 # 合伙人项目 1 # 合伙人项目
2 2
  3 +### 对应的管理后台项目
  4 +
  5 +http://gitlab.fjmaimaimai.com/mmm-go/partnermg
  6 +
3 ### app对接的测试环境 7 ### app对接的测试环境
4 ``` 8 ```
5 服务端地址 http://mmm-partner-test.fjmaimaimai.com/ 9 服务端地址 http://mmm-partner-test.fjmaimaimai.com/
  10 +日志文件地址 http://mmm-partner-test.fjmaimaimai.com/log?id=12345
  11 +
  12 +```
  13 +### app 对接的正式环境
6 ``` 14 ```
  15 +服务端地址 https://public-interface.fjmaimaimai.com/mmm-partner
7 16
  17 +```
@@ -52,9 +52,9 @@ spec: @@ -52,9 +52,9 @@ spec:
52 ports: 52 ports:
53 - containerPort: 8082 53 - containerPort: 8082
54 - containerPort: 443 54 - containerPort: 443
55 -# volumeMounts:  
56 -# - mountPath: /opt/logs  
57 -# name: accesslogs 55 + # volumeMounts:
  56 + # - mountPath: /opt/logs
  57 + # name: accesslogs
58 env: 58 env:
59 - name: HTTP_PORT 59 - name: HTTP_PORT
60 value: "8082" 60 value: "8082"
@@ -84,6 +84,8 @@ spec: @@ -84,6 +84,8 @@ spec:
84 value: "https://mmm-open-api-dev.fjmaimaimai.com" 84 value: "https://mmm-open-api-dev.fjmaimaimai.com"
85 - name: UCENTER_SERVICE_HOST 85 - name: UCENTER_SERVICE_HOST
86 value: "https://suplus-ucenter-dev.fjmaimaimai.com" 86 value: "https://suplus-ucenter-dev.fjmaimaimai.com"
  87 + - name: SERVICE_RUNMOD
  88 + value: "dev"
87 - name: BUSINESS_ADMIN_SERVICE_HOST 89 - name: BUSINESS_ADMIN_SERVICE_HOST
88 valueFrom: 90 valueFrom:
89 configMapKeyRef: 91 configMapKeyRef:
@@ -103,4 +105,4 @@ spec: @@ -103,4 +105,4 @@ spec:
103 value: "" 105 value: ""
104 # volumes: 106 # volumes:
105 # - name: accesslogs 107 # - name: accesslogs
106 -# emptyDir: {}  
  108 +# emptyDir: {}
@@ -84,6 +84,8 @@ spec: @@ -84,6 +84,8 @@ spec:
84 value: "https://public-interface.fjmaimaimai.com/openapi" 84 value: "https://public-interface.fjmaimaimai.com/openapi"
85 - name: UCENTER_SERVICE_HOST 85 - name: UCENTER_SERVICE_HOST
86 value: "https://suplus-ucenter-prd.fjmaimaimai.com" 86 value: "https://suplus-ucenter-prd.fjmaimaimai.com"
  87 + - name: SERVICE_RUNMOD
  88 + value: "prd"
87 - name: BUSINESS_ADMIN_SERVICE_HOST 89 - name: BUSINESS_ADMIN_SERVICE_HOST
88 valueFrom: 90 valueFrom:
89 configMapKeyRef: 91 configMapKeyRef:
@@ -103,4 +105,4 @@ spec: @@ -103,4 +105,4 @@ spec:
103 value: "" 105 value: ""
104 volumes: 106 volumes:
105 - name: accesslogs 107 - name: accesslogs
106 - emptyDir: {}  
  108 + emptyDir: {}
@@ -52,9 +52,9 @@ spec: @@ -52,9 +52,9 @@ spec:
52 ports: 52 ports:
53 - containerPort: 8082 53 - containerPort: 8082
54 - containerPort: 443 54 - containerPort: 443
55 -# volumeMounts:  
56 -# - mountPath: /opt/logs  
57 -# name: accesslogs 55 + # volumeMounts:
  56 + # - mountPath: /opt/logs
  57 + # name: accesslogs
58 env: 58 env:
59 - name: HTTP_PORT 59 - name: HTTP_PORT
60 value: "8082" 60 value: "8082"
@@ -84,6 +84,8 @@ spec: @@ -84,6 +84,8 @@ spec:
84 value: "https://mmm-open-api-dev.fjmaimaimai.com" 84 value: "https://mmm-open-api-dev.fjmaimaimai.com"
85 - name: UCENTER_SERVICE_HOST 85 - name: UCENTER_SERVICE_HOST
86 value: "https://suplus-ucenter-test.fjmaimaimai.com" 86 value: "https://suplus-ucenter-test.fjmaimaimai.com"
  87 + - name: SERVICE_RUNMOD
  88 + value: "dev"
87 - name: BUSINESS_ADMIN_SERVICE_HOST 89 - name: BUSINESS_ADMIN_SERVICE_HOST
88 valueFrom: 90 valueFrom:
89 configMapKeyRef: 91 configMapKeyRef:
@@ -103,4 +105,4 @@ spec: @@ -103,4 +105,4 @@ spec:
103 value: "" 105 value: ""
104 # volumes: 106 # volumes:
105 # - name: accesslogs 107 # - name: accesslogs
106 -# emptyDir: {}  
  108 +# emptyDir: {}
@@ -226,6 +226,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT @@ -226,6 +226,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
226 226
227 // 验证短信验证码 T 227 // 验证短信验证码 T
228 func CheckSmsCode(phone, code string) (result bool, err error) { 228 func CheckSmsCode(phone, code string) (result bool, err error) {
  229 +
229 sms, _ := factory.CreateSmsCodeService() 230 sms, _ := factory.CreateSmsCodeService()
230 var data map[string]interface{} 231 var data map[string]interface{}
231 data, err = sms.CheckSmsCode(phone, code) 232 data, err = sms.CheckSmsCode(phone, code)
1 package factory 1 package factory
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr"
6 ) 7 )
7 8
8 func CreateSmsCodeService() (service.SmsCodeService, error) { 9 func CreateSmsCodeService() (service.SmsCodeService, error) {
  10 + if constant.SERVICE_RUNMOD == "dev" {
  11 + return svr.NewHttplibMmmSmsApiEmpty(), nil
  12 + }
9 return svr.NewHttplibMmmSmsApiServiceGateway(), nil 13 return svr.NewHttplibMmmSmsApiServiceGateway(), nil
10 } 14 }
@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 7
8 const SERVICE_NAME = "partner" 8 const SERVICE_NAME = "partner"
9 9
  10 +var SERVICE_RUNMOD = "dev"
  11 +
10 var LOG_LEVEL = "debug" 12 var LOG_LEVEL = "debug"
11 var LOG_File = "logs/app.log" 13 var LOG_File = "logs/app.log"
12 var LOG_PREFIX = "[partner_dev]" 14 var LOG_PREFIX = "[partner_dev]"
@@ -41,4 +43,8 @@ func init() { @@ -41,4 +43,8 @@ func init() {
41 if v := os.Getenv("DEFAULT_GUEST_COMPANY"); v != "" { 43 if v := os.Getenv("DEFAULT_GUEST_COMPANY"); v != "" {
42 DEFAULT_GUEST_COMPANY, _ = strconv.Atoi(v) 44 DEFAULT_GUEST_COMPANY, _ = strconv.Atoi(v)
43 } 45 }
  46 +
  47 + if v := os.Getenv("SERVICE_RUNMOD"); v != "" {
  48 + SERVICE_RUNMOD = v
  49 + }
44 } 50 }
1 package svr 1 package svr
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"  
5 - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"  
6 "strings" 4 "strings"
7 "time" 5 "time"
  6 +
  7 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
  8 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
8 ) 9 )
9 10
10 type HttplibMmmSmsApiServiceGateway struct { 11 type HttplibMmmSmsApiServiceGateway struct {
@@ -49,3 +50,19 @@ func NewHttplibMmmSmsApiServiceGateway() *HttplibMmmSmsApiServiceGateway { @@ -49,3 +50,19 @@ func NewHttplibMmmSmsApiServiceGateway() *HttplibMmmSmsApiServiceGateway {
49 }, 50 },
50 } 51 }
51 } 52 }
  53 +
  54 +type HttplibMmmSmsApiEmpty struct{}
  55 +
  56 +func NewHttplibMmmSmsApiEmpty() *HttplibMmmSmsApiEmpty {
  57 + return &HttplibMmmSmsApiEmpty{}
  58 +}
  59 +
  60 +func (serviceGateway *HttplibMmmSmsApiEmpty) SendSms(phone string) (map[string]interface{}, error) {
  61 + log.Info("非正式环境调用HttplibMmmSmsApiEmpty.SendSms发送短信")
  62 + return map[string]interface{}{}, nil
  63 +}
  64 +
  65 +func (serviceGateway *HttplibMmmSmsApiEmpty) CheckSmsCode(phone string, code string) (map[string]interface{}, error) {
  66 + log.Info("非正式环境调用HttplibMmmSmsApiEmpty.CheckSmsCode 检查短信验证码")
  67 + return map[string]interface{}{}, nil
  68 +}