admin_backend/sdk/ship/main.go
2025-11-14 16:08:42 +08:00

42 lines
960 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"backend/common"
shipcommon "backend/sdk/ship/common"
"backend/sdk/ship/model/test"
"backend/sdk/ship/model/tuyou"
"fmt"
"io"
"log"
"os"
"github.com/gin-gonic/gin"
)
func init() {
// 以追加模式打开或创建日志文件
file, err := os.OpenFile("./log/charge.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
log.Fatalf("failed to open log file: %v", err)
}
// 将默认日志输出指向文件Go 标准 log
log.SetOutput(file)
// 让 gin 的日志也写入文件,并同时输出到控制台
gin.DefaultWriter = io.MultiWriter(file, os.Stdout)
gin.DefaultErrorWriter = io.MultiWriter(file, os.Stderr)
common.Init()
}
func main() {
// gin.SetMode(gin.ReleaseMode)
r := gin.Default()
ChargeApi := r.Group("/api")
{
// 充值发货
ChargeApi.POST("test/charge", test.Charge)
ChargeApi.POST("tuyou/charge", tuyou.Charge)
}
r.Run(fmt.Sprintf(":%d", shipcommon.AppConf.Port))
}