package cn.superdesk.uniorder.pattern.state.invoice.supplier.invoiceApplySupplier.mailTickStatus.context;

import cn.superdesk.uniorder.common.enums.invoice.supplier.InvoiceApplySupplierMailTickStatusEnum;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.supplier.InvoiceApplySupplier;
import cn.superdesk.uniorder.pattern.state.invoice.supplier.invoiceApplySupplier.mailTickStatus.state.InvoiceApplySupplierFieldMailTickStatusState;
import cn.superdesk.uniorder.pattern.state.invoice.supplier.invoiceApplySupplier.mailTickStatus.state.concrete.InvoiceApplySupplierFieldMailTickStatusConcreteState_0_未邮寄;
import cn.superdesk.uniorder.pattern.state.invoice.supplier.invoiceApplySupplier.mailTickStatus.state.concrete.InvoiceApplySupplierFieldMailTickStatusConcreteState_1_已邮寄;
import lombok.Data;

/**
 * @Description: 简易状态机 星型结构
 * @Author: linjinyu
 * @CreateDate: 10/12/20 4:28 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/12/20 4:28 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Data
public class InvoiceApplySupplierFieldMailTickStatusContext {

	private InvoiceApplySupplierFieldMailTickStatusState state_0_未邮寄;
	private InvoiceApplySupplierFieldMailTickStatusState state_1_已邮寄;

	private InvoiceApplySupplierFieldMailTickStatusState state;

	private InvoiceApplySupplier entity;

	private LoginSysUser loginSysUser;


	public InvoiceApplySupplierFieldMailTickStatusContext(InvoiceApplySupplier entity, LoginSysUser loginSysUser) {

		this.state_0_未邮寄 = new InvoiceApplySupplierFieldMailTickStatusConcreteState_0_未邮寄(this);
		this.state_1_已邮寄 = new InvoiceApplySupplierFieldMailTickStatusConcreteState_1_已邮寄(this);


		this.entity = entity;
		this.loginSysUser = loginSysUser;

		switch (InvoiceApplySupplierMailTickStatusEnum.get(this.entity.getMailTickStatus())) {

			case 未邮寄:
				state = state_0_未邮寄;
				break;
			case 已邮寄:
				state = state_1_已邮寄;
				break;

			default:
//				state = state_0_未邮寄;
				break;

		}
	}

	// 未邮寄(0, "未邮寄"),
	public void opInit() {
		state.opInit();
	}
	// 已邮寄(1, "已邮寄"),
	public void opComplete() {
		state.opComplete();
	}


	@Override
	public String toString() {
		return "状态 :" + getState().getClass().getName();
	}
}