package com.ruoyi.postCheck.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ruoyi.common.constant.PostTeamEnum;
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.PostTeamMapper;
import com.ruoyi.postCheck.domain.PostTeam;
import com.ruoyi.postCheck.service.IPostTeamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 岗检小组Service业务层处理
 *
 * @author csg
 * @date 2023-12-19
 */
@Service
public class PostTeamServiceImpl extends ServiceImpl<PostTeamMapper, PostTeam> implements IPostTeamService {
    @Autowired
    private PostTeamMapper postTeamMapper;

    /**
     * 查询岗检小组
     *
     * @param id 岗检小组主键
     * @return 岗检小组
     */
    @Override
    public PostTeam selectPostTeamById(Long id) {
        return postTeamMapper.selectPostTeamById(id);
    }

    /**
     * 查询岗检小组列表
     *
     * @param postTeam 岗检小组
     * @return 岗检小组
     */
    @Override
    public List<PostTeam> selectPostTeamList(PostTeam postTeam) {
        return postTeamMapper.selectPostTeamList(postTeam);
    }

    /**
     * 新增岗检小组
     *
     * @param postTeam 岗检小组
     * @return 结果
     */
    @Override
    public int insertPostTeam(PostTeam postTeam) {

        //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
        if (postTeam.getId() == null)
            postTeam.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
        postTeam.setCreateDefault();
        postTeam.setStatus(PostTeamEnum.VALID.getValue());
        postTeam.setCreateUserId(SecurityUtils.getUserId());
        return postTeamMapper.insertPostTeam(postTeam);
    }

    /**
     * 修改岗检小组
     *
     * @param postTeam 岗检小组
     * @return 结果
     */
    @Override
    public int updatePostTeam(PostTeam postTeam) {
        postTeam.setUpdateDefault();
        return postTeamMapper.updatePostTeam(postTeam);
    }

    /**
     * 批量删除岗检小组
     *
     * @param ids 需要删除的岗检小组主键
     * @return 结果
     */
    @Override
    public int deletePostTeamByIds(Long[] ids) {
        return postTeamMapper.deletePostTeamByIds(ids);
    }

    /**
     * 删除岗检小组信息
     *
     * @param id 岗检小组主键
     * @return 结果
     */
    @Override
    public int deletePostTeamById(Long id) {
        return postTeamMapper.deletePostTeamById(id);
    }
}
