From 7707dcd211874ee95b6e02784565e87e0ff52ae2 Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 7 Apr 2023 11:16:24 +0900 Subject: [PATCH 1/4] minor fix: add path paramter(organization) for user resource --- api/swagger/docs.go | 429 +++++++++++++++++-------- api/swagger/swagger.json | 426 ++++++++++++++++-------- api/swagger/swagger.yaml | 345 ++++++++++++++------ go.mod | 1 - internal/delivery/http/organization.go | 18 +- internal/delivery/http/user.go | 163 ++++++---- internal/repository/organization.go | 1 + internal/repository/user.go | 6 +- internal/route/route.go | 14 +- internal/usecase/user.go | 87 ++--- pkg/domain/organization.go | 2 + pkg/domain/user.go | 5 +- 12 files changed, 1014 insertions(+), 483 deletions(-) diff --git a/api/swagger/docs.go b/api/swagger/docs.go index f198b50c..77f2895c 100644 --- a/api/swagger/docs.go +++ b/api/swagger/docs.go @@ -1,5 +1,4 @@ -// Package swagger GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Code generated by swaggo/swag. DO NOT EDIT package swagger import "github.com/swaggo/swag" @@ -1071,14 +1070,14 @@ const docTemplate = `{ } } }, - "/stack-templates": { + "/organizations/{organizationId}/users": { "get": { "security": [ { "JWT": [] } ], - "description": "Get StackTemplates", + "description": "Get user list", "consumes": [ "application/json" ], @@ -1086,14 +1085,26 @@ const docTemplate = `{ "application/json" ], "tags": [ - "StackTemplates" + "Users" + ], + "summary": "Get user list", + "parameters": [ + { + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + } ], - "summary": "Get StackTemplates", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetStackTemplatesResponse" + "type": "array", + "items": { + "$ref": "#/definitions/domain.ListUserBody" + } } } } @@ -1104,7 +1115,7 @@ const docTemplate = `{ "JWT": [] } ], - "description": "Create StackTemplate", + "description": "Create user", "consumes": [ "application/json" ], @@ -1112,38 +1123,45 @@ const docTemplate = `{ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Create StackTemplate 'NOT IMPLEMENTED'", + "summary": "Create user", "parameters": [ { - "description": "create stack template request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "description": "create user request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.CreateStackTemplateRequest" + "$ref": "#/definitions/domain.CreateUserRequest" } } ], "responses": { "200": { - "description": "OK", + "description": "create user response", "schema": { - "$ref": "#/definitions/domain.CreateStackTemplateResponse" + "$ref": "#/definitions/domain.CreateUserResponse" } } } } }, - "/stack-templates/{stackTemplateId}": { + "/organizations/{organizationId}/users/{accountId}": { "get": { "security": [ { "JWT": [] } ], - "description": "Get StackTemplate", + "description": "Get user detail", "consumes": [ "application/json" ], @@ -1151,14 +1169,21 @@ const docTemplate = `{ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Get StackTemplate", + "summary": "Get user detail", "parameters": [ { "type": "string", - "description": "stackTemplateId", - "name": "stackTemplateId", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", "in": "path", "required": true } @@ -1167,7 +1192,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetStackTemplateResponse" + "$ref": "#/definitions/domain.GetUserResponse" } } } @@ -1178,7 +1203,7 @@ const docTemplate = `{ "JWT": [] } ], - "description": "Update StackTemplate", + "description": "Update user detail", "consumes": [ "application/json" ], @@ -1186,23 +1211,40 @@ const docTemplate = `{ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Update StackTemplate 'NOT IMPLEMENTED'", + "summary": "Update user detail", "parameters": [ { - "description": "Update stack template request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + }, + { + "description": "update user request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateStackTemplateRequest" + "$ref": "#/definitions/domain.UpdateUserRequest" } } ], "responses": { "200": { - "description": "OK" + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UpdateUserResponse" + } } } }, @@ -1212,7 +1254,7 @@ const docTemplate = `{ "JWT": [] } ], - "description": "Delete StackTemplate", + "description": "Delete user", "consumes": [ "application/json" ], @@ -1220,33 +1262,43 @@ const docTemplate = `{ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Delete StackTemplate 'NOT IMPLEMENTED'", + "summary": "Delete user", "parameters": [ { "type": "string", - "description": "stackTemplateId", - "name": "stackTemplateId", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", "in": "path", "required": true } ], "responses": { "200": { - "description": "OK" + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } } } } }, - "/users": { + "/organizations/{organizationId}/users/{accountId}/existence": { "get": { "security": [ { "JWT": [] } ], - "description": "Get user list", + "description": "return true when accountId exists", "consumes": [ "application/json" ], @@ -1256,26 +1308,38 @@ const docTemplate = `{ "tags": [ "Users" ], - "summary": "Get user list", + "summary": "Get user id existence", + "parameters": [ + { + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + } + ], "responses": { "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.ListUserBody" - } - } + "description": "OK" } } - }, - "post": { + } + }, + "/organizations/{organizationId}/users/{accountId}/password": { + "put": { "security": [ { "JWT": [] } ], - "description": "Create user", + "description": "Update user password detail", "consumes": [ "application/json" ], @@ -1285,36 +1349,50 @@ const docTemplate = `{ "tags": [ "Users" ], - "summary": "Create user", + "summary": "Update user password detail", "parameters": [ { - "description": "create user request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + }, + { + "description": "update user password request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.CreateUserRequest" + "$ref": "#/definitions/domain.UpdatePasswordRequest" } } ], "responses": { "200": { - "description": "create user response", + "description": "OK", "schema": { - "$ref": "#/definitions/domain.CreateUserResponse" + "$ref": "#/definitions/domain.UpdatePasswordResponse" } } } } }, - "/users/{userId}": { + "/stack-templates": { "get": { "security": [ { "JWT": [] } ], - "description": "Get user detail", + "description": "Get StackTemplates", "consumes": [ "application/json" ], @@ -1322,34 +1400,25 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" - ], - "summary": "Get user detail", - "parameters": [ - { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true - } + "StackTemplates" ], + "summary": "Get StackTemplates", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetUserResponse" + "$ref": "#/definitions/domain.GetStackTemplatesResponse" } } } }, - "put": { + "post": { "security": [ { "JWT": [] } ], - "description": "Update user detail", + "description": "Create StackTemplate", "consumes": [ "application/json" ], @@ -1357,24 +1426,17 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user detail", + "summary": "Create StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true - }, - { - "description": "update user request", + "description": "create stack template request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateUserRequest" + "$ref": "#/definitions/domain.CreateStackTemplateRequest" } } ], @@ -1382,18 +1444,20 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.UpdateUserResponse" + "$ref": "#/definitions/domain.CreateStackTemplateResponse" } } } - }, - "post": { + } + }, + "/stack-templates/{stackTemplateId}": { + "get": { "security": [ { "JWT": [] } ], - "description": "Update user password detail", + "description": "Get StackTemplate", "consumes": [ "application/json" ], @@ -1401,34 +1465,34 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user password detail", + "summary": "Get StackTemplate", "parameters": [ { "type": "string", - "description": "userId", - "name": "userId", + "description": "stackTemplateId", + "name": "stackTemplateId", "in": "path", "required": true } ], "responses": { - "204": { - "description": "No Content" - }, - "409": { - "description": "Conflict" + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.GetStackTemplateResponse" + } } } }, - "delete": { + "put": { "security": [ { "JWT": [] } ], - "description": "Delete user", + "description": "Update StackTemplate", "consumes": [ "application/json" ], @@ -1436,36 +1500,33 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Delete user", + "summary": "Update StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true + "description": "Update stack template request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateStackTemplateRequest" + } } ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.User" - } + "description": "OK" } } - } - }, - "/users/{userId}/password": { - "put": { + }, + "delete": { "security": [ { "JWT": [] } ], - "description": "Update user password detail", + "description": "Delete StackTemplate", "consumes": [ "application/json" ], @@ -1473,33 +1534,21 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user password detail", + "summary": "Delete StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { "type": "string", - "description": "userId", - "name": "userId", + "description": "stackTemplateId", + "name": "stackTemplateId", "in": "path", "required": true - }, - { - "description": "update user password request", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePasswordRequest" - } } ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.UpdatePasswordResponse" - } + "description": "OK" } } } @@ -1510,7 +1559,7 @@ const docTemplate = `{ "type": "object", "properties": { "appGroupType": { - "type": "integer" + "$ref": "#/definitions/domain.AppGroupType" }, "clusterId": { "type": "string" @@ -1531,7 +1580,7 @@ const docTemplate = `{ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.AppGroupStatus" }, "statusDescription": { "type": "string" @@ -1547,6 +1596,38 @@ const docTemplate = `{ } } }, + "domain.AppGroupStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "AppGroupStatus_PENDING", + "AppGroupStatus_INSTALLING", + "AppGroupStatus_RUNNING", + "AppGroupStatus_DELETING", + "AppGroupStatus_DELETED", + "AppGroupStatus_ERROR" + ] + }, + "domain.AppGroupType": { + "type": "integer", + "enum": [ + 0, + 1, + 2 + ], + "x-enum-varnames": [ + "AppGroupType_UNSPECIFIED", + "AppGroupType_LMA", + "AppGroupType_SERVICE_MESH" + ] + }, "domain.AppServeApp": { "type": "object", "properties": { @@ -1703,7 +1784,7 @@ const docTemplate = `{ "type": "string" }, "applicationType": { - "type": "integer" + "$ref": "#/definitions/domain.ApplicationType" }, "createdAt": { "type": "string" @@ -1722,6 +1803,35 @@ const docTemplate = `{ } } }, + "domain.ApplicationType": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "x-enum-varnames": [ + "ApplicationType_UNSPECIFIED", + "ApplicationType_THANOS", + "ApplicationType_PROMETHEUS", + "ApplicationType_GRAFANA", + "ApplicationType_KIALI", + "ApplicationType_KIBANA", + "ApplicationType_ELASTICSERCH", + "ApplicationType_CLOUD_CONSOLE", + "ApplicationType_HORIZON", + "ApplicationType_JAEGER", + "ApplicationType_KUBERNETES_DASHBOARD" + ] + }, "domain.CloudSetting": { "type": "object", "properties": { @@ -1838,7 +1948,7 @@ const docTemplate = `{ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.ClusterStatus" }, "statusDesc": { "type": "string" @@ -1950,6 +2060,25 @@ const docTemplate = `{ } } }, + "domain.ClusterStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "ClusterStatus_PENDING", + "ClusterStatus_INSTALLING", + "ClusterStatus_RUNNING", + "ClusterStatus_DELETING", + "ClusterStatus_DELETED", + "ClusterStatus_ERROR" + ] + }, "domain.CreateAppGroupRequest": { "type": "object", "required": [ @@ -2398,7 +2527,7 @@ const docTemplate = `{ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" }, "statusDescription": { "type": "string" @@ -2514,7 +2643,7 @@ const docTemplate = `{ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" } } }, @@ -2625,7 +2754,7 @@ const docTemplate = `{ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" }, "statusDescription": { "type": "string" @@ -2635,6 +2764,29 @@ const docTemplate = `{ } } }, + "domain.OrganizationStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "x-enum-varnames": [ + "OrganizationStatus_PENDING", + "OrganizationStatus_CREATE", + "OrganizationStatus_CREATING", + "OrganizationStatus_CREATED", + "OrganizationStatus_DELETE", + "OrganizationStatus_DELETING", + "OrganizationStatus_DELETED", + "OrganizationStatus_ERROR" + ] + }, "domain.Role": { "type": "object", "properties": { @@ -2825,12 +2977,20 @@ const docTemplate = `{ }, "domain.UpdateOrganizationRequest": { "type": "object", + "required": [ + "name" + ], "properties": { "description": { "type": "string", "maxLength": 100, "minLength": 0 }, + "name": { + "type": "string", + "maxLength": 20, + "minLength": 3 + }, "phone": { "type": "string" }, @@ -2848,6 +3008,9 @@ const docTemplate = `{ "id": { "type": "string" }, + "name": { + "type": "string" + }, "phone": { "type": "string" } diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index 0f86e7ea..63e416bb 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -1064,14 +1064,14 @@ } } }, - "/stack-templates": { + "/organizations/{organizationId}/users": { "get": { "security": [ { "JWT": [] } ], - "description": "Get StackTemplates", + "description": "Get user list", "consumes": [ "application/json" ], @@ -1079,14 +1079,26 @@ "application/json" ], "tags": [ - "StackTemplates" + "Users" + ], + "summary": "Get user list", + "parameters": [ + { + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + } ], - "summary": "Get StackTemplates", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetStackTemplatesResponse" + "type": "array", + "items": { + "$ref": "#/definitions/domain.ListUserBody" + } } } } @@ -1097,7 +1109,7 @@ "JWT": [] } ], - "description": "Create StackTemplate", + "description": "Create user", "consumes": [ "application/json" ], @@ -1105,38 +1117,45 @@ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Create StackTemplate 'NOT IMPLEMENTED'", + "summary": "Create user", "parameters": [ { - "description": "create stack template request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "description": "create user request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.CreateStackTemplateRequest" + "$ref": "#/definitions/domain.CreateUserRequest" } } ], "responses": { "200": { - "description": "OK", + "description": "create user response", "schema": { - "$ref": "#/definitions/domain.CreateStackTemplateResponse" + "$ref": "#/definitions/domain.CreateUserResponse" } } } } }, - "/stack-templates/{stackTemplateId}": { + "/organizations/{organizationId}/users/{accountId}": { "get": { "security": [ { "JWT": [] } ], - "description": "Get StackTemplate", + "description": "Get user detail", "consumes": [ "application/json" ], @@ -1144,14 +1163,21 @@ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Get StackTemplate", + "summary": "Get user detail", "parameters": [ { "type": "string", - "description": "stackTemplateId", - "name": "stackTemplateId", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", "in": "path", "required": true } @@ -1160,7 +1186,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetStackTemplateResponse" + "$ref": "#/definitions/domain.GetUserResponse" } } } @@ -1171,7 +1197,7 @@ "JWT": [] } ], - "description": "Update StackTemplate", + "description": "Update user detail", "consumes": [ "application/json" ], @@ -1179,23 +1205,40 @@ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Update StackTemplate 'NOT IMPLEMENTED'", + "summary": "Update user detail", "parameters": [ { - "description": "Update stack template request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + }, + { + "description": "update user request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateStackTemplateRequest" + "$ref": "#/definitions/domain.UpdateUserRequest" } } ], "responses": { "200": { - "description": "OK" + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UpdateUserResponse" + } } } }, @@ -1205,7 +1248,7 @@ "JWT": [] } ], - "description": "Delete StackTemplate", + "description": "Delete user", "consumes": [ "application/json" ], @@ -1213,33 +1256,43 @@ "application/json" ], "tags": [ - "StackTemplates" + "Users" ], - "summary": "Delete StackTemplate 'NOT IMPLEMENTED'", + "summary": "Delete user", "parameters": [ { "type": "string", - "description": "stackTemplateId", - "name": "stackTemplateId", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", "in": "path", "required": true } ], "responses": { "200": { - "description": "OK" + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } } } } }, - "/users": { + "/organizations/{organizationId}/users/{accountId}/existence": { "get": { "security": [ { "JWT": [] } ], - "description": "Get user list", + "description": "return true when accountId exists", "consumes": [ "application/json" ], @@ -1249,26 +1302,38 @@ "tags": [ "Users" ], - "summary": "Get user list", + "summary": "Get user id existence", + "parameters": [ + { + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + } + ], "responses": { "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.ListUserBody" - } - } + "description": "OK" } } - }, - "post": { + } + }, + "/organizations/{organizationId}/users/{accountId}/password": { + "put": { "security": [ { "JWT": [] } ], - "description": "Create user", + "description": "Update user password detail", "consumes": [ "application/json" ], @@ -1278,36 +1343,50 @@ "tags": [ "Users" ], - "summary": "Create user", + "summary": "Update user password detail", "parameters": [ { - "description": "create user request", + "type": "string", + "description": "organizationId", + "name": "organizationId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "accountId", + "name": "accountId", + "in": "path", + "required": true + }, + { + "description": "update user password request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.CreateUserRequest" + "$ref": "#/definitions/domain.UpdatePasswordRequest" } } ], "responses": { "200": { - "description": "create user response", + "description": "OK", "schema": { - "$ref": "#/definitions/domain.CreateUserResponse" + "$ref": "#/definitions/domain.UpdatePasswordResponse" } } } } }, - "/users/{userId}": { + "/stack-templates": { "get": { "security": [ { "JWT": [] } ], - "description": "Get user detail", + "description": "Get StackTemplates", "consumes": [ "application/json" ], @@ -1315,34 +1394,25 @@ "application/json" ], "tags": [ - "Users" - ], - "summary": "Get user detail", - "parameters": [ - { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true - } + "StackTemplates" ], + "summary": "Get StackTemplates", "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.GetUserResponse" + "$ref": "#/definitions/domain.GetStackTemplatesResponse" } } } }, - "put": { + "post": { "security": [ { "JWT": [] } ], - "description": "Update user detail", + "description": "Create StackTemplate", "consumes": [ "application/json" ], @@ -1350,24 +1420,17 @@ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user detail", + "summary": "Create StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true - }, - { - "description": "update user request", + "description": "create stack template request", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.UpdateUserRequest" + "$ref": "#/definitions/domain.CreateStackTemplateRequest" } } ], @@ -1375,18 +1438,20 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.UpdateUserResponse" + "$ref": "#/definitions/domain.CreateStackTemplateResponse" } } } - }, - "post": { + } + }, + "/stack-templates/{stackTemplateId}": { + "get": { "security": [ { "JWT": [] } ], - "description": "Update user password detail", + "description": "Get StackTemplate", "consumes": [ "application/json" ], @@ -1394,34 +1459,34 @@ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user password detail", + "summary": "Get StackTemplate", "parameters": [ { "type": "string", - "description": "userId", - "name": "userId", + "description": "stackTemplateId", + "name": "stackTemplateId", "in": "path", "required": true } ], "responses": { - "204": { - "description": "No Content" - }, - "409": { - "description": "Conflict" + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.GetStackTemplateResponse" + } } } }, - "delete": { + "put": { "security": [ { "JWT": [] } ], - "description": "Delete user", + "description": "Update StackTemplate", "consumes": [ "application/json" ], @@ -1429,36 +1494,33 @@ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Delete user", + "summary": "Update StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { - "type": "string", - "description": "userId", - "name": "userId", - "in": "path", - "required": true + "description": "Update stack template request", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateStackTemplateRequest" + } } ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.User" - } + "description": "OK" } } - } - }, - "/users/{userId}/password": { - "put": { + }, + "delete": { "security": [ { "JWT": [] } ], - "description": "Update user password detail", + "description": "Delete StackTemplate", "consumes": [ "application/json" ], @@ -1466,33 +1528,21 @@ "application/json" ], "tags": [ - "Users" + "StackTemplates" ], - "summary": "Update user password detail", + "summary": "Delete StackTemplate 'NOT IMPLEMENTED'", "parameters": [ { "type": "string", - "description": "userId", - "name": "userId", + "description": "stackTemplateId", + "name": "stackTemplateId", "in": "path", "required": true - }, - { - "description": "update user password request", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdatePasswordRequest" - } } ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.UpdatePasswordResponse" - } + "description": "OK" } } } @@ -1503,7 +1553,7 @@ "type": "object", "properties": { "appGroupType": { - "type": "integer" + "$ref": "#/definitions/domain.AppGroupType" }, "clusterId": { "type": "string" @@ -1524,7 +1574,7 @@ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.AppGroupStatus" }, "statusDescription": { "type": "string" @@ -1540,6 +1590,38 @@ } } }, + "domain.AppGroupStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "AppGroupStatus_PENDING", + "AppGroupStatus_INSTALLING", + "AppGroupStatus_RUNNING", + "AppGroupStatus_DELETING", + "AppGroupStatus_DELETED", + "AppGroupStatus_ERROR" + ] + }, + "domain.AppGroupType": { + "type": "integer", + "enum": [ + 0, + 1, + 2 + ], + "x-enum-varnames": [ + "AppGroupType_UNSPECIFIED", + "AppGroupType_LMA", + "AppGroupType_SERVICE_MESH" + ] + }, "domain.AppServeApp": { "type": "object", "properties": { @@ -1696,7 +1778,7 @@ "type": "string" }, "applicationType": { - "type": "integer" + "$ref": "#/definitions/domain.ApplicationType" }, "createdAt": { "type": "string" @@ -1715,6 +1797,35 @@ } } }, + "domain.ApplicationType": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "x-enum-varnames": [ + "ApplicationType_UNSPECIFIED", + "ApplicationType_THANOS", + "ApplicationType_PROMETHEUS", + "ApplicationType_GRAFANA", + "ApplicationType_KIALI", + "ApplicationType_KIBANA", + "ApplicationType_ELASTICSERCH", + "ApplicationType_CLOUD_CONSOLE", + "ApplicationType_HORIZON", + "ApplicationType_JAEGER", + "ApplicationType_KUBERNETES_DASHBOARD" + ] + }, "domain.CloudSetting": { "type": "object", "properties": { @@ -1831,7 +1942,7 @@ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.ClusterStatus" }, "statusDesc": { "type": "string" @@ -1943,6 +2054,25 @@ } } }, + "domain.ClusterStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "x-enum-varnames": [ + "ClusterStatus_PENDING", + "ClusterStatus_INSTALLING", + "ClusterStatus_RUNNING", + "ClusterStatus_DELETING", + "ClusterStatus_DELETED", + "ClusterStatus_ERROR" + ] + }, "domain.CreateAppGroupRequest": { "type": "object", "required": [ @@ -2391,7 +2521,7 @@ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" }, "statusDescription": { "type": "string" @@ -2507,7 +2637,7 @@ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" } } }, @@ -2618,7 +2748,7 @@ "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/domain.OrganizationStatus" }, "statusDescription": { "type": "string" @@ -2628,6 +2758,29 @@ } } }, + "domain.OrganizationStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "x-enum-varnames": [ + "OrganizationStatus_PENDING", + "OrganizationStatus_CREATE", + "OrganizationStatus_CREATING", + "OrganizationStatus_CREATED", + "OrganizationStatus_DELETE", + "OrganizationStatus_DELETING", + "OrganizationStatus_DELETED", + "OrganizationStatus_ERROR" + ] + }, "domain.Role": { "type": "object", "properties": { @@ -2818,12 +2971,20 @@ }, "domain.UpdateOrganizationRequest": { "type": "object", + "required": [ + "name" + ], "properties": { "description": { "type": "string", "maxLength": 100, "minLength": 0 }, + "name": { + "type": "string", + "maxLength": 20, + "minLength": 3 + }, "phone": { "type": "string" }, @@ -2841,6 +3002,9 @@ "id": { "type": "string" }, + "name": { + "type": "string" + }, "phone": { "type": "string" } diff --git a/api/swagger/swagger.yaml b/api/swagger/swagger.yaml index cdac99c5..2d7040d1 100644 --- a/api/swagger/swagger.yaml +++ b/api/swagger/swagger.yaml @@ -3,7 +3,7 @@ definitions: domain.AppGroupResponse: properties: appGroupType: - type: integer + $ref: '#/definitions/domain.AppGroupType' clusterId: type: string createdAt: @@ -17,7 +17,7 @@ definitions: name: type: string status: - type: integer + $ref: '#/definitions/domain.AppGroupStatus' statusDescription: type: string updatedAt: @@ -27,6 +27,32 @@ definitions: workflowId: type: string type: object + domain.AppGroupStatus: + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + type: integer + x-enum-varnames: + - AppGroupStatus_PENDING + - AppGroupStatus_INSTALLING + - AppGroupStatus_RUNNING + - AppGroupStatus_DELETING + - AppGroupStatus_DELETED + - AppGroupStatus_ERROR + domain.AppGroupType: + enum: + - 0 + - 1 + - 2 + type: integer + x-enum-varnames: + - AppGroupType_UNSPECIFIED + - AppGroupType_LMA + - AppGroupType_SERVICE_MESH domain.AppServeApp: properties: app_serve_app_tasks: @@ -139,7 +165,7 @@ definitions: appGroupId: type: string applicationType: - type: integer + $ref: '#/definitions/domain.ApplicationType' createdAt: type: string endpoint: @@ -151,6 +177,32 @@ definitions: updatedAt: type: string type: object + domain.ApplicationType: + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + type: integer + x-enum-varnames: + - ApplicationType_UNSPECIFIED + - ApplicationType_THANOS + - ApplicationType_PROMETHEUS + - ApplicationType_GRAFANA + - ApplicationType_KIALI + - ApplicationType_KIBANA + - ApplicationType_ELASTICSERCH + - ApplicationType_CLOUD_CONSOLE + - ApplicationType_HORIZON + - ApplicationType_JAEGER + - ApplicationType_KUBERNETES_DASHBOARD domain.CloudSetting: properties: cloudService: @@ -228,7 +280,7 @@ definitions: organizationId: type: string status: - type: integer + $ref: '#/definitions/domain.ClusterStatus' statusDesc: type: string templateId: @@ -301,6 +353,22 @@ definitions: updator: $ref: '#/definitions/domain.SimpleUserResponse' type: object + domain.ClusterStatus: + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + type: integer + x-enum-varnames: + - ClusterStatus_PENDING + - ClusterStatus_INSTALLING + - ClusterStatus_RUNNING + - ClusterStatus_DELETING + - ClusterStatus_DELETED + - ClusterStatus_ERROR domain.CreateAppGroupRequest: properties: appGroupType: @@ -605,7 +673,7 @@ definitions: primaryClusterId: type: string status: - type: integer + $ref: '#/definitions/domain.OrganizationStatus' statusDescription: type: string updatedAt: @@ -680,7 +748,7 @@ definitions: primaryClusterId: type: string status: - type: integer + $ref: '#/definitions/domain.OrganizationStatus' type: object domain.ListUserBody: properties: @@ -753,12 +821,32 @@ definitions: primaryClusterId: type: string status: - type: integer + $ref: '#/definitions/domain.OrganizationStatus' statusDescription: type: string updatedAt: type: string type: object + domain.OrganizationStatus: + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + type: integer + x-enum-varnames: + - OrganizationStatus_PENDING + - OrganizationStatus_CREATE + - OrganizationStatus_CREATING + - OrganizationStatus_CREATED + - OrganizationStatus_DELETE + - OrganizationStatus_DELETING + - OrganizationStatus_DELETED + - OrganizationStatus_ERROR domain.Role: properties: createdAt: @@ -890,10 +978,16 @@ definitions: maxLength: 100 minLength: 0 type: string + name: + maxLength: 20 + minLength: 3 + type: string phone: type: string primaryClusterId: type: string + required: + - name type: object domain.UpdateOrganizationResponse: properties: @@ -901,6 +995,8 @@ definitions: type: string id: type: string + name: + type: string phone: type: string type: object @@ -1661,55 +1757,73 @@ paths: summary: Update primary cluster tags: - Organizations - /stack-templates: + /organizations/{organizationId}/users: get: consumes: - application/json - description: Get StackTemplates + description: Get user list + parameters: + - description: organizationId + in: path + name: organizationId + required: true + type: string produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.GetStackTemplatesResponse' + items: + $ref: '#/definitions/domain.ListUserBody' + type: array security: - JWT: [] - summary: Get StackTemplates + summary: Get user list tags: - - StackTemplates + - Users post: consumes: - application/json - description: Create StackTemplate + description: Create user parameters: - - description: create stack template request + - description: organizationId + in: path + name: organizationId + required: true + type: string + - description: create user request in: body name: body required: true schema: - $ref: '#/definitions/domain.CreateStackTemplateRequest' + $ref: '#/definitions/domain.CreateUserRequest' produces: - application/json responses: "200": - description: OK + description: create user response schema: - $ref: '#/definitions/domain.CreateStackTemplateResponse' + $ref: '#/definitions/domain.CreateUserResponse' security: - JWT: [] - summary: Create StackTemplate 'NOT IMPLEMENTED' + summary: Create user tags: - - StackTemplates - /stack-templates/{stackTemplateId}: + - Users + /organizations/{organizationId}/users/{accountId}: delete: consumes: - application/json - description: Delete StackTemplate + description: Delete user parameters: - - description: stackTemplateId + - description: organizationId in: path - name: stackTemplateId + name: organizationId + required: true + type: string + - description: accountId + in: path + name: accountId required: true type: string produces: @@ -1717,19 +1831,26 @@ paths: responses: "200": description: OK + schema: + $ref: '#/definitions/domain.User' security: - JWT: [] - summary: Delete StackTemplate 'NOT IMPLEMENTED' + summary: Delete user tags: - - StackTemplates + - Users get: consumes: - application/json - description: Get StackTemplate + description: Get user detail parameters: - - description: stackTemplateId + - description: organizationId in: path - name: stackTemplateId + name: organizationId + required: true + type: string + - description: accountId + in: path + name: accountId required: true type: string produces: @@ -1738,199 +1859,209 @@ paths: "200": description: OK schema: - $ref: '#/definitions/domain.GetStackTemplateResponse' + $ref: '#/definitions/domain.GetUserResponse' security: - JWT: [] - summary: Get StackTemplate + summary: Get user detail tags: - - StackTemplates + - Users put: consumes: - application/json - description: Update StackTemplate + description: Update user detail parameters: - - description: Update stack template request + - description: organizationId + in: path + name: organizationId + required: true + type: string + - description: accountId + in: path + name: accountId + required: true + type: string + - description: update user request in: body name: body required: true schema: - $ref: '#/definitions/domain.UpdateStackTemplateRequest' + $ref: '#/definitions/domain.UpdateUserRequest' produces: - application/json responses: "200": description: OK + schema: + $ref: '#/definitions/domain.UpdateUserResponse' security: - JWT: [] - summary: Update StackTemplate 'NOT IMPLEMENTED' + summary: Update user detail tags: - - StackTemplates - /users: + - Users + /organizations/{organizationId}/users/{accountId}/existence: get: consumes: - application/json - description: Get user list + description: return true when accountId exists + parameters: + - description: organizationId + in: path + name: organizationId + required: true + type: string + - description: accountId + in: path + name: accountId + required: true + type: string produces: - application/json responses: "200": description: OK - schema: - items: - $ref: '#/definitions/domain.ListUserBody' - type: array security: - JWT: [] - summary: Get user list + summary: Get user id existence tags: - Users - post: + /organizations/{organizationId}/users/{accountId}/password: + put: consumes: - application/json - description: Create user + description: Update user password detail parameters: - - description: create user request + - description: organizationId + in: path + name: organizationId + required: true + type: string + - description: accountId + in: path + name: accountId + required: true + type: string + - description: update user password request in: body name: body required: true schema: - $ref: '#/definitions/domain.CreateUserRequest' + $ref: '#/definitions/domain.UpdatePasswordRequest' produces: - application/json responses: "200": - description: create user response + description: OK schema: - $ref: '#/definitions/domain.CreateUserResponse' + $ref: '#/definitions/domain.UpdatePasswordResponse' security: - JWT: [] - summary: Create user + summary: Update user password detail tags: - Users - /users/{userId}: - delete: + /stack-templates: + get: consumes: - application/json - description: Delete user - parameters: - - description: userId - in: path - name: userId - required: true - type: string + description: Get StackTemplates produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.User' + $ref: '#/definitions/domain.GetStackTemplatesResponse' security: - JWT: [] - summary: Delete user + summary: Get StackTemplates tags: - - Users - get: + - StackTemplates + post: consumes: - application/json - description: Get user detail + description: Create StackTemplate parameters: - - description: userId - in: path - name: userId + - description: create stack template request + in: body + name: body required: true - type: string + schema: + $ref: '#/definitions/domain.CreateStackTemplateRequest' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.GetUserResponse' + $ref: '#/definitions/domain.CreateStackTemplateResponse' security: - JWT: [] - summary: Get user detail + summary: Create StackTemplate 'NOT IMPLEMENTED' tags: - - Users - post: + - StackTemplates + /stack-templates/{stackTemplateId}: + delete: consumes: - application/json - description: Update user password detail + description: Delete StackTemplate parameters: - - description: userId + - description: stackTemplateId in: path - name: userId + name: stackTemplateId required: true type: string produces: - application/json responses: - "204": - description: No Content - "409": - description: Conflict + "200": + description: OK security: - JWT: [] - summary: Update user password detail + summary: Delete StackTemplate 'NOT IMPLEMENTED' tags: - - Users - put: + - StackTemplates + get: consumes: - application/json - description: Update user detail + description: Get StackTemplate parameters: - - description: userId + - description: stackTemplateId in: path - name: userId + name: stackTemplateId required: true type: string - - description: update user request - in: body - name: body - required: true - schema: - $ref: '#/definitions/domain.UpdateUserRequest' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/domain.UpdateUserResponse' + $ref: '#/definitions/domain.GetStackTemplateResponse' security: - JWT: [] - summary: Update user detail + summary: Get StackTemplate tags: - - Users - /users/{userId}/password: + - StackTemplates put: consumes: - application/json - description: Update user password detail + description: Update StackTemplate parameters: - - description: userId - in: path - name: userId - required: true - type: string - - description: update user password request + - description: Update stack template request in: body name: body required: true schema: - $ref: '#/definitions/domain.UpdatePasswordRequest' + $ref: '#/definitions/domain.UpdateStackTemplateRequest' produces: - application/json responses: "200": description: OK - schema: - $ref: '#/definitions/domain.UpdatePasswordResponse' security: - JWT: [] - summary: Update user password detail + summary: Update StackTemplate 'NOT IMPLEMENTED' tags: - - Users + - StackTemplates securityDefinitions: JWT: in: header diff --git a/go.mod b/go.mod index 49d88118..a16a791e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/Nerzal/gocloak/v13 v13.1.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/go-playground/validator v9.31.0+incompatible - github.com/gofrs/uuid v4.0.0+incompatible github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang/mock v1.6.0 diff --git a/internal/delivery/http/organization.go b/internal/delivery/http/organization.go index 487ed3f8..40e9bc5a 100644 --- a/internal/delivery/http/organization.go +++ b/internal/delivery/http/organization.go @@ -125,6 +125,10 @@ func (h *OrganizationHandler) GetOrganization(w http.ResponseWriter, r *http.Req organization, err := h.usecase.Get(organizationId) if err != nil { log.Errorf("error is :%s(%T)", err.Error(), err) + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } ErrorJSON(w, err) return @@ -174,7 +178,10 @@ func (h *OrganizationHandler) DeleteOrganization(w http.ResponseWriter, r *http. err = h.usecase.Delete(organizationId, token) if err != nil { log.Errorf("error is :%s(%T)", err.Error(), err) - + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } ErrorJSON(w, err) return } @@ -211,7 +218,10 @@ func (h *OrganizationHandler) UpdateOrganization(w http.ResponseWriter, r *http. organization, err := h.usecase.Update(organizationId, input) if err != nil { log.Errorf("error is :%s(%T)", err.Error(), err) - + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } ErrorJSON(w, err) return } @@ -252,6 +262,10 @@ func (h *OrganizationHandler) UpdatePrimaryCluster(w http.ResponseWriter, r *htt err = h.usecase.UpdatePrimaryClusterId(organizationId, input.PrimaryClusterId) if err != nil { + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } ErrorJSON(w, err) return } diff --git a/internal/delivery/http/user.go b/internal/delivery/http/user.go index fd28dc1f..7a351d35 100644 --- a/internal/delivery/http/user.go +++ b/internal/delivery/http/user.go @@ -7,7 +7,6 @@ import ( "github.com/openinfradev/tks-api/pkg/log" "github.com/gorilla/mux" - "github.com/openinfradev/tks-api/internal/auth/request" "github.com/openinfradev/tks-api/internal/usecase" "github.com/openinfradev/tks-api/pkg/domain" "github.com/openinfradev/tks-api/pkg/httpErrors" @@ -33,12 +32,19 @@ type UserHandler struct { // @Description Create user // @Accept json // @Produce json +// @Param organizationId path string true "organizationId" // @Param body body domain.CreateUserRequest true "create user request" // @Success 200 {object} domain.CreateUserResponse "create user response" -// @Router /users [post] +// @Router /organizations/{organizationId}/users [post] // @Security JWT func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { - // TODO implement validation + vars := mux.Vars(r) + organizationId, ok := vars["organizationId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) + return + } + input := domain.CreateUserRequest{} err := UnmarshalRequestInput(r, &input) if err != nil { @@ -48,11 +54,11 @@ func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { return } - userInfo, ok := request.UserFrom(r.Context()) - if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("user info not found in token"))) - return - } + //userInfo, ok := request.UserFrom(r.Context()) + //if !ok { + // ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("user info not found in token"))) + // return + //} ctx := r.Context() var user domain.User @@ -60,8 +66,9 @@ func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { log.Error(err) } user.Organization = domain.Organization{ - ID: userInfo.GetOrganizationId(), + ID: organizationId, } + resUser, err := u.usecase.Create(ctx, &user) if err != nil { log.Errorf("error is :%s(%T)", err.Error(), err) @@ -89,22 +96,33 @@ func (u UserHandler) Create(w http.ResponseWriter, r *http.Request) { // @Description Get user detail // @Accept json // @Produce json -// @Param userId path string true "userId" +// @Param organizationId path string true "organizationId" +// @Param accountId path string true "accountId" // @Success 200 {object} domain.GetUserResponse -// @Router /users/{userId} [get] +// @Router /organizations/{organizationId}/users/{accountId} [get] // @Security JWT func (u UserHandler) Get(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - userId, ok := vars["userId"] + userId, ok := vars["accountId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("accountId not found in path"))) + return + } + organizationId, ok := vars["organizationId"] if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("userId not found in path"))) + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) return } - user, err := u.usecase.GetByAccountId(r.Context(), userId) + user, err := u.usecase.GetByAccountId(r.Context(), userId, organizationId) if err != nil { log.Errorf("error is :%s(%T)", err.Error(), err) + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } + ErrorJSON(w, err) return } @@ -123,11 +141,19 @@ func (u UserHandler) Get(w http.ResponseWriter, r *http.Request) { // @Description Get user list // @Accept json // @Produce json +// @Param organizationId path string true "organizationId" // @Success 200 {object} []domain.ListUserBody -// @Router /users [get] +// @Router /organizations/{organizationId}/users [get] // @Security JWT func (u UserHandler) List(w http.ResponseWriter, r *http.Request) { - users, err := u.usecase.List(r.Context()) + vars := mux.Vars(r) + organizationId, ok := vars["organizationId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) + return + } + + users, err := u.usecase.List(r.Context(), organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { ResponseJSON(w, http.StatusNoContent, domain.ListUserResponse{}) @@ -156,22 +182,28 @@ func (u UserHandler) List(w http.ResponseWriter, r *http.Request) { // @Description Delete user // @Accept json // @Produce json -// @Param userId path string true "userId" +// @Param organizationId path string true "organizationId" +// @Param accountId path string true "accountId" // @Success 200 {object} domain.User -// @Router /users/{userId} [delete] +// @Router /organizations/{organizationId}/users/{accountId} [delete] // @Security JWT func (u UserHandler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - userId, ok := vars["userId"] + userId, ok := vars["accountId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("accountId not found in path"))) + return + } + organizationId, ok := vars["organizationId"] if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("userId not found in path"))) + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) return } - err := u.usecase.DeleteByAccountId(r.Context(), userId) + err := u.usecase.DeleteByAccountId(r.Context(), userId, organizationId) if err != nil { if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { - ErrorJSON(w, httpErrors.NewNotFoundError(err)) + ErrorJSON(w, httpErrors.NewBadRequestError(err)) return } log.Errorf("error is :%s(%T)", err.Error(), err) @@ -189,16 +221,22 @@ func (u UserHandler) Delete(w http.ResponseWriter, r *http.Request) { // @Description Update user detail // @Accept json // @Produce json -// @Param userId path string true "userId" +// @Param organizationId path string true "organizationId" +// @Param accountId path string true "accountId" // @Param body body domain.UpdateUserRequest true "update user request" // @Success 200 {object} domain.UpdateUserResponse -// @Router /users/{userId} [put] +// @Router /organizations/{organizationId}/users/{accountId} [put] // @Security JWT func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - userId, ok := vars["userId"] + accountId, ok := vars["accountId"] if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("userId not found in path"))) + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("accountId not found in path"))) + return + } + organizationId, ok := vars["organizationId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) return } @@ -211,25 +249,21 @@ func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) { return } - userInfo, ok := request.UserFrom(r.Context()) - if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("user info not found in token"))) - return - } - ctx := r.Context() var user domain.User if err = domain.Map(input, &user); err != nil { log.Error(err) } user.Organization = domain.Organization{ - ID: userInfo.GetOrganizationId(), + ID: organizationId, } - user.AccountId = userId + user.AccountId = accountId - resUser, err := u.usecase.UpdateByAccountId(ctx, userId, &user) + resUser, err := u.usecase.UpdateByAccountId(ctx, accountId, &user) if err != nil { - log.Errorf("error is :%s(%T)", err.Error(), err) + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + } ErrorJSON(w, err) return @@ -249,30 +283,38 @@ func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) { // @Description Update user password detail // @Accept json // @Produce json -// @Param userId path string true "userId" +// @Param organizationId path string true "organizationId" +// @Param accountId path string true "accountId" // @Param body body domain.UpdatePasswordRequest true "update user password request" // @Success 200 {object} domain.UpdatePasswordResponse -// @Router /users/{userId}/password [put] +// @Router /organizations/{organizationId}/users/{accountId}/password [put] // @Security JWT func (u UserHandler) UpdatePassword(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - userId, ok := vars["userId"] + accountId, ok := vars["accountId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("accountId not found in path"))) + return + } + organizationId, ok := vars["organizationId"] if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("userId not found in path"))) + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) return } input := domain.UpdatePasswordRequest{} err := UnmarshalRequestInput(r, &input) if err != nil { - log.Errorf("error is :%s(%T)", err.Error(), err) - ErrorJSON(w, httpErrors.NewBadRequestError(err)) return } - err = u.usecase.UpdatePasswordByAccountId(r.Context(), userId, input.Password) + err = u.usecase.UpdatePasswordByAccountId(r.Context(), accountId, input.Password, organizationId) if err != nil { + if _, status := httpErrors.ErrorResponse(err); status == http.StatusNotFound { + ErrorJSON(w, httpErrors.NewBadRequestError(err)) + return + } log.Errorf("error is :%s(%T)", err.Error(), err) ErrorJSON(w, err) @@ -284,34 +326,43 @@ func (u UserHandler) UpdatePassword(w http.ResponseWriter, r *http.Request) { // CheckId godoc // @Tags Users -// @Summary Update user password detail -// @Description Update user password detail +// @Summary Get user id existence +// @Description return true when accountId exists // @Accept json // @Produce json -// @Param userId path string true "userId" -// @Success 204 -// @Failure 409 -// @Router /users/{userId} [post] +// @Param organizationId path string true "organizationId" +// @Param accountId path string true "accountId" +// @Success 200 +// @Router /organizations/{organizationId}/users/{accountId}/existence [get] // @Security JWT func (u UserHandler) CheckId(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - userId, ok := vars["userId"] + accountId, ok := vars["accountId"] + if !ok { + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("accountId not found in path"))) + return + } + organizationId, ok := vars["organizationId"] if !ok { - ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("userId not found in path"))) + ErrorJSON(w, httpErrors.NewBadRequestError(fmt.Errorf("organizationId not found in path"))) return } - _, err := u.usecase.GetByAccountId(r.Context(), userId) + exist := true + _, err := u.usecase.GetByAccountId(r.Context(), accountId, organizationId) if err != nil { if _, code := httpErrors.ErrorResponse(err); code == http.StatusNotFound { - ResponseJSON(w, http.StatusNoContent, nil) + exist = false + } else { + ErrorJSON(w, err) return } - ErrorJSON(w, err) - return } - ResponseJSON(w, http.StatusConflict, nil) + var out domain.CheckExistedIdResponse + out.Existed = exist + + ResponseJSON(w, http.StatusOK, out) } func NewUserHandler(h usecase.IUserUsecase) IUserHandler { diff --git a/internal/repository/organization.go b/internal/repository/organization.go index 3c53462f..ce4e54d8 100644 --- a/internal/repository/organization.go +++ b/internal/repository/organization.go @@ -100,6 +100,7 @@ func (r *OrganizationRepository) Update(organizationId string, in domain.UpdateO res := r.db.Model(&Organization{}). Where("id = ?", organizationId). Updates(Organization{ + Name: in.Name, Description: in.Description, Phone: in.Phone, PrimaryClusterId: in.PrimaryClusterId, diff --git a/internal/repository/user.go b/internal/repository/user.go index 6fa75d88..449399f6 100644 --- a/internal/repository/user.go +++ b/internal/repository/user.go @@ -17,7 +17,7 @@ type IUserRepository interface { List(...FilterFunc) (out *[]domain.User, err error) Get(accountId string, organizationId string) (domain.User, error) GetByUuid(userId uuid.UUID) (domain.User, error) - UpdateWithUuid(uuid uuid.UUID, accountId string, name string, password string, email string, + UpdateWithUuid(uuid uuid.UUID, accountId string, name string, password string, roleId uuid.UUID, email string, department string, description string) (domain.User, error) DeleteWithUuid(uuid uuid.UUID) error Flush(organizationId string) error @@ -177,7 +177,8 @@ func (r *UserRepository) GetByUuid(userId uuid.UUID) (respUser domain.User, err return r.reflect(user), nil } -func (r *UserRepository) UpdateWithUuid(uuid uuid.UUID, accountId string, name string, password string, email string, department string, description string) (domain.User, error) { +func (r *UserRepository) UpdateWithUuid(uuid uuid.UUID, accountId string, name string, password string, roleId uuid.UUID, + email string, department string, description string) (domain.User, error) { var user User res := r.db.Model(&User{}).Where("id = ?", uuid).Updates(User{ AccountId: accountId, @@ -186,6 +187,7 @@ func (r *UserRepository) UpdateWithUuid(uuid uuid.UUID, accountId string, name s Email: email, Department: department, Description: description, + RoleId: roleId, }) if res.RowsAffected == 0 || res.Error != nil { return domain.User{}, httpErrors.NewNotFoundError(httpErrors.NotFound) diff --git a/internal/route/route.go b/internal/route/route.go index 81bffb8e..b3fe9e2b 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -120,13 +120,13 @@ func SetupRouter(db *gorm.DB, argoClient argowf.ArgoClient, asset http.Handler, r.HandleFunc(API_PREFIX+API_VERSION+"/auth/find-password", authHandler.FindPassword).Methods(http.MethodPost) userHandler := delivery.NewUserHandler(usecase.NewUserUsecase(repository.NewUserRepository(db), kc)) - r.Handle(API_PREFIX+API_VERSION+"/users", authMiddleware(http.HandlerFunc(userHandler.Create), kc)).Methods(http.MethodPost) - r.Handle(API_PREFIX+API_VERSION+"/users", authMiddleware(http.HandlerFunc(userHandler.List), kc)).Methods(http.MethodGet) - r.Handle(API_PREFIX+API_VERSION+"/users/{userId}", authMiddleware(http.HandlerFunc(userHandler.Get), kc)).Methods(http.MethodGet) - r.Handle(API_PREFIX+API_VERSION+"/users/{userId}", authMiddleware(http.HandlerFunc(userHandler.Delete), kc)).Methods(http.MethodDelete) - r.Handle(API_PREFIX+API_VERSION+"/users/{userId}", authMiddleware(http.HandlerFunc(userHandler.Update), kc)).Methods(http.MethodPut) - r.Handle(API_PREFIX+API_VERSION+"/users/{userId}/password", authMiddleware(http.HandlerFunc(userHandler.UpdatePassword), kc)).Methods(http.MethodPatch) - r.Handle(API_PREFIX+API_VERSION+"/users/{userId}", authMiddleware(http.HandlerFunc(userHandler.CheckId), kc)).Methods(http.MethodPost) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users", authMiddleware(http.HandlerFunc(userHandler.Create), kc)).Methods(http.MethodPost) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users", authMiddleware(http.HandlerFunc(userHandler.List), kc)).Methods(http.MethodGet) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users/{accountId}", authMiddleware(http.HandlerFunc(userHandler.Get), kc)).Methods(http.MethodGet) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users/{accountId}", authMiddleware(http.HandlerFunc(userHandler.Delete), kc)).Methods(http.MethodDelete) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users/{accountId}", authMiddleware(http.HandlerFunc(userHandler.Update), kc)).Methods(http.MethodPut) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users/{accountId}/password", authMiddleware(http.HandlerFunc(userHandler.UpdatePassword), kc)).Methods(http.MethodPut) + r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/users/{accountId}/existence", authMiddleware(http.HandlerFunc(userHandler.CheckId), kc)).Methods(http.MethodGet) organizationHandler := delivery.NewOrganizationHandler(usecase.NewOrganizationUsecase(repository.NewOrganizationRepository(db), argoClient, kc), usecase.NewUserUsecase(repository.NewUserRepository(db), kc)) diff --git a/internal/usecase/user.go b/internal/usecase/user.go index acd80ac6..0ae9e4c8 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -22,11 +22,11 @@ type IUserUsecase interface { DeleteAdmin(organizationId string) error DeleteAll(ctx context.Context, organizationId string) error Create(ctx context.Context, user *domain.User) (*domain.User, error) - List(ctx context.Context) (*[]domain.User, error) - GetByAccountId(ctx context.Context, accountId string) (*domain.User, error) + List(ctx context.Context, organizationId string) (*[]domain.User, error) + GetByAccountId(ctx context.Context, accountId string, organizationId string) (*domain.User, error) UpdateByAccountId(ctx context.Context, accountId string, user *domain.User) (*domain.User, error) - UpdatePasswordByAccountId(ctx context.Context, accountId string, password string) error - DeleteByAccountId(ctx context.Context, accountId string) error + UpdatePasswordByAccountId(ctx context.Context, accountId string, password string, organizationId string) error + DeleteByAccountId(ctx context.Context, accountId string, organizationId string) error } type UserUsecase struct { @@ -145,21 +145,17 @@ func (u *UserUsecase) CreateAdmin(orgainzationId string) (*domain.User, error) { return &resUser, nil } -func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId string, newPassword string) error { +func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId string, newPassword string, + organizationId string) error { token, ok := request.TokenFrom(ctx) - if !ok { + if ok == false { return fmt.Errorf("token in the context is empty") } - userInfo, ok := request.UserFrom(ctx) - if !ok { - return fmt.Errorf("user in the context is empty") - } - - originUser, err := u.kc.GetUser(userInfo.GetOrganizationId(), accountId, token) + originUser, err := u.kc.GetUser(organizationId, accountId, token) if err != nil { - return errors.Wrap(err, "getting user from keycloak failed") + return err } originUser.Credentials = &[]gocloak.CredentialRepresentation{ @@ -170,18 +166,18 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s }, } - err = u.kc.UpdateUser(userInfo.GetOrganizationId(), originUser, token) + err = u.kc.UpdateUser(organizationId, originUser, token) if err != nil { return errors.Wrap(err, "updating user in keycloak failed") } // update password in DB - user, err := u.repo.Get(accountId, userInfo.GetOrganizationId()) + user, err := u.repo.Get(accountId, organizationId) if err != nil { return errors.Wrap(err, "getting user from repository failed") } - uuid, err := uuid.Parse(user.ID) + userUuid, err := uuid.Parse(user.ID) if err != nil { return errors.Wrap(err, "parsing uuid failed") } @@ -190,7 +186,18 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s return errors.Wrap(err, "hashing password failed") } - _, err = u.repo.UpdateWithUuid(uuid, user.AccountId, user.Name, hashedPassword, user.Email, + roles, err := u.repo.FetchRoles() + if err != nil { + return err + } + for _, role := range *roles { + if role.Name == user.Role.Name { + user.Role.ID = role.ID + } + } + roleUuid, err := uuid.Parse(user.Role.ID) + + _, err = u.repo.UpdateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, roleUuid, user.Email, user.Department, user.Description) if err != nil { return errors.Wrap(err, "updating user in repository failed") @@ -199,13 +206,8 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s return nil } -func (u *UserUsecase) List(ctx context.Context) (*[]domain.User, error) { - userInfo, ok := request.UserFrom(ctx) - if !ok { - return nil, fmt.Errorf("user in the context is empty") - } - - users, err := u.repo.List(u.repo.OrganizationFilter(userInfo.GetOrganizationId())) +func (u *UserUsecase) List(ctx context.Context, organizationId string) (*[]domain.User, error) { + users, err := u.repo.List(u.repo.OrganizationFilter(organizationId)) if err != nil { return nil, err } @@ -213,13 +215,8 @@ func (u *UserUsecase) List(ctx context.Context) (*[]domain.User, error) { return users, nil } -func (u *UserUsecase) GetByAccountId(ctx context.Context, accountId string) (*domain.User, error) { - userInfo, ok := request.UserFrom(ctx) - if !ok { - return nil, fmt.Errorf("user in the context is empty") - } - - users, err := u.repo.List(u.repo.OrganizationFilter(userInfo.GetOrganizationId()), +func (u *UserUsecase) GetByAccountId(ctx context.Context, accountId string, organizationId string) (*domain.User, error) { + users, err := u.repo.List(u.repo.OrganizationFilter(organizationId), u.repo.AccountIdFilter(accountId)) if err != nil { return nil, err @@ -270,7 +267,18 @@ func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, u originPassword := (*users)[0].Password - *user, err = u.repo.UpdateWithUuid(userUuid, user.AccountId, user.Name, originPassword, user.Email, + roles, err := u.repo.FetchRoles() + if err != nil { + return nil, err + } + for _, role := range *roles { + if role.Name == user.Role.Name { + user.Role.ID = role.ID + } + } + roleUuid, err := uuid.Parse(user.Role.ID) + + *user, err = u.repo.UpdateWithUuid(userUuid, user.AccountId, user.Name, originPassword, roleUuid, user.Email, user.Department, user.Description) if err != nil { return nil, errors.Wrap(err, "updating user in repository failed") @@ -279,22 +287,17 @@ func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, u return user, nil } -func (u *UserUsecase) DeleteByAccountId(ctx context.Context, accountId string) error { - userInfo, ok := request.UserFrom(ctx) - if !ok { - return fmt.Errorf("user in the context is empty") - } - - user, err := u.repo.Get(accountId, userInfo.GetOrganizationId()) +func (u *UserUsecase) DeleteByAccountId(ctx context.Context, accountId string, organizationId string) error { + user, err := u.repo.Get(accountId, organizationId) if err != nil { return err } - uuid, err := uuid.Parse(user.ID) + userUuid, err := uuid.Parse(user.ID) if err != nil { return err } - err = u.repo.DeleteWithUuid(uuid) + err = u.repo.DeleteWithUuid(userUuid) if err != nil { return err } @@ -304,7 +307,7 @@ func (u *UserUsecase) DeleteByAccountId(ctx context.Context, accountId string) e if !ok { return fmt.Errorf("token in the context is empty") } - err = u.kc.DeleteUser(userInfo.GetOrganizationId(), accountId, token) + err = u.kc.DeleteUser(organizationId, accountId, token) if err != nil { return err } diff --git a/pkg/domain/organization.go b/pkg/domain/organization.go index a3f70b96..a281e3ff 100644 --- a/pkg/domain/organization.go +++ b/pkg/domain/organization.go @@ -90,12 +90,14 @@ type ListOrganizationBody struct { type UpdateOrganizationRequest struct { PrimaryClusterId string `json:"primaryClusterId"` + Name string `json:"name" validate:"required,min=3,max=20"` Description string `json:"description" validate:"omitempty,min=0,max=100"` Phone string `json:"phone"` } type UpdateOrganizationResponse struct { ID string `json:"id"` + Name string `json:"name"` Description string `json:"description"` Phone string `json:"phone"` } diff --git a/pkg/domain/user.go b/pkg/domain/user.go index 46d457fe..5dc5255e 100644 --- a/pkg/domain/user.go +++ b/pkg/domain/user.go @@ -165,9 +165,10 @@ type UpdatePasswordRequest struct { type UpdatePasswordResponse struct { } -type CheckDuplicatedIdRequest struct { +type CheckExistedIdRequest struct { AccountId string `json:"accountId" validate:"required"` } -type CheckDuplicatedIdResponse struct { +type CheckExistedIdResponse struct { + Existed bool `json:"existed"` } From bfcc5a3a6528727ab647e2be0222cd171b2585eb Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 7 Apr 2023 11:38:35 +0900 Subject: [PATCH 2/4] minor fix: add path paramter(organization) for user resource --- internal/usecase/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/usecase/user.go b/internal/usecase/user.go index 0ae9e4c8..9d22634e 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -149,7 +149,7 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s organizationId string) error { token, ok := request.TokenFrom(ctx) - if ok == false { + if !ok { return fmt.Errorf("token in the context is empty") } From 9e1ac98c76c2e794dd34b90a7c6aeebdec77c8e2 Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 7 Apr 2023 13:48:54 +0900 Subject: [PATCH 3/4] lin fix --- internal/usecase/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/usecase/user.go b/internal/usecase/user.go index 9d22634e..ca819ad0 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -196,6 +196,9 @@ func (u *UserUsecase) UpdatePasswordByAccountId(ctx context.Context, accountId s } } roleUuid, err := uuid.Parse(user.Role.ID) + if err != nil { + return err + } _, err = u.repo.UpdateWithUuid(userUuid, user.AccountId, user.Name, hashedPassword, roleUuid, user.Email, user.Department, user.Description) @@ -277,6 +280,9 @@ func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, u } } roleUuid, err := uuid.Parse(user.Role.ID) + if err != nil { + return nil, err + } *user, err = u.repo.UpdateWithUuid(userUuid, user.AccountId, user.Name, originPassword, roleUuid, user.Email, user.Department, user.Description) From 1476d44bd4135bfe21b65b19aba1683d966bd1c7 Mon Sep 17 00:00:00 2001 From: donggyu Date: Fri, 7 Apr 2023 14:13:15 +0900 Subject: [PATCH 4/4] test: dummy value --- internal/usecase/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/usecase/user.go b/internal/usecase/user.go index ca819ad0..329b8487 100644 --- a/internal/usecase/user.go +++ b/internal/usecase/user.go @@ -231,7 +231,7 @@ func (u *UserUsecase) GetByAccountId(ctx context.Context, accountId string, orga func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, user *domain.User) (*domain.User, error) { userInfo, ok := request.UserFrom(ctx) if !ok { - return nil, fmt.Errorf("user in the context is empty") + return nil, fmt.Errorf("user in the context is empty") } token, ok := request.TokenFrom(ctx) if !ok {