chenjiahe
2023-02-07 1b181507f2564bfd327cc3a8e5d75a8620c3d09d
src/main/java/com/hx/common/service/impl/CommonDaoImpl.java
@@ -1,7 +1,7 @@
package com.hx.common.service.impl;
import com.hx.common.dao.CommonDao;
import com.hx.mybatisTool.SqlParam;
import com.hx.common.dao.mapper.CommonMapper;
import com.hx.mybatisTool.SqlSentence;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
@@ -29,10 +29,23 @@
        return sqlSessionFactory.openSession().insert(getStatement(mapperClass,"insert"),entity);
    }
    /**获取条数*/
    @Override
    public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlParam sqlParam) {
        return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCount"),sqlParam);
    public <T extends Serializable> int insertById(Class<?> mapperClass, T entity) {
        return sqlSessionFactory.openSession().insert(getStatement(mapperClass,"insertById"),entity);
    }
    /**获取条数
     * @return*/
    @Override
    public <T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCount"),sqlSentence);
    }
    /**获取条数
     * @return*/
    @Override
    public <T extends Serializable> int selectCountSql(Class<?> mapperClass, SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCountSql"),sqlSentence);
    }
    /**获取列表*/
@@ -73,8 +86,8 @@
    /**更新*/
    @Override
    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlParam sqlParam) {
        return sqlSessionFactory.openSession().update(getStatement(mapperClass,"updateWhere"),sqlParam);
    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().update(getStatement(mapperClass,"updateWhere"),sqlSentence);
    }
    /**全部字段更新*/
@@ -85,8 +98,8 @@
    /**删除*/
    @Override
    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlParam sqlParam) {
        return sqlSessionFactory.openSession().delete(getStatement(mapperClass,"deleteWhere"),sqlParam);
    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().delete(getStatement(mapperClass,"deleteWhere"),sqlSentence);
    }
    /**删除*/
@@ -95,4 +108,16 @@
        return sqlSessionFactory.openSession().delete(getStatement(mapperClass,"deleteById"),object);
    }
    /**更新sql语句(全语句)*/
    @Override
    public <T extends Serializable> int updateSentence(SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().update(getStatement(CommonMapper.class,"updateSentence"),sqlSentence);
    }
    /**查询条数(全语句)*/
    @Override
    public <T extends Serializable> int selectCountSql(SqlSentence sqlSentence) {
        return sqlSessionFactory.openSession().selectOne(getStatement(CommonMapper.class,"selectCountSql"),sqlSentence);
    }
}