Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
c24e00868b | 4 years ago |
11 changed files with 144 additions and 2 deletions
@ -0,0 +1,19 @@ |
|||||
|
package common |
||||
|
|
||||
|
import ( |
||||
|
"io/ioutil" |
||||
|
"net/http" |
||||
|
) |
||||
|
|
||||
|
//Get请求
|
||||
|
func CurlGet(getUrl string) []byte { |
||||
|
client := &http.Client{} |
||||
|
reqest, err := http.NewRequest("GET", getUrl, nil) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
response, _ := client.Do(reqest) |
||||
|
defer response.Body.Close() |
||||
|
body, err := ioutil.ReadAll(response.Body) |
||||
|
return body |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package config |
||||
|
|
||||
|
import ( |
||||
|
"main_exam_server/loges" |
||||
|
|
||||
|
"github.com/go-ini/ini" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
WorkWechatInfo = &workWechatConfig{} |
||||
|
) |
||||
|
|
||||
|
//加载企业微信配置
|
||||
|
func LoadWorkWechatConfig(configPath, configName string) (err error) { |
||||
|
dataBaseSetUp, err := ini.Load(configPath) |
||||
|
if err != nil { |
||||
|
loges.LongInit("企业微信置加载失败!") |
||||
|
return err |
||||
|
} |
||||
|
err = dataBaseSetUp.Section(configName).MapTo(WorkWechatInfo) |
||||
|
if err != nil { |
||||
|
loges.LongInit("企业微信置加载失败!") |
||||
|
return err |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package config |
||||
@ -0,0 +1,36 @@ |
|||||
|
package controller |
||||
|
|
||||
|
import ( |
||||
|
"flag" |
||||
|
"main_exam_server/common" |
||||
|
"main_exam_server/config" |
||||
|
"main_exam_server/loges" |
||||
|
"net/http" |
||||
|
"os" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
wechatConfigFiles = flag.String("wechatconfigFile", "iniconfig/workWechatConfig.ini", "APP配置文件") |
||||
|
) |
||||
|
|
||||
|
func Shiyan(ret *http.Request) (prt common.JsonOut) { |
||||
|
// flag.Parse()
|
||||
|
getdddAppConfig := config.LoadWorkWechatConfig(*wechatConfigFiles, "CompanySet") |
||||
|
if getdddAppConfig != nil { |
||||
|
loges.LongInit("App配置文件读取错误!") |
||||
|
os.Exit(3) |
||||
|
} |
||||
|
getddoAppConfig := config.LoadWorkWechatConfig(*wechatConfigFiles, "MailList") |
||||
|
if getddoAppConfig != nil { |
||||
|
loges.LongInit("App配置文件读取错误!") |
||||
|
os.Exit(3) |
||||
|
} |
||||
|
|
||||
|
getToken := "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + config.WorkWechatInfo.CompanyId + "&corpsecret=" + config.WorkWechatInfo.SecretStr |
||||
|
|
||||
|
returData := common.MapOut() |
||||
|
returData["alenda"] = config.WorkWechatInfo |
||||
|
returData["body"] = common.CurlGet(getToken) |
||||
|
prt.Data = returData |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
;企业微信 |
||||
@ -0,0 +1,14 @@ |
|||||
|
[CompanySet] |
||||
|
;企业ID |
||||
|
CompanyId = ww02f310301953277a |
||||
|
|
||||
|
|
||||
|
;通讯录 |
||||
|
[MailList] |
||||
|
;Secret |
||||
|
SecretStr = yjcQXkh6_116QKjfZfbRSyzdrFFZ9jbVlKJtL2tn3OU |
||||
|
|
||||
|
;知行学院 |
||||
|
[ZhixingCollege] |
||||
|
WeChatAgentId = 1000008 |
||||
|
SecretStr = YJOHrmHtvevAdctg-06TMLnPokIaLHdfrQMyQolZQC8 |
||||
@ -0,0 +1,4 @@ |
|||||
|
2021/11/01 07:51:16 runlog.go:42: 启动程序,开始加载基础配置... |
||||
|
2021/11/01 07:51:16 runlog.go:42: app基础配置全部加载完成! |
||||
|
2021/11/01 07:58:24 runlog.go:42: 启动程序,开始加载基础配置... |
||||
|
2021/11/01 07:58:24 runlog.go:42: app基础配置全部加载完成! |
||||
Loading…
Reference in new issue