chore(电子名片): 增加及优化视频号模型字段

This commit is contained in:
2026-01-10 15:55:13 +08:00
parent 1d5ea6acd7
commit 338b33f52c
5 changed files with 102 additions and 18 deletions

View File

@@ -3,24 +3,29 @@ SET NAMES 'utf8';
-- 创建视频号表
CREATE TABLE IF NOT EXISTS `lucky_personnel_channel`
(
`channel_id` int auto_increment
primary key,
`site_id` int null,
`channel_type` varchar(50) default 'wechat' null comment '视频号类型wechat-微信视频号douyin-抖音kuaishou-快手redbook-小红书bilibili-B站',
`channel_name` varchar(255) null,
`avatar_image_type` varchar(20) default 'upload' null comment '头像类型upload-上传图片url-URL',
`avatar_url` varchar(255) null,
`video_title` varchar(255) null,
`feed_id` varchar(255) null,
`cover_image_type` varchar(20) default 'upload' null comment '封面类型upload-上传图片url-URL',
`cover_url` varchar(255) null,
`sort` int default 0 null comment '排序',
`is_show` tinyint(1) default 1 null comment '是否显示0-隐藏1-显示',
`create_time` int null
)
engine = MyISAM
collate = utf8_unicode_ci
comment = '电子名片视频号资源表';
`channel_id` int unsigned NOT NULL AUTO_INCREMENT,
`site_id` int unsigned NOT NULL DEFAULT 0 COMMENT '站点ID',
`create_time` int unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
`channel_type` varchar(20) NOT NULL DEFAULT 'wechat' COMMENT '视频号类型wechat-微信视频号douyin-抖音kuaishou-快手redbook-小红书bilibili-B站',
`channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号名称',
`feed_id` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号内容ID',
`feed_token` varchar(255) NOT NULL DEFAULT '' COMMENT '视频号视频的标识',
`avatar_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '头像类型upload-上传图片url-URL',
`avatar_url` varchar(500) NOT NULL DEFAULT '' COMMENT '头像URL',
`video_title` varchar(200) NOT NULL DEFAULT '' COMMENT '视频标题',
`cover_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '封面类型upload-上传图片url-URL',
`cover_url` varchar(500) NOT NULL DEFAULT '' COMMENT '封面URL',
`view_count` int unsigned NOT NULL DEFAULT 0 COMMENT '视频观看次数',
`show_view_count` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示视频观看次数0-不显示1-显示',
`show_follow` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示关注按钮0-不显示1-显示',
`is_show` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否显示0-隐藏1-显示',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序,数值越小越靠前',
PRIMARY KEY (`channel_id`),
KEY `idx_site_id` (`site_id`),
KEY `idx_channel_type` (`channel_type`),
KEY `idx_is_show` (`is_show`),
KEY `idx_sort` (`sort`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='电子名片视频号资源表';
-- 插入视频号菜单权限(使用 IGNORE 避免重复插入报错)
INSERT IGNORE INTO `lucky_menu` (`app_module`, `addon`, `title`, `name`, `parent`, `level`, `url`, `is_show`, `sort`, `desc`, `is_icon`, `picture`, `picture_select`, `is_control`)

View File

@@ -0,0 +1,35 @@
-- 升级脚本:为 personnel_channel 表添加新字段并优化表结构
-- 执行时间: 2026-01-10
-- 1. 为 lucky_personnel_channel 表添加新字段
ALTER TABLE `lucky_personnel_channel`
ADD COLUMN `feed_token` varchar(255) NOT NULL DEFAULT '' COMMENT '视频号视频的标识' AFTER `feed_id`,
ADD COLUMN `view_count` int unsigned NOT NULL DEFAULT 0 COMMENT '视频观看次数' AFTER `cover_url`,
ADD COLUMN `show_view_count` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示视频观看次数0-不显示1-显示' AFTER `view_count`,
ADD COLUMN `show_follow` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示关注按钮0-不显示1-显示' AFTER `show_view_count`;
-- 2. 优化现有字段长度和类型
ALTER TABLE `lucky_personnel_channel`
MODIFY COLUMN `channel_type` varchar(20) NOT NULL DEFAULT 'wechat' COMMENT '视频号类型wechat-微信视频号douyin-抖音kuaishou-快手redbook-小红书bilibili-B站',
MODIFY COLUMN `channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号名称',
MODIFY COLUMN `avatar_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '头像类型upload-上传图片url-URL',
MODIFY COLUMN `avatar_url` varchar(500) NOT NULL DEFAULT '' COMMENT '头像URL',
MODIFY COLUMN `video_title` varchar(200) NOT NULL DEFAULT '' COMMENT '视频标题',
MODIFY COLUMN `feed_id` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号内容ID',
MODIFY COLUMN `cover_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '封面类型upload-上传图片url-URL',
MODIFY COLUMN `cover_url` varchar(500) NOT NULL DEFAULT '' COMMENT '封面URL',
MODIFY COLUMN `sort` int NOT NULL DEFAULT 0 COMMENT '排序,数值越小越靠前',
MODIFY COLUMN `is_show` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否显示0-隐藏1-显示',
MODIFY COLUMN `channel_id` int unsigned NOT NULL AUTO_INCREMENT,
MODIFY COLUMN `site_id` int unsigned NOT NULL DEFAULT 0 COMMENT '站点ID',
MODIFY COLUMN `create_time` int unsigned NOT NULL DEFAULT 0 COMMENT '创建时间';
-- 3. 添加索引优化查询性能
ALTER TABLE `lucky_personnel_channel`
ADD INDEX `idx_site_id` (`site_id`),
ADD INDEX `idx_channel_type` (`channel_type`),
ADD INDEX `idx_is_show` (`is_show`),
ADD INDEX `idx_sort` (`sort`);
-- 4. 修改表引擎为 InnoDB 和字符集为 utf8mb4
ALTER TABLE `lucky_personnel_channel` ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@@ -222,6 +222,10 @@ class Enterprise extends BaseShop
'cover_url' => input('cover_url', ''),
'sort' => input('sort', 0),
'is_show' => input('is_show', 1),
'feed_token' => input('feed_token', ''),
'view_count' => input('view_count', 0),
'show_view_count' => input('show_view_count', 0),
'show_follow' => input('show_follow', 0),
'create_time' => time()
];
return $model->addChannel($data);
@@ -251,6 +255,10 @@ class Enterprise extends BaseShop
'cover_url' => input('cover_url', ''),
'sort' => input('sort', 0),
'is_show' => input('is_show', 1),
'feed_token' => input('feed_token', ''),
'view_count' => input('view_count', 0),
'show_view_count' => input('show_view_count', 0),
'show_follow' => input('show_follow', 0),
];
return $model->editChannel($data);
} else {

View File

@@ -123,6 +123,36 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">视频标识:</label>
<div class="layui-input-inline">
<input type="text" name="feed_token" value="{$info.feed_token}" maxlength="255" autocomplete="off" placeholder="请输入视频号视频的标识" class="layui-input len-long">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">观看次数:</label>
<div class="layui-input-inline">
<input type="number" name="view_count" value="{$info.view_count|default=0}" autocomplete="off" placeholder="请输入视频观看次数" class="layui-input len-short">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">显示观看次数:</label>
<div class="layui-input-block">
<input type="radio" name="show_view_count" value="1" title="显示" {$info.show_view_count == 1 ? 'checked' : ''}>
<input type="radio" name="show_view_count" value="0" title="不显示" {$info.show_view_count != 1 ? 'checked' : ''}>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">显示关注按钮:</label>
<div class="layui-input-block">
<input type="radio" name="show_follow" value="1" title="显示" {$info.show_follow == 1 ? 'checked' : ''}>
<input type="radio" name="show_follow" value="0" title="不显示" {$info.show_follow != 1 ? 'checked' : ''}>
</div>
</div>
<div class="form-row" id="save">
<button class="layui-btn" lay-submit lay-filter="save">提交</button>
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>

View File

@@ -146,6 +146,12 @@
width: '5%',
unresize: 'false'
},
{
field: 'view_count',
title: '观看次数',
width: '8%',
unresize: 'false'
},
{
title: '操作',
toolbar: '#operation',