修复长整形问题,基础包新增count方法

This commit is contained in:
lhc
2021-04-01 09:05:08 +08:00
parent 5326d6fdfc
commit 1e32b137e2
5 changed files with 16 additions and 3 deletions

View File

@@ -44,4 +44,6 @@ public interface TableMapper {
Object getSequence(@Param("tableName") String tableName);
int createSequence(@Param("tableName") String tableName, @Param("lastId")Object lastId);
Long count(@Param("tableName")String tableName,@Param("sql")String sql);
}

View File

@@ -122,4 +122,6 @@ public interface BaseMapper {
Map<String, Object> selectOneSql(String sql);
Long count(String tableName, Condition condition);
}

View File

@@ -199,9 +199,7 @@ public class BaseMapperImpl implements BaseMapper {
Condition condition = Condition.creatCriteria()
.andIn(dataMap.getPkName(), dataMap.getIdList())
.build();
int i = tableMapper.updateByWhere(dataMap.getData(), dataMap.getTableName(), condition.getSql());
SqlException.base(i, "更新失败");
return i;
return tableMapper.updateByWhere(dataMap.getData(), dataMap.getTableName(), condition.getSql());
}
@Override
@@ -601,6 +599,11 @@ public class BaseMapperImpl implements BaseMapper {
return tableMapper.userSqlByOne(sql);
}
@Override
public Long count(String tableName, Condition condition) {
return tableMapper.count(tableName,condition.getSql());
}
public void JudgesNull(Object object, String str) {
if (object == null) {
throw new BaseMapperException(str);

View File

@@ -251,6 +251,9 @@ public class Condition implements Serializable {
public ConditionBuilder equal(String key, Object value) {
sqlCheck(value);
if (value.toString().contains("\"")) {
value = value.toString().replaceAll("\"", "");
}
this.conditionSql += " " + key + EQUAL + "'" + value + "'";
return this;
}

View File

@@ -164,4 +164,7 @@
select ${tableName}_seq.nextval
from dual
</select>
<select id="count" resultType="java.lang.Long">
SELECT count(0) FROM ${tableName} ${sql}
</select>
</mapper>