mirror of
https://github.com/ctwj/urldb.git
synced 2025-11-25 03:15:04 +08:00
update: 更细 ready_resource
This commit is contained in:
@@ -92,14 +92,15 @@ type UpdateTagRequest struct {
|
||||
|
||||
// CreateReadyResourceRequest 创建待处理资源请求
|
||||
type CreateReadyResourceRequest struct {
|
||||
Title *string `json:"title"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"`
|
||||
Img string `json:"img"`
|
||||
Source string `json:"source"`
|
||||
Extra string `json:"extra"`
|
||||
IP *string `json:"ip"`
|
||||
Title *string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"`
|
||||
Img string `json:"img"`
|
||||
Source string `json:"source"`
|
||||
Extra string `json:"extra"`
|
||||
IP *string `json:"ip"`
|
||||
}
|
||||
|
||||
// BatchCreateReadyResourceRequest 批量创建待处理资源请求
|
||||
|
||||
@@ -67,16 +67,17 @@ type CksResponse struct {
|
||||
|
||||
// ReadyResourceResponse 待处理资源响应
|
||||
type ReadyResourceResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Title *string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"`
|
||||
Img string `json:"img"`
|
||||
Source string `json:"source"`
|
||||
Extra string `json:"extra"`
|
||||
CreateTime time.Time `json:"create_time"`
|
||||
IP *string `json:"ip"`
|
||||
ID uint `json:"id"`
|
||||
Title *string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"`
|
||||
Img string `json:"img"`
|
||||
Source string `json:"source"`
|
||||
Extra string `json:"extra"`
|
||||
CreateTime time.Time `json:"create_time"`
|
||||
IP *string `json:"ip"`
|
||||
}
|
||||
|
||||
// Stats 统计信息
|
||||
|
||||
@@ -8,19 +8,20 @@ import (
|
||||
|
||||
// ReadyResource 待处理资源模型
|
||||
type ReadyResource struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Title *string `json:"title" gorm:"size:255;comment:资源标题"`
|
||||
URL string `json:"url" gorm:"size:500;not null;comment:资源链接"`
|
||||
Category string `json:"category" gorm:"size:100;comment:资源分类"`
|
||||
Tags string `json:"tags" gorm:"size:500;comment:资源标签,多个标签用逗号分隔"`
|
||||
Img string `json:"img" gorm:"size:500;comment:封面链接"`
|
||||
Source string `json:"source" gorm:"size:100;comment:数据来源"`
|
||||
Extra string `json:"extra" gorm:"type:text;comment:额外附加数据"`
|
||||
CreateTime time.Time `json:"create_time" gorm:"default:CURRENT_TIMESTAMP"`
|
||||
IP *string `json:"ip" gorm:"size:45;comment:IP地址"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Title *string `json:"title" gorm:"size:255;comment:资源标题"`
|
||||
Description string `json:"description" gorm:"type:text;comment:资源描述"`
|
||||
URL string `json:"url" gorm:"size:500;not null;comment:资源链接"`
|
||||
Category string `json:"category" gorm:"size:100;comment:资源分类"`
|
||||
Tags string `json:"tags" gorm:"size:500;comment:资源标签,多个标签用逗号分隔"`
|
||||
Img string `json:"img" gorm:"size:500;comment:封面链接"`
|
||||
Source string `json:"source" gorm:"size:100;comment:数据来源"`
|
||||
Extra string `json:"extra" gorm:"type:text;comment:额外附加数据"`
|
||||
CreateTime time.Time `json:"create_time" gorm:"default:CURRENT_TIMESTAMP"`
|
||||
IP *string `json:"ip" gorm:"size:45;comment:IP地址"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
|
||||
@@ -55,14 +55,15 @@ func CreateReadyResource(c *gin.Context) {
|
||||
}
|
||||
|
||||
resource := &entity.ReadyResource{
|
||||
Title: req.Title,
|
||||
URL: req.URL,
|
||||
Category: req.Category,
|
||||
Tags: req.Tags,
|
||||
Img: req.Img,
|
||||
Source: req.Source,
|
||||
Extra: req.Extra,
|
||||
IP: req.IP,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
URL: req.URL,
|
||||
Category: req.Category,
|
||||
Tags: req.Tags,
|
||||
Img: req.Img,
|
||||
Source: req.Source,
|
||||
Extra: req.Extra,
|
||||
IP: req.IP,
|
||||
}
|
||||
|
||||
err := repoManager.ReadyResourceRepository.Create(resource)
|
||||
@@ -88,14 +89,15 @@ func BatchCreateReadyResources(c *gin.Context) {
|
||||
var resources []entity.ReadyResource
|
||||
for _, reqResource := range req.Resources {
|
||||
resource := entity.ReadyResource{
|
||||
Title: reqResource.Title,
|
||||
URL: reqResource.URL,
|
||||
Category: reqResource.Category,
|
||||
Tags: reqResource.Tags,
|
||||
Img: reqResource.Img,
|
||||
Source: reqResource.Source,
|
||||
Extra: reqResource.Extra,
|
||||
IP: reqResource.IP,
|
||||
Title: reqResource.Title,
|
||||
Description: reqResource.Description,
|
||||
URL: reqResource.URL,
|
||||
Category: reqResource.Category,
|
||||
Tags: reqResource.Tags,
|
||||
Img: reqResource.Img,
|
||||
Source: reqResource.Source,
|
||||
Extra: reqResource.Extra,
|
||||
IP: reqResource.IP,
|
||||
}
|
||||
resources = append(resources, resource)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,19 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 描述 -->
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||
描述 <span class="text-gray-400 text-xs">(可选)</span>
|
||||
</label>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="3"
|
||||
class="input-field dark:bg-gray-900 dark:text-gray-100 dark:border-gray-700"
|
||||
placeholder="输入资源描述,如:剧情简介、文件大小、清晰度等"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- URL -->
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||
@@ -132,6 +145,7 @@ const newTag = ref('')
|
||||
// 根据 ready_resource 表字段定义表单
|
||||
const form = ref({
|
||||
title: '',
|
||||
description: '',
|
||||
url: '',
|
||||
category: '',
|
||||
tags: [] as string[],
|
||||
@@ -176,6 +190,7 @@ const validateForm = () => {
|
||||
const clearForm = () => {
|
||||
form.value = {
|
||||
title: '',
|
||||
description: '',
|
||||
url: '',
|
||||
category: '',
|
||||
tags: [],
|
||||
@@ -199,6 +214,7 @@ const handleSubmit = async () => {
|
||||
for (const url of urls) {
|
||||
const resourceData = {
|
||||
title: form.value.title || undefined, // 如果为空则传undefined
|
||||
description: form.value.description || undefined, // 添加描述
|
||||
url: url,
|
||||
category: form.value.category || '',
|
||||
tags: form.value.tags.join(','), // 转换为逗号分隔的字符串
|
||||
|
||||
Reference in New Issue
Block a user