package com.gxwebsoft.cms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;

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 = "CmsArticle对象", description = "文章")
public class CmsArticle implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "文章ID")
    @TableId(value = "article_id", type = IdType.AUTO)
    private Integer articleId;

    @Schema(description = "文章标题")
    private String title;

    @Schema(description = "文章类型 0常规 1视频")
    private Integer type;

    @Schema(description = "文章模型")
    private String model;

    @Schema(description = "文章编号")
    private String code;

    @Schema(description = "内容模板页面")
    private String detail;

    @Schema(description = "banner")
    @TableField(exist = false)
    private String banner;

    @Schema(description = "访问路径")
    @TableField(exist = false)
    private String path;

    @Schema(description = "列表显示方式(10小图展示 20大图展示)")
    private Integer showType;

    @Schema(description = "话题")
    private String topic;

    @Schema(description = "标签")
    private String tags;

    @Schema(description = "文章分类ID")
    private Integer categoryId;

    @Schema(description = "当前分类")
    @TableField(exist = false)
    private String categoryName;

    @Schema(description = "父级分类ID")
    private Integer parentId;

    @Schema(description = "父级分类")
    @TableField(exist = false)
    private String parentName;

    @Schema(description = "封面图")
    private String image;

    @Schema(description = "封面图宽度")
    private Integer imageWidth;

    @Schema(description = "封面图高度")
    private Integer imageHeight;

    @Schema(description = "价格")
    private BigDecimal price;

    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @Schema(description = "到期时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    @Schema(description = "来源")
    private String source;

    @Schema(description = "产品概述")
    private String overview;

    @Schema(description = "虚拟阅读量(仅用作展示)")
    private Integer virtualViews;

    @Schema(description = "实际阅读量")
    private Integer actualViews;

    @Schema(description = "评分")
    private BigDecimal rate;

    @Schema(description = "可见类型 0所有人 1登录可见 2密码可见")
    private Integer permission;

    @Schema(description = "访问密码")
    private String password;

    @Schema(description = "验证密码(前端回传)")
    @TableField(exist = false)
    private String password2;

    @Schema(description = "发布来源客户端 (APP、H5、小程序等)")
    private String platform;

    @Schema(description = "文章附件")
    private String files;

    @Schema(description = "视频地址")
    private String video;

    @Schema(description = "接受的文件类型")
    private String accept;

    @Schema(description = "经度")
    private String longitude;

    @Schema(description = "纬度")
    private String latitude;

    @Schema(description = "所在省份")
    private String province;

    @Schema(description = "所在城市")
    private String city;

    @Schema(description = "所在辖区")
    private String region;

    @Schema(description = "街道地址")
    private String address;

    @Schema(description = "点赞数")
    private Integer likes;

    @Schema(description = "评论数")
    private Integer commentNumbers;

    @Schema(description = "提醒谁看")
    private String toUsers;

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

    @Schema(description = "作者")
    private String author;

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

    @Schema(description = "关联默认语言的文章ID,用于同步翻译更新")
    private Integer langArticleId;

    @Schema(description = "是否启用自动翻译")
    private Boolean translation;

    @Schema(description = "编辑器类型 1 富文本编辑器 2 Markdown编辑器")
    private Integer editor;

    @Schema(description = "PDF地址")
    private String pdfUrl;

    @Schema(description = "版本号")
    private Integer version;

    @Schema(description = "商户ID")
    private Long merchantId;

    @Schema(description = "项目ID")
    private Long projectId;

    @Schema(description = "商户名称")
    @TableField(exist = false)
    private String merchantName;

    @Schema(description = "商户名称")
    @TableField(exist = false)
    private String merchantAvatar;

    @Schema(description = "昵称")
    @TableField(exist = false)
    private String nickname;

    @Schema(description = "头像")
    @TableField(exist = false)
    private String avatar;

    @Schema(description = "是否推荐")
    private Integer recommend;

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

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

    @Schema(description = "状态, 0已发布, 1待审核 2已驳回 3违规内容")
    private Integer status;

    @Schema(description = "状态文本")
    @TableField(exist = false)
    private String statusText;

    @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;

    @Schema(description = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "是否更新")
    @TableField(exist = false)
    private Boolean isUpdate;

    @Schema(description = "文章内容")
    @TableField(exist = false)
    private String content;

    @Schema(description = "已报名人数")
    private Integer bmUsers;

    public String getStatusText() {
      if (this.status == 0) {
        return "已发布";
      }
      if (this.status == 1) {
        return "待审核";
      }
      if (this.status == 2) {
        return "已驳回";
      }
      if (this.status == 3) {
        return "违规内容";
      }
      return "";
    }
}
