package com.ruoyi.framework.recovery.service.impl;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

import com.ruoyi.framework.recovery.domain.dto.ContentDto;
import com.ruoyi.framework.recovery.domain.vo.WxContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.framework.recovery.mapper.RecContentMapper;
import com.ruoyi.framework.recovery.domain.RecContent;
import com.ruoyi.framework.recovery.service.IRecContentService;

/**
 * 评论Service业务层处理
 *
 * @author jin
 * @date 2024-11-16
 */
@Service
public class RecContentServiceImpl implements IRecContentService
{
    @Autowired
    private RecContentMapper recContentMapper;

    /**
     * 查询评论
     *
     * @param id 评论主键
     * @return 评论
     */
    @Override
    public RecContent selectRecContentById(Long id)
    {
        return recContentMapper.selectRecContentById(id);
    }

    /**
     * 查询评论列表
     *
     * @param recContent 评论
     * @return 评论
     */
    @Override
    public List<RecContent> selectRecContentList(RecContent recContent)
    {
        return recContentMapper.selectRecContentList(recContent);
    }

    /**
     * 新增评论
     *
     * @param recContent 评论
     * @return 结果
     */
    @Override
    public int insertRecContent(RecContent recContent)
    {
        recContent.setCreateDate(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
        return recContentMapper.insertRecContent(recContent);
    }

    /**
     * 修改评论
     *
     * @param recContent 评论
     * @return 结果
     */
    @Override
    public int updateRecContent(RecContent recContent)
    {
        return recContentMapper.updateRecContent(recContent);
    }

    /**
     * 批量删除评论
     *
     * @param ids 需要删除的评论主键
     * @return 结果
     */
    @Override
    public int deleteRecContentByIds(Long[] ids)
    {
        return recContentMapper.deleteRecContentByIds(ids);
    }

    /**
     * 删除评论信息
     *
     * @param id 评论主键
     * @return 结果
     */
    @Override
    public int deleteRecContentById(Long id)
    {
        return recContentMapper.deleteRecContentById(id);
    }

    @Override
    public int insertRecContentUser(String wxOpenid, Long id) {
        ContentDto dto = new ContentDto();
        dto.setContentId(id);
        dto.setOpenId(wxOpenid);
        dto.setCreateTime(new Date());
        return recContentMapper.insertRecContentUser(dto);
    }

    @Override
    public List<WxContent> selectWxContentList(WxContent wxContentVo) {
        return recContentMapper.selectWxContentList(wxContentVo);
    }

    @Override
    public List<WxContent> selectRecContentByOpenId(String wxOpenid) {
        return recContentMapper.selectRecContentByOpenId(wxOpenid);
    }
}
