MassConvert.java 3.55 KB
package cn.com.glsx.entmicro.converter;

import cn.com.glsx.entmicro.entity.Mass;
import cn.com.glsx.entmicro.entity.MassConditionCrowd;
import cn.com.glsx.entmicro.entity.mass.MassTemplate;
import cn.com.glsx.entmicro.model.request.mass.CustomerInfoRequest;
import cn.com.glsx.entmicro.model.request.mass.MassConditionCrowdRequest;
import cn.com.glsx.entmicro.model.request.mass.MassFollowStaffEchoApi;
import cn.com.glsx.entmicro.model.response.*;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangxw
 * @version 1.0.0
 * @ClassName MassConvert.java
 * @description: ${description}
 * @createTime 2021年11月15日 11:03:00
 */
public class MassConvert {

    public static MassResponse convertMassData(Mass selectResult) {
        MassResponse massResponse = new MassResponse();
        BeanUtils.copyProperties(selectResult, massResponse);
        return massResponse;
    }

    public static List<MassTemplateApiResponse> convertMassTemplateData(List<MassTemplate> list){
        if (list==null||list.isEmpty()){
            return null;
        }
        List<MassTemplateApiResponse> resp = new ArrayList<>(list.size());
        list.forEach(s->{
            MassTemplateApiResponse apiResponse = new MassTemplateApiResponse();
            BeanUtils.copyProperties(s,apiResponse);
            resp.add(apiResponse);
        });
        return resp;
    }

    public static List<MassConditionCrowd> convertMassConditionCrowdList(List<MassConditionCrowdRequest> list){
        if (list==null){
            return null;
        }else if (list.isEmpty()){
            return new ArrayList<>();
        }
        List<MassConditionCrowd> resp = new ArrayList<>(list.size());
        list.forEach(s->{
            MassConditionCrowd apiResponse = new MassConditionCrowd();
            BeanUtils.copyProperties(s,apiResponse);
            resp.add(apiResponse);
        });
        return resp;
    }

    public static List<MassCrowdConditionResponse> convertMassCrowdConditionResponse(List<MassConditionCrowd> list){
        if (list==null){
            return null;
        }else if (list.isEmpty()){
            return new ArrayList<>();
        }
        List<MassCrowdConditionResponse> resp = new ArrayList<>(list.size());
        list.forEach(s->{
            MassCrowdConditionResponse apiResponse = new MassCrowdConditionResponse();
            BeanUtils.copyProperties(s,apiResponse);
            resp.add(apiResponse);
        });
        return resp;
    }

    public static List<MassFollowStaffEchoApi> convertMassFollowStaffEchoApi(List<StaffFollowResponse> list){
        if (list==null){
            return null;
        }else if (list.isEmpty()){
            return new ArrayList<>();
        }
        List<MassFollowStaffEchoApi> resp = new ArrayList<>(list.size());
        list.forEach(s->{
            MassFollowStaffEchoApi apiResponse = new MassFollowStaffEchoApi();
            BeanUtils.copyProperties(s,apiResponse);
            resp.add(apiResponse);
        });
        return resp;
    }

    public static List<CustomerInfoResponse> convertCustomerInfoResponse(List<CustomerInfoRequest> list){
        if (list==null){
            return null;
        }else if (list.isEmpty()){
            return new ArrayList<>();
        }
        List<CustomerInfoResponse> resp = new ArrayList<>(list.size());
        list.forEach(s->{
            CustomerInfoResponse apiResponse = new CustomerInfoResponse();
            BeanUtils.copyProperties(s,apiResponse);
            resp.add(apiResponse);
        });
        return resp;
    }

}