package com.ruoyi.xq.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.xq.domain.Report;
import com.ruoyi.xq.dto.admin.report.ReportAdminVo;
import com.ruoyi.xq.dto.app.report.ReportPushReq;
import com.ruoyi.xq.mapper.ReportMapper;
import com.ruoyi.xq.service.ReportService;
import org.springframework.stereotype.Service;

/**
 * 举报Service业务层处理
 *
 * @author 77
 * @date 2024-03-19
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper,Report> implements ReportService {

    @Override
    public void close(Long id) {
        Report updateReport = new Report();
        updateReport.setId(id);
        updateReport.setReportStatus(1);
        this.updateById(updateReport);
    }

    @Override
    public IPage<ReportAdminVo> pageAdmin(PageQuery pageQuery, ReportAdminVo bo) {
        return baseMapper.pageAdmin(pageQuery.build(), bo);
    }

    @Override
    public void push(ReportPushReq reportPushReq) {
        Report report = new Report();
        report.setCateName(reportPushReq.getCateName());
        report.setUserId(LoginHelper.getUserId());
        report.setReportUid(reportPushReq.getReportUid());
        report.setContent(reportPushReq.getContent());
        report.setContentImage(reportPushReq.getContentImage());
        this.save(report);
    }
}
