package com.ruoyi.hezhi.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.hezhi.domain.TbMemberDiscuss;
import com.ruoyi.hezhi.domain.dto.MemberDiscussDTO;
import com.ruoyi.hezhi.mapper.TbMemberDiscussMapper;
import com.ruoyi.hezhi.service.ITbMemberDiscussService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 用户讨论Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-19
 */
@Service
public class TbMemberDiscussServiceImpl implements ITbMemberDiscussService
{
    @Autowired
    private TbMemberDiscussMapper tbMemberDiscussMapper;

    /**
     * 查询用户讨论
     *
     * @param memberDiscussId 用户讨论主键
     * @return 用户讨论
     */
    @Override
    public TbMemberDiscuss selectTbMemberDiscussByMemberDiscussId(Long memberDiscussId)
    {
        return tbMemberDiscussMapper.selectTbMemberDiscussByMemberDiscussId(memberDiscussId);
    }

    /**
     * 查询用户讨论列表
     *
     * @param tbMemberDiscuss 用户讨论
     * @return 用户讨论
     */
    @Override
    public List<TbMemberDiscuss> selectTbMemberDiscussList(TbMemberDiscuss tbMemberDiscuss)
    {
        return tbMemberDiscussMapper.selectTbMemberDiscussList(tbMemberDiscuss);
    }

    /**
     * 新增用户讨论
     *
     * @param tbMemberDiscuss 用户讨论
     * @return 结果
     */
    @Override
    public int insertTbMemberDiscuss(TbMemberDiscuss tbMemberDiscuss)
    {
        tbMemberDiscuss.setCreateTime(DateUtils.getNowDate());
        return tbMemberDiscussMapper.insertTbMemberDiscuss(tbMemberDiscuss);
    }

    /**
     * 修改用户讨论
     *
     * @param tbMemberDiscuss 用户讨论
     * @return 结果
     */
    @Override
    public int updateTbMemberDiscuss(TbMemberDiscuss tbMemberDiscuss)
    {
        tbMemberDiscuss.setUpdateTime(DateUtils.getNowDate());
        return tbMemberDiscussMapper.updateTbMemberDiscuss(tbMemberDiscuss);
    }

    /**
     * 批量删除用户讨论
     *
     * @param memberDiscussIds 需要删除的用户讨论主键
     * @return 结果
     */
    @Override
    public int deleteTbMemberDiscussByMemberDiscussIds(Long[] memberDiscussIds)
    {
        return tbMemberDiscussMapper.deleteTbMemberDiscussByMemberDiscussIds(memberDiscussIds);
    }

    /**
     * 删除用户讨论信息
     *
     * @param memberDiscussId 用户讨论主键
     * @return 结果
     */
    @Override
    public int deleteTbMemberDiscussByMemberDiscussId(Long memberDiscussId)
    {
        return tbMemberDiscussMapper.deleteTbMemberDiscussByMemberDiscussId(memberDiscussId);
    }

    /**
     * 用户讨论列表
     *
     * @param params 参数
     * @return 用户讨论列表
     */
    @Override
    public List<Map<String, Object>> getMemberDiscussList(Map<String, Object> params) {
        return tbMemberDiscussMapper.getMemberDiscussList(params);
    }

    /**
     * 发布讨论信息
     *
     * @param memberDiscussDTO
     * @return ok
     */
    @Override
    public AjaxResult releaseMemberDiscuss(MemberDiscussDTO memberDiscussDTO) {
        TbMemberDiscuss memberDiscuss = new TbMemberDiscuss();
        memberDiscuss.setMemberUserId(memberDiscussDTO.getMemberUserId());
        memberDiscuss.setLiveBroadcastId(memberDiscussDTO.getLiveBroadcastId());
        memberDiscuss.setCourseId(memberDiscussDTO.getCourseId());
        memberDiscuss.setChapterId(memberDiscussDTO.getChapterId());
        memberDiscuss.setContent(memberDiscussDTO.getContent());
        memberDiscuss.setCreateTime(DateUtils.getNowDate());
        tbMemberDiscussMapper.insertTbMemberDiscuss(memberDiscuss);
        return AjaxResult.success();
    }
}
