add
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
package com.qiaoba.common.base.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* 对象工具类
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/5/18 14:59
|
||||
*/
|
||||
public class ObjectUtil {
|
||||
|
||||
/**
|
||||
* 判断对象所有属性是否都为空
|
||||
*
|
||||
* @param obj obj
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isAllFieldNull(Object obj) {
|
||||
// 得到类对象
|
||||
Class clazz = (Class) obj.getClass();
|
||||
//得到属性集合
|
||||
Field[] fs = clazz.getDeclaredFields();
|
||||
boolean flag = true;
|
||||
//遍历属性
|
||||
for (Field f : fs) {
|
||||
try {
|
||||
// 设置属性是可以访问的(私有的也可以)
|
||||
f.setAccessible(true);
|
||||
// 得到此属性的值
|
||||
Object val = f.get(obj);
|
||||
// 只要有1个属性不为空,那么就不是所有的属性值都为空
|
||||
if(val != null) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}catch (IllegalAccessException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public class ExcelUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 默认导出
|
||||
*
|
||||
@ -67,8 +66,8 @@ public class ExcelUtil {
|
||||
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("content-Type" , "application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition" , "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx" , "UTF-8"));
|
||||
response.setHeader("content-Type", "application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
|
||||
workbook.write(response.getOutputStream());
|
||||
IOUtils.closeQuietly(workbook);
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user