package cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.deleted.context;

import cn.superdesk.uniorder.common.enums.common.CommonSoftDeleteEnum;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoiced;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.deleted.state.InvoiceInvoicedFieldDeletedState;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.deleted.state.concrete.InvoiceInvoicedFieldDeletedConcreteState_0_正常;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.deleted.state.concrete.InvoiceInvoicedFieldDeletedConcreteState_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 InvoiceInvoicedFieldDeletedContext {

	private InvoiceInvoicedFieldDeletedState state_0_正常;
	private InvoiceInvoicedFieldDeletedState state_1_删除;

	private InvoiceInvoicedFieldDeletedState state;

	private InvoiceInvoiced entity;

	private LoginSysUser loginSysUser;


	public InvoiceInvoicedFieldDeletedContext(InvoiceInvoiced entity, LoginSysUser loginSysUser) {

		this.state_0_正常 = new InvoiceInvoicedFieldDeletedConcreteState_0_正常(this);
		this.state_1_删除 = new InvoiceInvoicedFieldDeletedConcreteState_1_删除(this);


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

		switch (CommonSoftDeleteEnum.get(this.entity.getDeleted())) {

			case 正常:
				state = state_0_正常;
				break;
			case 删除:
				state = state_1_删除;
				break;

			default:
//				state = state_3_待提交;
				break;

		}
	}

	// 正常(0, "正常"),
	public void opInit() {
		state.opInit();
	}

	// 删除(1, "删除"),
	public void opDelete() {
		state.opDelete();
	}


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