package com.fjhx.service.flow;

import com.fjhx.entity.material.Material;
import com.fjhx.params.JumpVo;
import com.fjhx.service.material.MaterialService;
import com.fjhx.utils.ExampleAbstract;
import com.fjhx.utils.FlowConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 物料修改审批
 */
@Service
public class MaterialUpdateFlowService {

    @Autowired
    private MaterialService materialService;

    private final FlowConstructor flowConstructor = FlowConstructor.init(new ExampleAbstract() {

        @Override
        public String getCode() {
            return "js_materialCode";
        }

        @Override
        public void end() {
            Material material = getCacheData(Material.class);
            materialService.updateById(material);
        }

    });

    @Transactional(rollbackFor = Exception.class)
    public void create(Material material) {
        flowConstructor.create(material.getId(), "物料修改", null, material);
    }

    @Transactional(rollbackFor = Exception.class)
    public void jump(JumpVo jumpVo) {
        flowConstructor.jump(jumpVo);
    }

}
