package org.onetwo.ext.ons.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.onetwo.dbm.jpa.BaseEntity;
import org.onetwo.dbm.mapping.DbmEnumValueMapping;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 消息消费记录表
 * @author wayshall
 * <br/>
 */
@SuppressWarnings("serial")
@Entity
@Table(name="data_mq_receive")
@Data
@EqualsAndHashCode(callSuper=true)
public class ReceiveMessageEntity extends BaseEntity {
	
	/***
	 * 自动生成id，消费端不能用msgkey作为唯一键，因为rmq不同的消费组可以接受同一个消息
	 */
//    @GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflake")
//    @DbmIdGenerator(name = "snowflake", generatorClass = SnowflakeGenerator.class)
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY) 
	Long id;
	private String msgkey;
	@Column(name="raw_msgid")
	private String rawMsgid;
	private String consumeGroup;
	@Enumerated(EnumType.ORDINAL)
	private ConsumeStates state;
	
	@AllArgsConstructor
	public static enum ConsumeStates implements DbmEnumValueMapping {
		/***
		 * 已消费
		 */
		CONSUMED(1);
		
		final private int value;
		@Override
		public int getMappingValue() {
			return value;
		}
	}

}

@@ -311,16 +311,110 @@
 Table;%0A%0A
+import org.onetwo.dbm.annotation.DbmIdGenerator;%0Aimport org.onetwo.dbm.id.SnowflakeGenerator;%0A
 import o
@@ -857,18 +857,21 @@
 %E6%B6%88%E6%81%AF%0A%09 */%0A
-//
+%09@Id%0A
     @Gen
@@ -943,10 +943,8 @@
 e%22)%0A
-//
     
@@ -1026,65 +1026,8 @@
 ss)%0A
-%09@Id%0A%09@GeneratedValue(strategy=GenerationType.IDENTITY) %0A
 %09Lon

rollback ReceiveMessageEntity autoid to snowflakeid