package com.boman.domain.dto;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;

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

/**
 * @author:zc
 * @since:2018/12/27
 * @createat:2018/12/274:41 PM
 */
public class FormDataDto implements Serializable {

    private static final long serialVersionUID = -8653990707913725671L;
    @JSONField(name = "objId")
    private Long objId;

    @JSONField(name = "fixedData")
    private JSONObject fixedData;

    @JSONField(name = "table")
    private String table;

    /**
     * 逻辑删除，数据库对应的属性名称
     */
    @JSONField(name = "logicDelName")
    private String logicDelName;

    /**
     * 逻辑删除，数据库对应的属性值
     */
    @JSONField(name = "logicDelValue")
    private String logicDelValue;

    /**
     * 删除时，前台传过来需要删除的idList
     */
    @JSONField(name = "idList")
    private List<Long> idList;

    /**
     * 批量提交时，提交到后台的数据
     */
    @JSONField(name = "commitData")
    private List<JSONObject> commitData;

    /**
     * orderBy eg: order_by columnName desc
     */
    @JSONField(name = "orderBy")
    private String orderBy;

    /**
     * 分页
     */
    @JSONField(name = "pageNo")
    private Integer pageNo;

    /**
     * 分页
     */
    @JSONField(name = "pageSize")
    private Integer pageSize;

    /**
     * 状态
     */
    @JSONField(name = "status")
    private String status;

    /**
     * username
     */
    private String username;

    /**
     * 跳转新增或者编辑页面显示的类型带不带折叠，如果isUi=true, 带折叠
     */
    @JSONField(name = "isUi")
    private Boolean isUi;

    /**
     * 表单类型
     */
    private String other;

    /**
     * 提交来源
     * @return
     */
    private String submitSource;


    public int getLimit() {
        try {
            return pageNo == 0 ? 0 : (pageNo - 1) * pageSize;
        } catch (Exception e) {
            e.printStackTrace();
            return 1;
        }
    }

    public int getOffset(){
        try {
            return pageSize == 0 ? 10 : pageSize;
        } catch (Exception e) {
            e.printStackTrace();
            return 10;
        }
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getObjId() {
        return objId;
    }

    public void setObjId(Long objId) {
        this.objId = objId;
    }

    public JSONObject getFixedData() {
        return fixedData;
    }

    public void setFixedData(JSONObject fixedData) {
        this.fixedData = fixedData;
    }

    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    public String getLogicDelName() {
        return logicDelName;
    }

    public void setLogicDelName(String logicDelName) {
        this.logicDelName = logicDelName;
    }

    public String getLogicDelValue() {
        return logicDelValue;
    }

    public void setLogicDelValue(String logicDelValue) {
        this.logicDelValue = logicDelValue;
    }

    public List<Long> getIdList() {
        return idList;
    }

    public void setIdList(List<Long> idList) {
        this.idList = idList;
    }

    public List<JSONObject> getCommitData() {
        return commitData;
    }

    public void setCommitData(List<JSONObject> commitData) {
        this.commitData = commitData;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Boolean getIsUi() {
        return isUi;
    }

    public void setIsUi(Boolean ui) {
        isUi = ui;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getOther() {
        return other;
    }

    public void setOther(String other) {
        this.other = other;
    }

    public String getSubmitSource() {
        return submitSource;
    }

    public void setSubmitSource(String submitSource) {
        this.submitSource = submitSource;
    }
}


