package com.sonic.frog.domain.entity;

import java.time.LocalDateTime;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;

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

/**
 * XXX: 实体声明的时候，必须保留@NoArgsConstructor注解，否则mybatisPlus在反序列化实体的时候会报错
 * mybatis-plus文档: https://mybatis.plus/guide/
 * @author code
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "demo", autoResultMap = true)
public class Demo {

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField
    private String name;

    @TableField
    private Status status;

    @TableField(typeHandler = FastjsonTypeHandler.class)
    private JSONObject ext;

    @TableField
    private LocalDateTime createdAt;

    @TableField
    private LocalDateTime updatedAt;

    public enum Status {
        /** 状态 */
        ENABLED,
        DISABLED,
        ;
    }
}
