All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.somta.core.base.BaseServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package net.somta.core.base;

import net.somta.core.exception.BizException;
import net.somta.core.protocol.ResponseDataResult;
import net.somta.core.protocol.ResponsePaginationDataResult;

import java.util.List;

import static net.somta.core.enums.SystemErrorEnum.*;

public abstract class BaseServiceImpl implements IBaseService {

    @Override
    public abstract IBaseMapper getMapper();

    @Override
    public  ResponseDataResult add(T t){
        if(getMapper().add(t) < 0){
            throw new BizException(BASE_ADD_ERROR);
        }
        return ResponseDataResult.setResponseResult();
    }

    @Override
    public ResponseDataResult deleteById(Object id){
        if(getMapper().deleteById(id) < 0){
            throw new BizException(BASE_DELETE_BY_ID_ERROR);
        }
        return ResponseDataResult.setResponseResult();
    }

    @Override
    public  ResponseDataResult update(T t){
        if(getMapper().update(t) < 0){
            throw new BizException(BASE_UPDATE_ERROR);
        }
        return ResponseDataResult.setResponseResult();
    }

    @Override
    public  T queryById(Object id){
        return getMapper().queryById(id);
    }

    @Override
    public  List queryByList(Object param){
        List list = getMapper().queryByList(param);
        return list;
    }

    @Override
    public Long queryListCount(Object param){
        return getMapper().queryListCount(param);
    }

    @Override
    public  ResponsePaginationDataResult queryByPageList(Integer pageNum, Integer pageSize, Object param){
        Long count = getMapper().queryListCount(param);
        if(count > 0){
            List list = getMapper().queryByList(param);
            return ResponsePaginationDataResult.setPaginationDataResult(count,list);
        }
        return ResponsePaginationDataResult.setPaginationDataResult(0L,null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy