package com.ruoyi.cai.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cai.domain.Report;
import com.ruoyi.cai.domain.ReportCate;
import com.ruoyi.cai.dto.app.query.UserReportReq;
import com.ruoyi.cai.mapper.ReportMapper;
import com.ruoyi.cai.service.ReportCateService;
import com.ruoyi.cai.service.ReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 举报Service业务层处理
 *
 * @author 77
 * @date 2023-12-24
 */
@RequiredArgsConstructor
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
    @Autowired
    private ReportCateService reportCateService;
    @Override
    public void report(UserReportReq reportRes) {
        ReportCate reportCate = reportCateService.getById(reportRes.getCateId());
        Report report = new Report();
        report.setType(reportRes.getType());
        report.setCateName(reportCate.getName());
        report.setCateId(reportRes.getCateId());
        report.setUserId(reportRes.getUserId());
        report.setReportUid(reportRes.getReportUid());
        report.setContent(reportRes.getContent());
        this.save(report);
    }
}
