package com.goafanti.common.model;

import java.util.Date;

import org.apache.commons.lang3.time.DateFormatUtils;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.goafanti.common.constant.AFTConstants;
import com.goafanti.common.enums.ActivityStatus;
import com.fasterxml.jackson.annotation.JsonIgnore;

public class Activity {
	private Long	id;

	/**
	 * 开始时间
	 */
	private Date	startTime;

	/**
	 * 结束时间
	 */
	private Date	endTime;

	/**
	 * 标题
	 */
	private String	name;

	/**
	 * 状态
	 */
	private Integer	status;

	/**
	 * 活动地址
	 */
	private String	address;

	/**
	 * 主办单位
	 */
	private String	host;

	/**
	 * 承办单位
	 */
	private String	undertake;

	/**
	 * 协办单位，逗号隔开
	 */
	private String	asist;

	/**
	 * 活动类型
	 */
	private Integer	type;

	/**
	 * 活动形式
	 */
	private Integer	form;

	/**
	 * 活动图片地址
	 */
	private String	imgUrls;

	/**
	 * 活动结果描述
	 */
	private String	result;

	/**
	 * 创建时间(报名开始时间)
	 */
	private Date	createTime;

	/**
	 * 报名截止时间
	 */
	private Date	enrollDeadline;

	/**
	 * 题图地址
	 */
	private String	titleUrl;

	/**
	 * 描述
	 */
	private String	summary;
	
	@JsonFormat(shape = Shape.STRING)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public String getUndertake() {
		return undertake;
	}

	public void setUndertake(String undertake) {
		this.undertake = undertake;
	}

	public String getAsist() {
		return asist;
	}

	public void setAsist(String asist) {
		this.asist = asist;
	}

	@JsonFormat(shape = Shape.STRING)
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@JsonFormat(shape = Shape.STRING)
	public Integer getForm() {
		return form;
	}

	public void setForm(Integer form) {
		this.form = form;
	}

	public String getImgUrls() {
		return imgUrls;
	}

	public void setImgUrls(String imgUrls) {
		this.imgUrls = imgUrls;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	@JsonIgnore
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getEnrollDeadline() {
		return enrollDeadline;
	}

	public void setEnrollDeadline(Date enrollDeadline) {
		this.enrollDeadline = enrollDeadline;
	}

	public String getTitleUrl() {
		return titleUrl;
	}

	public void setTitleUrl(String titleUrl) {
		this.titleUrl = titleUrl;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getStartTimeFormattedDate() {
		if (this.startTime == null) {
			return null;
		} else {
			return DateFormatUtils.format(this.startTime, AFTConstants.YYYYMMDDHHMMSS);
		}
	}

	public void setStartTimeFormattedDate(String startTimeFormattedDate) {

	}

	public String getEndTimeFormattedDate() {
		if (this.endTime == null) {
			return null;
		} else {
			return DateFormatUtils.format(this.endTime, AFTConstants.YYYYMMDDHHMMSS);
		}
	}

	public void setEndTimeFormattedDate(String endTimeFormattedDate) {

	}

	public String getEnrollDeadlineFormattedDate() {
		if (this.enrollDeadline == null) {
			return null;
		} else {
			return DateFormatUtils.format(this.enrollDeadline, AFTConstants.YYYYMMDDHHMMSS);
		}
	}

	public void setEnrollDeadlineFormattedDate(String enrollDeadlineFormattedDate) {

	}
	
	public Integer getActivityStatus(){
		if (this.enrollDeadline == null){
			return ActivityStatus.ENROLL.getCode();
		} 
		if (new Date().getTime() > this.enrollDeadline.getTime()){
			return ActivityStatus.CLOSED.getCode();
		}
		return ActivityStatus.ENROLL.getCode();
	}
	
	public void setActivityStatus(Integer activityStatus){
		
	}
}