作者 tangxvhui

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

... ... @@ -6,7 +6,7 @@ COPY ./pkg pkg
COPY ./conf conf
COPY ./go.mod go.mod
COPY ./main.go main.go
# RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn,direct
RUN ["go","mod","tidy"]
... ...
# 合伙人项目
### 对应的管理后台项目
http://gitlab.fjmaimaimai.com/mmm-go/partnermg
### app对接的测试环境
```
服务端地址 http://mmm-partner-test.fjmaimaimai.com/
日志文件地址 http://mmm-partner-test.fjmaimaimai.com/log?id=12345
```
### app 对接的正式环境
```
服务端地址 https://public-interface.fjmaimaimai.com/mmm-partner
```
\ No newline at end of file
... ...
... ... @@ -52,9 +52,9 @@ spec:
ports:
- containerPort: 8082
- containerPort: 443
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
... ... @@ -84,6 +84,8 @@ spec:
value: "https://mmm-open-api-dev.fjmaimaimai.com"
- name: UCENTER_SERVICE_HOST
value: "https://suplus-ucenter-dev.fjmaimaimai.com"
- name: SERVICE_RUNMOD
value: "dev"
- name: BUSINESS_ADMIN_SERVICE_HOST
valueFrom:
configMapKeyRef:
... ...
... ... @@ -84,6 +84,8 @@ spec:
value: "https://public-interface.fjmaimaimai.com/openapi"
- name: UCENTER_SERVICE_HOST
value: "https://suplus-ucenter-prd.fjmaimaimai.com"
- name: SERVICE_RUNMOD
value: "prd"
- name: BUSINESS_ADMIN_SERVICE_HOST
valueFrom:
configMapKeyRef:
... ...
... ... @@ -52,9 +52,9 @@ spec:
ports:
- containerPort: 8082
- containerPort: 443
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
# volumeMounts:
# - mountPath: /opt/logs
# name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
... ... @@ -84,6 +84,8 @@ spec:
value: "https://mmm-open-api-dev.fjmaimaimai.com"
- name: UCENTER_SERVICE_HOST
value: "https://suplus-ucenter-test.fjmaimaimai.com"
- name: SERVICE_RUNMOD
value: "dev"
- name: BUSINESS_ADMIN_SERVICE_HOST
valueFrom:
configMapKeyRef:
... ...
... ... @@ -226,6 +226,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
// 验证短信验证码 T
func CheckSmsCode(phone, code string) (result bool, err error) {
sms, _ := factory.CreateSmsCodeService()
var data map[string]interface{}
data, err = sms.CheckSmsCode(phone, code)
... ...
package factory
import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/service"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr"
)
func CreateSmsCodeService() (service.SmsCodeService, error) {
if constant.SERVICE_RUNMOD == "dev" {
return svr.NewHttplibMmmSmsApiEmpty(), nil
}
return svr.NewHttplibMmmSmsApiServiceGateway(), nil
}
... ...
... ... @@ -7,6 +7,8 @@ import (
const SERVICE_NAME = "partner"
var SERVICE_RUNMOD = "dev"
var LOG_LEVEL = "debug"
var LOG_File = "logs/app.log"
var LOG_PREFIX = "[partner_dev]"
... ... @@ -41,4 +43,8 @@ func init() {
if v := os.Getenv("DEFAULT_GUEST_COMPANY"); v != "" {
DEFAULT_GUEST_COMPANY, _ = strconv.Atoi(v)
}
if v := os.Getenv("SERVICE_RUNMOD"); v != "" {
SERVICE_RUNMOD = v
}
}
... ...
package svr
import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
"strings"
"time"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
)
type HttplibMmmSmsApiServiceGateway struct {
... ... @@ -49,3 +50,19 @@ func NewHttplibMmmSmsApiServiceGateway() *HttplibMmmSmsApiServiceGateway {
},
}
}
type HttplibMmmSmsApiEmpty struct{}
func NewHttplibMmmSmsApiEmpty() *HttplibMmmSmsApiEmpty {
return &HttplibMmmSmsApiEmpty{}
}
func (serviceGateway *HttplibMmmSmsApiEmpty) SendSms(phone string) (map[string]interface{}, error) {
log.Info("非正式环境调用HttplibMmmSmsApiEmpty.SendSms发送短信")
return map[string]interface{}{}, nil
}
func (serviceGateway *HttplibMmmSmsApiEmpty) CheckSmsCode(phone string, code string) (map[string]interface{}, error) {
log.Info("非正式环境调用HttplibMmmSmsApiEmpty.CheckSmsCode 检查短信验证码")
return map[string]interface{}{}, nil
}
... ...