LingxinMeng 1 سال پیش
والد
کامیت
0306c19dfb

+ 0 - 1
amd64/report-server/application.yaml

@@ -15,5 +15,4 @@ mysql:
   password: 1qaz2wsx!
   dbname: dataclosedloop
   charset: utf8
-  sql-files-dir: D:\code\yuexin-platform\yuexin-pay\sql
 

+ 10 - 0
amd64/report-server/entity/e_record.go

@@ -0,0 +1,10 @@
+package entity
+
+type Record struct {
+	Team         string  `json:"team"`
+	Topic        string  `json:"topic"`
+	ScoreOnline  float64 `json:"scoreOnline"`
+	ScoreOffline float64 `json:"scoreOffline"`
+	ScoreFinal   float64 `json:"scoreFinal"`
+	Details      string  `json:"string"`
+}

+ 30 - 0
amd64/report-server/handler/h_report.go

@@ -0,0 +1,30 @@
+package handler
+
+import (
+	"cicv-data-closedloop/common/entity"
+	"github.com/gin-gonic/gin"
+	"net/http"
+)
+
+type testStruct struct {
+	Id   int    `db:"id"`
+	Name string `db:"name"`
+}
+
+// Page 分页查询
+func Page(c *gin.Context) {
+	//// 获取请求参数
+	//param := c.Query("param")
+	//c_log.GlobalLogger.Info("接受到请求参数:", param)
+	//var tests []testStruct
+	//// 查询数据库
+	//var testSql string
+	//if err := c_db.MysqlDb.Select(&tests, testSql); err != nil {
+	//	c_log.GlobalLogger.Error("数据库查询报错:", err)
+	//	c.JSON(http.StatusInternalServerError, entity.DefaultFailHttpResult)
+	//	return
+	//}
+	//c_log.GlobalLogger.Info("数据库查询成功:", tests)
+
+	c.JSON(http.StatusOK, entity.DefaultSuccessHttpResult)
+}

+ 3 - 6
amd64/report-server/main.go

@@ -70,12 +70,9 @@ func main() {
 	router.Use(middleware.ValidateHeaders(ApplicationYaml.Web.WhiteList, ApplicationYaml.Web.Token)) // 全局请求头校验
 	// 通过路由组设置全局前缀
 	projectPrefix := router.Group(ApplicationYaml.Web.RoutePrefix)
-	// hello 测试接口
-	apiTest := projectPrefix.Group("/test")
-	apiTest.GET("/hello", handler.Hello)
-	// YunGouOs 支付接口
-	apiYunGouOs := projectPrefix.Group("/yungouos")
-	apiYunGouOs.GET("/hello", handler.Hello)
+	// 接口
+	projectPrefix.POST("/page", handler.Hello) // 分页查询
+	projectPrefix.POST("/pdf", handler.Hello)  // pdf下载
 	// 端口
 	err := router.Run(":" + ApplicationYaml.Web.Port)
 	if err != nil {

+ 23 - 0
common/entity/http_result.go

@@ -1,5 +1,7 @@
 package entity
 
+import "encoding/json"
+
 var DefaultSuccessHttpResult = &HttpResult{Status: true, Code: "1000", Message: "请求成功。"}
 var DefaultFailHttpResult = &HttpResult{Status: true, Code: "2000", Message: "请求失败。"}
 
@@ -9,3 +11,24 @@ type HttpResult struct {
 	Message string `json:"message"`
 	Details string `json:"details"`
 }
+
+type Response struct {
+	Code int         `json:"code"` // 错误码
+	Msg  string      `json:"msg"`  // 错误描述
+	Data interface{} `json:"data"` // 返回数据
+}
+
+// ToString 返回 JSON 格式的错误详情
+func (res *Response) ToString() string {
+	err := &struct {
+		Code int         `json:"code"`
+		Msg  string      `json:"msg"`
+		Data interface{} `json:"data"`
+	}{
+		Code: res.Code,
+		Msg:  res.Msg,
+		Data: res.Data,
+	}
+	raw, _ := json.Marshal(err)
+	return string(raw)
+}