#!/usr/bin/env python
"""预置各俱乐部小程序图标配置（仅写 DB 路径，不上传文件）。"""
import os
import sys
import django

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, BASE_DIR)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
django.setup()

from jituan.models import Club
from jituan.services.miniapp_assets import seed_miniapp_icons_for_club


def main():
    clubs = Club.query.filter(status=1).values_list('club_id', flat=True)
    club_ids = list(clubs) or ['xq', 'xzj']
    total = 0
    for cid in club_ids:
        n = seed_miniapp_icons_for_club(cid, overwrite=False)
        total += n
        print(f'俱乐部 {cid}: 新增 {n} 条图标配置')
    print(f'完成，共新增 {total} 条')


if __name__ == '__main__':
    main()
