SmartMurphytt/chainmaker_go/controller/resourceStatisticsControlle...

35 lines
591 B
Go

package controller
import (
"chainmaker_go/database"
"chainmaker_go/model"
"fmt"
"github.com/gin-gonic/gin"
"log"
)
func ResourceStatistics(ctx *gin.Context) {
DB := database.GetDB()
cookie, err := ctx.Cookie("username")
if err != nil {
cookie = "NotSet"
}
fmt.Printf("Cookie value: %s \n", cookie)
//获取参数
user_id = cookie
//查询该用户所有资源
var resources []model.Resource
DB.Where("User_id = ? ", user_id).Find(&resources)
log.Println(resources)
//返回结果
ctx.JSON(200, gin.H{
"code": 200,
"msg": "成功!",
"data": resources,
})
}