package com.bonait.bnframework.HttpModel;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.bonait.bnframework.HBL.Result.OperateResultT;

import java.util.List;

public class GoodsTechnologyActionList {
    /**
     * 步骤名称
     */
    public String stepName;

    /**
     * 工艺步骤值
     */
    public String actionJson;

    /**
     * 商品属性ID
     */
    public String goodsAttributeId;

    /**
     * 是否批量
     */
    public boolean isBatch;

    public String chnologyId;

    /**
     * 分组ID
     */
    public String groupId;

    /**
     * 排序
     */
    public int sort;

    /**
     * 商品ID
     */
    public String goodsId;

    /**
     * 设备ID
     */
    public String deviceId;

    /**
     * 模板ID
     */
    public String warehousrTemplateId;

    /**
     * 获取工艺信息
     * @return
     */
    public OperateResultT<List<FuncModel>> GetFuncModel(){
        if(actionJson == null || actionJson.isEmpty())return OperateResultT.CreateFailed("工艺步骤值为空");
        try{
            List<FuncModel> res = JSON.parseObject(actionJson,new TypeReference<List<FuncModel>>(){});
            if(res!=null) return OperateResultT.CreateSuccess(res);
            else return OperateResultT.CreateFailed("工艺步骤值解析失败");
        }catch(Exception e){
            return OperateResultT.CreateFailed(e.getMessage());
        }
    }

}
