fix(): 钉钉通知取消全局配置
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
package global
|
||||
|
||||
import "github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/config"
|
||||
|
||||
var GlobalConfig = new(config.DingDing)
|
||||
@@ -0,0 +1,9 @@
|
||||
package global
|
||||
|
||||
import "github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/config"
|
||||
|
||||
var GlobalConfig_ = &config.DingDing{
|
||||
Url: "https://oapi.dingtalk.com/robot/send",
|
||||
Token: "77d18293e221b3b7bdae7330d19a213c3cbb20fa07de5f4c273c0363ae475c34",
|
||||
Secret: "SEC38425b7bd57c6bca9ce20611c41b437994ed65e0ddbd42e840ffa7a8c7da2106",
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/router"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -12,10 +11,7 @@ type ddPlugin struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
func CreateDDPlug(Url string, Secret string, Token string) *ddPlugin {
|
||||
global.GlobalConfig.Secret = Secret
|
||||
global.GlobalConfig.Token = Token
|
||||
global.GlobalConfig.Url = Url
|
||||
func CreateDDPlug() *ddPlugin {
|
||||
return &ddPlugin{}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ func SendMessage(msg interface{}) error {
|
||||
}
|
||||
|
||||
value := url.Values{}
|
||||
value.Set("access_token", global.GlobalConfig.Token)
|
||||
if global.GlobalConfig.Secret != "" {
|
||||
value.Set("access_token", global.GlobalConfig_.Token)
|
||||
if global.GlobalConfig_.Secret != "" {
|
||||
t := time.Now().UnixNano() / 1e6
|
||||
value.Set("timestamp", fmt.Sprintf("%d", t))
|
||||
value.Set("sign", sign(t, global.GlobalConfig.Secret))
|
||||
value.Set("sign", sign(t, global.GlobalConfig_.Secret))
|
||||
}
|
||||
|
||||
request, err := http.NewRequest(http.MethodPost, global.GlobalConfig.Url, body)
|
||||
request, err := http.NewRequest(http.MethodPost, global.GlobalConfig_.Url, body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error request: %v", err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user