基础包新增count统计方法

This commit is contained in:
lhc
2021-04-27 14:34:28 +08:00
parent f3370b820e
commit 942a15f48d
5 changed files with 15 additions and 3 deletions

View File

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

View File

@@ -124,4 +124,6 @@ public interface BaseMapper {
Long count(String tableName, Condition condition);
Long count(Condition condition);
}

View File

@@ -604,6 +604,11 @@ public class BaseMapperImpl implements BaseMapper {
return tableMapper.count(tableName,condition.getSql());
}
@Override
public Long count(Condition condition) {
return tableMapper.countBySql(condition.getSql());
}
public void JudgesNull(Object object, String str) {
if (object == null) {
throw new BaseMapperException(str);

View File

@@ -44,7 +44,7 @@ public class AuthFilter extends AuthenticatingFilter {
httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with, X-Access-Token, datasource-Key");
httpResponse.setHeader("Access-Control-Allow-Origin", myOrigin);
httpResponse.setCharacterEncoding("UTF-8");
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("code", 3);
result.put("msg", "未登陆");
String json = JSON.toJSONString(result);
@@ -86,7 +86,7 @@ public class AuthFilter extends AuthenticatingFilter {
httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with, X-Access-Token, datasource-Key");
httpResponse.setHeader("Access-Control-Allow-Origin", myOrigin);
httpResponse.setCharacterEncoding("UTF-8");
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("code", 3);
result.put("msg", "未登陆");
String json = JSON.toJSONString(result);
@@ -117,7 +117,7 @@ public class AuthFilter extends AuthenticatingFilter {
try {
//处理登录失败的异常
Throwable throwable = e.getCause() == null ? e : e.getCause();
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("code", 3);
result.put("msg", "未登陆");
String json = JSON.toJSONString(result);

View File

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