package com.gxwebsoft.cms.entity;

import cn.hutool.core.util.DesensitizedUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.gxwebsoft.common.core.utils.JSONUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 广告位
 *
 * @author 科技小王子
 * @since 2024-09-10 20:47:57
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "CmsAd对象", description = "广告位")
public class CmsAd implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "ID")
    @TableId(value = "ad_id", type = IdType.AUTO)
    private Integer adId;

    @Schema(description = "类型")
    private Integer type;

    @Schema(description = "唯一标识")
    private String code;

    @Schema(description = "栏目ID")
    private Integer categoryId;

    @Schema(description = "栏目名称")
    @TableField(exist = false)
    private String categoryName;

    @Schema(description = "广告位名称")
    private String name;

    @Schema(description = "宽")
    private String width;

    @Schema(description = "高")
    private String height;

    @Schema(description = "边框")
    private String border;

    @Schema(description = "CSS样式")
    private String style;

    @Schema(description = "广告图片")
    private String images;

    @Schema(description = "广告图片")
    @TableField(exist = false)
    private JSONArray imageList;

    @Schema(description = "路由/链接地址")
    private String path;

    @Schema(description = "用户ID")
    private Integer userId;

    @Schema(description = "国际化语言")
    private String lang;

    @Schema(description = "排序(数字越小越靠前)")
    private Integer sortNumber;

    @Schema(description = "备注")
    private String comments;

    @Schema(description = "状态, 0正常, 1冻结")
    private Integer status;

    @Schema(description = "是否删除, 0否, 1是")
    @TableLogic
    private Integer deleted;

    @Schema(description = "租户id")
    private Integer tenantId;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    public JSONArray getImageList() {
      return JSON.parseArray(this.images);
    }
}
