package cn.com.ctop.common.module.service.impl;

import cn.com.ctop.common.module.entity.MaterialParameter;
import cn.com.ctop.common.module.mapper.MaterialParameterMapper;
import cn.com.ctop.common.module.service.IMaterialParameterService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * 素材归属标
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2019-11-23
 */
@Service
@Primary
public class MaterialParameterServiceImpl extends ServiceImpl<MaterialParameterMapper, MaterialParameter> implements IMaterialParameterService {

    @Override
    public MaterialParameter getOneByMaterialId(String materialInfoId) {
        QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
        parameterQueryWrapper.eq("material_id", materialInfoId);
        parameterQueryWrapper.orderByDesc("create_time").last("limit 1");
        return getOne(parameterQueryWrapper);
    }
}
