package com.op.mes.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.mes.domain.ProRecipeContent;
import com.op.mes.mapper.ProRecipeContentMapper;
import com.op.mes.service.IProRecipeContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 生产工序内容Service业务层处理
 *
 * @author yinjinlu
 * @date 2022-05-12
 */
@Service
public class ProRecipeContentServiceImpl implements IProRecipeContentService
{
    @Autowired
    private ProRecipeContentMapper proRecipeContentMapper;

    /**
     * 查询生产工序内容
     *
     * @param contentId 生产工序内容主键
     * @return 生产工序内容
     */
    @Override
    @DS("#header.poolName")
    public ProRecipeContent selectProRecipeContentByContentId(String contentId)
    {
        return proRecipeContentMapper.selectProRecipeContentByContentId(contentId);
    }

    /**
     * 查询生产工序内容列表
     *
     * @param proRecipeContent 生产工序内容
     * @return 生产工序内容
     */
    @Override
    @DS("#header.poolName")
    public List<ProRecipeContent> selectProRecipeContentList(ProRecipeContent proRecipeContent)
    {
        return proRecipeContentMapper.selectProRecipeContentList(proRecipeContent);
    }

    /**
     * 新增生产工序内容
     *
     * @param proRecipeContent 生产工序内容
     * @return 结果
     */
    @Override
    @DS("#header.poolName")
    public int insertProRecipeContent(ProRecipeContent proRecipeContent)
    {
        proRecipeContent.setCreateTime(DateUtils.getNowDate());
        proRecipeContent.setContentId(IdUtils.fastSimpleUUID());
        return proRecipeContentMapper.insertProRecipeContent(proRecipeContent);
    }

    /**
     * 修改生产工序内容
     *
     * @param proRecipeContent 生产工序内容
     * @return 结果
     */
    @Override
    @DS("#header.poolName")
    public int updateProRecipeContent(ProRecipeContent proRecipeContent)
    {
        proRecipeContent.setUpdateTime(DateUtils.getNowDate());
        return proRecipeContentMapper.updateProRecipeContent(proRecipeContent);
    }

    /**
     * 批量删除生产工序内容
     *
     * @param contentIds 需要删除的生产工序内容主键
     * @return 结果
     */
    @Override
    @DS("#header.poolName")
    public int deleteProRecipeContentByContentIds(String[] contentIds)
    {
        return proRecipeContentMapper.deleteProRecipeContentByContentIds(contentIds);
    }

    /**
     * 删除生产工序内容信息
     *
     * @param contentId 生产工序内容主键
     * @return 结果
     */
    @Override
    @DS("#header.poolName")
    public int deleteProRecipeContentByContentId(String contentId)
    {
        return proRecipeContentMapper.deleteProRecipeContentByContentId(contentId);
    }
}
