package com.bocloud.ims.entity.resource;

import com.bocloud.common.utils.DateDeserializer;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.*;
import com.bocloud.entity.bean.Generic;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

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

@Data
@Table("lb_listener_policy")
public class LbListenerPolicy extends Generic {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID

	@Column("name")
	private String name;

	@Column("remark")
	private String remark;

	@Column("policy_uuid")
	private String policyUuid;

	@Column("action")
	private String action;

	@Column("provisioning_status")
	private String provisioningStatus;

	@Column("tenant_uuid")
	private String tenantUuid;

	@Column("admin_state_up")
	private Boolean adminStateUp;

	@Column("listener_id")
	private Long listenerId;

	@Column("listener_uuid")
	private String listenerUuid;

	@Column("redirect_pool_id")
	private Long redirectPoolId;

	@Column("redirect_pool_uuid")
	private String redirectPoolUuid;

	@Column("redirect_listener_id")
	private Long redirectListenerId;

	@Column("redirect_listener_uuid")
	private String redirectListenerUuid;

	@Column("redirect_url")
	private String redirectUrl;

	@Column("position")
	private Integer position;

	@Column("rule_uuids")
	private String ruleUuids;

	@Column("vendor_id")
	private Long vendorId;

	@Column("region_id")
	private String regionId;// 所属域

	@IgnoreUpdate
	@Column(value = "gmt_create", nullable = false)
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtCreate;
	@Column("gmt_modify")
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtModify;
	@IgnoreUpdate
	@Column("creator_id")
	private Long creatorId;
	@Column("owner_id")
	private Long ownerId;
	@Column("mender_id")
	private Long menderId;
	@Column("is_deleted")
	private Boolean deleted;

	@IgnoreAll
	private List<LbListenerRule> rules;
	@IgnoreAll
	private String redirectListenerName;
	@IgnoreAll
	private String redirectPoolName;
}
