package com.yanzhu.jh.project.service.impl;

import java.util.List;

import com.ruoyi.common.enums.PublicStateEnum;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.jh.project.mapper.SurProjectMaterialSealMapper;
import com.yanzhu.jh.project.domain.SurProjectMaterialSeal;
import com.yanzhu.jh.project.service.ISurProjectMaterialSealService;
import com.ruoyi.common.utils.SecurityUtils;
/**
 * 材料封样Service业务层处理
 * 
 * @author JiangYuQi
 * @date 2023-08-22
 */
@Service
public class SurProjectMaterialSealServiceImpl implements ISurProjectMaterialSealService 
{
    @Autowired
    private SurProjectMaterialSealMapper surProjectMaterialSealMapper;

    /**
     * 查询材料封样
     * 
     * @param id 材料封样主键
     * @return 材料封样
     */
    @Override
    public SurProjectMaterialSeal selectSurProjectMaterialSealById(Long id)
    {
        return surProjectMaterialSealMapper.selectSurProjectMaterialSealById(id);
    }

    /**
     * 查询材料封样列表
     * 
     * @param surProjectMaterialSeal 材料封样
     * @return 材料封样
     */
    @Override
    public List<SurProjectMaterialSeal> selectSurProjectMaterialSealList(SurProjectMaterialSeal surProjectMaterialSeal)
    {
        return surProjectMaterialSealMapper.selectSurProjectMaterialSealList(surProjectMaterialSeal);
    }

    /**
     * 新增材料封样
     * 
     * @param surProjectMaterialSeal 材料封样
     * @return 结果
     */
    @Override
    public int insertSurProjectMaterialSeal(SurProjectMaterialSeal surProjectMaterialSeal)
    {
        surProjectMaterialSeal.setIsDel(PublicStateEnum.OK.getCode());
        surProjectMaterialSeal.setMainImage(surProjectMaterialSeal.getImageUrls().split(",")[0]);
        surProjectMaterialSeal.setCreateBy(SecurityUtils.getUsername());
        surProjectMaterialSeal.setCreateTime(DateUtils.getNowDate());
        return surProjectMaterialSealMapper.insertSurProjectMaterialSeal(surProjectMaterialSeal);
    }

    /**
     * 修改材料封样
     * 
     * @param surProjectMaterialSeal 材料封样
     * @return 结果
     */
    @Override
    public int updateSurProjectMaterialSeal(SurProjectMaterialSeal surProjectMaterialSeal)
    {
        surProjectMaterialSeal.setMainImage(surProjectMaterialSeal.getImageUrls().split(",")[0]);
        surProjectMaterialSeal.setUpdateBy(SecurityUtils.getUsername());
        surProjectMaterialSeal.setUpdateTime(DateUtils.getNowDate());
        return surProjectMaterialSealMapper.updateSurProjectMaterialSeal(surProjectMaterialSeal);
    }

    /**
     * 批量删除材料封样
     * 
     * @param ids 需要删除的材料封样主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectMaterialSealByIds(Long[] ids)
    {
        return surProjectMaterialSealMapper.deleteSurProjectMaterialSealByIds(ids);
    }

    /**
     * 删除材料封样信息
     * 
     * @param id 材料封样主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectMaterialSealById(Long id)
    {
        return surProjectMaterialSealMapper.deleteSurProjectMaterialSealById(id);
    }
}
