package main

import (
	_ "ARKItems/configs"
	configs "ARKItems/configs"
	"ARKItems/entity"
	"ARKItems/router"
	"github.com/gin-gonic/gin"
	"net/http"
	"strings"
)

func main() {
	RunGin()
	//router.WriteFileConfig(nil)
}
func RunGin() {
	engine := gin.Default()
	engine.StaticFS("/static", http.Dir("file"))
	router.LoadRouter(engine)
	engine.Run(configs.Server.Host + ":" + configs.Server.Port)
}
func ResetTek() {
	var items []entity.ArkDinoInfo
	_, err := configs.Engine.Table("ark_dino_info").FindAndCount(&items)
	if err != nil {
		panic(err)
	}
	for i := range items {
		blueprint := items[i].Blueprint
		if strings.Index(blueprint, "\"") == 0 && strings.LastIndex(blueprint, "\"") == len(blueprint)-1 {
			blueprint = blueprint[1 : len(blueprint)-1]
		}
		_, err := configs.Engine.Table("ark_dino_info").Where("id = ?", items[i].Id).
			Update(map[string]interface{}{"blueprint": blueprint})
		if err != nil {
			panic(err)
		}
	}

}
