package com.zcxk.charge.web.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcxk.charge.core.dao.SceneImageMapper;
import com.zcxk.charge.core.entity.SceneImageEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 场景图片信息Service接口
 *
 * @author: WYY
 * @date 2020-11-17 22:38
 */
@Service
public class SceneImageService extends ServiceImpl<SceneImageMapper, SceneImageEntity> {

    @Resource
    private SceneImageMapper sceneImageMapper;

    /**
     * 查列表
     */
    public List<SceneImageEntity> findList(SceneImageEntity sceneImageEntity) {
        return sceneImageMapper.findList(sceneImageEntity);
    }

    /**
     * 批量删除
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean delSceneImageByIds(Long[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    /**
     * 单个删除
     */
    public boolean delSceneImageById(Long id) {
        return this.removeById(id);
    }

    /**
     * 保存
     */
    public boolean addSceneImage(SceneImageEntity sceneImage) {
        if (this.save(sceneImage)) {
            return true;
        }
        return false;
    }

    /**
     * 修改根居ID
     */
    public boolean updateSceneImageById(SceneImageEntity sceneImage) {
        if (this.updateById(sceneImage)) {
            return true;
        }
        return false;
    }
    public int updateBySceneId(@Param("id")Long id)
    {
       return sceneImageMapper.updateBySceneId(id);
    }
    /**
     * 根居ID获取对象
     */
    public SceneImageEntity findSceneImageById(Long id) {
        return sceneImageMapper.findSceneImageById(id);
    }
}
