-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: 서비스 데이터는 public이므로 인증 없이 사용자 조회하도록 반영 * rename: 함수명 변경 * up: token 기반으로 사용자 조회하는 api 복구 * rename: 명확하게 이름 변경 * up: 명확하게 변수명 변경 * up: 중복 코드 함수화 * up: 문서화 * up: 누락된 http status 추가
- Loading branch information
Showing
7 changed files
with
188 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
package models | ||
|
||
import ( | ||
"encoding/base64" | ||
"net/http" | ||
|
||
"github.com/belf-kr/oauth-server/internal/app/entitys" | ||
) | ||
|
||
type UserInfo struct { | ||
Id int `json:"id" binding:"required" example:"1"` | ||
Email string `json:"email" binding:"required" example:"[email protected]"` | ||
Name string `json:"name" binding:"required" example:"사용자01"` | ||
AvatarImage string `json:"avatarImage" binding:"required" example:"base64으로 인코딩된 이미지"` | ||
} | ||
|
||
func NewUserInfo(user entitys.User) UserInfo { | ||
// [base64 encoding for any image](https://freshman.tech/snippets/go/image-to-base64/) | ||
var base64Encoding string | ||
|
||
// 이미지 파일의 콘텐츠 유형에 맞게 적절한 URI 체계 헤더를 추가합니다. | ||
mimeType := http.DetectContentType(user.AvatarImage) | ||
switch mimeType { | ||
case "image/jpeg": | ||
base64Encoding += "data:image/jpeg;base64," | ||
case "image/png": | ||
base64Encoding += "data:image/png;base64," | ||
} | ||
|
||
base64Encoding += base64.StdEncoding.EncodeToString(user.AvatarImage) | ||
|
||
return UserInfo{ | ||
Id: int(user.Id), | ||
Email: user.Email, | ||
Name: user.Name, | ||
AvatarImage: base64Encoding, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ package project | |
|
||
const ( | ||
AppName string = "oauth-server" | ||
AppVersion string = "0.2.2" | ||
AppVersion string = "0.3.0" | ||
) |