package cn.estsh.i3plus.pojo.model.form;

import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.form.bean.BfDataObject;
import cn.estsh.i3plus.pojo.form.bean.BfDataObjectProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @Description :
 * @Reference :
 * @Author : Adair Peng
 * @CreateDate : 2019-06-06 15:40
 * @Modify:
 **/
@Data
public class CloudFormModel implements Serializable {

    private static final long serialVersionUID = -4880909594223592633L;
    private BfDataObject dataObject;

    // 数据源编码
    private String sourceCode;      //任何操作必填 必须真实
    // 数据对象编码
    private String dataObjectCode; // 任何操作必填 必须真实

    // 单条插入
    private Map<String, Object> insert;

    // 单条修改
    private Map<String, Object> update;

    // 新增数据
    private List<Map<String, Object>> insertList;

    // 修改条件
//    private List<BfDataObjectProperty> updateConditionList;
    // 修改数据
    private List<Map<String, Object>> updateList;

    // 查询数据
    private List<BfDataObjectProperty> selectList;

    // 删除数据
    private List<Map<String, Object>> deleteList;

    private Map<String, Object> delete;

    public String orderByParam;

    public Integer ascOrDesc = 1;

    public String orderBy() {
        String result = "";
        if (orderByParam != null && orderByParam.trim().length() > 0) {
            result = " order by " + orderByParam;
            if (ascOrDesc == CommonEnumUtil.ASC_OR_DESC.ASC.getValue()) {
                result += " asc";
            } else {
                result += " desc";
            }
        }
        return result;
    }

}
