package com.zcloud.primeport.service;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.primeport.api.MkmjServiceI;
import com.zcloud.primeport.command.MkmjAddExe;
import com.zcloud.primeport.command.MkmjRemoveExe;
import com.zcloud.primeport.command.MkmjUpdateExe;
import com.zcloud.primeport.command.query.MkmjQueryExe;
import com.zcloud.primeport.domain.gateway.MkmjGateway;
import com.zcloud.primeport.dto.MkmjAddCmd;
import com.zcloud.primeport.dto.MkmjPageQry;
import com.zcloud.primeport.dto.MkmjUpdateCmd;
import com.zcloud.primeport.dto.clientobject.MkmjCO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
@AllArgsConstructor
public class MkmjServiceImpl implements MkmjServiceI {
    private final MkmjAddExe mkmjAddExe;
    private final MkmjUpdateExe mkmjUpdateExe;
    private final MkmjRemoveExe mkmjRemoveExe;
    private final MkmjQueryExe mkmjQueryExe;
    private final MkmjGateway mkmjGateway;

    @Override
    public PageResponse<MkmjCO> listPage(MkmjPageQry qry) {
        return mkmjQueryExe.execute(qry);
    }

    @Override
    public SingleResponse add(MkmjAddCmd cmd) {
        mkmjAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public void edit(MkmjUpdateCmd mkmjUpdateCmd) {
        mkmjUpdateExe.execute(mkmjUpdateCmd);
    }

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

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

    @Override
    public MkmjCO getInfoById(Long id) {
        return mkmjQueryExe.getInfoById(id);
    }

    @Override
    public Boolean checkName(String mkmjName, Long id) {
        return mkmjGateway.checkName(mkmjName, id);
    }

    @Override
    public List<MkmjCO> listAll(MkmjPageQry qry) {
        return mkmjQueryExe.listAll(qry);
    }
}

