animeic 1 年之前
父节点
当前提交
32de915e86
共有 2 个文件被更改,包括 0 次插入87 次删除
  1. 0 3
      pay/api/router.go
  2. 0 84
      pay/api/test.go

+ 0 - 3
pay/api/router.go

@@ -21,9 +21,6 @@ func RegRouters(svc *Service) {
 	// 支付订单
 	// PayOrder(payGroup)
 
-	// 其他测试
-	payGroup.GET("/print", PrintParam)
-	payGroup.GET("/getIp", GetIp)
 }
 
 func Logger() gin.HandlerFunc {

+ 0 - 84
pay/api/test.go

@@ -1,84 +0,0 @@
-package api
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"io/ioutil"
-	"net"
-	"net/http"
-	"pay/log"
-	"strings"
-	"time"
-
-	"github.com/gin-gonic/gin"
-)
-
-func PrintParam(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	// return utils.IntToDecimal(1)
-	return time.Now(), nil
-}
-func GetIp(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	return getIpInfo(c)
-}
-
-const IPV6_API = "https://api.vore.top/api/IPv6?v6="
-const IPV4_API = "https://api.vore.top/api/IPv4?v4="
-
-type IPVRes struct {
-	Msg    string  `json:"msg"`
-	IpData *IpArea `json:"ipdata"`
-}
-
-type IpArea struct {
-	Province string `json:"info1"`
-	City     string `json:"info2"`
-	District string `json:"info3"`
-	Isp      string `json:"isp"`
-}
-
-type IpInfo struct {
-	Ip string `json:"ip"`
-	IPVRes
-}
-
-func getIpInfo(c *gin.Context) (interface{}, error) {
-
-	_ips := c.Request.Header.Get("X-Forwarded-For")
-	fmt.Println("remoteip-------------:", c.RemoteIP())
-	ips := strings.Split(_ips, ",")
-	fmt.Println("ips-----------:", ips)
-	ipurl := ""
-	ipType := net.ParseIP(ips[0])
-	if ipType.To4() != nil {
-		ipurl = IPV4_API
-	} else {
-		ipurl = IPV6_API
-	}
-
-	getInfoReq := fmt.Sprintf("%s%s", ipurl, ips[0])
-	fmt.Println("requrl-----------:", getInfoReq)
-
-	resp, err := http.Get(getInfoReq)
-	if err != nil {
-		log.Error(err)
-		return nil, errors.New("ipv6获取地域失败")
-	}
-	defer resp.Body.Close()
-
-	body, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		log.Error(err)
-		return nil, errors.New("ipv6读取请求数据失败")
-	}
-	var infos IPVRes
-	err = json.Unmarshal(body, &infos)
-	if err != nil {
-		log.Error(err)
-		return nil, errors.New("unmarshal数据失败")
-	}
-
-	return IpInfo{Ip: ips[0], IPVRes: infos}, nil
-}