-- 更新书籍封面示例SQL脚本
-- 使用方法：根据实际情况修改URL和书籍ID，然后执行

-- ============================================
-- 方法1: 根据content_id更新
-- ============================================
-- 更新ID为1的书籍封面
UPDATE `content` 
SET `cover_url` = 'https://img3.doubanio.com/view/subject/l/public/s1070959.jpg' 
WHERE `content_id` = 1;

-- ============================================
-- 方法2: 根据书名更新
-- ============================================
-- 更新"活着"这本书的封面
UPDATE `content` 
SET `cover_url` = 'https://img3.doubanio.com/view/subject/l/public/s1070959.jpg' 
WHERE `title` = '活着';

-- ============================================
-- 方法3: 使用本地图片（小程序内）
-- ============================================
-- 如果图片放在 xiao/images/covers/ 目录下
UPDATE `content` 
SET `cover_url` = '/images/covers/huozhe.jpg' 
WHERE `content_id` = 1;

-- ============================================
-- 方法4: 批量更新多个书籍
-- ============================================
UPDATE `content` 
SET `cover_url` = CASE 
    WHEN `content_id` = 1 THEN 'https://example.com/covers/book1.jpg'
    WHEN `content_id` = 2 THEN 'https://example.com/covers/book2.jpg'
    WHEN `content_id` = 3 THEN 'https://example.com/covers/book3.jpg'
    ELSE `cover_url`
END
WHERE `content_id` IN (1, 2, 3);

-- ============================================
-- 方法5: 批量设置默认封面（如果为空）
-- ============================================
UPDATE `content` 
SET `cover_url` = 'https://example.com/default-cover.jpg' 
WHERE `cover_url` IS NULL OR `cover_url` = '';

-- ============================================
-- 查询当前封面状态
-- ============================================
-- 查看所有书籍的封面URL
SELECT `content_id`, `title`, `cover_url` FROM `content`;

-- 查看没有封面的书籍
SELECT `content_id`, `title` FROM `content` 
WHERE `cover_url` IS NULL OR `cover_url` = '';

-- 查看特定书籍的封面
SELECT `content_id`, `title`, `cover_url` FROM `content` 
WHERE `content_id` = 1;

-- ============================================
-- 常用书籍封面URL示例（豆瓣）
-- ============================================
-- 活着 - 余华
-- UPDATE `content` SET `cover_url` = 'https://img3.doubanio.com/view/subject/l/public/s1070959.jpg' WHERE `title` = '活着';

-- 注意：实际使用时，请替换为真实的图片URL






