package com.ruoyi.interfaces.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.interfaces.core.page.PageParam;
import com.ruoyi.interfaces.core.service.AbstractCrudService;
import com.ruoyi.interfaces.domain.PtHelpFile;
import com.ruoyi.interfaces.mapper.PtHelpFileDao;
import com.ruoyi.interfaces.service.PtHelpFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author
 * @date 2022-1-25
 */
@Service
@Transactional
public class PtHelpFileServiceImpl extends AbstractCrudService<PtHelpFile, PageParam<PtHelpFile>> implements PtHelpFileService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private PtHelpFileDao ptHelpFileDao;

    public PtHelpFileServiceImpl(PtHelpFileDao ptHelpFileDao) {
        super(ptHelpFileDao);
        this.ptHelpFileDao = ptHelpFileDao;
    }

    @Override
    public int insert(PtHelpFile ptHelpFile) {
        ptHelpFile.setViewNum(0L);
        ptHelpFile.setStatus("0");
        ptHelpFile.setIntm(new Date());
        return this.ptHelpFileDao.insert(ptHelpFile);
    }

    @Override
    public int update(PtHelpFile ptHelpFile) {
        return this.ptHelpFileDao.update(ptHelpFile);
    }

    @Override
    public PtHelpFile get(String id) {
        return ptHelpFileDao.get(id);
    }

    @Override
    public int delete(String id) {
        return this.ptHelpFileDao.delete(id);
    }

    @Override
    public PageInfo<PtHelpFile> findPageInfo(PageParam<PtHelpFile> param) {
        PageHelper.startPage(param);
        List<PtHelpFile> list = this.ptHelpFileDao.list(param.getData());
        return new PageInfo<>(list);
    }

}
