From 22b1567b3523aaa1cb9d0640b2986ce2652d28f7 Mon Sep 17 00:00:00 2001 From: minkj1992 <> Date: Sun, 26 Jun 2022 04:35:06 +0900 Subject: [PATCH] fix: room api field --- .dockerignore | 1 + .gitignore | 107 +++++++++++++++++++++++ README.md | 16 +++- application/controller/roomController.go | 4 +- docs/docs.go | 21 +++-- docs/swagger.json | 17 +++- docs/swagger.yaml | 14 ++- infrastructure/configs/config.go | 5 ++ infrastructure/configs/dev.yaml | 1 + 9 files changed, 176 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dc5cb7b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +credentials.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12aa95b --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +.idea + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/**/out/ +/**/*.iml +/**/*.ipr + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Gradle template +.gradle +/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!/gradle/wrapper/gradle-wrapper.jar +!/java/gradle/wrapper/gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +### macOS template +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +/**/generated/ +/logs/ +/application.pid +/application.port + +# Ignore `bin` dir +*/bin/* + + +.vscode/ + +credentials.json +firebase-credential.json \ No newline at end of file diff --git a/README.md b/README.md index b011aa1..7484849 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,22 @@ # pitch backend > GDG summer hackerton 2022 + +## local ``` -# local $ make run +``` + +- http://localhost:8080/swagger/index.html + +## prod +- cloud run ci/cd + - https://cloud.google.com/run/docs/quickstarts/deploy-continuously?hl=en_US#cloudrun_deploy_continuous_code-go + - https://cloud.google.com/build/docs/automating-builds/build-repos-from-github +- [cloud run](https://cloud.google.com/run/docs/quickstarts/deploy-continuously?hl=en_US) +- [cloud sql](https://cloud.google.com/sql/docs/mysql/connect-run) +- https://cloud.google.com/sql/docs/mysql/connect-instance-cloud-run ``` -- http://localhost:8080/swagger/index.html \ No newline at end of file +``` \ No newline at end of file diff --git a/application/controller/roomController.go b/application/controller/roomController.go index f0be05a..04759a7 100644 --- a/application/controller/roomController.go +++ b/application/controller/roomController.go @@ -39,6 +39,7 @@ type responseRoom struct { Name string `json:"name"` CreatedAt *time.Time `json:"createdAt"` TaskProgress int `json:"taskProgress"` + Goal string `json:"goal"` StartEnd string `json:"startEnd"` } @@ -50,7 +51,7 @@ const ( allDone = 100 ) -// TODO: move to domain but fxxking hackaton +// TODO: move to domain but notime hackaton func getTasksProgress(tasks entity.Tasks) int { total := len(tasks) count := 0 @@ -97,6 +98,7 @@ func (rc *roomController) GetAll() gin.HandlerFunc { ID: room.ID, Name: room.Name, CreatedAt: room.CreatedAt, + Goal: room.Goal, TaskProgress: getTasksProgress(*tasks), StartEnd: room.GetStartEnd(), }) diff --git a/docs/docs.go b/docs/docs.go index 40c8885..3be9488 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -10,7 +10,15 @@ const docTemplate = `{ "info": { "description": "{{escape .Description}}", "title": "{{.Title}}", - "contact": {}, + "contact": { + "name": "API Support", + "url": "https://minkj1992.github.io", + "email": "minkj1992@gmail.com" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, "version": "{{.Version}}" }, "host": "{{.Host}}", @@ -389,6 +397,9 @@ const docTemplate = `{ "createdAt": { "type": "string" }, + "goal": { + "type": "string" + }, "id": { "type": "integer" }, @@ -435,12 +446,12 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ - Version: "", + Version: "1.0", Host: "", - BasePath: "", + BasePath: "/v1", Schemes: []string{}, - Title: "", - Description: "", + Title: "Pitch API Server (dobby's)", + Description: "This is a pitch api server.", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, } diff --git a/docs/swagger.json b/docs/swagger.json index 90b611f..90e6e3a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,8 +1,20 @@ { "swagger": "2.0", "info": { - "contact": {} + "description": "This is a pitch api server.", + "title": "Pitch API Server (dobby's)", + "contact": { + "name": "API Support", + "url": "https://minkj1992.github.io", + "email": "minkj1992@gmail.com" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" }, + "basePath": "/v1", "paths": { "/rooms": { "get": { @@ -377,6 +389,9 @@ "createdAt": { "type": "string" }, + "goal": { + "type": "string" + }, "id": { "type": "integer" }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 5659069..8b9d09e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,3 +1,4 @@ +basePath: /v1 definitions: controller.ResponseTask: properties: @@ -87,6 +88,8 @@ definitions: properties: createdAt: type: string + goal: + type: string id: type: integer name: @@ -115,7 +118,16 @@ definitions: type: string type: object info: - contact: {} + contact: + email: minkj1992@gmail.com + name: API Support + url: https://minkj1992.github.io + description: This is a pitch api server. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + title: Pitch API Server (dobby's) + version: "1.0" paths: /rooms: get: diff --git a/infrastructure/configs/config.go b/infrastructure/configs/config.go index d69f0af..b246244 100644 --- a/infrastructure/configs/config.go +++ b/infrastructure/configs/config.go @@ -1,6 +1,8 @@ package configs import ( + "fmt" + "github.com/piTch-time/pitch-backend/infrastructure/logger" "github.com/spf13/viper" "go.uber.org/zap" @@ -13,6 +15,7 @@ const ( // Config ... type Config struct { + Host string `mapstructure:"host"` DBConfig DBConfig `mapstructure:"db-config"` } @@ -41,6 +44,8 @@ func Load(path string) (Config, error) { } err = viper.Unmarshal(&config) + + fmt.Println(config) return config, err } diff --git a/infrastructure/configs/dev.yaml b/infrastructure/configs/dev.yaml index 258b748..d1d111d 100644 --- a/infrastructure/configs/dev.yaml +++ b/infrastructure/configs/dev.yaml @@ -1,3 +1,4 @@ +host: "localhost:8080" db-config: host: "0.0.0.0" port: 3306