All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opendynamic.ff.query.DelegateQuery Maven / Gradle / Ivy

package com.opendynamic.ff.query;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.opendynamic.ff.service.FfDelegateService;
import com.opendynamic.ff.vo.Delegate;

@Service
public class DelegateQuery {
    private FfDelegateService ffDelegateService;

    String delegateId;
    private List delegateIdList;
    String assignee;
    private List assigneeList;
    String assigneeName;
    private List assigneeNameList;
    String delegator;
    private List delegatorList;
    String delegatorName;
    private List delegatorNameList;
    Date fromStartDate;
    Date toStartDate;
    Date fromEndDate;
    Date toEndDate;
    private Integer page;
    private Integer limit;

    public DelegateQuery(FfDelegateService ffDelegateService) {
        super();
        this.ffDelegateService = ffDelegateService;
    }

    public DelegateQuery setDelegateId(String delegateId) {
        this.delegateId = delegateId;
        return this;
    }

    public DelegateQuery setDelegateIdList(List delegateIdList) {
        this.delegateIdList = delegateIdList;
        return this;
    }

    public DelegateQuery setAssignee(String assignee) {
        this.assignee = assignee;
        return this;
    }

    public DelegateQuery setAssigneeList(List assigneeList) {
        this.assigneeList = assigneeList;
        return this;
    }

    public DelegateQuery setAssigneeName(String assigneeName) {
        this.assigneeName = assigneeName;
        return this;
    }

    public DelegateQuery setAssigneeNameList(List assigneeNameList) {
        this.assigneeNameList = assigneeNameList;
        return this;
    }

    public DelegateQuery setDelegator(String delegator) {
        this.delegator = delegator;
        return this;
    }

    public DelegateQuery setDelegatorList(List delegatorList) {
        this.delegatorList = delegatorList;
        return this;
    }

    public DelegateQuery setDelegatorName(String delegatorName) {
        this.delegatorName = delegatorName;
        return this;
    }

    public DelegateQuery setDelegatorNameList(List delegatorNameList) {
        this.delegatorNameList = delegatorNameList;
        return this;
    }

    public DelegateQuery setFromStartDate(Date fromStartDate) {
        this.fromStartDate = fromStartDate;
        return this;
    }

    public DelegateQuery setToStartDate(Date toStartDate) {
        this.toStartDate = toStartDate;
        return this;
    }

    public DelegateQuery setFromEndDate(Date fromEndDate) {
        this.fromEndDate = fromEndDate;
        return this;
    }

    public DelegateQuery setToEndDate(Date toEndDate) {
        this.toEndDate = toEndDate;
        return this;
    }

    public DelegateQuery setPage(Integer page) {
        this.page = page;
        return this;
    }

    public DelegateQuery setLimit(Integer limit) {
        this.limit = limit;
        return this;
    }

    /**
     * 查询对象列表。对象格式为Map。
     * 
     * @return
     */
    public List> queryForMapList() {
        return ffDelegateService.selectDelegate(delegateId, delegateIdList, assignee, assigneeList, assigneeName, assigneeNameList, delegator, delegatorList, delegatorName, delegatorNameList, fromStartDate, toStartDate, fromEndDate, toEndDate, page, limit);
    }

    /**
     * 查询单个对象。对象格式为Map。
     * 
     * @return
     */
    public Map queryForMap() {
        List> result = queryForMapList();
        if (result.size() == 1) {
            return result.get(0);
        }
        else {
            return null;
        }
    }

    /**
     * 查询对象列表。对象格式为实体Bean。
     * 
     * @return
     */
    public List queryForObjectList() {
        List> result = queryForMapList();
        List delegateList = new ArrayList<>();
        for (int i = 0; i < result.size(); i++) {
            delegateList.add(new Delegate(result.get(i)));
        }

        return delegateList;
    }

    /**
     * 查询单个对象。对象格式为实体Bean。
     * 
     * @return
     */
    public Delegate queryForObject() {
        List> result = queryForMapList();
        if (result.size() == 1) {
            return new Delegate(result.get(0));
        }
        else {
            return null;
        }
    }

    /**
     * 查询总数。
     * 
     * @return
     */
    public int count() {
        return ffDelegateService.countDelegate(delegateId, delegateIdList, assignee, assigneeList, assigneeName, assigneeNameList, delegator, delegatorList, delegatorName, delegatorNameList, fromStartDate, toStartDate, fromEndDate, toEndDate);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy