Optimization: merge user models into one
This commit is contained in:
parent
10b1b41006
commit
d98d0cbd87
5 changed files with 36 additions and 34 deletions
|
@ -9,7 +9,7 @@ type Illust struct {
|
|||
ID int `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Caption template.HTML `json:"caption"`
|
||||
Artist UserBrief `json:"user"`
|
||||
Artist User `json:"user"`
|
||||
Date time.Time `json:"create_date"`
|
||||
Pages int `json:"page_count"`
|
||||
Views int `json:"total_view"`
|
||||
|
@ -32,29 +32,23 @@ type Tag struct {
|
|||
}
|
||||
|
||||
type User struct {
|
||||
User UserBrief `json:"user"`
|
||||
Profile UserProfile `json:"profile"`
|
||||
}
|
||||
|
||||
type UserBrief struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account"`
|
||||
Avatar map[string]string `json:"profile_image_urls"`
|
||||
}
|
||||
|
||||
type UserProfile struct {
|
||||
Webpage string `json:"webpage"`
|
||||
Gender string `json:"gender"`
|
||||
Birth string `json:"birth"`
|
||||
BirthDay string `json:"birth_day"`
|
||||
BirthYear int `json:"birth_year"`
|
||||
Region string `json:"region"`
|
||||
BackgroundImage string `json:"background_image_url"`
|
||||
Followers int `json:"total_follow_users"`
|
||||
MyPixiv int `json:"total_mypixiv_users"`
|
||||
TwitterURL string `json:"twitter_url"`
|
||||
PawooURL string `json:"pawoo_url"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account"`
|
||||
Avatar map[string]string `json:"profile_image_urls"`
|
||||
Webpage string `json:"webpage"`
|
||||
Gender string `json:"gender"`
|
||||
Birth string `json:"birth"`
|
||||
BirthDay string `json:"birth_day"`
|
||||
BirthYear int `json:"birth_year"`
|
||||
Region string `json:"region"`
|
||||
BackgroundImage string `json:"background_image_url"`
|
||||
Followers int `json:"total_follow_users"`
|
||||
MyPixiv int `json:"total_mypixiv_users"`
|
||||
Illusts int `json:"total_illusts"`
|
||||
Mangas int `json:"total_mangas"`
|
||||
TwitterURL string `json:"twitter_url"`
|
||||
PawooURL string `json:"pawoo_url"`
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
|
|
|
@ -184,7 +184,15 @@ func GetUserInfo(c *gin.Context) (entity.User, error) {
|
|||
var user entity.User
|
||||
|
||||
s := Request(URL)
|
||||
err := json.Unmarshal([]byte(s), &user)
|
||||
user_string := GetInnerJSON(s, "user")
|
||||
profile_string := GetInnerJSON(s, "profile")
|
||||
|
||||
err := json.Unmarshal([]byte(user_string), &user)
|
||||
if err != nil {
|
||||
panic("Failed to parse JSON")
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(profile_string), &user)
|
||||
if err != nil {
|
||||
panic("Failed to parse JSON")
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@ body {
|
|||
font-size: 0.9rem;
|
||||
}
|
||||
.artwork-thumbnail .artwork-master-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-position: center center;
|
||||
}
|
||||
.artwork-thumbnail .artwork-thumbnail-artist {
|
||||
|
@ -88,10 +86,12 @@ body {
|
|||
|
||||
.artwork-thumbnail-small {
|
||||
width: 184px;
|
||||
height: 184px;
|
||||
}
|
||||
|
||||
.artwork-thumbnail-large {
|
||||
width: 288px;
|
||||
height: 288px;
|
||||
}
|
||||
|
||||
.spotlight-thumbnail {
|
||||
|
|
|
@ -79,8 +79,6 @@ body {
|
|||
}
|
||||
|
||||
.artwork-master-image {
|
||||
width: 184px;
|
||||
height: 184px;
|
||||
object-position: center center;
|
||||
}
|
||||
|
||||
|
@ -108,10 +106,12 @@ body {
|
|||
|
||||
.artwork-thumbnail-small {
|
||||
width: 184px;
|
||||
height: 184px;
|
||||
}
|
||||
|
||||
.artwork-thumbnail-large {
|
||||
width: 288px;
|
||||
height: 288px;
|
||||
}
|
||||
|
||||
.spotlight-thumbnail {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{ template "header.html" }} {{ $Recent := .Recent }} {{ with .User }}
|
||||
{{ template "header.html" }}
|
||||
<div class="user-background">
|
||||
<img src="{{ .Profile.BackgroundImage }}" alt="alt" />
|
||||
<img src="{{ .User.BackgroundImage }}" alt="{{ .User.Name }}" />
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="user-page">
|
||||
|
@ -8,12 +8,12 @@
|
|||
<img src="{{ .User.Avatar.medium }}" alt="avatar" class="user-avatar" />
|
||||
<h2 class="user-name">{{ .User.Name }}</h2>
|
||||
<p class="user-id">@{{ .User.Account }}</p>
|
||||
<p>{{ .Profile.Followers }} Following | {{ .Profile.MyPixiv }} MyPixiv</p>
|
||||
<p>{{ .User.Followers }} Following | {{ .User.MyPixiv }} MyPixiv</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h1>Illustrations and Mangas</h1>
|
||||
{{ template "small-tn.html" $Recent }}
|
||||
{{ template "small-tn.html" .Recent }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }} {{ template "footer.html" }}
|
||||
{{ template "footer.html" }}
|
||||
|
|
Loading…
Reference in a new issue