package com.ruoyi.postCheck.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.postCheck.mapper.PostHighlightsMapper;
import com.ruoyi.postCheck.domain.PostHighlights;
import com.ruoyi.postCheck.service.IPostHighlightsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 岗检亮点Service业务层处理
 *
 * @author csg
 * @date 2023-12-26
 */
@Service
public class PostHighlightsServiceImpl extends ServiceImpl<PostHighlightsMapper, PostHighlights> implements IPostHighlightsService
{
    @Autowired
    private PostHighlightsMapper postHighlightsMapper;

    /**
     * 查询岗检亮点
     *
     * @param id 岗检亮点主键
     * @return 岗检亮点
     */
    @Override
    public PostHighlights selectPostHighlightsById(Long id)
    {
        return postHighlightsMapper.selectPostHighlightsById(id);
    }

    /**
     * 查询岗检亮点列表
     *
     * @param postHighlights 岗检亮点
     * @return 岗检亮点
     */
    @Override
    public List<PostHighlights> selectPostHighlightsList(PostHighlights postHighlights)
    {
        return postHighlightsMapper.selectPostHighlightsList(postHighlights);
    }

    /**
     * 新增岗检亮点
     *
     * @param postHighlights 岗检亮点
     * @return 结果
     */
    @Override
    public int insertPostHighlights(PostHighlights postHighlights)
    {
        //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
        if (postHighlights.getId() == null)
            postHighlights.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
        // postHighlights.setCreateTime(DateUtils.getNowDate());
        postHighlights.setCreateDefault();
        return postHighlightsMapper.insertPostHighlights(postHighlights);
    }

    /**
     * 修改岗检亮点
     *
     * @param postHighlights 岗检亮点
     * @return 结果
     */
    @Override
    public int updatePostHighlights(PostHighlights postHighlights)
    {
        // postHighlights.setUpdateTime(DateUtils.getNowDate());
        postHighlights.setUpdateDefault();
        return postHighlightsMapper.updatePostHighlights(postHighlights);
    }

    /**
     * 批量删除岗检亮点
     *
     * @param ids 需要删除的岗检亮点主键
     * @return 结果
     */
    @Override
    public int deletePostHighlightsByIds(Long[] ids)
    {
        return postHighlightsMapper.deletePostHighlightsByIds(ids);
    }

    /**
     * 删除岗检亮点信息
     *
     * @param id 岗检亮点主键
     * @return 结果
     */
    @Override
    public int deletePostHighlightsById(Long id)
    {
        return postHighlightsMapper.deletePostHighlightsById(id);
    }
}
