package com.zcloud.basic.info.service;

import com.alibaba.cola.dto.MultiResponse;
import com.zcloud.basic.info.api.PostServiceI;
import com.zcloud.basic.info.command.PostAddExe;
import com.zcloud.basic.info.command.PostRemoveExe;
import com.zcloud.basic.info.command.PostUpdateExe;
import com.zcloud.basic.info.command.query.PostQueryExe;
import com.zcloud.basic.info.dto.PostAddCmd;
import com.zcloud.basic.info.dto.PostListQry;
import com.zcloud.basic.info.dto.PostPageQry;
import com.zcloud.basic.info.dto.PostUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.PostCO;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * web-app
 *
 * @Author SondonYong
 * @Date 2025-10-31 17:24:04
 */
@Service
@AllArgsConstructor
public class PostServiceImpl implements PostServiceI {
    private final PostAddExe postAddExe;
    private final PostUpdateExe postUpdateExe;
    private final PostRemoveExe postRemoveExe;
    private final PostQueryExe postQueryExe;

    @Override
    public PageResponse<PostCO> listPage(PostPageQry qry) {
        return postQueryExe.execute(qry);
    }

    @Override
    public MultiResponse<PostCO> list(PostListQry qry) {
        return postQueryExe.execute(qry);
    }


    @Override
    public SingleResponse<PostCO> getInfoById(Long id) {
        return postQueryExe.execute(id);
    }

    @Override
    public SingleResponse add(PostAddCmd cmd) {
        postAddExe.execute(cmd);
        return SingleResponse.buildSuccess();
    }

    @Override
    public void edit(PostUpdateCmd postUpdateCmd) {
        postUpdateExe.execute(postUpdateCmd);
    }

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

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

    @Override
    public List<PostCO> listByPostIds(Collection<Long> collection) {
        return postQueryExe.listByPostIds(collection);
    }

    @Override
    public List<PostCO> getPostList() {
        return postQueryExe.getPostList();
    }

    @Override
    public PostCO getPostById(Long aLong) {
        return postQueryExe.getPostById(aLong);
    }
}

