chore: initial commit
This commit is contained in:
25
internal/model/response/post.go
Normal file
25
internal/model/response/post.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type ArchivePost struct {
|
||||
ID int32 `json:"id"`
|
||||
Slug string `json:"slug"`
|
||||
Title string `json:"title"`
|
||||
PublishedAt time.Time `json:"published_at"`
|
||||
PublishedAtDisplay string `json:"published_at_display"`
|
||||
CategoryName string `json:"category_name"`
|
||||
}
|
||||
|
||||
type ArchiveMonth struct {
|
||||
Month int `json:"month"`
|
||||
Archive []ArchivePost `json:"list"`
|
||||
}
|
||||
|
||||
type ArchiveYear struct {
|
||||
Year int `json:"year"`
|
||||
Total int `json:"total"`
|
||||
ArchiveMonth []ArchiveMonth `json:"list"`
|
||||
}
|
||||
15
internal/model/response/sys_file.go
Normal file
15
internal/model/response/sys_file.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
db "server/internal/db/sqlc"
|
||||
"server/internal/pkg/httputil"
|
||||
)
|
||||
|
||||
func ToFiles(files []db.File) []db.File {
|
||||
result := make([]db.File, len(files))
|
||||
for i := range files {
|
||||
result[i] = files[i]
|
||||
result[i].FilePath = httputil.BuildFileUrl(&files[i].FilePath)
|
||||
}
|
||||
return result
|
||||
}
|
||||
45
internal/model/response/sys_user.go
Normal file
45
internal/model/response/sys_user.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
db "server/internal/db/sqlc"
|
||||
"server/internal/pkg/httputil"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysUserRolesResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type SysUserInfo struct {
|
||||
ID int32 `json:"id"`
|
||||
Account string `json:"account"`
|
||||
Username string `json:"username"`
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
Roles []string `json:"roles"`
|
||||
Menus []db.SysMenu `json:"menus"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
AccessTokenExp time.Time `json:"access_token_exp"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
RefreshTokenExp time.Time `json:"refresh_token_exp"`
|
||||
}
|
||||
|
||||
func NewSysUserInfo(user db.GetSysUserByIDRow, roles []db.SysRole, menus []db.SysMenu) *SysUserInfo {
|
||||
roleCodes := make([]string, len(roles))
|
||||
for i, role := range roles {
|
||||
roleCodes[i] = role.Code
|
||||
}
|
||||
|
||||
return &SysUserInfo{
|
||||
ID: user.ID,
|
||||
Account: user.Account,
|
||||
Username: user.Username,
|
||||
AvatarUrl: httputil.BuildFileUrl(user.AvatarUrl),
|
||||
Roles: roleCodes,
|
||||
Menus: menus,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user