Skip to content

Commit

Permalink
3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shimingxy committed Jul 10, 2024
1 parent 5913b78 commit 3a7818e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.dromara.mybatis.jpa.query.LambdaQuery;
import org.dromara.mybatis.jpa.query.Query;
import org.dromara.mybatis.jpa.spring.MybatisJpaContext;
import org.dromara.mybatis.jpa.util.BeanUtil;
import org.dromara.mybatis.jpa.util.InstanceUtil;
import org.dromara.mybatis.jpa.util.StrUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -73,8 +72,8 @@ public JpaService() {}
* Load mapperClass by class type
* @param cls
*/
@SuppressWarnings("unchecked")
public JpaService(@SuppressWarnings("rawtypes") Class cls) {
@SuppressWarnings({ "unchecked" })
public JpaService(Class<?> cls) {
logger.trace("class name : {}" , cls.getSimpleName());
mapperClass = cls.getSimpleName();
Type[] pType = ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments();
Expand Down Expand Up @@ -209,7 +208,6 @@ public JpaPageResults<T> fetchPageResults(String mapperId,JpaPage page ,T entity
return null;
}


/**
* select with filter and args
*
Expand Down Expand Up @@ -415,7 +413,6 @@ public List<T> query(T entity) {
return Collections.emptyList();
}



/**
* query list entity by Query
Expand All @@ -431,8 +428,6 @@ public List<T> query(Query query) {
return Collections.emptyList();
}



/**
* query list entity by LambdaQuery
* @param entity
Expand All @@ -447,7 +442,6 @@ public List<T> query(LambdaQuery<T> lambdaQuery) {
return Collections.emptyList();
}


//follow function for insert update and delete
/**
* insert new entity
Expand All @@ -472,7 +466,7 @@ public boolean insert(T entity) {
*/
public boolean insertBatch(List<T> listEntity){
try {
if(BeanUtil.isNotNull(listEntity)) {
if(CollectionUtils.isNotEmpty(listEntity)) {
Integer count = 0;
for(T entity : listEntity) {
if(getMapper().insert(entity)>0) {
Expand Down Expand Up @@ -504,7 +498,7 @@ public boolean persist(T entity) {
*/
public boolean merge(T entity) {
List<T> resultList = query(entity);
if(resultList == null || resultList.isEmpty()) {
if(CollectionUtils.isEmpty(resultList)) {
return insert(entity);
}else {
return update(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@


package org.dromara.mybatis.jpa.id;

/*
* snowflakeid(default) and uuid
*/
public class IdStrategy {

/**
* uuid
*/
public static final String UUID = "uuid";

/**
* snowflakeid
*/
public static final String SNOWFLAKEID = "snowflakeid";

/**
* as snowflakeid
*/
public static final String DEFAULT = "default";

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.PropertyAccessorFactory;
Expand Down Expand Up @@ -72,11 +70,6 @@ public static Object getValue(Object bean,String field ) {
return null;
}

@SuppressWarnings("rawtypes")
public static boolean isNotNull(Collection collection) {
return CollectionUtils.isNotEmpty(collection);
}

@SuppressWarnings("rawtypes")
public static boolean isNotNull(Map map) {
return (map != null && map.size() > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class StringGenerator {

public static final char[] DEFAULT_CODE_NUMBER_LETTERS = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();

private static final String uuidRegex = "^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$";
private static final String UUID_REGEX = "^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$";

private Random random = new SecureRandom();

Expand Down Expand Up @@ -147,7 +147,7 @@ public void setCodec(char[] codec) {
}

public static boolean uuidMatches(String uuidString) {
return uuidString.matches(uuidRegex);
return uuidString.matches(UUID_REGEX);
}

}

0 comments on commit 3a7818e

Please sign in to comment.