From 2b398e9cf222d44405f382bfbf6cda133f39f4b8 Mon Sep 17 00:00:00 2001 From: daz-3ux Date: Mon, 9 Oct 2023 16:01:00 +0800 Subject: [PATCH] fix: postcount always is zero Signed-off-by: daz-3ux --- configs/dazBlog.yaml | 2 +- internal/pkg/model/user.go | 2 +- pkg/api/dazBlog/v1/user.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/dazBlog.yaml b/configs/dazBlog.yaml index bc9e7e5..4bdc387 100644 --- a/configs/dazBlog.yaml +++ b/configs/dazBlog.yaml @@ -23,7 +23,7 @@ db: max-idle-connections: 100 max-open-connections: 100 max-connection-life-time: 10s - log-level: 4 # GORM log level, 1: silent, 2:error, 3:warn, 4:info + log-level: 2 # GORM log level, 1: silent, 2:error, 3:warn, 4:info # log configs log: diff --git a/internal/pkg/model/user.go b/internal/pkg/model/user.go index 65b0d8d..e0262d9 100644 --- a/internal/pkg/model/user.go +++ b/internal/pkg/model/user.go @@ -13,7 +13,7 @@ import ( type UserM struct { ID int64 `gorm:"column:id;primary_key"` // unique id for the user, server as the primary key - PostCount int64 `gorm:"column:postCount"` // number of posts the user has + PostCount int64 `gorm:"column:postcount"` // number of posts the user has Username string `gorm:"column:username"` // username of the user Password string `gorm:"column:password"` // password of the user Nickname string `gorm:"column:nickname"` // nickname of the user diff --git a/pkg/api/dazBlog/v1/user.go b/pkg/api/dazBlog/v1/user.go index f28baf0..025c164 100644 --- a/pkg/api/dazBlog/v1/user.go +++ b/pkg/api/dazBlog/v1/user.go @@ -8,7 +8,7 @@ package v1 // CreateUserRequest specifies the request parameters for // `POST /v1/users` type CreateUserRequest struct { - PostCount string `json:"postcount" valid:"required,stringlength(1|255)"` + Postcount int64 `json:"postcount" valid:"required,stringlength(1|255)"` Username string `json:"username" valid:"alphanum,required,stringlength(1|255)"` Password string `json:"password" valid:"required,stringlength(6|18)"` Nickname string `json:"nickname" valid:"required,stringlength(1|255)"` @@ -26,7 +26,7 @@ type UserInfo struct { Nickname string `json:"nickname"` Email string `json:"email"` Phone string `json:"phone"` - PostCount int64 `json:"postCount"` + PostCount int64 `json:"postcount"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` }