package thyyxxk.webserver.entity.ca;

import java.io.Serializable;
import java.util.Date;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "ca_sign_redis")
public class CaSignRedis implements Serializable {

    private static final long serialVersionUID = 5993045632606048143L;

    /**
     * key
     */
    @TableId(type = IdType.NONE)
    private String id;

    /**
     * 值
     */
    @TableField(value = "value")
    private String value;

    @TableField(value = "create_time")
    private Date createTime;

    public static LambdaQueryWrapper<CaSignRedis> lambdaQueryWrapper() {
        return new LambdaQueryWrapper<>();
    }

    public static QueryWrapper<CaSignRedis> queryWrapper() {
        return new QueryWrapper<>();
    }

    public <T> T getCaRedisValue(Class<T> clazz) {
        if (value == null) {
            return null;
        }
        return JSONUtil.toBean(value, clazz);
    }

    public static <T> T getCaRedisValue(CaSignRedis caRedis, Class<T> clazz) {
        if (caRedis == null) {
            return null;
        }

        return caRedis.getCaRedisValue(clazz);
    }

}
