add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
@@ -4,7 +4,7 @@ server:
|
|||||||
writeTimeout: 5s
|
writeTimeout: 5s
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
dsn: "root:mysql_78GywN@tcp(111.228.49.52:3306)/db?parseTime=true&loc=Local"
|
dsn: "root:mysql_78GywN@tcp(111.228.49.52:3306)/epic_db?parseTime=true&loc=Local"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
addr: "111.228.49.52"
|
addr: "111.228.49.52"
|
||||||
@@ -13,7 +13,7 @@ redis:
|
|||||||
|
|
||||||
log:
|
log:
|
||||||
level: info
|
level: info
|
||||||
format: json
|
format: console
|
||||||
|
|
||||||
cron:
|
cron:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -5,6 +5,7 @@ go 1.24.11
|
|||||||
require (
|
require (
|
||||||
github.com/go-sql-driver/mysql v1.9.3
|
github.com/go-sql-driver/mysql v1.9.3
|
||||||
github.com/labstack/echo/v4 v4.15.0
|
github.com/labstack/echo/v4 v4.15.0
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/redis/go-redis/v9 v9.17.2
|
github.com/redis/go-redis/v9 v9.17.2
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/spf13/viper v1.21.0
|
github.com/spf13/viper v1.21.0
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -65,6 +65,8 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
|
|||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
|
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (h *HeroController) GetByID(c echo.Context) error {
|
|||||||
hero, err := h.svc.GetByID(c.Request().Context(), id)
|
hero, err := h.svc.GetByID(c.Request().Context(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return echo.NewHTTPError(http.StatusNotFound, "hero not found")
|
return c.JSON(http.StatusOK, vo.OK(nil))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicArtifactInfo struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicArtifactInfo) Table() string {
|
func (EpicArtifactInfo) Annotations() []schema.Annotation {
|
||||||
return "epic_artifact_info"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_artifact_info"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicArtifactInfo) Fields() []ent.Field {
|
func (EpicArtifactInfo) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicGvgAttackTeams struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgAttackTeams) Table() string {
|
func (EpicGvgAttackTeams) Annotations() []schema.Annotation {
|
||||||
return "epic_gvg_attack_teams"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_gvg_attack_teams"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgAttackTeams) Fields() []ent.Field {
|
func (EpicGvgAttackTeams) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicGvgDefenseAttackMapping struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgDefenseAttackMapping) Table() string {
|
func (EpicGvgDefenseAttackMapping) Annotations() []schema.Annotation {
|
||||||
return "epic_gvg_defense_attack_mapping"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_gvg_defense_attack_mapping"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgDefenseAttackMapping) Fields() []ent.Field {
|
func (EpicGvgDefenseAttackMapping) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicGvgDefenseTeams struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgDefenseTeams) Table() string {
|
func (EpicGvgDefenseTeams) Annotations() []schema.Annotation {
|
||||||
return "epic_gvg_defense_teams"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_gvg_defense_teams"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicGvgDefenseTeams) Fields() []ent.Field {
|
func (EpicGvgDefenseTeams) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicHeroInfo struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicHeroInfo) Table() string {
|
func (EpicHeroInfo) Annotations() []schema.Annotation {
|
||||||
return "epic_hero_info"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_hero_info"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicHeroInfo) Fields() []ent.Field {
|
func (EpicHeroInfo) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicHeroUserBuild struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicHeroUserBuild) Table() string {
|
func (EpicHeroUserBuild) Annotations() []schema.Annotation {
|
||||||
return "epic_hero_user_build"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_hero_user_build"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicHeroUserBuild) Fields() []ent.Field {
|
func (EpicHeroUserBuild) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type EpicI18NMappings struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicI18NMappings) Table() string {
|
func (EpicI18NMappings) Annotations() []schema.Annotation {
|
||||||
return "epic_i18n_mappings"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "epic_i18n_mappings"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (EpicI18NMappings) Fields() []ent.Field {
|
func (EpicI18NMappings) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type FribbleHeroSet struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (FribbleHeroSet) Table() string {
|
func (FribbleHeroSet) Annotations() []schema.Annotation {
|
||||||
return "fribble_hero_set"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "fribble_hero_set"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (FribbleHeroSet) Fields() []ent.Field {
|
func (FribbleHeroSet) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,10 @@ type GearSetInfo struct {
|
|||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (GearSetInfo) Table() string {
|
func (GearSetInfo) Annotations() []schema.Annotation {
|
||||||
return "gear_set_info"
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "gear_set_info"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (GearSetInfo) Fields() []ent.Field {
|
func (GearSetInfo) Fields() []ent.Field {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package vo
|
|||||||
type Response struct {
|
type Response struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Data any `json:"data,omitempty"`
|
Data any `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func OK(data any) Response {
|
func OK(data any) Response {
|
||||||
@@ -18,5 +18,6 @@ func Error(message string) Response {
|
|||||||
return Response{
|
return Response{
|
||||||
Code: "ERROR",
|
Code: "ERROR",
|
||||||
Message: message,
|
Message: message,
|
||||||
|
Data: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const (
|
|||||||
// FieldImageURL holds the string denoting the image_url field in the database.
|
// FieldImageURL holds the string denoting the image_url field in the database.
|
||||||
FieldImageURL = "image_url"
|
FieldImageURL = "image_url"
|
||||||
// Table holds the table name of the epicartifactinfo in the database.
|
// Table holds the table name of the epicartifactinfo in the database.
|
||||||
Table = "epic_artifact_infos"
|
Table = "epic_artifact_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for epicartifactinfo fields.
|
// Columns holds all SQL columns for epicartifactinfo fields.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const (
|
|||||||
// FieldDeleted holds the string denoting the deleted field in the database.
|
// FieldDeleted holds the string denoting the deleted field in the database.
|
||||||
FieldDeleted = "deleted"
|
FieldDeleted = "deleted"
|
||||||
// Table holds the table name of the epicgvgdefenseattackmapping in the database.
|
// Table holds the table name of the epicgvgdefenseattackmapping in the database.
|
||||||
Table = "epic_gvg_defense_attack_mappings"
|
Table = "epic_gvg_defense_attack_mapping"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for epicgvgdefenseattackmapping fields.
|
// Columns holds all SQL columns for epicgvgdefenseattackmapping fields.
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const (
|
|||||||
// FieldUpdateTimeSet holds the string denoting the update_time_set field in the database.
|
// FieldUpdateTimeSet holds the string denoting the update_time_set field in the database.
|
||||||
FieldUpdateTimeSet = "update_time_set"
|
FieldUpdateTimeSet = "update_time_set"
|
||||||
// Table holds the table name of the epicheroinfo in the database.
|
// Table holds the table name of the epicheroinfo in the database.
|
||||||
Table = "epic_hero_infos"
|
Table = "epic_hero_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for epicheroinfo fields.
|
// Columns holds all SQL columns for epicheroinfo fields.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const (
|
|||||||
// FieldDeleted holds the string denoting the deleted field in the database.
|
// FieldDeleted holds the string denoting the deleted field in the database.
|
||||||
FieldDeleted = "deleted"
|
FieldDeleted = "deleted"
|
||||||
// Table holds the table name of the epicherouserbuild in the database.
|
// Table holds the table name of the epicherouserbuild in the database.
|
||||||
Table = "epic_hero_user_builds"
|
Table = "epic_hero_user_build"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for epicherouserbuild fields.
|
// Columns holds all SQL columns for epicherouserbuild fields.
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const (
|
|||||||
// FieldSuccessGet holds the string denoting the success_get field in the database.
|
// FieldSuccessGet holds the string denoting the success_get field in the database.
|
||||||
FieldSuccessGet = "success_get"
|
FieldSuccessGet = "success_get"
|
||||||
// Table holds the table name of the fribbleheroset in the database.
|
// Table holds the table name of the fribbleheroset in the database.
|
||||||
Table = "fribble_hero_sets"
|
Table = "fribble_hero_set"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for fribbleheroset fields.
|
// Columns holds all SQL columns for fribbleheroset fields.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const (
|
|||||||
// FieldTenantID holds the string denoting the tenant_id field in the database.
|
// FieldTenantID holds the string denoting the tenant_id field in the database.
|
||||||
FieldTenantID = "tenant_id"
|
FieldTenantID = "tenant_id"
|
||||||
// Table holds the table name of the gearsetinfo in the database.
|
// Table holds the table name of the gearsetinfo in the database.
|
||||||
Table = "gear_set_infos"
|
Table = "gear_set_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for gearsetinfo fields.
|
// Columns holds all SQL columns for gearsetinfo fields.
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
package migrate
|
package migrate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
"entgo.io/ent/dialect/sql/schema"
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// EpicArtifactInfosColumns holds the columns for the "epic_artifact_infos" table.
|
// EpicArtifactInfoColumns holds the columns for the "epic_artifact_info" table.
|
||||||
EpicArtifactInfosColumns = []*schema.Column{
|
EpicArtifactInfoColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "artifact_name", Type: field.TypeString, Size: 255},
|
{Name: "artifact_name", Type: field.TypeString, Size: 255},
|
||||||
{Name: "artifact_code", Type: field.TypeString, Size: 255},
|
{Name: "artifact_code", Type: field.TypeString, Size: 255},
|
||||||
@@ -26,11 +27,11 @@ var (
|
|||||||
{Name: "artifact_name_en", Type: field.TypeString, Size: 255},
|
{Name: "artifact_name_en", Type: field.TypeString, Size: 255},
|
||||||
{Name: "image_url", Type: field.TypeString, Size: 255},
|
{Name: "image_url", Type: field.TypeString, Size: 255},
|
||||||
}
|
}
|
||||||
// EpicArtifactInfosTable holds the schema information for the "epic_artifact_infos" table.
|
// EpicArtifactInfoTable holds the schema information for the "epic_artifact_info" table.
|
||||||
EpicArtifactInfosTable = &schema.Table{
|
EpicArtifactInfoTable = &schema.Table{
|
||||||
Name: "epic_artifact_infos",
|
Name: "epic_artifact_info",
|
||||||
Columns: EpicArtifactInfosColumns,
|
Columns: EpicArtifactInfoColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicArtifactInfosColumns[0]},
|
PrimaryKey: []*schema.Column{EpicArtifactInfoColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicGvgAttackTeamsColumns holds the columns for the "epic_gvg_attack_teams" table.
|
// EpicGvgAttackTeamsColumns holds the columns for the "epic_gvg_attack_teams" table.
|
||||||
EpicGvgAttackTeamsColumns = []*schema.Column{
|
EpicGvgAttackTeamsColumns = []*schema.Column{
|
||||||
@@ -48,8 +49,8 @@ var (
|
|||||||
Columns: EpicGvgAttackTeamsColumns,
|
Columns: EpicGvgAttackTeamsColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicGvgAttackTeamsColumns[0]},
|
PrimaryKey: []*schema.Column{EpicGvgAttackTeamsColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicGvgDefenseAttackMappingsColumns holds the columns for the "epic_gvg_defense_attack_mappings" table.
|
// EpicGvgDefenseAttackMappingColumns holds the columns for the "epic_gvg_defense_attack_mapping" table.
|
||||||
EpicGvgDefenseAttackMappingsColumns = []*schema.Column{
|
EpicGvgDefenseAttackMappingColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "defense_id", Type: field.TypeInt64},
|
{Name: "defense_id", Type: field.TypeInt64},
|
||||||
{Name: "attack_id", Type: field.TypeInt64},
|
{Name: "attack_id", Type: field.TypeInt64},
|
||||||
@@ -64,11 +65,11 @@ var (
|
|||||||
{Name: "update_time", Type: field.TypeTime, Nullable: true},
|
{Name: "update_time", Type: field.TypeTime, Nullable: true},
|
||||||
{Name: "deleted", Type: field.TypeBool},
|
{Name: "deleted", Type: field.TypeBool},
|
||||||
}
|
}
|
||||||
// EpicGvgDefenseAttackMappingsTable holds the schema information for the "epic_gvg_defense_attack_mappings" table.
|
// EpicGvgDefenseAttackMappingTable holds the schema information for the "epic_gvg_defense_attack_mapping" table.
|
||||||
EpicGvgDefenseAttackMappingsTable = &schema.Table{
|
EpicGvgDefenseAttackMappingTable = &schema.Table{
|
||||||
Name: "epic_gvg_defense_attack_mappings",
|
Name: "epic_gvg_defense_attack_mapping",
|
||||||
Columns: EpicGvgDefenseAttackMappingsColumns,
|
Columns: EpicGvgDefenseAttackMappingColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicGvgDefenseAttackMappingsColumns[0]},
|
PrimaryKey: []*schema.Column{EpicGvgDefenseAttackMappingColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicGvgDefenseTeamsColumns holds the columns for the "epic_gvg_defense_teams" table.
|
// EpicGvgDefenseTeamsColumns holds the columns for the "epic_gvg_defense_teams" table.
|
||||||
EpicGvgDefenseTeamsColumns = []*schema.Column{
|
EpicGvgDefenseTeamsColumns = []*schema.Column{
|
||||||
@@ -86,8 +87,8 @@ var (
|
|||||||
Columns: EpicGvgDefenseTeamsColumns,
|
Columns: EpicGvgDefenseTeamsColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicGvgDefenseTeamsColumns[0]},
|
PrimaryKey: []*schema.Column{EpicGvgDefenseTeamsColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicHeroInfosColumns holds the columns for the "epic_hero_infos" table.
|
// EpicHeroInfoColumns holds the columns for the "epic_hero_info" table.
|
||||||
EpicHeroInfosColumns = []*schema.Column{
|
EpicHeroInfoColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "hero_name", Type: field.TypeString, Size: 255},
|
{Name: "hero_name", Type: field.TypeString, Size: 255},
|
||||||
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
||||||
@@ -108,14 +109,14 @@ var (
|
|||||||
{Name: "content_json_set", Type: field.TypeString, Size: 255},
|
{Name: "content_json_set", Type: field.TypeString, Size: 255},
|
||||||
{Name: "update_time_set", Type: field.TypeTime, Nullable: true},
|
{Name: "update_time_set", Type: field.TypeTime, Nullable: true},
|
||||||
}
|
}
|
||||||
// EpicHeroInfosTable holds the schema information for the "epic_hero_infos" table.
|
// EpicHeroInfoTable holds the schema information for the "epic_hero_info" table.
|
||||||
EpicHeroInfosTable = &schema.Table{
|
EpicHeroInfoTable = &schema.Table{
|
||||||
Name: "epic_hero_infos",
|
Name: "epic_hero_info",
|
||||||
Columns: EpicHeroInfosColumns,
|
Columns: EpicHeroInfoColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicHeroInfosColumns[0]},
|
PrimaryKey: []*schema.Column{EpicHeroInfoColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicHeroUserBuildsColumns holds the columns for the "epic_hero_user_builds" table.
|
// EpicHeroUserBuildColumns holds the columns for the "epic_hero_user_build" table.
|
||||||
EpicHeroUserBuildsColumns = []*schema.Column{
|
EpicHeroUserBuildColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "artifact_code", Type: field.TypeString, Size: 255},
|
{Name: "artifact_code", Type: field.TypeString, Size: 255},
|
||||||
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
||||||
@@ -128,11 +129,11 @@ var (
|
|||||||
{Name: "update_time", Type: field.TypeTime, Nullable: true},
|
{Name: "update_time", Type: field.TypeTime, Nullable: true},
|
||||||
{Name: "deleted", Type: field.TypeBool},
|
{Name: "deleted", Type: field.TypeBool},
|
||||||
}
|
}
|
||||||
// EpicHeroUserBuildsTable holds the schema information for the "epic_hero_user_builds" table.
|
// EpicHeroUserBuildTable holds the schema information for the "epic_hero_user_build" table.
|
||||||
EpicHeroUserBuildsTable = &schema.Table{
|
EpicHeroUserBuildTable = &schema.Table{
|
||||||
Name: "epic_hero_user_builds",
|
Name: "epic_hero_user_build",
|
||||||
Columns: EpicHeroUserBuildsColumns,
|
Columns: EpicHeroUserBuildColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicHeroUserBuildsColumns[0]},
|
PrimaryKey: []*schema.Column{EpicHeroUserBuildColumns[0]},
|
||||||
}
|
}
|
||||||
// EpicI18nMappingsColumns holds the columns for the "epic_i18n_mappings" table.
|
// EpicI18nMappingsColumns holds the columns for the "epic_i18n_mappings" table.
|
||||||
EpicI18nMappingsColumns = []*schema.Column{
|
EpicI18nMappingsColumns = []*schema.Column{
|
||||||
@@ -155,8 +156,8 @@ var (
|
|||||||
Columns: EpicI18nMappingsColumns,
|
Columns: EpicI18nMappingsColumns,
|
||||||
PrimaryKey: []*schema.Column{EpicI18nMappingsColumns[0]},
|
PrimaryKey: []*schema.Column{EpicI18nMappingsColumns[0]},
|
||||||
}
|
}
|
||||||
// FribbleHeroSetsColumns holds the columns for the "fribble_hero_sets" table.
|
// FribbleHeroSetColumns holds the columns for the "fribble_hero_set" table.
|
||||||
FribbleHeroSetsColumns = []*schema.Column{
|
FribbleHeroSetColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
{Name: "hero_code", Type: field.TypeString, Size: 255},
|
||||||
{Name: "json_content", Type: field.TypeString, Size: 255},
|
{Name: "json_content", Type: field.TypeString, Size: 255},
|
||||||
@@ -168,14 +169,14 @@ var (
|
|||||||
{Name: "deleted", Type: field.TypeBool},
|
{Name: "deleted", Type: field.TypeBool},
|
||||||
{Name: "success_get", Type: field.TypeInt},
|
{Name: "success_get", Type: field.TypeInt},
|
||||||
}
|
}
|
||||||
// FribbleHeroSetsTable holds the schema information for the "fribble_hero_sets" table.
|
// FribbleHeroSetTable holds the schema information for the "fribble_hero_set" table.
|
||||||
FribbleHeroSetsTable = &schema.Table{
|
FribbleHeroSetTable = &schema.Table{
|
||||||
Name: "fribble_hero_sets",
|
Name: "fribble_hero_set",
|
||||||
Columns: FribbleHeroSetsColumns,
|
Columns: FribbleHeroSetColumns,
|
||||||
PrimaryKey: []*schema.Column{FribbleHeroSetsColumns[0]},
|
PrimaryKey: []*schema.Column{FribbleHeroSetColumns[0]},
|
||||||
}
|
}
|
||||||
// GearSetInfosColumns holds the columns for the "gear_set_infos" table.
|
// GearSetInfoColumns holds the columns for the "gear_set_info" table.
|
||||||
GearSetInfosColumns = []*schema.Column{
|
GearSetInfoColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
{Name: "level", Type: field.TypeInt},
|
{Name: "level", Type: field.TypeInt},
|
||||||
{Name: "gear_id", Type: field.TypeInt64},
|
{Name: "gear_id", Type: field.TypeInt64},
|
||||||
@@ -200,25 +201,52 @@ var (
|
|||||||
{Name: "deleted", Type: field.TypeBool},
|
{Name: "deleted", Type: field.TypeBool},
|
||||||
{Name: "tenant_id", Type: field.TypeInt64},
|
{Name: "tenant_id", Type: field.TypeInt64},
|
||||||
}
|
}
|
||||||
// GearSetInfosTable holds the schema information for the "gear_set_infos" table.
|
// GearSetInfoTable holds the schema information for the "gear_set_info" table.
|
||||||
GearSetInfosTable = &schema.Table{
|
GearSetInfoTable = &schema.Table{
|
||||||
Name: "gear_set_infos",
|
Name: "gear_set_info",
|
||||||
Columns: GearSetInfosColumns,
|
Columns: GearSetInfoColumns,
|
||||||
PrimaryKey: []*schema.Column{GearSetInfosColumns[0]},
|
PrimaryKey: []*schema.Column{GearSetInfoColumns[0]},
|
||||||
}
|
}
|
||||||
// Tables holds all the tables in the schema.
|
// Tables holds all the tables in the schema.
|
||||||
Tables = []*schema.Table{
|
Tables = []*schema.Table{
|
||||||
EpicArtifactInfosTable,
|
EpicArtifactInfoTable,
|
||||||
EpicGvgAttackTeamsTable,
|
EpicGvgAttackTeamsTable,
|
||||||
EpicGvgDefenseAttackMappingsTable,
|
EpicGvgDefenseAttackMappingTable,
|
||||||
EpicGvgDefenseTeamsTable,
|
EpicGvgDefenseTeamsTable,
|
||||||
EpicHeroInfosTable,
|
EpicHeroInfoTable,
|
||||||
EpicHeroUserBuildsTable,
|
EpicHeroUserBuildTable,
|
||||||
EpicI18nMappingsTable,
|
EpicI18nMappingsTable,
|
||||||
FribbleHeroSetsTable,
|
FribbleHeroSetTable,
|
||||||
GearSetInfosTable,
|
GearSetInfoTable,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
EpicArtifactInfoTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_artifact_info",
|
||||||
|
}
|
||||||
|
EpicGvgAttackTeamsTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_gvg_attack_teams",
|
||||||
|
}
|
||||||
|
EpicGvgDefenseAttackMappingTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_gvg_defense_attack_mapping",
|
||||||
|
}
|
||||||
|
EpicGvgDefenseTeamsTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_gvg_defense_teams",
|
||||||
|
}
|
||||||
|
EpicHeroInfoTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_hero_info",
|
||||||
|
}
|
||||||
|
EpicHeroUserBuildTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_hero_user_build",
|
||||||
|
}
|
||||||
|
EpicI18nMappingsTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "epic_i18n_mappings",
|
||||||
|
}
|
||||||
|
FribbleHeroSetTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "fribble_hero_set",
|
||||||
|
}
|
||||||
|
GearSetInfoTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "gear_set_info",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package exception
|
package exception
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"epic-ent/internal/domain/vo"
|
"epic-ent/internal/domain/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterErrorHandler(e *echo.Echo) {
|
func RegisterErrorHandler(e *echo.Echo, logger *zap.Logger) {
|
||||||
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
msg := err.Error()
|
msg := err.Error()
|
||||||
@@ -19,6 +21,14 @@ func RegisterErrorHandler(e *echo.Echo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verbose := fmt.Sprintf("%+v", err)
|
||||||
|
logger.With(
|
||||||
|
zap.Int("status", code),
|
||||||
|
zap.String("path", c.Path()),
|
||||||
|
zap.String("method", c.Request().Method),
|
||||||
|
zap.Error(err),
|
||||||
|
).Error(verbose)
|
||||||
|
|
||||||
_ = c.JSON(code, vo.Error(msg))
|
_ = c.JSON(code, vo.Error(msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,21 @@ func NewLogger(cfg *config.Config) (*zap.Logger, error) {
|
|||||||
|
|
||||||
zapCfg := zap.NewProductionConfig()
|
zapCfg := zap.NewProductionConfig()
|
||||||
zapCfg.Level = zap.NewAtomicLevelAt(level)
|
zapCfg.Level = zap.NewAtomicLevelAt(level)
|
||||||
|
zapCfg.EncoderConfig.CallerKey = "caller"
|
||||||
|
zapCfg.EncoderConfig.StacktraceKey = "stacktrace"
|
||||||
if cfg.Log.Format == "console" {
|
if cfg.Log.Format == "console" {
|
||||||
zapCfg.Encoding = "console"
|
devCfg := zap.NewDevelopmentConfig()
|
||||||
|
devCfg.Level = zap.NewAtomicLevelAt(level)
|
||||||
|
devCfg.EncoderConfig.CallerKey = "caller"
|
||||||
|
devCfg.EncoderConfig.StacktraceKey = "stacktrace"
|
||||||
|
return devCfg.Build(
|
||||||
|
zap.AddCaller(),
|
||||||
|
zap.AddStacktrace(zapcore.ErrorLevel),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return zapCfg.Build()
|
return zapCfg.Build(
|
||||||
|
zap.AddCaller(),
|
||||||
|
zap.AddStacktrace(zapcore.ErrorLevel),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"epic-ent/internal/domain/dto"
|
"epic-ent/internal/domain/dto"
|
||||||
"epic-ent/internal/domain/vo"
|
"epic-ent/internal/domain/vo"
|
||||||
"epic-ent/internal/ent"
|
"epic-ent/internal/ent"
|
||||||
@@ -49,7 +51,7 @@ func (r *HeroRepository) Create(ctx context.Context, req dto.HeroCreateRequest)
|
|||||||
|
|
||||||
hero, err := create.Save(ctx)
|
hero, err := create.Save(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vo.Hero{}, err
|
return vo.Hero{}, errors.Wrap(err, "create hero")
|
||||||
}
|
}
|
||||||
|
|
||||||
return toVO(hero), nil
|
return toVO(hero), nil
|
||||||
@@ -63,7 +65,10 @@ func (r *HeroRepository) GetByID(ctx context.Context, id int64) (vo.Hero, error)
|
|||||||
).
|
).
|
||||||
Only(ctx)
|
Only(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vo.Hero{}, err
|
if ent.IsNotFound(err) {
|
||||||
|
return vo.Hero{}, sql.ErrNoRows
|
||||||
|
}
|
||||||
|
return vo.Hero{}, errors.Wrap(err, "get hero by id")
|
||||||
}
|
}
|
||||||
|
|
||||||
return toVO(hero), nil
|
return toVO(hero), nil
|
||||||
@@ -151,7 +156,7 @@ func (r *HeroRepository) Update(ctx context.Context, id int64, req dto.HeroUpdat
|
|||||||
|
|
||||||
affected, err := update.Save(ctx)
|
affected, err := update.Save(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vo.Hero{}, err
|
return vo.Hero{}, errors.Wrap(err, "update hero")
|
||||||
}
|
}
|
||||||
if affected == 0 {
|
if affected == 0 {
|
||||||
return vo.Hero{}, sql.ErrNoRows
|
return vo.Hero{}, sql.ErrNoRows
|
||||||
@@ -170,7 +175,7 @@ func (r *HeroRepository) Delete(ctx context.Context, id int64) error {
|
|||||||
SetUpdateTime(time.Now()).
|
SetUpdateTime(time.Now()).
|
||||||
Save(ctx)
|
Save(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Wrap(err, "delete hero")
|
||||||
}
|
}
|
||||||
if affected == 0 {
|
if affected == 0 {
|
||||||
return sql.ErrNoRows
|
return sql.ErrNoRows
|
||||||
|
|||||||
Reference in New Issue
Block a user