SmartSceneServiceImpl.java 2.04 KB
package com.glsx.smart.service.impl;

import javax.annotation.Resource;
import java.util.List;
import com.glsx.smart.dao.entity.SmartScene;
import com.glsx.smart.dao.mapper.SmartSceneMapper;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartSceneService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>Description:
 * <p>Project: chejia-smart
 *
 * @author wbh
 * @date 2021-03-15
 */
@Slf4j
@Service
public class SmartSceneServiceImpl implements SmartSceneService {
    @Resource
    private SmartSceneMapper smartSceneMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return smartSceneMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertOrUpdate(SmartScene scene) {
        if (scene.getId() == null) {
            return smartSceneMapper.insertSelective(scene);
        } else {
            SmartScene record = smartSceneMapper.selectByPrimaryKey(scene.getId());
            if (record != null) {
                return smartSceneMapper.updateByPrimaryKeySelective(scene);
            } else {
                throw new BusinessException(ResultEnum.ID_NOT_FOUND);
            }
        }
    }

    @Override
    public int insertSelective(SmartScene scene) {
        return smartSceneMapper.insertSelective(scene);
    }

    @Override
    public List<SmartScene> selectByExample(SmartScene example) {
        return smartSceneMapper.select(example);
    }

    @Override
    public SmartScene selectByPrimaryKey(Long id) {
        return smartSceneMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SmartScene record) {
        return smartSceneMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateBatchSelective(List<SmartScene> list) {
        return smartSceneMapper.updateBatchSelective(list);
    }

    @Override
    public int batchInsert(List<SmartScene> list) {
        return smartSceneMapper.batchInsert(list);
    }

}