package jnpf.notice.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import jnpf.model.notice.domain.FtbNoticeAnnouncementsLog;
import jnpf.model.notice.dto.FtbNoticeAnnouncementsLogDto;
import jnpf.model.notice.req.oplog.QueryLogListReq;
import jnpf.notice.mapper.FtbNoticeAnnouncementsLogMapper;
import jnpf.notice.service.FtbNoticeAnnouncementsLogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 许贵林
 * @description 针对表【ftb_notice_announcements_log(公告操作日志表)】的数据库操作Service实现
 * @createDate 2024-05-08 09:42:09
 */
@Service
public class FtbNoticeAnnouncementsLogServiceImpl extends ServiceImpl<FtbNoticeAnnouncementsLogMapper, FtbNoticeAnnouncementsLog>
        implements FtbNoticeAnnouncementsLogService {

    /**
     * 查询公告操作日志列表
     *
     * @param req 查询条件对象，包含查询列表所需的各种过滤条件
     * @return
     */
    @Override
    public PageInfo<FtbNoticeAnnouncementsLogDto> queryList(QueryLogListReq req) {
        Page<FtbNoticeAnnouncementsLogDto> queryPage = baseMapper.pagingQuery(Page.of(req.getCurrentPage(), req.getPageSize()), req);
        List<FtbNoticeAnnouncementsLogDto> records = queryPage.getRecords();
        //构建分页返回数据
        PageInfo<FtbNoticeAnnouncementsLogDto> pageInfo = new PageInfo<>();
        pageInfo.setList(records);
        pageInfo.setPageSize((int) queryPage.getSize());
        pageInfo.setPageNum((int) queryPage.getCurrent());
        pageInfo.setTotal((int) queryPage.getTotal());
        return pageInfo;
    }

    /**
     * 记录日志
     *
     * @param log 日志对象，包含需要记录的日志详细信息
     */
    @Override
    public void recordLog(FtbNoticeAnnouncementsLog log) {
        baseMapper.insert(log);
    }
}




