package com.czg.account.entity;

import cn.hutool.core.util.StrUtil;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;

import java.io.Serial;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 店铺扩展信息 实体类。
 *
 * @author zs
 * @since 2025-02-19
 */
@Data

@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_extend")
public class ShopExtend implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 自增id
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 商户Id
     */
    private Long shopId;

    /**
     * img:图片；text:文本；
     */
    private String type;

    /**
     * 描述
     */
    private String name;

    /**
     * 自定义key
     */
    private String autoKey;

    /**
     * 值
     */
    private String value;

    /**
     * 更新时间
     */
    @Column(onInsertValue = "now()", onUpdateValue = "now()")
    private LocalDateTime updateTime;

    /**
     * 创建时间
     */
    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;

    private String detail;
    /**
     * index_bg：店铺首页背景图
     * my_bg：  我的页面背景图
     * member_bg：会员卡页面背景图
     * shopinfo_bg：商品列表顶部背景图
     */
    public void initAutoKey(String autokey,long shopId) {
        if (StrUtil.isBlank(name)) {
            switch (autokey) {
                case "index_bg":
                    this.name = "首页";
                    this.detail="建议尺寸: 375*600 ";
                    this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png";
                    break;
                case "my_bg":
                    this.name = "个人中心";
                    this.detail="建议尺寸: 375*200";
                    this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png";
                    break;
                case "member_bg":
                    this.name = "会员卡";
                    this.detail="建议尺寸: 315*152";
                    this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/member_bg.png";
                    break;
                case "shopinfo_bg":
                    this.name = "商品列表";
                    this.detail="建议尺寸: 375*120";
                    this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png";
                    break;
                case "ticket_logo":
                    this.name = "标签打印logo";
                    this.detail="建议尺寸: 417*139";
                    this.value = "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20241022/eeee8e85c66947e5bcaebf687381b5d6.png";
                    break;
            }
        }
        this.type="img";
        this.shopId=shopId;
        this.autoKey = autokey;
    }
}
