You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
605 B

package cn.teammodel.utils;
import cn.teammodel.common.ErrorCode;
import cn.teammodel.config.exception.ServiceException;
import org.apache.commons.lang3.ObjectUtils;
import java.util.List;
/**
* @author winter
* @create 2023-11-29 15:41
*/
public class RepositoryUtil {
/**
* ,listlist1,
*/
public static <T> T findOne(List<T> list) {
if (ObjectUtils.isEmpty(list) || list.size() > 1) {
throw new ServiceException(ErrorCode.PARAMS_ERROR);
}
return list.get(0);
}
}