Skip to content

Commit

Permalink
fix: update Item Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
slowhigh committed May 24, 2024
1 parent 201d973 commit 7654cb7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 19 deletions.
3 changes: 0 additions & 3 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package main
// @title nerd-planet-api-server
// @version 1.0
// @description nerd-planet-api-server

// @host localhost:5000

// @schemes http
type Server interface {
Run() error
Expand Down
6 changes: 5 additions & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ const docTemplate = `{
"description": "개시 시간",
"type": "string"
},
"item_thumbnail": {
"description": "글 썸네일",
"type": "string"
},
"item_title": {
"description": "글 제목",
"type": "string"
Expand Down Expand Up @@ -327,7 +331,7 @@ const docTemplate = `{
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:5000",
Host: "",
BasePath: "",
Schemes: []string{"http"},
Title: "nerd-planet-api-server",
Expand Down
5 changes: 4 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"contact": {},
"version": "1.0"
},
"host": "localhost:5000",
"paths": {
"/v1/item": {
"get": {
Expand Down Expand Up @@ -247,6 +246,10 @@
"description": "개시 시간",
"type": "string"
},
"item_thumbnail": {
"description": "글 썸네일",
"type": "string"
},
"item_title": {
"description": "글 제목",
"type": "string"
Expand Down
4 changes: 3 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ definitions:
item_published:
description: 개시 시간
type: string
item_thumbnail:
description: 글 썸네일
type: string
item_title:
description: 글 제목
type: string
Expand Down Expand Up @@ -87,7 +90,6 @@ definitions:
- MEDIUM
- LARGE
- FOREIGN
host: localhost:5000
info:
contact: {}
description: nerd-planet-api-server
Expand Down
6 changes: 6 additions & 0 deletions infra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
App App `mapstructure:"APP"`
Rest Rest `mapstructure:"REST"`
Database Database `mapstructure:"DATABASE"`
Swagger Swagger `mapstructure:"SWAGGER"`
}

type App struct {
Expand All @@ -32,6 +33,11 @@ type Database struct {
DbName string `mapstructure:"DB_NAME"`
}

type Swagger struct {
Host string `mapstructure:"HOST"`
BasePath string `mapstructure:"BASE_PATH"`
}

func NewConfig() (*Config, error) {
_, b, _, _ := runtime.Caller(0)
configDirPath := path.Join(path.Dir(b))
Expand Down
4 changes: 4 additions & 0 deletions infra/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"PASSWORD": "planet1!",
"DB_NAME": "nerd_planet",
"LOG_LEVEL": 4
},
"SWAGGER": {
"HOST": "localhost",
"BASE_PATH": "/"
}
}
3 changes: 2 additions & 1 deletion infra/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ func NewRouter(conf *config.Config, itemCtrl rest.ItemController, tabCtrl rest.T
r.Use(middleware.CorsHandler())
s := persistence.NewInMemoryStore(time.Hour)

docs.SwaggerInfo.BasePath = "/"
docs.SwaggerInfo.Host = conf.Swagger.Host
docs.SwaggerInfo.BasePath = conf.Swagger.BasePath
v1 := r.Group("/v1")
{
v1.GET("/docs/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
Expand Down
26 changes: 14 additions & 12 deletions internal/controller/rest/dto/item_dto/item_find_all_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type FindAllItemRes struct {
ItemTitle string `json:"item_title"` // 글 제목
ItemDescription string `json:"item_description"` // 글 설명
ItemLink string `json:"item_link"` // 글 URL
ItemThumbnail *string `json:"item_thumbnail"` // 글 썸네일
ItemPublished time.Time `json:"item_published"` // 개시 시간
FeedName string `json:"feed_name"` // 회사 이름
FeedTitle string `json:"feed_title"` // 회사 Feed 제목
Expand All @@ -28,18 +29,19 @@ type FindAllItemRes struct {
SkillTagIDArr []int64 `json:"skill_tags_id_arr"` // 관련 스킬 DB ID 배열
}

func NewFindAllItemRes(viewItem entity.ItemView) FindAllItemRes {
func NewFindAllItemRes(itemView entity.ItemView) FindAllItemRes {
return FindAllItemRes{
ItemID: viewItem.ItemID,
ItemTitle: viewItem.ItemTitle,
ItemDescription: viewItem.ItemDescription,
ItemLink: viewItem.ItemLink,
ItemPublished: viewItem.ItemPublished,
FeedName: viewItem.FeedName,
FeedTitle: viewItem.FeedTitle,
FeedLink: viewItem.FeedLink,
CompanySize: viewItem.CompanySize,
JobTagIDArr: viewItem.JobTagIDArr,
SkillTagIDArr: viewItem.SkillTagIDArr,
ItemID: itemView.ItemID,
ItemTitle: itemView.ItemTitle,
ItemDescription: itemView.ItemDescription,
ItemLink: itemView.ItemLink,
ItemThumbnail: itemView.ItemThumbnail,
ItemPublished: itemView.ItemPublished,
FeedName: itemView.FeedName,
FeedTitle: itemView.FeedTitle,
FeedLink: itemView.FeedLink,
CompanySize: itemView.CompanySize,
JobTagIDArr: itemView.JobTagIDArr,
SkillTagIDArr: itemView.SkillTagIDArr,
}
}
2 changes: 2 additions & 0 deletions internal/entity/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Item struct {
Title string `gorm:"column:title;type:varchar;not null"`
Description string `gorm:"column:description;type:varchar;not null"`
Link string `gorm:"column:link;type:varchar;not null"`
Thumbnail *string `gorm:"column:thumbnail;type:varchar"`
Published time.Time `gorm:"column:published;type:timestamp;not null"`
GUID string `gorm:"column:guid;type:varchar;not null"`
FeedID uint `gorm:"column:feed_id;type:int8;not null"`
Expand All @@ -23,6 +24,7 @@ type ItemView struct {
ItemTitle string `gorm:"column:item_title;type:varchar"`
ItemDescription string `gorm:"column:item_description;type:varchar"`
ItemLink string `gorm:"column:item_link;type:varchar"`
ItemThumbnail *string `gorm:"column:item_thumbnail;type:varchar"`
ItemPublished time.Time `gorm:"column:item_published;type:timestamp"`
FeedName string `gorm:"column:feed_name;type:varchar"`
FeedTitle string `gorm:"column:feed_title;type:varchar"`
Expand Down

0 comments on commit 7654cb7

Please sign in to comment.