sige 1 year ago
parent
commit
f1fe9f3f3a
  1. 30
      src/main/java/com/iflytop/uf/UfActiveRecord.java

30
src/main/java/com/iflytop/uf/UfActiveRecord.java

@ -69,6 +69,18 @@ public class UfActiveRecord {
}
}
// 更新所有
public static <T extends UfActiveRecord> Integer updateAll(
Class<T> modelClass,
Map<String,Object> data,
Map<String,Object> conditions
) {
var context = UfApplication.getContext();
UfActiveRecordMapper mapper = context.getBean(UfActiveRecordMapper.class);
String tableName = UfActiveRecord.getTableNameFromModelClass(modelClass);
return mapper.updateAll(tableName, conditions, data);
}
// find by id
public static <T extends UfActiveRecord> T findOne(Class<T> modelClass, String id) {
return UfActiveRecord.findOne(modelClass, Map.of("id", id));
@ -94,11 +106,25 @@ public class UfActiveRecord {
}
// count by criteria
public static Integer count(Class<? extends UfActiveRecord> modelClass, UfActiveRecordCriteria criteria ) {
public static Integer count(
Class<? extends UfActiveRecord> modelClass,
UfActiveRecordCriteria criteria
) {
criteria.tableName = UfActiveRecord.getTableNameFromModelClass(modelClass);
var context = UfApplication.getContext();
UfActiveRecordMapper mapper = context.getBean(UfActiveRecordMapper.class);
return mapper.count(criteria);
return mapper.count(criteria.tableName, criteria.conditions);
}
// count by conditions
public static Integer count(
Class<? extends UfActiveRecord> modelClass,
Map<String,Object> conditions
) {
String tableName = UfActiveRecord.getTableNameFromModelClass(modelClass);
var context = UfApplication.getContext();
UfActiveRecordMapper mapper = context.getBean(UfActiveRecordMapper.class);
return mapper.count(tableName, conditions);
}
// find by conditions

Loading…
Cancel
Save