package com.cdm.module.trade.convert.brokerage;

import com.cdm.framework.common.pojo.PageResult;
import com.cdm.module.member.api.user.dto.MemberUserRespDTO;
import com.cdm.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
import com.cdm.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO;
import com.cdm.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
import com.cdm.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
import com.cdm.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
import com.cdm.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-12-21T17:56:56+0800",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.3 (JetBrains s.r.o.)"
)
public class BrokerageRecordConvertImpl implements BrokerageRecordConvert {

    @Override
    public BrokerageRecordRespVO convert(BrokerageRecordDO bean) {
        if ( bean == null ) {
            return null;
        }

        BrokerageRecordRespVO brokerageRecordRespVO = new BrokerageRecordRespVO();

        brokerageRecordRespVO.setUserId( bean.getUserId() );
        brokerageRecordRespVO.setBizId( bean.getBizId() );
        brokerageRecordRespVO.setBizType( bean.getBizType() );
        brokerageRecordRespVO.setTitle( bean.getTitle() );
        brokerageRecordRespVO.setPrice( bean.getPrice() );
        brokerageRecordRespVO.setTotalPrice( bean.getTotalPrice() );
        brokerageRecordRespVO.setDescription( bean.getDescription() );
        brokerageRecordRespVO.setStatus( bean.getStatus() );
        brokerageRecordRespVO.setFrozenDays( bean.getFrozenDays() );
        brokerageRecordRespVO.setUnfreezeTime( bean.getUnfreezeTime() );
        brokerageRecordRespVO.setSourceUserLevel( bean.getSourceUserLevel() );
        brokerageRecordRespVO.setSourceUserId( bean.getSourceUserId() );
        brokerageRecordRespVO.setId( bean.getId() );
        brokerageRecordRespVO.setCreateTime( bean.getCreateTime() );

        return brokerageRecordRespVO;
    }

    @Override
    public List<BrokerageRecordRespVO> convertList(List<BrokerageRecordDO> list) {
        if ( list == null ) {
            return null;
        }

        List<BrokerageRecordRespVO> list1 = new ArrayList<BrokerageRecordRespVO>( list.size() );
        for ( BrokerageRecordDO brokerageRecordDO : list ) {
            list1.add( convert( brokerageRecordDO ) );
        }

        return list1;
    }

    @Override
    public PageResult<BrokerageRecordRespVO> convertPage(PageResult<BrokerageRecordDO> page) {
        if ( page == null ) {
            return null;
        }

        PageResult<BrokerageRecordRespVO> pageResult = new PageResult<BrokerageRecordRespVO>();

        pageResult.setList( convertList( page.getList() ) );
        pageResult.setTotal( page.getTotal() );

        return pageResult;
    }

    @Override
    public BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId) {
        if ( pageReqVO == null && userId == null ) {
            return null;
        }

        BrokerageRecordPageReqVO brokerageRecordPageReqVO = new BrokerageRecordPageReqVO();

        if ( pageReqVO != null ) {
            brokerageRecordPageReqVO.setPageNo( pageReqVO.getPageNo() );
            brokerageRecordPageReqVO.setPageSize( pageReqVO.getPageSize() );
            brokerageRecordPageReqVO.setBizType( pageReqVO.getBizType() );
            brokerageRecordPageReqVO.setStatus( pageReqVO.getStatus() );
        }
        brokerageRecordPageReqVO.setUserId( userId );

        return brokerageRecordPageReqVO;
    }

    @Override
    public PageResult<AppBrokerageRecordRespVO> convertPage02(PageResult<BrokerageRecordDO> pageResult) {
        if ( pageResult == null ) {
            return null;
        }

        PageResult<AppBrokerageRecordRespVO> pageResult1 = new PageResult<AppBrokerageRecordRespVO>();

        pageResult1.setList( brokerageRecordDOListToAppBrokerageRecordRespVOList( pageResult.getList() ) );
        pageResult1.setTotal( pageResult.getTotal() );

        return pageResult1;
    }

    @Override
    public void copyTo(MemberUserRespDTO from, AppBrokerageUserRankByPriceRespVO to) {
        if ( from == null ) {
            return;
        }

        to.setId( from.getId() );
        to.setNickname( from.getNickname() );
        to.setAvatar( from.getAvatar() );
    }

    protected AppBrokerageRecordRespVO brokerageRecordDOToAppBrokerageRecordRespVO(BrokerageRecordDO brokerageRecordDO) {
        if ( brokerageRecordDO == null ) {
            return null;
        }

        AppBrokerageRecordRespVO appBrokerageRecordRespVO = new AppBrokerageRecordRespVO();

        if ( brokerageRecordDO.getId() != null ) {
            appBrokerageRecordRespVO.setId( brokerageRecordDO.getId().longValue() );
        }
        appBrokerageRecordRespVO.setTitle( brokerageRecordDO.getTitle() );
        appBrokerageRecordRespVO.setPrice( brokerageRecordDO.getPrice() );
        appBrokerageRecordRespVO.setCreateTime( brokerageRecordDO.getCreateTime() );

        return appBrokerageRecordRespVO;
    }

    protected List<AppBrokerageRecordRespVO> brokerageRecordDOListToAppBrokerageRecordRespVOList(List<BrokerageRecordDO> list) {
        if ( list == null ) {
            return null;
        }

        List<AppBrokerageRecordRespVO> list1 = new ArrayList<AppBrokerageRecordRespVO>( list.size() );
        for ( BrokerageRecordDO brokerageRecordDO : list ) {
            list1.add( brokerageRecordDOToAppBrokerageRecordRespVO( brokerageRecordDO ) );
        }

        return list1;
    }
}
