Skip to main content

资源模块

Project description

模块介绍

1.资源上传

1.文件上传

2.图片上传

SQL

CREATE TABLE `resource_file` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '保存路径',
  `filename` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '文件名称',
  `format` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `thumb` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '缩略图位置',
  `md5` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `snapshot` json DEFAULT NULL COMMENT '文件快照',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='文件上传表';


CREATE TABLE `resource_file_map` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `file_id` int(11) NOT NULL COMMENT '图片ID',
  `source_id` int(11) NOT NULL COMMENT '来源表 关联ID',
  `source_table` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '来源表表明',
  `price` int(10) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `image_id` (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE `resource_image` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '保存路径',
  `filename` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '文件名称',
  `format` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '文件后缀',
  `thumb` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '缩略图位置',
  `md5` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `snapshot` json DEFAULT NULL COMMENT '文件快照',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='文件上传表';

CREATE TABLE `resource_image_map` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `image_id` int(11) NOT NULL COMMENT '图片ID',
  `source_id` int(11) NOT NULL COMMENT '来源表 关联ID',
  `source_table` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '来源表表明',
  `price` int(10) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `image_id` (`image_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

配置

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

xj-resource

依赖

配置

  • settings.py
STATIC_URL = '/static/'  # 配置浏览器访问静态资源的“根路径”

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
STATIC_ROOT = os.path.join(BASE_DIR, "static")  # 不要和 STATICFILES_DIRS 相同,会冲突的 部署django项目需要用到STATIC_ROOT
# 注意:STATIC_ROOT 和 STATICFILES_DIRS 不是同一个东西,只有在这里才是真的 /static/

# 公共的静态文件的文件夹

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "resource"),
    # os.path.join(BASE_DIR, "media")
    # os.path.join(BASE_DIR, "static")

]

====================

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xj_resource-1.2.17.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

xj_resource-1.2.17-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file xj_resource-1.2.17.tar.gz.

File metadata

  • Download URL: xj_resource-1.2.17.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.5

File hashes

Hashes for xj_resource-1.2.17.tar.gz
Algorithm Hash digest
SHA256 f7122f4b01b59ae43979e6b3c2932837befc31ad421e4a99eced719e74f799c3
MD5 b15486ff99e8732c6f1fe6dd72ae3cf5
BLAKE2b-256 a4c623cdb7adead86dea3429e6bc1746615cdf19af9ed40f52da7b7346b88a61

See more details on using hashes here.

File details

Details for the file xj_resource-1.2.17-py3-none-any.whl.

File metadata

File hashes

Hashes for xj_resource-1.2.17-py3-none-any.whl
Algorithm Hash digest
SHA256 cd2b3a3bd480906bf6ac52a7ef62c3120c43a2086d0711a705804ddc7f9c1712
MD5 1ca4b0d014cdaaa276b0712a728edd47
BLAKE2b-256 abe5f8bb69d14a494e434c59c9dd3d9a7a05c13f27c4f67df92313b0f67155cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page