Browse Source

修改底层配置

rdluck 4 years ago
parent
commit
c206055d90
5 changed files with 33 additions and 31 deletions
  1. 7 1
      controllers/base_common.go
  2. 13 16
      utils/common.go
  3. 6 6
      utils/config.go
  4. 5 6
      utils/constants.go
  5. 2 2
      utils/jwt.go

+ 7 - 1
controllers/base_common.go

@@ -16,8 +16,14 @@ type BaseCommonController struct {
 }
 
 func (this *BaseCommonController) Prepare() {
+	var requestBody string
+	method := this.Ctx.Input.Method()
+	if method == "GET" {
+		requestBody = this.Ctx.Request.RequestURI
+	} else {
+		requestBody, _ = url.QueryUnescape(string(this.Ctx.Input.RequestBody))
+	}
 	ip := this.Ctx.Input.IP()
-	requestBody, _ := url.QueryUnescape(string(this.Ctx.Input.RequestBody))
 	apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)
 }
 

+ 13 - 16
utils/common.go

@@ -1,4 +1,3 @@
-
 package utils
 
 import (
@@ -292,22 +291,22 @@ func SaveBase64ToFile(content, path string) error {
 
 func SaveBase64ToFileBySeek(content, path string) (err error) {
 	data, err := base64.StdEncoding.DecodeString(content)
-	exist,err:=PathExists(path)
-	if err!=nil {
+	exist, err := PathExists(path)
+	if err != nil {
 		return
 	}
 	if !exist {
 		f, err := os.Create(path)
-		if err!=nil {
+		if err != nil {
 			return err
 		}
 		n, _ := f.Seek(0, 2)
 		// 从末尾的偏移量开始写入内容
 		_, err = f.WriteAt([]byte(data), n)
 		defer f.Close()
-	}else{
+	} else {
 		f, err := os.OpenFile(path, os.O_WRONLY, 0644)
-		if err!=nil {
+		if err != nil {
 			return err
 		}
 		n, _ := f.Seek(0, 2)
@@ -319,7 +318,7 @@ func SaveBase64ToFileBySeek(content, path string) (err error) {
 	return nil
 }
 
-func PathExists(path string) (bool,error) {
+func PathExists(path string) (bool, error) {
 	_, err := os.Stat(path)
 	if err == nil {
 		return true, nil
@@ -489,7 +488,6 @@ func Sha1(data string) string {
 	return hex.EncodeToString(sha1.Sum([]byte("")))
 }
 
-
 func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
 	cmd := `ffmpeg -i ` + videoPath + `  2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//`
 	out, err := exec.Command("bash", "-c", cmd).Output()
@@ -497,7 +495,7 @@ func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
 		return
 	}
 	outTimes := string(out)
-	fmt.Println("outTimes:",outTimes)
+	fmt.Println("outTimes:", outTimes)
 	if outTimes != "" {
 		timeArr := strings.Split(outTimes, ":")
 		h := timeArr[0]
@@ -505,18 +503,18 @@ func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
 		s := timeArr[2]
 		hInt, err := strconv.Atoi(h)
 		if err != nil {
-			return playSeconds,err
+			return playSeconds, err
 		}
 
 		mInt, err := strconv.Atoi(m)
 		if err != nil {
-			return playSeconds,err
+			return playSeconds, err
 		}
-		s=strings.Trim(s," ")
-		s=strings.Trim(s,"\n")
-		sInt, err :=strconv.ParseFloat(s, 64)
+		s = strings.Trim(s, " ")
+		s = strings.Trim(s, "\n")
+		sInt, err := strconv.ParseFloat(s, 64)
 		if err != nil {
-			return playSeconds,err
+			return playSeconds, err
 		}
 		playSeconds = float64(hInt)*3600 + float64(mInt)*60 + float64(sInt)
 	}
@@ -535,7 +533,6 @@ func GetMaxTradeCode(tradeCode string) (maxTradeCode string, err error) {
 	return
 }
 
-
 // excel日期字段格式化 yyyy-mm-dd
 func ConvertToFormatDay(excelDaysString string) string {
 	// 2006-01-02 距离 1900-01-01的天数

+ 6 - 6
utils/config.go

@@ -20,8 +20,8 @@ var (
 	WxId                string //微信原始ID
 	WxAppId             string
 	WxAppSecret         string
-	TemplateIdByProduct string//产品运行报告通知-模板ID
-	TemplateRedirectUrl string//模板消息跳转地址
+	TemplateIdByProduct string //产品运行报告通知-模板ID
+	TemplateRedirectUrl string //模板消息跳转地址
 )
 
 func init() {
@@ -40,17 +40,17 @@ func init() {
 		WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
 		WxId = "gh_b67e0049fb8c"
 		TemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84"
-		TemplateRedirectUrl="https://ficc.hzinsights.com/reportdtl?id="
+		TemplateRedirectUrl = "https://ficc.hzinsights.com/reportdtl?id="
 
-		STATIC_DIR="/home/static/imgs/"
+		STATIC_DIR = "/home/static/imgs/"
 	} else {
 		WxAppId = "wx9b5d7291e581233a"
 		WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
 		WxId = "gh_5dc508325c6f"
 		TemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
-		TemplateRedirectUrl="http://rddpweb.brilliantstart.cn/reportdtl?id="
+		TemplateRedirectUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id="
 
-		STATIC_DIR="/home/static/imgs/"
+		STATIC_DIR = "/home/static/imgs/"
 	}
 }
 

+ 5 - 6
utils/constants.go

@@ -46,7 +46,7 @@ const (
 	XfSTATUS_FIRST_FRAME    = 0 //第一帧标识
 	XfSTATUS_CONTINUE_FRAME = 1 //中间帧标识
 	XfSTATUS_LAST_FRAME     = 2 //最后一帧标识
-	XfAPPID               = "5ed70e9d"
+	XfAPPID                 = "5ed70e9d"
 	XfAPIKey                = "d580509ca262e9586fb65a7064d5ce77"
 	XfAPISecret             = "a085720dc55850c720fa5576335f847a"
 	XfHostUrl               = "wss://tts-api.xfyun.cn/v2/tts"
@@ -54,14 +54,13 @@ const (
 	XfHost                  = "tts-api.xfyun.cn"
 )
 
-
 //OSS
 var (
-	Endpoint        string = "oss-cn-shanghai.aliyuncs.com"
-	Bucketname      string = "hongze"
+	Endpoint   string = "oss-cn-shanghai.aliyuncs.com"
+	Bucketname string = "hongze"
 
-	Imghost         string = "http://hongze.oss-cn-shanghai.aliyuncs.com/"
-	Upload_dir      string = "static/images/"
+	Imghost    string = "http://hongze.oss-cn-shanghai.aliyuncs.com/"
+	Upload_dir string = "static/images/"
 
 	AccessKeyId     string = "LTAIFMZYQhS2BTvW"
 	AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"

+ 2 - 2
utils/jwt.go

@@ -17,8 +17,8 @@ func GenToken(account string) string {
 	token := jwt.New(jwt.SigningMethodHS256)
 	token.Claims = &jwt.StandardClaims{
 		NotBefore: int64(time.Now().Unix()),
-		ExpiresAt: int64(time.Now().Unix() + 3600*3),
-		Issuer:    "csdp",
+		ExpiresAt: int64(time.Now().Unix() + 90*24*60*60),
+		Issuer:    "hongze_api",
 		Subject:   account,
 	}
 	ss, err := token.SignedString(KEY)