package com.zcloud.primeport.service;

import com.zcloud.primeport.api.ClosedAreaCarApplyServiceI;
import com.zcloud.primeport.command.ClosedAreaCarApplyAddExe;
import com.zcloud.primeport.command.ClosedAreaCarApplyRemoveExe;
import com.zcloud.primeport.command.ClosedAreaCarApplyUpdateExe;
import com.zcloud.primeport.command.query.ClosedAreaCarApplyQueryExe;
import com.zcloud.primeport.domain.enums.CloseCarBelongTypeEnum;
import com.zcloud.primeport.dto.*;
import com.zcloud.primeport.dto.clientobject.ClosedAreaCarApplyCO;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * web-app
 *
 * @Author dearLin
 * @Date 2026-03-20 10:07:15
 */
@Service
@AllArgsConstructor
public class ClosedAreaCarApplyServiceImpl implements ClosedAreaCarApplyServiceI {
    private final ClosedAreaCarApplyAddExe closedAreaCarApplyAddExe;
    private final ClosedAreaCarApplyUpdateExe closedAreaCarApplyUpdateExe;
    private final ClosedAreaCarApplyRemoveExe closedAreaCarApplyRemoveExe;
    private final ClosedAreaCarApplyQueryExe closedAreaCarApplyQueryExe;

    @Override
    public ClosedAreaCarApplyCO queryById(Long id) {
        return closedAreaCarApplyQueryExe.queryById(id);
    }

    @Override
    public PageResponse<ClosedAreaCarApplyCO> listPage(ClosedAreaCarApplyPageQry qry) {

        return closedAreaCarApplyQueryExe.execute(qry);
    }

    @Override
    public SingleResponse add(ClosedAreaCarApplyAddCmd cmd) {

        closedAreaCarApplyAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public void edit(ClosedAreaCarApplyUpdateCmd closedAreaCarApplyUpdateCmd) {
        closedAreaCarApplyUpdateExe.execute(closedAreaCarApplyUpdateCmd);
    }

    @Override
    public void remove(Long id) {
        closedAreaCarApplyRemoveExe.execute(id);
    }

    @Override
    public void removeBatch(Long[] ids) {
        closedAreaCarApplyRemoveExe.execute(ids);
    }

    @Override
    public void auditCarApply(ClosedAreaCarApplyAuditCmd auditCmd) {
        closedAreaCarApplyUpdateExe.auditCarApply(auditCmd);
    }

    @Override
    @Transactional
    public Long saveTmpCarApply(ClosedTmpApplyAddCmd cmd) {
        ClosedAreaCarApplyAddCmd closedAreaCarApplyAddCmd = new ClosedAreaCarApplyAddCmd();
        BeanUtils.copyProperties(cmd, closedAreaCarApplyAddCmd);
        closedAreaCarApplyAddCmd.setApplyPersonUserName(cmd.getDrivingUserName());
        closedAreaCarApplyAddCmd.setCarBelongType(CloseCarBelongTypeEnum.TEMPORARY_VEHICLES.getCode());
        return closedAreaCarApplyAddExe.execute(closedAreaCarApplyAddCmd);
    }
}

