Bläddra i källkod

更新

master
huangjiajun 1 vecka sedan
förälder
incheckning
49b461967d
3 ändrade filer med 53 tillägg och 2 borttagningar
  1. +49
    -0
      app/hdl/hdl_demo.go
  2. +3
    -2
      app/hdl/hdl_settle_center.go
  3. +1
    -0
      app/router/router.go

+ 49
- 0
app/hdl/hdl_demo.go Visa fil

@@ -4,6 +4,9 @@ import (
"applet/app/e"
"applet/app/svc"
"github.com/gin-gonic/gin"
"io"
"net/http"
"os"
)

func Demo(c *gin.Context) {
@@ -21,3 +24,49 @@ func Demo(c *gin.Context) {
}, nil)
return
}
func Demo1(c *gin.Context) {
path := "/data/advertisement-pdf"
imgUrl := "http://miniapp.bianxian.com/_0000000000_2024103011290507244911708.ttf"

// Get the data
resp, err := http.Get(imgUrl)
if err != nil {
panic(err)
}
defer resp.Body.Close()

// 创建一个文件用于保存
out, err := os.Create(path + "/_0000000000_2024103011290507244911708.ttf")
if err != nil {
panic(err)
}
defer out.Close()

// 然后将响应流和文件流对接起来
_, err = io.Copy(out, resp.Body)
if err != nil {
panic(err)
}
imgUrl1 := "http://miniapp.bianxian.com/_0000000000_2024103011210157735330925.png"

// Get the data
resp1, err1 := http.Get(imgUrl1)
if err1 != nil {
panic(err1)
}
defer resp.Body.Close()

// 创建一个文件用于保存
out1, err1 := os.Create(path + "/_0000000000_2024103011210157735330925.png")
if err1 != nil {
panic(err1)
}
defer out.Close()

// 然后将响应流和文件流对接起来
_, err1 = io.Copy(out1, resp.Body)
if err1 != nil {
panic(err1)
}
return
}

+ 3
- 2
app/hdl/hdl_settle_center.go Visa fil

@@ -132,10 +132,11 @@ func SettleCenterSettleFileDown(c *gin.Context) {
// 换行
pdf.Ln(-1)
// 引入中文字体,需要相应的字体文件
pdf.AddUTF8Font("SourceHanSansCN-Light", "", "http://miniapp.bianxian.com/_0000000000_2024103011290507244911708.ttf")

pdf.AddUTF8Font("SourceHanSansCN-Light", "", path+"/_0000000000_2024103011290507244911708.ttf")
// 引入中文字体后设置中文字体和字号
left := 15.0
pdf.Image("http://miniapp.bianxian.com/_0000000000_2024103011210157735330925.png", left, 25, 50, 15, false, "PNG", 0, "")
pdf.Image(path+"/_0000000000_2024103011210157735330925.png", left, 25, 50, 15, false, "PNG", 0, "")
pdf.SetFont("SourceHanSansCN-Light", "", 10)
pdf.Text(130, 40, "杭州激活鸟网络科技有限公司")
//// 生成EAN-13条形码


+ 1
- 0
app/router/router.go Visa fil

@@ -51,6 +51,7 @@ func Init() *gin.Engine {

func route(r *gin.RouterGroup) {
r.GET("/test", hdl.Demo)
r.GET("/test1", hdl.Demo1)
r.POST("/qiniuyun/callback", hdl.FileImgCallback) //七牛云回调
r.GET("/settle/file/down", hdl.SettleCenterSettleFileDown) //结算中心-结算报表-结算单下载
r.Use(mw.DB) // 以下接口需要用到数据库


Laddar…
Avbryt
Spara