Compare commits
10 Commits
ea0eb449d8
...
9b38699764
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b38699764 | ||
|
|
5798b01376 | ||
|
|
998941511f | ||
|
|
69ac9ddd9c | ||
|
|
b68fb0aac2 | ||
|
|
6b1d9d5feb | ||
|
|
ab1dec1f79 | ||
|
|
9f488cbb7e | ||
|
|
f950fc0a8e | ||
|
|
7ebab50d1e |
@@ -138,4 +138,10 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Query[requests.Pagination]("pagination"),
|
||||
))
|
||||
|
||||
router.Post("/admin/users/:id/balance", Func2(
|
||||
r.users.Balance,
|
||||
PathParam[int64]("id"),
|
||||
Body[UserBalance]("balance"),
|
||||
))
|
||||
|
||||
}
|
||||
|
||||
@@ -194,7 +194,11 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
|
||||
log.WithError(err).Errorf("medias GetByID err: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
url, err := ctl.oss.GetSignedUrl(ctx.Context(), media.Path)
|
||||
duration := 2*asset.Metas.Duration + 30
|
||||
if asset.Metas.Duration == 0 {
|
||||
duration = 60 * 5
|
||||
}
|
||||
url, err := ctl.oss.GetSignedUrl(ctx.Context(), media.Path, ali.WithExpire(time.Second*time.Duration(duration)))
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("media GetSignedUrl err: %v", err)
|
||||
return nil, err
|
||||
|
||||
@@ -224,12 +224,15 @@ func (m *postsModel) DeleteByID(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
// SendTo
|
||||
func (m *postsModel) SendTo(ctx context.Context, userId, postId int64) error {
|
||||
func (m *postsModel) SendTo(ctx context.Context, postId, userId int64) error {
|
||||
// add record to user_posts
|
||||
tbl := table.UserPosts
|
||||
stmt := tbl.INSERT(tbl.MutableColumns).MODEL(model.UserPosts{
|
||||
UserID: userId,
|
||||
PostID: postId,
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
UserID: userId,
|
||||
PostID: postId,
|
||||
Price: -1,
|
||||
})
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
if _, err := stmt.ExecContext(ctx, db); err != nil {
|
||||
|
||||
@@ -167,6 +167,7 @@ func (m *usersModel) Update(ctx context.Context, id int64, userModel *model.User
|
||||
stmt := tbl.
|
||||
UPDATE(
|
||||
tbl.MutableColumns.Except(
|
||||
tbl.Balance,
|
||||
tbl.CreatedAt,
|
||||
tbl.DeletedAt,
|
||||
),
|
||||
|
||||
@@ -27,7 +27,12 @@ export const userService = {
|
||||
getUserById(id) {
|
||||
return httpClient.get(`/admin/users/${id}`);
|
||||
},
|
||||
getUserArticles(userId) {
|
||||
return httpClient.get(`/admin/users/${userId}/articles`);
|
||||
getUserArticles(userId, page, limit) {
|
||||
return httpClient.get(`/admin/users/${userId}/articles`, {
|
||||
params: {
|
||||
page,
|
||||
limit,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,14 @@ const formatPrice = (price) => {
|
||||
<div class="flex-1">
|
||||
<h2 class="text-xl font-bold mb-2">{{ user.username }}</h2>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<p class="text-gray-500">ID</p>
|
||||
<p>{{ user.id }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500">余额</p>
|
||||
<p>{{ (user.balance / 100).toFixed(2) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500">OpenID</p>
|
||||
<p>{{ user.open_id }}</p>
|
||||
|
||||
@@ -27,45 +27,35 @@ const showArticle = (article) => {
|
||||
router.push(`/posts/${article.id}`)
|
||||
}
|
||||
|
||||
const getBgImage = (id) => {
|
||||
const idx = id % 79
|
||||
return `background-image: url(/avatar/${idx}.jpeg); background-size: 100% 100%`
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="bg-white shadow overflow-hidden hover:shadow-md transition-shadow duration-200 cursor-pointer flex h-32"
|
||||
<div :style="getBgImage(article.id)"
|
||||
class="flex flex-col rounded-md overflow-hidden bg-gray-500 bg-no-repeat shadow-lg shadow-gray-500"
|
||||
@click="showArticle(article)">
|
||||
<!-- Left side - Image -->
|
||||
<div v-if="article.head_images && article.head_images.length > 0"
|
||||
class="relative w-32 flex-shrink-0 bg-gray-100 overflow-hidden">
|
||||
<img :src="article.head_images[0]"
|
||||
class="absolute inset-0 h-full w-full object-cover transition-transform duration-300 hover:scale-105"
|
||||
:alt="article.title" />
|
||||
<div class="absolute inset-0 bg-gradient-to-r from-transparent to-black/20"></div>
|
||||
</div>
|
||||
<div class="flex-1 p-4 backdrop-blur-xl w-full h-full backdrop-brightness-50">
|
||||
<h3 class="text-xl font-semibold text-gray-200 drop-shadow-md drop-shadow-white-100">
|
||||
{{ article.title }}
|
||||
</h3>
|
||||
|
||||
<!-- Right side - Content -->
|
||||
<div class="flex-1 p-4 flex flex-col justify-between min-w-0">
|
||||
<div class="space-y-2">
|
||||
<h3 class="text-lg font-semibold text-gray-800 line-clamp-2">
|
||||
{{ article.title }}
|
||||
</h3>
|
||||
|
||||
<p v-if="article.description" class="text-gray-600 text-sm line-clamp-2">
|
||||
{{ article.description }}
|
||||
</p>
|
||||
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<span v-for="tag in article.tags" :key="tag"
|
||||
class="px-2 py-0.5 text-xs bg-blue-50 text-blue-600 rounded-full">
|
||||
{{ tag }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<span v-for="tag in article.tags" :key="tag"
|
||||
class="px-2 py-0.5 text-xs bg-blue-50 text-blue-600 rounded-full">
|
||||
{{ tag }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between pt-1 text-sm">
|
||||
<div class="flex items-center gap-2 text-gray-500">
|
||||
<div class="flex items-center justify-between pt-4 text-sm">
|
||||
<div class="flex items-center gap-2 text-gray-100">
|
||||
<AiOutlineEye class="w-4 h-4" />
|
||||
<span>{{ article.view_count || 0 }}</span>
|
||||
</div>
|
||||
<div class="text-orange-600 font-mono text-lg" v-if="!article.bought">
|
||||
<div class="text-gray-100 font-mono text-lg" v-if="!article.bought">
|
||||
¥{{ discountPrice }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,8 +87,8 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
<div class="container max-w-2xl mx-auto py-4">
|
||||
<div class="grid gap-4">
|
||||
<div class="container max-w-2xl mx-auto p-4">
|
||||
<div class="grid gap-6">
|
||||
<ArticleListItem v-for="article in articles" :key="article.id" :article="article" />
|
||||
</div>
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user