package com.ruoyi.postCheck.service.impl;

import java.util.List;

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

/**
 * 岗检表管理明细Service业务层处理
 *
 * @author csg
 * @date 2024-01-05
 */
@Service
public class PostCheckedItemsServiceImpl extends ServiceImpl<PostCheckedItemsMapper, PostCheckedItems> implements IPostCheckedItemsService {
    @Autowired
    private PostCheckedItemsMapper postCheckedItemsMapper;

    /**
     * 查询岗检表管理明细
     *
     * @param id 岗检表管理明细主键
     * @return 岗检表管理明细
     */
    @Override
    public PostCheckedItems selectPostCheckedItemsById(Long id) {
        return postCheckedItemsMapper.selectPostCheckedItemsById(id);
    }

    /**
     * 查询岗检表管理明细列表
     *
     * @param postCheckedItems 岗检表管理明细
     * @return 岗检表管理明细
     */
    @Override
    public List<PostCheckedItems> selectPostCheckedItemsList(PostCheckedItems postCheckedItems) {
        return postCheckedItemsMapper.selectPostCheckedItemsList(postCheckedItems);
    }

    /**
     * 新增岗检表管理明细
     *
     * @param postCheckedItems 岗检表管理明细
     * @return 结果
     */
    @Override
    public int insertPostCheckedItems(PostCheckedItems postCheckedItems) {
        //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
//        if (postCheckedItems.getId() == null)
            postCheckedItems.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
        // postCheckedItems.setCreateTime(DateUtils.getNowDate());
        postCheckedItems.setCreateDefault();
//        postCheckedItems.setStatus(PostCheckedItemsEnum.STATUS_WAIT.getValue()); // 去创建自己的枚举类
        postCheckedItems.setCreateUserId(SecurityUtils.getUserId());
        return postCheckedItemsMapper.insertPostCheckedItems(postCheckedItems);
    }

    /**
     * 修改岗检表管理明细
     *
     * @param postCheckedItems 岗检表管理明细
     * @return 结果
     */
    @Override
    public int updatePostCheckedItems(PostCheckedItems postCheckedItems) {
        // postCheckedItems.setUpdateTime(DateUtils.getNowDate());
        postCheckedItems.setUpdateDefault();
        return postCheckedItemsMapper.updatePostCheckedItems(postCheckedItems);
    }

    /**
     * 批量删除岗检表管理明细
     *
     * @param ids 需要删除的岗检表管理明细主键
     * @return 结果
     */
    @Override
    public int deletePostCheckedItemsByIds(Long[] ids) {
        return postCheckedItemsMapper.deletePostCheckedItemsByIds(ids);
    }

    /**
     * 删除岗检表管理明细信息
     *
     * @param id 岗检表管理明细主键
     * @return 结果
     */
    @Override
    public int deletePostCheckedItemsById(Long id) {
        return postCheckedItemsMapper.deletePostCheckedItemsById(id);
    }
}
