后台文章列表显示点击数量

版本页面HTML使\n换行
This commit is contained in:
sysnix 2023-09-28 03:11:26 +08:00
parent 167593e65f
commit 108e9ad206
4 changed files with 11 additions and 1 deletions

2
.gitignore vendored
View File

@ -34,3 +34,5 @@ build/
*.db
*.log
*.exe
*.sum
blog

View File

@ -13,6 +13,7 @@ type AdminArticle struct {
Content string `json:"content" gorm:"-"`
ContentType string `json:"contentType"`
Tags string `json:"tags"`
View int `json:"view" gorm:"-"`
PublishTime int64 `json:"publishTime"`
CreateBy string `json:"createBy"`
CreateTime int64 `json:"createTime"`

View File

@ -70,6 +70,7 @@ func (*articleService) GetAdminArticle(id string) admin.AdminArticle {
func (*articleService) PageAdminArticle(page int, itemsPerPage int) vo.Page[admin.AdminArticle] {
var content []admin.AdminArticle
var totalElements int64
ctx := context.Background()
database.GormTemplate.Table("blog_articles").Count(&totalElements)
database.GormTemplate.Table("blog_articles").
Where("del != ?", 1).
@ -78,6 +79,12 @@ func (*articleService) PageAdminArticle(page int, itemsPerPage int) vo.Page[admi
Order("create_time DESC").
Find(&content)
for i, v := range content {
id := v.Id
view, _ := database.RedisTemplate.HGet(ctx, consts.REDIS_BLOG_VIEW_RECORD, id).Int()
content[i].View = view
}
pre := int(totalElements) % itemsPerPage
if pre > 0 {
pre = 1

View File

@ -75,7 +75,7 @@
<v-card :color="item.milestone==1?'primary':''">
<v-card-title class="text-h6">{{item.version}}</v-card-title>
<v-card-text class="white text--primary">
<p style="font-size: 16px;">{{item.description}}</p>
<p style="font-size: 16px;white-space: pre-wrap;">{{item.description}}</p>
</v-card-text>
</v-card>
</v-timeline-item>