SmartUserRelationServiceImpl.java 2.27 KB
package com.glsx.smart.service.impl;

import javax.annotation.Resource;
import java.util.List;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.dao.mapper.SmartUserRelationMapper;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartUserRelationService;
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 SmartUserRelationServiceImpl implements SmartUserRelationService {
    @Resource
    private SmartUserRelationMapper smartUserRelationMapper;

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

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

    @Override
    public int insertSelective(SmartUserRelation record) {
        return smartUserRelationMapper.insertSelective(record);
    }

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

    @Override
    public SmartUserRelation selectByPrimaryKey(Long id) {
        return smartUserRelationMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SmartUserRelation record) {
        return smartUserRelationMapper.updateByPrimaryKeySelective(record);
    }

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

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

}