package com.fs.doc.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.fs.common.utils.DateUtils;
import com.fs.common.utils.StringUtils;
import com.fs.doc.param.DocRecordReplyQueryParam;
import com.fs.doc.vo.DocRecordReplyListQueryVO;
import com.fs.store.mapper.FsStoreProductMapper;
import com.fs.store.vo.FsStoreProductListQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.doc.mapper.DocRecordReplyMapper;
import com.fs.doc.domain.DocRecordReply;
import com.fs.doc.service.IDocRecordReplyService;

/**
 * 回复Service业务层处理
 * 
 * @author fs
 * @date 2023-01-09
 */
@Service
public class DocRecordReplyServiceImpl implements IDocRecordReplyService 
{
    @Autowired
    private DocRecordReplyMapper docRecordReplyMapper;
    @Autowired
    private FsStoreProductMapper storeProductMapper;
    /**
     * 查询回复
     * 
     * @param replyId 回复ID
     * @return 回复
     */
    @Override
    public DocRecordReply selectDocRecordReplyById(Long replyId)
    {
        return docRecordReplyMapper.selectDocRecordReplyById(replyId);
    }

    /**
     * 查询回复列表
     * 
     * @param docRecordReply 回复
     * @return 回复
     */
    @Override
    public List<DocRecordReply> selectDocRecordReplyList(DocRecordReply docRecordReply)
    {
        return docRecordReplyMapper.selectDocRecordReplyList(docRecordReply);
    }

    /**
     * 新增回复
     * 
     * @param docRecordReply 回复
     * @return 结果
     */
    @Override
    public int insertDocRecordReply(DocRecordReply docRecordReply)
    {
        docRecordReply.setCreateTime(DateUtils.getNowDate());
        return docRecordReplyMapper.insertDocRecordReply(docRecordReply);
    }

    /**
     * 修改回复
     * 
     * @param docRecordReply 回复
     * @return 结果
     */
    @Override
    public int updateDocRecordReply(DocRecordReply docRecordReply)
    {
        return docRecordReplyMapper.updateDocRecordReply(docRecordReply);
    }

    /**
     * 批量删除回复
     * 
     * @param replyIds 需要删除的回复ID
     * @return 结果
     */
    @Override
    public int deleteDocRecordReplyByIds(Long[] replyIds)
    {
        return docRecordReplyMapper.deleteDocRecordReplyByIds(replyIds);
    }

    /**
     * 删除回复信息
     * 
     * @param replyId 回复ID
     * @return 结果
     */
    @Override
    public int deleteDocRecordReplyById(Long replyId)
    {
        return docRecordReplyMapper.deleteDocRecordReplyById(replyId);
    }

    @Override
    public List<DocRecordReplyListQueryVO> selectDocRecordReplyListVOQuery(DocRecordReplyQueryParam param) {
        List<DocRecordReplyListQueryVO> list= docRecordReplyMapper.selectDocRecordReplyListVOQuery(param);
        for(DocRecordReplyListQueryVO vo:list){
            List<FsStoreProductListQueryVO> productList=new ArrayList<>();
            if(StringUtils.isEmpty(vo.getProductIds())){
                productList=storeProductMapper.selectFsStoreProductListByIds(vo.getProductIds());
            }
            vo.setProducts(productList);
        }
        return list;
    }
}
