package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.List;

/**
 * @author zwhui
 * @date 2023/10/12 14:58
 */
@Getter
@Setter
@SearchBean(tables = "information i",where = "i.deleted is true :ct:")
public class InformationView {
    @DbField("i.id")
    private Long id;

    /**
     * 文章标题
     */
    @DbField("i.title")
    private String title;

    /**
     * 文章标题
     */
    @DbField("i.sub_title")
    private String subTitle;


    /**
     * 文章标题
     */
    @DbField("i.logo")
    private String logo;

    @DbField("i.is_black_font")
    private Boolean isBlackFont;

    /**
     * 缩略图
     */
    @DbField("i.thumbnail")
    private String thumbnail;

    /**
     * 文章类型
     */
    @DbField("i.category_ids")
    private String categoryIds;

    /**
     * 文章类型名
     */
    @DbIgnore
    private List<String> categoryNames;

    /**
     * 内容
     */
    @DbField("i.content")
    private String content;

    /**
     * true 上架 || false 下架
     */
    @DbField("i.status")
    private Boolean status;

    /**
     * true 推荐 || false
     */
    @DbField("i.recommend")
    private Boolean recommend;

    /**
     * true 置顶 || false
     */
    @DbField("i.top")
    private Boolean top;

    @DbField("i.sorted")
    private Integer sorted;

    /**
     * 推荐商品id
     */
    @DbField("i.goods_ids")
    private String goodsIds;

    @DbField("i.created_time")
    private Date createdTime;

    /**
     * 推荐商品名
     */
    @DbIgnore
    private List<String> goodsTitles;

    /**
     * 点击数
     */
    @DbField("select count(*) from information_click_user_record ir where ir.info_id = i.id and ir.goods_id is not null")
    private Integer click;

    /**
     * 下单数
     */
    @DbField("select count(*) from information_click_user_record ir left join order_don o on o.id = ir.order_id where ir.info_id = i.id and o.status not in ('close','noPayment','refund')")
    private Integer orderNum;

    /**
     * 浏览量
     */
    @DbField("select count(*) from information_click_user_record ir where ir.info_id = i.id and ir.goods_id is null and ir.order_id is null")
    private Integer visit;
}
