mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-11-04 09:01:40 +08:00 
			
		
		
		
	refactor: 优化部分代码
修复 Sonar、Codacy 扫描问题
This commit is contained in:
		@@ -65,7 +65,6 @@ public class IpUtils {
 | 
				
			|||||||
     * @return 是否为内网 IP
 | 
					     * @return 是否为内网 IP
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static boolean isInnerIp(String ip) {
 | 
					    public static boolean isInnerIp(String ip) {
 | 
				
			||||||
        ip = "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip);
 | 
					        return NetUtil.isInnerIP("0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip));
 | 
				
			||||||
        return NetUtil.isInnerIP(ip);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
 | 
				
			|||||||
import java.util.Collections;
 | 
					import java.util.Collections;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.util.StrUtil;
 | 
				
			||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 | 
					import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 | 
				
			||||||
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
 | 
					import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -67,13 +68,14 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
 | 
				
			|||||||
            Method[] methodArr = clazz.getMethods();
 | 
					            Method[] methodArr = clazz.getMethods();
 | 
				
			||||||
            for (Method method : methodArr) {
 | 
					            for (Method method : methodArr) {
 | 
				
			||||||
                DataPermission dataPermission = method.getAnnotation(DataPermission.class);
 | 
					                DataPermission dataPermission = method.getAnnotation(DataPermission.class);
 | 
				
			||||||
                if (null != dataPermission && (method.getName().equals(methodName) || (method.getName() + "_COUNT")
 | 
					                String name = method.getName();
 | 
				
			||||||
                    .equals(methodName))) {
 | 
					                if (null == dataPermission || !StrUtil.equalsAny(methodName, name, name + "_COUNT")) {
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                if (dataPermissionFilter.isFilter()) {
 | 
					                if (dataPermissionFilter.isFilter()) {
 | 
				
			||||||
                    return buildDataScopeFilter(dataPermission, where);
 | 
					                    return buildDataScopeFilter(dataPermission, where);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } catch (ClassNotFoundException e) {
 | 
					        } catch (ClassNotFoundException e) {
 | 
				
			||||||
            log.error("Data permission handler build data scope filter occurred an error: {}.", e.getMessage(), e);
 | 
					            log.error("Data permission handler build data scope filter occurred an error: {}.", e.getMessage(), e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -227,7 +229,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private Column buildColumn(String tableAlias, String columnName) {
 | 
					    private Column buildColumn(String tableAlias, String columnName) {
 | 
				
			||||||
        if (StringUtils.isNotEmpty(tableAlias)) {
 | 
					        if (StringUtils.isNotEmpty(tableAlias)) {
 | 
				
			||||||
            columnName = String.format("%s.%s", tableAlias, columnName);
 | 
					            return new Column(String.format("%s.%s", tableAlias, columnName));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return new Column(columnName);
 | 
					        return new Column(columnName);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,10 +70,9 @@ public class ExcelUtils {
 | 
				
			|||||||
                                  Class<T> clazz,
 | 
					                                  Class<T> clazz,
 | 
				
			||||||
                                  HttpServletResponse response) {
 | 
					                                  HttpServletResponse response) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            fileName = String.format("%s_%s.xlsx", fileName, DateUtil
 | 
					            String exportFileName = URLUtil.encode(String.format("%s_%s.xlsx", fileName, DateUtil
 | 
				
			||||||
                .format(new Date(), DatePattern.PURE_DATETIME_PATTERN));
 | 
					                .format(new Date(), DatePattern.PURE_DATETIME_PATTERN)));
 | 
				
			||||||
            fileName = URLUtil.encode(fileName);
 | 
					            response.setHeader("Content-disposition", "attachment;filename=" + exportFileName);
 | 
				
			||||||
            response.setHeader("Content-disposition", "attachment;filename=" + fileName);
 | 
					 | 
				
			||||||
            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
 | 
					            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
 | 
				
			||||||
            EasyExcel.write(response.getOutputStream(), clazz)
 | 
					            EasyExcel.write(response.getOutputStream(), clazz)
 | 
				
			||||||
                .autoCloseStream(false)
 | 
					                .autoCloseStream(false)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user