ReportLogService.java 942 Bytes
package com.tanpu.community.service;

import com.tanpu.community.api.enums.ReportTypeEnum;
import com.tanpu.community.dao.entity.community.ReportLogEntity;
import com.tanpu.community.dao.mapper.community.ReportLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Service
@Slf4j
public class ReportLogService {

    @Resource
    private ReportLogMapper reportLogMapper;

    public void insert(ReportTypeEnum type,String userId, String themeId, String authorId, String reason){
        ReportLogEntity entity = ReportLogEntity.builder().userId(userId)
                .reportType(type.getCode())
                .targetId(themeId)
                .targetUserId(authorId)
                .reportReason(reason)
                .reportTime(LocalDateTime.now())
                .build();
        reportLogMapper.insert(entity);


    }
}