package com.fjhx.service.production.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.entity.production.ProductionLine;
import com.fjhx.params.production.ProductionLineEx;
import com.fjhx.params.production.ProductionLineVo;
import com.fjhx.mapper.production.ProductionLineMapper;
import com.fjhx.service.production.ProductionLineService;
import com.fjhx.utils.WrapperUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 生产线 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-06-28
 */
@Service
public class ProductionLineServiceImpl extends ServiceImpl<ProductionLineMapper, ProductionLine> implements ProductionLineService {

    @Override
    public Page<ProductionLineEx> getPage(Map<String, String> condition) {
        QueryWrapper<?> wrapper = WrapperUtil.init(condition)
                .eq("pl.production_workshop_id", "productionWorkshopId") // 车间id
                .eq("pl.status", "status") // 生产线状态
                .keyword("pl.name") // 生产线名称
                .createTimeDesc("pl")
                .getWrapper();
        return baseMapper.getPage(createPage(condition), wrapper);
    }

    @Override
    public void add(ProductionLineVo productionLineVo) {
        save(productionLineVo);
    }

    @Override
    public void edit(ProductionLineVo productionLineVo) {
        updateById(productionLineVo);
    }

    @Override
    public void delete(ProductionLineVo productionLineVo) {
        removeById(productionLineVo.getId());
    }

}
