
com.baomidou.framework.service.impl.ServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-plus Show documentation
Show all versions of mybatis-plus Show documentation
An enhanced toolkit of Mybatis to simplify development.
/**
* Copyright (c) 2011-2016, hubin ([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.baomidou.framework.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.framework.service.IService;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
/**
*
* IService 实现类( 泛型:M 是 mapper 对象, T 是实体 , I 是主键泛型 )
*
*
* @author hubin
* @Date 2016-04-20
*/
public class ServiceImpl, T, I> implements IService {
@Autowired
protected M baseMapper;
/**
* 判断数据库操作是否成功
*
* @param result
* 数据库操作返回影响条数
* @return boolean
*/
protected boolean retBool( int result ) {
return (result >= 1) ? true : false;
}
public boolean insert( T entity ) {
return retBool(baseMapper.insert(entity));
}
public boolean insertSelective( T entity ) {
return retBool(baseMapper.insertSelective(entity));
}
public boolean insertBatch( List entityList ) {
return retBool(baseMapper.insertBatch(entityList));
}
public boolean deleteById( I id ) {
return retBool(baseMapper.deleteById(id));
}
public boolean deleteSelective( T entity ) {
return retBool(baseMapper.deleteSelective(entity));
}
public boolean deleteBatchIds( List idList ) {
return retBool(baseMapper.deleteBatchIds(idList));
}
public boolean updateById( T entity ) {
return retBool(baseMapper.updateById(entity));
}
public boolean updateSelectiveById( T entity ) {
return retBool(baseMapper.updateSelectiveById(entity));
}
public boolean update( T entity, T whereEntity ) {
return retBool(baseMapper.update(entity, whereEntity));
}
public boolean updateSelective( T entity, T whereEntity ) {
return retBool(baseMapper.updateSelective(entity, whereEntity));
}
public boolean updateBatchById(List entityList) {
return retBool(baseMapper.updateBatchById(entityList));
}
public T selectById( I id ) {
return baseMapper.selectById(id);
}
public List selectBatchIds( List idList ) {
return baseMapper.selectBatchIds(idList);
}
public T selectOne( T entity ) {
return baseMapper.selectOne(entity);
}
public int selectCount(T entity) {
return baseMapper.selectCount(entity);
}
public List selectList( T entity, String orderByField ) {
return baseMapper.selectList(new EntityWrapper(entity, orderByField));
}
public List selectList( T entity ) {
return baseMapper.selectList(new EntityWrapper(entity, null));
}
public Page selectPage( Page page, T entity, String orderByField ) {
page.setRecords(baseMapper.selectPage(page, new EntityWrapper(entity, orderByField)));
return page;
}
public Page selectPage( Page page, T entity ) {
page.setRecords(baseMapper.selectPage(page, new EntityWrapper(entity, null)));
return page;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy