Merge branch 'zhangzeliang' into dev

dev
RIceWqy 2 years ago
commit 21d924ffb4

@ -0,0 +1,51 @@
case $3 in
"")
goarch="amd64"
releasePath="x86_64"
break
;;
"arm")
goarch="arm"
releasePath="arm"
break
;;
"arm64")
goarch="arm64"
releasePath="arm64"
break
;;
"loong64")
goarch="loong64"
releasePath="loong64"
break
;;
*)
echo '目标 ' $3 ' 无法编译'
exit
;;
esac
buildfile=$1
case $2 in
"linux") echo '交叉编译目标为linux+'$goarch
echo "CGO_ENABLED=0 GOOS=linux GOARCH="$goarch" go build "$1
CGO_ENABLED=0 GOOS=linux GOARCH=$goarch go build -o ./"${buildfile%%.*}-"$releasePath $1
break
;;
"windows") echo '交叉编译目标为windows+'$goarch
echo "CGO_ENABLED=0 GOOS=windows GOARCH="$goarch" go build "$1
CGO_ENABLED=0 GOOS=windows GOARCH=$goarch go build -o ././"${buildfile%%.*}-"$releasePath".exe" $1
break
;;
"darwin") echo '交叉编译目标为maxos+'$goarch
echo "CGO_ENABLED=0 GOOS=darwin GOARCH="$goarch" go build "$1
CGO_ENABLED=0 GOOS=darwin GOARCH=$goarch go build -o ./"${buildfile%%.*}-"$releasePath $1
break
;;
*) echo '参数不正确:'$goarch
break
;;
esac
echo '脚本执行结束...'

@ -0,0 +1,10 @@
[
{
"DbType":"mysql",
"IsMaster":true,
"Dsn":"root:Password1!@tcp(mysql-a.fanhaninfo.test:3306)/dev_digital?charset=utf8mb4",
"sqlMaxIdleConns":100,
"sqlMaxOpenConns":100,
"sqlLogLevel":2
}
]

@ -0,0 +1,10 @@
[
{
"DbType":"mysql",
"IsMaster":true,
"Dsn":"root:12345678@tcp(127.0.0.1:3306)/fushouxian?charset=utf8mb4",
"sqlMaxIdleConns":1,
"sqlMaxOpenConns":1,
"sqlLogLevel":2
}
]

@ -0,0 +1,5 @@
{
"rpa_url": "http://172.0.0.19:19005",
"username": "admin",
"password": "123"
}

@ -0,0 +1,7 @@
{
"Priority":100,
"ModuleName":"go",
"ServerUrls":[
"wss://shop.ruixininfo.com/websocket/jsonrpc"
]
}

@ -0,0 +1,108 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
_ "src/init"
"github.com/towgo/towgo/dao/basedboperat"
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/lib/processmanager"
"github.com/towgo/towgo/lib/system"
"github.com/towgo/towgo/towgo"
)
var appName string = "fushouxian-server"
var appVersion string = "1.0.0"
var basePath = system.GetPathOfProgram()
func init() {
//初始化xorm数据库驱动
var dbconfig []xormDriver.DsnConfig
system.ScanConfigJson(basePath+"/config/dbconfig.json", &dbconfig)
xormDriver.New(dbconfig)
//设定默认orm引擎
err := basedboperat.SetOrmEngine("xorm")
if err != nil {
log.Print(err.Error())
}
}
func main() {
pm := processmanager.GetManager()
for k, v := range os.Args {
switch v {
case "start":
if k == 1 {
if pm.Start() {
log.Print("启动成功")
start()
return
} else {
log.Print("启动失败:" + pm.Error.Error())
return
}
}
case "restart":
if k == 1 {
if pm.ReStart() {
log.Print("重启成功")
start()
return
} else {
log.Print("重启失败:" + pm.Error.Error())
}
return
}
case "stop":
if k == 1 {
if pm.Stop() {
log.Print("程序停止成功")
} else {
log.Print("程序停止失败:程序没有运行")
}
return
}
case "version":
if k == 1 {
fmt.Print(appName + ":" + appVersion + "\n")
os.Exit(0)
}
return
}
}
log.Print("参数传递错误,有效参数如下:\n" + os.Args[0] + " start | stop | reload | stop")
}
func start() {
moduleClientInit()
conf := struct {
Serverport string `json:"serverport"`
}{}
system.ScanConfigJson(basePath+"/config/config.json", &conf)
http.HandleFunc("/jsonrpc", towgo.HttpHandller)
log.Print("http服务运行中:0.0.0.0:" + conf.Serverport + "\n")
http.ListenAndServe("0.0.0.0:"+conf.Serverport, nil)
}
func moduleClientInit() {
var node towgo.EdgeServerNodeConfig
system.ScanConfigJson(basePath+"config/togocdn.client.config.json", &node)
node.Methods = towgo.GetMethods()
node.ModuleName = appName
for _, v := range node.ServerUrls {
node.ServerUrl = v
client := towgo.NewEdgeServerNode(node)
client.Connect()
}
}

@ -1 +1 @@
{"pid":33859} {"pid":36728}

@ -1,7 +1,9 @@
package tencent package tencent
import ( import (
"encoding/json"
"fmt" "fmt"
"log"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
@ -9,6 +11,21 @@ import (
sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111" // 引入sms sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111" // 引入sms
) )
type SMSResponse struct {
SendStatusSet []SendStatus `json:"SendStatusSet"` // 发送状态集
RequestId string `json:"RequestId"` // 请求ID
}
type SendStatus struct {
SerialNo string `json:"SerialNo"` // 序列号
PhoneNumber string `json:"PhoneNumber"` // 手机号码
Fee int `json:"Fee"` // 费用
SessionContext string `json:"SessionContext"` // 会话上下文
Code string `json:"Code"` // 状态码
Message string `json:"Message"` // 消息
IsoCode string `json:"IsoCode"` // 国际标准化组织代码
}
func SendSMSVerificationCode(templateID, signName, mobile, verificationCode string) error { func SendSMSVerificationCode(templateID, signName, mobile, verificationCode string) error {
/* /*
* secretIdsecretKey * secretIdsecretKey
@ -86,7 +103,7 @@ func SendSMSVerificationCode(templateID, signName, mobile, verificationCode stri
request.SenderId = common.StringPtr("") request.SenderId = common.StringPtr("")
// 通过client对象调用想要访问的接口需要传入请求对象 // 通过client对象调用想要访问的接口需要传入请求对象
_, err := client.SendSms(request) response, err := client.SendSms(request)
// 处理异常 // 处理异常
if _, ok := err.(*errors.TencentCloudSDKError); ok { if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err) fmt.Printf("An API error has returned: %s", err)
@ -97,6 +114,14 @@ func SendSMSVerificationCode(templateID, signName, mobile, verificationCode stri
return err return err
} }
var resp SMSResponse
b, _ := json.Marshal(response.Response)
json.Unmarshal(b, &resp)
// 打印返回的json字符串
log.Print(resp)
/* /*
* [FailedOperation.SignatureIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.signatureincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F) * [FailedOperation.SignatureIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.signatureincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
* [FailedOperation.TemplateIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.templateincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F) * [FailedOperation.TemplateIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.templateincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)

@ -8,26 +8,26 @@ import (
"time" "time"
) )
var loginOrregSMSVerificationCode sync.Map var loginOrRegSMSVerificationCode sync.Map
// 登记注册用验证码 // 登记注册用验证码
func StoreLoginOrloginOrRegSMSVerificationCode(mobile string) (string, error) { func StoreLoginOrloginOrRegSMSVerificationCode(mobile string) (string, error) {
codeInterface, ok := loginOrregSMSVerificationCode.Load(mobile) codeInterface, ok := loginOrRegSMSVerificationCode.Load(mobile)
if ok { if ok {
return codeInterface.(string), nil return codeInterface.(string), nil
} }
verificationCode := randCharNumber(6) verificationCode := randCharNumber(6)
loginOrregSMSVerificationCode.Store(mobile, verificationCode) loginOrRegSMSVerificationCode.Store(mobile, verificationCode)
go func(mobile string) { go func(mobile string) {
time.Sleep(time.Second * 5 * 60) time.Sleep(time.Second * 5 * 60)
loginOrregSMSVerificationCode.Delete(mobile) loginOrRegSMSVerificationCode.Delete(mobile)
}(mobile) }(mobile)
return verificationCode, nil return verificationCode, nil
} }
// 验证注册验证码 // 验证注册验证码
func LoginOrRegSMSVerification(mobile, verificationCode string) bool { func LoginOrRegSMSVerification(mobile, verificationCode string) bool {
codeInterface, ok := loginOrregSMSVerificationCode.LoadAndDelete(mobile) codeInterface, ok := loginOrRegSMSVerificationCode.LoadAndDelete(mobile)
if !ok { if !ok {
return false return false
} }

Loading…
Cancel
Save