diff --git a/src/main/java/com/archive/common/constant/GenConstants.java b/src/main/java/com/archive/common/constant/GenConstants.java index ae28476..79eaff8 100644 --- a/src/main/java/com/archive/common/constant/GenConstants.java +++ b/src/main/java/com/archive/common/constant/GenConstants.java @@ -1,82 +1,82 @@ -/* */ package com.archive.common.constant; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class GenConstants -/* */ { -/* */ public static final String TPL_CRUD = "crud"; -/* */ public static final String TPL_TREE = "tree"; -/* */ public static final String TPL_SUB = "sub"; -/* */ public static final String TREE_CODE = "treeCode"; -/* */ public static final String TREE_PARENT_CODE = "treeParentCode"; -/* */ public static final String TREE_NAME = "treeName"; -/* */ public static final String PARENT_MENU_ID = "parentMenuId"; -/* */ public static final String PARENT_MENU_NAME = "parentMenuName"; -/* 35 */ public static final String[] COLUMNTYPE_STR = new String[] { "char", "varchar", "nvarchar", "varchar2" }; -/* */ -/* */ -/* 38 */ public static final String[] COLUMNTYPE_TEXT = new String[] { "tinytext", "text", "mediumtext", "longtext" }; -/* */ -/* */ -/* 41 */ public static final String[] COLUMNTYPE_TIME = new String[] { "datetime", "time", "date", "timestamp" }; -/* */ -/* */ -/* 44 */ public static final String[] COLUMNTYPE_NUMBER = new String[] { "tinyint", "smallint", "mediumint", "int", "number", "integer", "bit", "bigint", "float", "double", "decimal" }; -/* */ -/* */ -/* */ -/* 48 */ public static final String[] COLUMNNAME_NOT_EDIT = new String[] { "id", "create_by", "create_time", "del_flag" }; -/* */ -/* */ -/* 51 */ public static final String[] COLUMNNAME_NOT_LIST = new String[] { "id", "create_by", "create_time", "del_flag", "update_by", "update_time" }; -/* */ -/* */ -/* */ -/* 55 */ public static final String[] COLUMNNAME_NOT_QUERY = new String[] { "id", "create_by", "create_time", "del_flag", "update_by", "update_time", "remark" }; -/* */ -/* */ -/* */ -/* 59 */ public static final String[] BASE_ENTITY = new String[] { "createBy", "createTime", "updateBy", "updateTime", "remark" }; -/* */ -/* */ -/* 62 */ public static final String[] TREE_ENTITY = new String[] { "parentName", "parentId", "orderNum", "ancestors" }; -/* */ public static final String HTML_INPUT = "input"; -/* */ public static final String HTML_TEXTAREA = "textarea"; -/* */ public static final String HTML_SELECT = "select"; -/* */ public static final String HTML_RADIO = "radio"; -/* */ public static final String HTML_CHECKBOX = "checkbox"; -/* */ public static final String HTML_DATETIME = "datetime"; -/* */ public static final String HTML_UPLOAD = "upload"; -/* */ public static final String HTML_SUMMERNOTE = "summernote"; -/* */ public static final String TYPE_STRING = "String"; -/* */ public static final String TYPE_INTEGER = "Integer"; -/* */ public static final String TYPE_LONG = "Long"; -/* */ public static final String TYPE_DOUBLE = "Double"; -/* */ public static final String TYPE_BIGDECIMAL = "BigDecimal"; -/* */ public static final String TYPE_DATE = "Date"; -/* */ public static final String QUERY_LIKE = "LIKE"; -/* */ public static final String REQUIRE = "1"; -/* */ } + package com.archive.common.constant; + + + + + + + + + + + + + + + + + + + + + + + + public class GenConstants + { + public static final String TPL_CRUD = "crud"; + public static final String TPL_TREE = "tree"; + public static final String TPL_SUB = "sub"; + public static final String TREE_CODE = "treeCode"; + public static final String TREE_PARENT_CODE = "treeParentCode"; + public static final String TREE_NAME = "treeName"; + public static final String PARENT_MENU_ID = "parentMenuId"; + public static final String PARENT_MENU_NAME = "parentMenuName"; + public static final String[] COLUMNTYPE_STR = new String[] { "char", "varchar", "nvarchar", "varchar2" }; + + + public static final String[] COLUMNTYPE_TEXT = new String[] { "tinytext", "text", "mediumtext", "longtext" }; + + + public static final String[] COLUMNTYPE_TIME = new String[] { "datetime", "time", "date", "timestamp" }; + + + public static final String[] COLUMNTYPE_NUMBER = new String[] { "tinyint", "smallint", "mediumint", "int", "number", "integer", "bit", "bigint", "float", "double", "decimal" }; + + + + public static final String[] COLUMNNAME_NOT_EDIT = new String[] { "id", "create_by", "create_time", "del_flag" }; + + + public static final String[] COLUMNNAME_NOT_LIST = new String[] { "id", "create_by", "create_time", "del_flag", "update_by", "update_time" }; + + + + public static final String[] COLUMNNAME_NOT_QUERY = new String[] { "id", "create_by", "create_time", "del_flag", "update_by", "update_time", "remark" }; + + + + public static final String[] BASE_ENTITY = new String[] { "createBy", "createTime", "updateBy", "updateTime", "remark" }; + + + public static final String[] TREE_ENTITY = new String[] { "parentName", "parentId", "orderNum", "ancestors" }; + public static final String HTML_INPUT = "input"; + public static final String HTML_TEXTAREA = "textarea"; + public static final String HTML_SELECT = "select"; + public static final String HTML_RADIO = "radio"; + public static final String HTML_CHECKBOX = "checkbox"; + public static final String HTML_DATETIME = "datetime"; + public static final String HTML_UPLOAD = "upload"; + public static final String HTML_SUMMERNOTE = "summernote"; + public static final String TYPE_STRING = "String"; + public static final String TYPE_INTEGER = "Integer"; + public static final String TYPE_LONG = "Long"; + public static final String TYPE_DOUBLE = "Double"; + public static final String TYPE_BIGDECIMAL = "BigDecimal"; + public static final String TYPE_DATE = "Date"; + public static final String QUERY_LIKE = "LIKE"; + public static final String REQUIRE = "1"; + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\constant\GenConstants.class diff --git a/src/main/java/com/archive/common/convert/HtmlToPdf.java b/src/main/java/com/archive/common/convert/HtmlToPdf.java index 9fbd31c..8d13169 100644 --- a/src/main/java/com/archive/common/convert/HtmlToPdf.java +++ b/src/main/java/com/archive/common/convert/HtmlToPdf.java @@ -1,53 +1,53 @@ -/* */ package com.archive.common.convert; + package com.archive.common.convert; -/* */ -/* */ import java.io.File; -/* */ import java.io.FileOutputStream; -/* */ import java.io.OutputStream; -/* */ import org.xhtmlrenderer.pdf.ITextFontResolver; -/* */ import org.xhtmlrenderer.pdf.ITextRenderer; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class HtmlToPdf -/* */ { -/* */ public static void html2pdf(String htmlFile, String pdfFile) throws Exception { -/* 21 */ String url = (new File(htmlFile)).toURI().toURL().toString(); -/* 22 */ System.out.println(url); -/* */ -/* 24 */ OutputStream os = new FileOutputStream(pdfFile); -/* 25 */ ITextRenderer renderer = new ITextRenderer(); -/* 26 */ renderer.setDocument(url); -/* */ -/* */ -/* 29 */ ITextFontResolver fontResolver = renderer.getFontResolver(); -/* 30 */ if ("linux".equals(getCurrentOperatingSystem())) { -/* 31 */ fontResolver.addFont("/usr/share/fonts/chiness/simsun.ttc", "Identity-H", true); -/* */ } else { -/* 33 */ fontResolver.addFont("c:/Windows/Fonts/simsun.ttc", "Identity-H", false); -/* */ } -/* */ -/* 36 */ renderer.layout(); -/* 37 */ renderer.createPDF(os); -/* 38 */ os.close(); -/* */ -/* 40 */ System.out.println("create pdf done!!"); -/* */ } -/* */ -/* */ -/* */ public static String getCurrentOperatingSystem() { -/* 45 */ String os = System.getProperty("os.name").toLowerCase(); -/* 46 */ System.out.println("---------当前操作系统是-----------" + os); -/* 47 */ return os; -/* */ } -/* */ } + + import java.io.File; + import java.io.FileOutputStream; + import java.io.OutputStream; + import org.xhtmlrenderer.pdf.ITextFontResolver; + import org.xhtmlrenderer.pdf.ITextRenderer; + + + + + + + + + + + public class HtmlToPdf + { + public static void html2pdf(String htmlFile, String pdfFile) throws Exception { + String url = (new File(htmlFile)).toURI().toURL().toString(); + System.out.println(url); + + OutputStream os = new FileOutputStream(pdfFile); + ITextRenderer renderer = new ITextRenderer(); + renderer.setDocument(url); + + + ITextFontResolver fontResolver = renderer.getFontResolver(); + if ("linux".equals(getCurrentOperatingSystem())) { + fontResolver.addFont("/usr/share/fonts/chiness/simsun.ttc", "Identity-H", true); + } else { + fontResolver.addFont("c:/Windows/Fonts/simsun.ttc", "Identity-H", false); + } + + renderer.layout(); + renderer.createPDF(os); + os.close(); + + System.out.println("create pdf done!!"); + } + + + public static String getCurrentOperatingSystem() { + String os = System.getProperty("os.name").toLowerCase(); + System.out.println("---------当前操作系统是-----------" + os); + return os; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\convert\HtmlToPdf.class diff --git a/src/main/java/com/archive/common/convert/ImgConvert.java b/src/main/java/com/archive/common/convert/ImgConvert.java index e49447d..8eb995c 100644 --- a/src/main/java/com/archive/common/convert/ImgConvert.java +++ b/src/main/java/com/archive/common/convert/ImgConvert.java @@ -1,393 +1,393 @@ -/* */ package com.archive.common.convert; + package com.archive.common.convert; -/* */ -/* */ import com.lowagie.text.Document; -/* */ import com.lowagie.text.Element; -/* */ import com.lowagie.text.Image; -/* */ import com.lowagie.text.Rectangle; -/* */ import com.lowagie.text.pdf.PdfWriter; -/* */ import java.awt.AlphaComposite; -/* */ import java.awt.Color; -/* */ import java.awt.Font; -/* */ import java.awt.Graphics; -/* */ import java.awt.Graphics2D; -/* */ -/* */ import java.awt.RenderingHints; -/* */ import java.awt.image.BufferedImage; -/* */ import java.io.File; -/* */ import java.io.FileOutputStream; -/* */ import java.io.IOException; -/* */ import java.text.DecimalFormat; -/* */ import java.util.ArrayList; -/* */ import java.util.Arrays; -/* */ import javax.imageio.ImageIO; -/* */ import javax.swing.ImageIcon; -/* */ -/* */ public class ImgConvert -/* */ { -/* */ public static void ImagesToPdf(String imageFolderPath, String pdfPath) { -/* */ try { -/* 29 */ long start = System.currentTimeMillis(); -/* 30 */ ArrayList list = new ArrayList<>(); -/* */ -/* 32 */ String imagePath = null; -/* 33 */ FileOutputStream fos = new FileOutputStream(pdfPath); -/* */ -/* 35 */ Document doc = new Document(null, 20.0F, 20.0F, 20.0F, 20.0F); -/* */ -/* 37 */ PdfWriter.getInstance(doc, fos); -/* */ -/* */ -/* */ -/* */ -/* */ -/* 43 */ File file = new File(imageFolderPath); -/* 44 */ File[] files = file.listFiles(); -/* */ -/* 46 */ for (File file1 : files) { -/* 47 */ if (file1.getName().endsWith(".png") || file1.getName().endsWith(".jpg") || file1.getName().endsWith(".gif") || file1 -/* 48 */ .getName().endsWith(".jpeg") || file1.getName().endsWith(".tif")) { -/* 49 */ imagePath = imageFolderPath + File.separator + file1.getName(); -/* 50 */ list.add(file1.getName()); -/* */ -/* 52 */ BufferedImage img = ImageIO.read(new File(imagePath)); -/* */ -/* 54 */ doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); -/* */ -/* 56 */ Image image = Image.getInstance(imagePath); -/* */ -/* 58 */ doc.open(); -/* 59 */ doc.add((Element)image); -/* */ } -/* */ } -/* */ -/* */ -/* 64 */ doc.close(); -/* 65 */ long endTime = System.currentTimeMillis(); -/* 66 */ int time = (int)((endTime - start) / 1000L); -/* 67 */ System.out.println("用时:{" + time + "}:秒!"); -/* 68 */ } catch (Exception e) { -/* 69 */ e.printStackTrace(); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void ImgToPdf(String imagePath, String pdfPath) { -/* */ try { -/* 81 */ long start = System.currentTimeMillis(); -/* 82 */ ArrayList list = new ArrayList<>(); -/* */ -/* */ -/* 85 */ FileOutputStream fos = new FileOutputStream(pdfPath); -/* */ -/* 87 */ Document doc = new Document(null, 20.0F, 20.0F, 20.0F, 20.0F); -/* */ -/* 89 */ PdfWriter.getInstance(doc, fos); -/* */ -/* */ -/* */ -/* */ -/* */ -/* 95 */ BufferedImage img = ImageIO.read(new File(imagePath)); -/* */ -/* 97 */ doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); -/* */ -/* 99 */ Image image = Image.getInstance(imagePath); -/* */ -/* 101 */ doc.open(); -/* 102 */ doc.add((Element)image); -/* */ -/* */ -/* */ -/* 106 */ doc.close(); -/* 107 */ long endTime = System.currentTimeMillis(); -/* 108 */ int time = (int)((endTime - start) / 1000L); -/* 109 */ System.out.println("用时:{" + time + "}:秒!"); -/* 110 */ } catch (Exception e) { -/* 111 */ e.printStackTrace(); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void PngToJpg(String pngPath, String jpgPath) { -/* */ try { -/* 125 */ BufferedImage bufferedImage = ImageIO.read(new File(pngPath)); -/* 126 */ BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), 1); -/* 127 */ newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.white, null); -/* 128 */ ImageIO.write(newBufferedImage, "jpg", new File(jpgPath)); -/* 129 */ } catch (Exception e) { -/* 130 */ System.out.println("ERROR:png转jpg出现异常:" + e.getMessage()); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void JpgToPng(String jpgPath, String pngPath) { -/* */ try { -/* 144 */ BufferedImage bufferedImage = ImageIO.read(new File(jpgPath)); -/* 145 */ BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), 1); -/* 146 */ newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.white, null); -/* 147 */ ImageIO.write(newBufferedImage, "png", new File(pngPath)); -/* 148 */ } catch (Exception e) { -/* 149 */ System.out.println("ERROR:jpg转png出现异常:" + e.getMessage()); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static BufferedImage waterMarkByText(int width, int heigth, String text, Color color, Font font, Double degree, float alpha) { -/* 167 */ BufferedImage buffImg = new BufferedImage(width, heigth, 1); -/* */ -/* 169 */ Graphics2D g2d = buffImg.createGraphics(); -/* */ -/* */ -/* 172 */ buffImg = g2d.getDeviceConfiguration().createCompatibleImage(width, heigth, 3); -/* 173 */ g2d.dispose(); -/* 174 */ g2d = buffImg.createGraphics(); -/* */ -/* */ -/* */ -/* 178 */ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* 186 */ if (null != degree) -/* */ { -/* */ -/* 189 */ g2d.rotate(Math.toRadians(degree.doubleValue()), buffImg.getWidth() / 2.0D, buffImg -/* 190 */ .getHeight() / 2.0D); -/* */ } -/* */ -/* */ -/* 194 */ g2d.setColor(color); -/* */ -/* */ -/* 197 */ g2d.setFont(font); -/* */ -/* */ -/* 200 */ g2d.setComposite(AlphaComposite.getInstance(3, alpha)); -/* */ -/* 202 */ float realWidth = getRealFontWidth(text); -/* 203 */ float fontSize = font.getSize(); -/* */ -/* */ -/* 206 */ float x = 0.5F * width - 0.5F * fontSize * realWidth; -/* 207 */ float y = 0.5F * heigth + 0.5F * fontSize; -/* */ -/* 209 */ g2d.drawString(text, x, y); -/* */ -/* 211 */ g2d.dispose(); -/* */ -/* 213 */ return buffImg; -/* */ } -/* */ -/* */ -/* */ -/* */ public static BufferedImage waterMarkByText(int width, int heigth, String text, Color color, float alpha) { -/* 219 */ Font font = new Font("Dialog", 0, 33); -/* 220 */ return waterMarkByText(width, heigth, text, color, font, Double.valueOf(-30.0D), alpha); -/* */ } -/* */ -/* */ public static BufferedImage waterMarkByText(int width, int heigth, String text, float alpha) { -/* 224 */ return waterMarkByText(width, heigth, text, Color.GRAY, alpha); -/* */ } -/* */ -/* */ -/* */ public static BufferedImage waterMarkByText(int width, int heigth, String text) { -/* 229 */ return waterMarkByText(width, heigth, text, 0.2F); -/* */ } -/* */ -/* */ public static BufferedImage waterMarkByText(String text) { -/* 233 */ return waterMarkByText(200, 150, text); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ private static float getRealFontWidth(String text) { -/* 240 */ int len = text.length(); -/* 241 */ float width = 0.0F; -/* 242 */ for (int i = 0; i < len; i++) { -/* 243 */ if (text.charAt(i) < 'Ā') { -/* 244 */ width += 0.5F; -/* */ } else { -/* 246 */ width++; -/* */ } -/* */ } -/* 249 */ return width; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void changeImgColor(String path, String newPath) throws IOException { -/* 263 */ File file = new File(path); -/* 264 */ BufferedImage bi = ImageIO.read(file); -/* 265 */ java.awt.Image image = bi; -/* */ -/* 267 */ ImageIcon imageIcon = new ImageIcon(image); -/* 268 */ int width = imageIcon.getIconWidth(); -/* 269 */ int height = imageIcon.getIconHeight(); -/* */ -/* 271 */ BufferedImage bufferedImage = new BufferedImage(width, height, 6); -/* 272 */ Graphics2D graphics2D = (Graphics2D)bufferedImage.getGraphics(); -/* 273 */ graphics2D.drawImage(imageIcon.getImage(), 0, 0, imageIcon.getImageObserver()); -/* 274 */ int alpha = 255; -/* */ -/* 276 */ int RGB = bufferedImage.getRGB(width - 1, height - 1); -/* 277 */ for (int i = bufferedImage.getMinX(); i < width; i++) { -/* 278 */ for (int j = bufferedImage.getMinY(); j < height; j++) { -/* 279 */ int rgb = bufferedImage.getRGB(i, j); -/* 280 */ int r = (rgb & 0xFF0000) >> 16; -/* 281 */ int g = (rgb & 0xFF00) >> 8; -/* 282 */ int b = rgb & 0xFF; -/* 283 */ int R = (RGB & 0xFF0000) >> 16; -/* 284 */ int G = (RGB & 0xFF00) >> 8; -/* 285 */ int B = RGB & 0xFF; -/* */ -/* 287 */ int a = 45; -/* 288 */ if (Math.abs(R - r) < a && Math.abs(G - g) < a && Math.abs(B - b) < a) { -/* 289 */ alpha = 0; -/* */ } else { -/* 291 */ alpha = 255; -/* */ } -/* 293 */ rgb = alpha << 24 | rgb & 0xFFFFFF; -/* 294 */ bufferedImage.setRGB(i, j, rgb); -/* */ } -/* */ } -/* 297 */ ImageIO.write(bufferedImage, "png", new File(newPath)); -/* */ } -/* */ -/* */ public static String convertRgbStr(int color) { -/* 301 */ int red = (color & 0xFF0000) >> 16; -/* 302 */ int green = (color & 0xFF00) >> 8; -/* 303 */ int blue = color & 0xFF; -/* 304 */ return red + "," + green + "," + blue; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String thumbnailImage(String imagePath, int w, int h, String prevfix, boolean force) { -/* 317 */ File imgFile = new File(imagePath); -/* 318 */ String newPath = ""; -/* 319 */ if (imgFile.exists()) { -/* */ -/* */ try { -/* 322 */ String types = Arrays.toString((Object[])ImageIO.getReaderFormatNames()); -/* 323 */ String suffix = null; -/* */ -/* 325 */ if (imgFile.getName().indexOf(".") > -1) { -/* 326 */ suffix = imgFile.getName().substring(imgFile.getName().lastIndexOf(".") + 1); -/* */ } -/* */ -/* 329 */ if (suffix == null || types.toLowerCase().indexOf(suffix.toLowerCase()) < 0) { -/* 330 */ System.out.println("Sorry, the image suffix is illegal. the standard image suffix is {}." + types); -/* 331 */ return newPath; -/* */ } -/* 333 */ System.out.println("target image's size, width:{" + w + "}, height:{" + h + "}."); -/* 334 */ java.awt.Image img = ImageIO.read(imgFile); -/* 335 */ if (!force) { -/* */ -/* 337 */ int width = img.getWidth(null); -/* 338 */ int height = img.getHeight(null); -/* 339 */ if (width * 1.0D / w < height * 1.0D / h) { -/* 340 */ if (width > w) { -/* 341 */ h = Integer.parseInt((new DecimalFormat("0")).format((height * w) / width * 1.0D)); -/* 342 */ System.out.println("change image's height, width:{" + w + "}, height:{" + h + "}."); -/* */ } -/* */ -/* 345 */ } else if (height > h) { -/* 346 */ w = Integer.parseInt((new DecimalFormat("0")).format((width * h) / height * 1.0D)); -/* 347 */ System.out.println("change image's width, width:{" + w + "}, height:{" + h + "}."); -/* */ } -/* */ } -/* */ -/* 351 */ BufferedImage bi = new BufferedImage(w, h, 1); -/* 352 */ Graphics g = bi.getGraphics(); -/* 353 */ g.drawImage(img, 0, 0, w, h, Color.LIGHT_GRAY, null); -/* 354 */ g.dispose(); -/* 355 */ String p = imgFile.getPath(); -/* */ -/* 357 */ newPath = p.substring(0, p.lastIndexOf(File.separator)) + File.separator + prevfix + imgFile.getName(); -/* 358 */ ImageIO.write(bi, suffix, new File(newPath)); -/* 359 */ System.out.println("缩略图在原路径下生成成功"); -/* 360 */ } catch (IOException e) { -/* 361 */ System.out.println("generate thumbnail image failed." + e); -/* */ } -/* */ } else { -/* 364 */ System.out.println("the image is not exist."); -/* */ } -/* 366 */ return newPath; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void main(String[] args) { -/* */ try { -/* 383 */ changeImgColor("F:\\FFOutput\\profile.png", "F:\\FFOutput\\profile1.png"); -/* 384 */ } catch (IOException e) { -/* 385 */ e.printStackTrace(); -/* */ } -/* */ } -/* */ } + + import com.lowagie.text.Document; + import com.lowagie.text.Element; + import com.lowagie.text.Image; + import com.lowagie.text.Rectangle; + import com.lowagie.text.pdf.PdfWriter; + import java.awt.AlphaComposite; + import java.awt.Color; + import java.awt.Font; + import java.awt.Graphics; + import java.awt.Graphics2D; + + import java.awt.RenderingHints; + import java.awt.image.BufferedImage; + import java.io.File; + import java.io.FileOutputStream; + import java.io.IOException; + import java.text.DecimalFormat; + import java.util.ArrayList; + import java.util.Arrays; + import javax.imageio.ImageIO; + import javax.swing.ImageIcon; + + public class ImgConvert + { + public static void ImagesToPdf(String imageFolderPath, String pdfPath) { + try { + long start = System.currentTimeMillis(); + ArrayList list = new ArrayList<>(); + + String imagePath = null; + FileOutputStream fos = new FileOutputStream(pdfPath); + + Document doc = new Document(null, 20.0F, 20.0F, 20.0F, 20.0F); + + PdfWriter.getInstance(doc, fos); + + + + + + File file = new File(imageFolderPath); + File[] files = file.listFiles(); + + for (File file1 : files) { + if (file1.getName().endsWith(".png") || file1.getName().endsWith(".jpg") || file1.getName().endsWith(".gif") || file1 + .getName().endsWith(".jpeg") || file1.getName().endsWith(".tif")) { + imagePath = imageFolderPath + File.separator + file1.getName(); + list.add(file1.getName()); + + BufferedImage img = ImageIO.read(new File(imagePath)); + + doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); + + Image image = Image.getInstance(imagePath); + + doc.open(); + doc.add((Element)image); + } + } + + + doc.close(); + long endTime = System.currentTimeMillis(); + int time = (int)((endTime - start) / 1000L); + System.out.println("用时:{" + time + "}:秒!"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + + + + + public static void ImgToPdf(String imagePath, String pdfPath) { + try { + long start = System.currentTimeMillis(); + ArrayList list = new ArrayList<>(); + + + FileOutputStream fos = new FileOutputStream(pdfPath); + + Document doc = new Document(null, 20.0F, 20.0F, 20.0F, 20.0F); + + PdfWriter.getInstance(doc, fos); + + + + + + BufferedImage img = ImageIO.read(new File(imagePath)); + + doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); + + Image image = Image.getInstance(imagePath); + + doc.open(); + doc.add((Element)image); + + + + doc.close(); + long endTime = System.currentTimeMillis(); + int time = (int)((endTime - start) / 1000L); + System.out.println("用时:{" + time + "}:秒!"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + + + + + + + public static void PngToJpg(String pngPath, String jpgPath) { + try { + BufferedImage bufferedImage = ImageIO.read(new File(pngPath)); + BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), 1); + newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.white, null); + ImageIO.write(newBufferedImage, "jpg", new File(jpgPath)); + } catch (Exception e) { + System.out.println("ERROR:png转jpg出现异常:" + e.getMessage()); + } + } + + + + + + + + + + public static void JpgToPng(String jpgPath, String pngPath) { + try { + BufferedImage bufferedImage = ImageIO.read(new File(jpgPath)); + BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), 1); + newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.white, null); + ImageIO.write(newBufferedImage, "png", new File(pngPath)); + } catch (Exception e) { + System.out.println("ERROR:jpg转png出现异常:" + e.getMessage()); + } + } + + + + + + + + + + + + + + + public static BufferedImage waterMarkByText(int width, int heigth, String text, Color color, Font font, Double degree, float alpha) { + BufferedImage buffImg = new BufferedImage(width, heigth, 1); + + Graphics2D g2d = buffImg.createGraphics(); + + + buffImg = g2d.getDeviceConfiguration().createCompatibleImage(width, heigth, 3); + g2d.dispose(); + g2d = buffImg.createGraphics(); + + + + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + + + + + + + + if (null != degree) + { + + g2d.rotate(Math.toRadians(degree.doubleValue()), buffImg.getWidth() / 2.0D, buffImg + .getHeight() / 2.0D); + } + + + g2d.setColor(color); + + + g2d.setFont(font); + + + g2d.setComposite(AlphaComposite.getInstance(3, alpha)); + + float realWidth = getRealFontWidth(text); + float fontSize = font.getSize(); + + + float x = 0.5F * width - 0.5F * fontSize * realWidth; + float y = 0.5F * heigth + 0.5F * fontSize; + + g2d.drawString(text, x, y); + + g2d.dispose(); + + return buffImg; + } + + + + public static BufferedImage waterMarkByText(int width, int heigth, String text, Color color, float alpha) { + Font font = new Font("Dialog", 0, 33); + return waterMarkByText(width, heigth, text, color, font, Double.valueOf(-30.0D), alpha); + } + + public static BufferedImage waterMarkByText(int width, int heigth, String text, float alpha) { + return waterMarkByText(width, heigth, text, Color.GRAY, alpha); + } + + + public static BufferedImage waterMarkByText(int width, int heigth, String text) { + return waterMarkByText(width, heigth, text, 0.2F); + } + + public static BufferedImage waterMarkByText(String text) { + return waterMarkByText(200, 150, text); + } + + + + + private static float getRealFontWidth(String text) { + int len = text.length(); + float width = 0.0F; + for (int i = 0; i < len; i++) { + if (text.charAt(i) < 'Ā') { + width += 0.5F; + } else { + width++; + } + } + return width; + } + + + + + + + + + + + + public static void changeImgColor(String path, String newPath) throws IOException { + File file = new File(path); + BufferedImage bi = ImageIO.read(file); + java.awt.Image image = bi; + + ImageIcon imageIcon = new ImageIcon(image); + int width = imageIcon.getIconWidth(); + int height = imageIcon.getIconHeight(); + + BufferedImage bufferedImage = new BufferedImage(width, height, 6); + Graphics2D graphics2D = (Graphics2D)bufferedImage.getGraphics(); + graphics2D.drawImage(imageIcon.getImage(), 0, 0, imageIcon.getImageObserver()); + int alpha = 255; + + int RGB = bufferedImage.getRGB(width - 1, height - 1); + for (int i = bufferedImage.getMinX(); i < width; i++) { + for (int j = bufferedImage.getMinY(); j < height; j++) { + int rgb = bufferedImage.getRGB(i, j); + int r = (rgb & 0xFF0000) >> 16; + int g = (rgb & 0xFF00) >> 8; + int b = rgb & 0xFF; + int R = (RGB & 0xFF0000) >> 16; + int G = (RGB & 0xFF00) >> 8; + int B = RGB & 0xFF; + + int a = 45; + if (Math.abs(R - r) < a && Math.abs(G - g) < a && Math.abs(B - b) < a) { + alpha = 0; + } else { + alpha = 255; + } + rgb = alpha << 24 | rgb & 0xFFFFFF; + bufferedImage.setRGB(i, j, rgb); + } + } + ImageIO.write(bufferedImage, "png", new File(newPath)); + } + + public static String convertRgbStr(int color) { + int red = (color & 0xFF0000) >> 16; + int green = (color & 0xFF00) >> 8; + int blue = color & 0xFF; + return red + "," + green + "," + blue; + } + + + + + + + + + + + public static String thumbnailImage(String imagePath, int w, int h, String prevfix, boolean force) { + File imgFile = new File(imagePath); + String newPath = ""; + if (imgFile.exists()) { + + try { + String types = Arrays.toString((Object[])ImageIO.getReaderFormatNames()); + String suffix = null; + + if (imgFile.getName().indexOf(".") > -1) { + suffix = imgFile.getName().substring(imgFile.getName().lastIndexOf(".") + 1); + } + + if (suffix == null || types.toLowerCase().indexOf(suffix.toLowerCase()) < 0) { + System.out.println("Sorry, the image suffix is illegal. the standard image suffix is {}." + types); + return newPath; + } + System.out.println("target image's size, width:{" + w + "}, height:{" + h + "}."); + java.awt.Image img = ImageIO.read(imgFile); + if (!force) { + + int width = img.getWidth(null); + int height = img.getHeight(null); + if (width * 1.0D / w < height * 1.0D / h) { + if (width > w) { + h = Integer.parseInt((new DecimalFormat("0")).format((height * w) / width * 1.0D)); + System.out.println("change image's height, width:{" + w + "}, height:{" + h + "}."); + } + + } else if (height > h) { + w = Integer.parseInt((new DecimalFormat("0")).format((width * h) / height * 1.0D)); + System.out.println("change image's width, width:{" + w + "}, height:{" + h + "}."); + } + } + + BufferedImage bi = new BufferedImage(w, h, 1); + Graphics g = bi.getGraphics(); + g.drawImage(img, 0, 0, w, h, Color.LIGHT_GRAY, null); + g.dispose(); + String p = imgFile.getPath(); + + newPath = p.substring(0, p.lastIndexOf(File.separator)) + File.separator + prevfix + imgFile.getName(); + ImageIO.write(bi, suffix, new File(newPath)); + System.out.println("缩略图在原路径下生成成功"); + } catch (IOException e) { + System.out.println("generate thumbnail image failed." + e); + } + } else { + System.out.println("the image is not exist."); + } + return newPath; + } + + + + + + + + + + + + + + public static void main(String[] args) { + try { + changeImgColor("F:\\FFOutput\\profile.png", "F:\\FFOutput\\profile1.png"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\convert\ImgConvert.class diff --git a/src/main/java/com/archive/common/exception/file/FileException.java b/src/main/java/com/archive/common/exception/file/FileException.java index 12752a8..8dd1b0f 100644 --- a/src/main/java/com/archive/common/exception/file/FileException.java +++ b/src/main/java/com/archive/common/exception/file/FileException.java @@ -1,21 +1,21 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.base.BaseException; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class FileException -/* */ extends BaseException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public FileException(String code, Object[] args) { -/* 16 */ super("file", code, args, null); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.base.BaseException; + + + + + + + public class FileException + extends BaseException + { + private static final long serialVersionUID = 1L; + + public FileException(String code, Object[] args) { + super("file", code, args, null); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\FileException.class diff --git a/src/main/java/com/archive/common/exception/file/FileNameLengthLimitExceededException.java b/src/main/java/com/archive/common/exception/file/FileNameLengthLimitExceededException.java index d2f600d..2f99b62 100644 --- a/src/main/java/com/archive/common/exception/file/FileNameLengthLimitExceededException.java +++ b/src/main/java/com/archive/common/exception/file/FileNameLengthLimitExceededException.java @@ -1,19 +1,19 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.file.FileException; -/* */ -/* */ -/* */ -/* */ -/* */ public class FileNameLengthLimitExceededException -/* */ extends FileException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public FileNameLengthLimitExceededException(int defaultFileNameLength) { -/* 14 */ super("upload.filename.exceed.length", new Object[] { Integer.valueOf(defaultFileNameLength) }); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.file.FileException; + + + + + public class FileNameLengthLimitExceededException + extends FileException + { + private static final long serialVersionUID = 1L; + + public FileNameLengthLimitExceededException(int defaultFileNameLength) { + super("upload.filename.exceed.length", new Object[] { Integer.valueOf(defaultFileNameLength) }); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\FileNameLengthLimitExceededException.class diff --git a/src/main/java/com/archive/common/exception/file/FileSizeLimitExceededException.java b/src/main/java/com/archive/common/exception/file/FileSizeLimitExceededException.java index 5513a55..40ce217 100644 --- a/src/main/java/com/archive/common/exception/file/FileSizeLimitExceededException.java +++ b/src/main/java/com/archive/common/exception/file/FileSizeLimitExceededException.java @@ -1,19 +1,19 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.file.FileException; -/* */ -/* */ -/* */ -/* */ -/* */ public class FileSizeLimitExceededException -/* */ extends FileException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public FileSizeLimitExceededException(long defaultMaxSize) { -/* 14 */ super("upload.exceed.maxSize", new Object[] { Long.valueOf(defaultMaxSize) }); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.file.FileException; + + + + + public class FileSizeLimitExceededException + extends FileException + { + private static final long serialVersionUID = 1L; + + public FileSizeLimitExceededException(long defaultMaxSize) { + super("upload.exceed.maxSize", new Object[] { Long.valueOf(defaultMaxSize) }); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\FileSizeLimitExceededException.class diff --git a/src/main/java/com/archive/common/exception/file/InvalidExtensionException.java b/src/main/java/com/archive/common/exception/file/InvalidExtensionException.java index b2f2146..8c47628 100644 --- a/src/main/java/com/archive/common/exception/file/InvalidExtensionException.java +++ b/src/main/java/com/archive/common/exception/file/InvalidExtensionException.java @@ -1,44 +1,44 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import java.util.Arrays; -/* */ import org.apache.commons.fileupload.FileUploadException; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class InvalidExtensionException -/* */ extends FileUploadException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ private String[] allowedExtension; -/* */ private String extension; -/* */ private String filename; -/* */ -/* */ public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { -/* 21 */ super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString((Object[])allowedExtension) + "]"); -/* 22 */ this.allowedExtension = allowedExtension; -/* 23 */ this.extension = extension; -/* 24 */ this.filename = filename; -/* */ } -/* */ -/* */ -/* */ public String[] getAllowedExtension() { -/* 29 */ return this.allowedExtension; -/* */ } -/* */ -/* */ -/* */ public String getExtension() { -/* 34 */ return this.extension; -/* */ } -/* */ -/* */ -/* */ public String getFilename() { -/* 39 */ return this.filename; -/* */ } -/* */ } + package com.archive.common.exception.file; + + import java.util.Arrays; + import org.apache.commons.fileupload.FileUploadException; + + + + + + + + public class InvalidExtensionException + extends FileUploadException + { + private static final long serialVersionUID = 1L; + private String[] allowedExtension; + private String extension; + private String filename; + + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { + super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString((Object[])allowedExtension) + "]"); + this.allowedExtension = allowedExtension; + this.extension = extension; + this.filename = filename; + } + + + public String[] getAllowedExtension() { + return this.allowedExtension; + } + + + public String getExtension() { + return this.extension; + } + + + public String getFilename() { + return this.filename; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\InvalidExtensionException.class diff --git a/src/main/java/com/archive/common/exception/file/InvalidImageExtensionException.java b/src/main/java/com/archive/common/exception/file/InvalidImageExtensionException.java index 11dd035..b904808 100644 --- a/src/main/java/com/archive/common/exception/file/InvalidImageExtensionException.java +++ b/src/main/java/com/archive/common/exception/file/InvalidImageExtensionException.java @@ -1,53 +1,53 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.file.InvalidExtensionException; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class InvalidImageExtensionException -/* */ extends InvalidExtensionException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { -/* 48 */ super(allowedExtension, extension, filename); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.file.InvalidExtensionException; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class InvalidImageExtensionException + extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\InvalidExtensionException$InvalidImageExtensionException.class diff --git a/src/main/java/com/archive/common/exception/file/InvalidMediaExtensionException.java b/src/main/java/com/archive/common/exception/file/InvalidMediaExtensionException.java index 1e00d4e..70a70f3 100644 --- a/src/main/java/com/archive/common/exception/file/InvalidMediaExtensionException.java +++ b/src/main/java/com/archive/common/exception/file/InvalidMediaExtensionException.java @@ -1,73 +1,73 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.file.InvalidExtensionException; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class InvalidMediaExtensionException -/* */ extends InvalidExtensionException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { -/* 68 */ super(allowedExtension, extension, filename); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.file.InvalidExtensionException; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class InvalidMediaExtensionException + extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\InvalidExtensionException$InvalidMediaExtensionException.class diff --git a/src/main/java/com/archive/common/exception/file/InvalidVideoExtensionException.java b/src/main/java/com/archive/common/exception/file/InvalidVideoExtensionException.java index 55468a2..6607e46 100644 --- a/src/main/java/com/archive/common/exception/file/InvalidVideoExtensionException.java +++ b/src/main/java/com/archive/common/exception/file/InvalidVideoExtensionException.java @@ -1,83 +1,83 @@ -/* */ package com.archive.common.exception.file; -/* */ -/* */ import com.archive.common.exception.file.InvalidExtensionException; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class InvalidVideoExtensionException -/* */ extends InvalidExtensionException -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ -/* */ public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) { -/* 78 */ super(allowedExtension, extension, filename); -/* */ } -/* */ } + package com.archive.common.exception.file; + + import com.archive.common.exception.file.InvalidExtensionException; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class InvalidVideoExtensionException + extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) { + super(allowedExtension, extension, filename); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exception\file\InvalidExtensionException$InvalidVideoExtensionException.class diff --git a/src/main/java/com/archive/common/ocr/ImageOcr.java b/src/main/java/com/archive/common/ocr/ImageOcr.java index 2e35497..89709c9 100644 --- a/src/main/java/com/archive/common/ocr/ImageOcr.java +++ b/src/main/java/com/archive/common/ocr/ImageOcr.java @@ -1,58 +1,58 @@ -/* */ package com.archive.common.ocr; -/* */ -/* */ import com.archive.common.convert.ImgConvert; -/* */ import java.io.File; -/* */ import net.sourceforge.tess4j.Tesseract; -/* */ import net.sourceforge.tess4j.util.LoadLibs; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class ImageOcr -/* */ { -/* */ public static String ImageOcr(String imagPath) { -/* 18 */ String res = ""; -/* */ try { -/* 20 */ String pngPath = ""; -/* */ -/* 22 */ if (imagPath.contains(".jpg") || imagPath.contains(".jpeg")) { -/* 23 */ File fil = new File(imagPath); -/* */ -/* 25 */ pngPath = fil.getParentFile().getPath() + File.separator + fil.getName().replace(".jpg", ".png").replace(".jpeg", ".png"); -/* 26 */ ImgConvert.JpgToPng(imagPath, pngPath); -/* */ } -/* */ -/* */ -/* 30 */ Tesseract tesseract = new Tesseract(); -/* */ -/* 32 */ File tessDataFolder = LoadLibs.extractTessResources("tessdata"); -/* 33 */ tesseract.setDatapath(tessDataFolder.getAbsolutePath()); -/* */ -/* 35 */ tesseract.setLanguage("chi_sim"); -/* */ -/* 37 */ String result = ""; -/* 38 */ if (pngPath.equals("")) { -/* 39 */ result = tesseract.doOCR(new File(imagPath)); -/* */ } else { -/* 41 */ result = tesseract.doOCR(new File(pngPath)); -/* */ } -/* */ -/* 44 */ res = result.replaceAll("\\r|\\n", "-").replaceAll(" ", ""); -/* 45 */ } catch (Exception ex) { -/* 46 */ System.out.println("图片OCR出现异常:" + ex.getMessage()); -/* */ -/* */ -/* 49 */ if (ex.getMessage().equals("javax.imageio.IIOException: JFIF APP0 must be first marker after SOI")); -/* */ } -/* */ -/* */ -/* 53 */ return res; -/* */ } -/* */ } + package com.archive.common.ocr; + + import com.archive.common.convert.ImgConvert; + import java.io.File; + import net.sourceforge.tess4j.Tesseract; + import net.sourceforge.tess4j.util.LoadLibs; + + + + + + + + + public class ImageOcr + { + public static String ImageOcr(String imagPath) { + String res = ""; + try { + String pngPath = ""; + + if (imagPath.contains(".jpg") || imagPath.contains(".jpeg")) { + File fil = new File(imagPath); + + pngPath = fil.getParentFile().getPath() + File.separator + fil.getName().replace(".jpg", ".png").replace(".jpeg", ".png"); + ImgConvert.JpgToPng(imagPath, pngPath); + } + + + Tesseract tesseract = new Tesseract(); + + File tessDataFolder = LoadLibs.extractTessResources("tessdata"); + tesseract.setDatapath(tessDataFolder.getAbsolutePath()); + + tesseract.setLanguage("chi_sim"); + + String result = ""; + if (pngPath.equals("")) { + result = tesseract.doOCR(new File(imagPath)); + } else { + result = tesseract.doOCR(new File(pngPath)); + } + + res = result.replaceAll("\\r|\\n", "-").replaceAll(" ", ""); + } catch (Exception ex) { + System.out.println("图片OCR出现异常:" + ex.getMessage()); + + + if (ex.getMessage().equals("javax.imageio.IIOException: JFIF APP0 must be first marker after SOI")); + } + + + return res; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\ocr\ImageOcr.class diff --git a/src/main/java/com/archive/common/utils/file/FileTypeUtils.java b/src/main/java/com/archive/common/utils/file/FileTypeUtils.java index cd641a3..2aafb45 100644 --- a/src/main/java/com/archive/common/utils/file/FileTypeUtils.java +++ b/src/main/java/com/archive/common/utils/file/FileTypeUtils.java @@ -1,79 +1,79 @@ -/* */ package com.archive.common.utils.file; -/* */ -/* */ import java.io.File; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class FileTypeUtils -/* */ { -/* */ public static String getFileType(File file) { -/* 23 */ if (null == file) -/* */ { -/* 25 */ return ""; -/* */ } -/* 27 */ return getFileType(file.getName()); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getFileType(String fileName) { -/* 40 */ int separatorIndex = fileName.lastIndexOf("."); -/* 41 */ if (separatorIndex < 0) -/* */ { -/* 43 */ return ""; -/* */ } -/* 45 */ return fileName.substring(separatorIndex + 1).toLowerCase(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getFileExtendName(byte[] photoByte) { -/* 56 */ String strFileExtendName = "JPG"; -/* 57 */ if (photoByte[0] == 71 && photoByte[1] == 73 && photoByte[2] == 70 && photoByte[3] == 56 && (photoByte[4] == 55 || photoByte[4] == 57) && photoByte[5] == 97) { -/* */ -/* */ -/* 60 */ strFileExtendName = "GIF"; -/* */ } -/* 62 */ else if (photoByte[6] == 74 && photoByte[7] == 70 && photoByte[8] == 73 && photoByte[9] == 70) { -/* */ -/* 64 */ strFileExtendName = "JPG"; -/* */ } -/* 66 */ else if (photoByte[0] == 66 && photoByte[1] == 77) { -/* */ -/* 68 */ strFileExtendName = "BMP"; -/* */ } -/* 70 */ else if (photoByte[1] == 80 && photoByte[2] == 78 && photoByte[3] == 71) { -/* */ -/* 72 */ strFileExtendName = "PNG"; -/* */ } -/* 74 */ return strFileExtendName; -/* */ } -/* */ } + package com.archive.common.utils.file; + + import java.io.File; + + + + + + + + + + + + + + + + + public class FileTypeUtils + { + public static String getFileType(File file) { + if (null == file) + { + return ""; + } + return getFileType(file.getName()); + } + + + + + + + + + + + public static String getFileType(String fileName) { + int separatorIndex = fileName.lastIndexOf("."); + if (separatorIndex < 0) + { + return ""; + } + return fileName.substring(separatorIndex + 1).toLowerCase(); + } + + + + + + + + + public static String getFileExtendName(byte[] photoByte) { + String strFileExtendName = "JPG"; + if (photoByte[0] == 71 && photoByte[1] == 73 && photoByte[2] == 70 && photoByte[3] == 56 && (photoByte[4] == 55 || photoByte[4] == 57) && photoByte[5] == 97) { + + + strFileExtendName = "GIF"; + } + else if (photoByte[6] == 74 && photoByte[7] == 70 && photoByte[8] == 73 && photoByte[9] == 70) { + + strFileExtendName = "JPG"; + } + else if (photoByte[0] == 66 && photoByte[1] == 77) { + + strFileExtendName = "BMP"; + } + else if (photoByte[1] == 80 && photoByte[2] == 78 && photoByte[3] == 71) { + + strFileExtendName = "PNG"; + } + return strFileExtendName; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\file\FileTypeUtils.class diff --git a/src/main/java/com/archive/common/utils/file/FileUtils.java b/src/main/java/com/archive/common/utils/file/FileUtils.java index ce0602a..15cafab 100644 --- a/src/main/java/com/archive/common/utils/file/FileUtils.java +++ b/src/main/java/com/archive/common/utils/file/FileUtils.java @@ -1,207 +1,207 @@ -/* */ package com.archive.common.utils.file; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ -/* */ import java.io.File; -/* */ import java.io.FileInputStream; -/* */ import java.io.IOException; -/* */ import java.io.OutputStream; -/* */ import java.io.UnsupportedEncodingException; -/* */ import java.net.URLEncoder; -/* */ import java.nio.charset.StandardCharsets; -/* */ import javax.servlet.http.HttpServletRequest; -/* */ import javax.servlet.http.HttpServletResponse; -/* */ import org.apache.commons.lang3.ArrayUtils; -/* */ -/* */ -/* */ -/* */ public class FileUtils -/* */ -/* */ { -/* 23 */ public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void writeBytes(String filePath, OutputStream os) throws IOException { -/* 34 */ FileInputStream fis = null; -/* */ -/* */ try { -/* 37 */ File file = new File(filePath); -/* 38 */ if (!file.exists()) -/* */ { -/* 40 */ if (!(new File(file.getParent())).exists()) { -/* 41 */ (new File(file.getParent())).mkdirs(); -/* */ } -/* */ } -/* */ -/* 45 */ fis = new FileInputStream(file); -/* 46 */ byte[] b = new byte[1024]; -/* */ int length; -/* 48 */ while ((length = fis.read(b)) > 0) -/* */ { -/* 50 */ os.write(b, 0, length); -/* */ } -/* */ } -/* 53 */ catch (IOException e) { -/* */ -/* 55 */ throw e; -/* */ } -/* */ finally { -/* */ -/* 59 */ if (os != null) { -/* */ -/* */ try { -/* */ -/* 63 */ os.close(); -/* */ } -/* 65 */ catch (IOException e1) { -/* */ -/* 67 */ e1.printStackTrace(); -/* */ } -/* */ } -/* 70 */ if (fis != null) { -/* */ -/* */ try { -/* */ -/* 74 */ fis.close(); -/* */ } -/* 76 */ catch (IOException e1) { -/* */ -/* 78 */ e1.printStackTrace(); -/* */ } -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean deleteFile(String filePath) { -/* 92 */ boolean flag = false; -/* 93 */ File file = new File(filePath); -/* */ -/* 95 */ if (file.isFile() && file.exists()) { -/* */ -/* 97 */ file.delete(); -/* 98 */ flag = true; -/* */ } -/* 100 */ return flag; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean isValidFilename(String filename) { -/* 111 */ return filename.matches(FILENAME_PATTERN); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean checkAllowDownload(String resource) { -/* 123 */ if (StringUtils.contains(resource, "..")) -/* */ { -/* 125 */ return false; -/* */ } -/* */ -/* */ -/* 129 */ if (ArrayUtils.contains((Object[])MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) -/* */ { -/* 131 */ return true; -/* */ } -/* */ -/* */ -/* 135 */ return false; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException { -/* 147 */ String agent = request.getHeader("USER-AGENT"); -/* 148 */ String filename = fileName; -/* 149 */ if (agent.contains("MSIE")) { -/* */ -/* */ -/* 152 */ filename = URLEncoder.encode(filename, "utf-8"); -/* 153 */ filename = filename.replace("+", " "); -/* */ } -/* 155 */ else if (agent.contains("Firefox")) { -/* */ -/* */ -/* 158 */ filename = new String(fileName.getBytes(), "ISO8859-1"); -/* */ } -/* 160 */ else if (agent.contains("Chrome")) { -/* */ -/* */ -/* 163 */ filename = URLEncoder.encode(filename, "utf-8"); -/* */ -/* */ } -/* */ else { -/* */ -/* 168 */ filename = URLEncoder.encode(filename, "utf-8"); -/* */ } -/* 170 */ return filename; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { -/* 182 */ String percentEncodedFileName = percentEncode(realFileName); -/* */ -/* 184 */ StringBuilder contentDispositionValue = new StringBuilder(); -/* 185 */ contentDispositionValue.append("attachment; filename=") -/* 186 */ .append(percentEncodedFileName) -/* 187 */ .append(";") -/* 188 */ .append("filename*=") -/* 189 */ .append("utf-8''") -/* 190 */ .append(percentEncodedFileName); -/* */ -/* 192 */ response.setHeader("Content-disposition", contentDispositionValue.toString()); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String percentEncode(String s) throws UnsupportedEncodingException { -/* 203 */ String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); -/* 204 */ return encode.replaceAll("\\+", "%20"); -/* */ } -/* */ } + package com.archive.common.utils.file; + + import com.archive.common.utils.StringUtils; + + import java.io.File; + import java.io.FileInputStream; + import java.io.IOException; + import java.io.OutputStream; + import java.io.UnsupportedEncodingException; + import java.net.URLEncoder; + import java.nio.charset.StandardCharsets; + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + import org.apache.commons.lang3.ArrayUtils; + + + + public class FileUtils + + { + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + + + + + + + + + public static void writeBytes(String filePath, OutputStream os) throws IOException { + FileInputStream fis = null; + + try { + File file = new File(filePath); + if (!file.exists()) + { + if (!(new File(file.getParent())).exists()) { + (new File(file.getParent())).mkdirs(); + } + } + + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) + { + os.write(b, 0, length); + } + } + catch (IOException e) { + + throw e; + } + finally { + + if (os != null) { + + try { + + os.close(); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + } + if (fis != null) { + + try { + + fis.close(); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + } + } + } + + + + + + + + + public static boolean deleteFile(String filePath) { + boolean flag = false; + File file = new File(filePath); + + if (file.isFile() && file.exists()) { + + file.delete(); + flag = true; + } + return flag; + } + + + + + + + + + public static boolean isValidFilename(String filename) { + return filename.matches(FILENAME_PATTERN); + } + + + + + + + + + + public static boolean checkAllowDownload(String resource) { + if (StringUtils.contains(resource, "..")) + { + return false; + } + + + if (ArrayUtils.contains((Object[])MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) + { + return true; + } + + + return false; + } + + + + + + + + + + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException { + String agent = request.getHeader("USER-AGENT"); + String filename = fileName; + if (agent.contains("MSIE")) { + + + filename = URLEncoder.encode(filename, "utf-8"); + filename = filename.replace("+", " "); + } + else if (agent.contains("Firefox")) { + + + filename = new String(fileName.getBytes(), "ISO8859-1"); + } + else if (agent.contains("Chrome")) { + + + filename = URLEncoder.encode(filename, "utf-8"); + + } + else { + + filename = URLEncoder.encode(filename, "utf-8"); + } + return filename; + } + + + + + + + + + + public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { + String percentEncodedFileName = percentEncode(realFileName); + + StringBuilder contentDispositionValue = new StringBuilder(); + contentDispositionValue.append("attachment; filename=") + .append(percentEncodedFileName) + .append(";") + .append("filename*=") + .append("utf-8''") + .append(percentEncodedFileName); + + response.setHeader("Content-disposition", contentDispositionValue.toString()); + } + + + + + + + + + public static String percentEncode(String s) throws UnsupportedEncodingException { + String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); + return encode.replaceAll("\\+", "%20"); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\file\FileUtils.class diff --git a/src/main/java/com/archive/common/utils/file/ImageUtils.java b/src/main/java/com/archive/common/utils/file/ImageUtils.java index d963892..d4bc314 100644 --- a/src/main/java/com/archive/common/utils/file/ImageUtils.java +++ b/src/main/java/com/archive/common/utils/file/ImageUtils.java @@ -1,103 +1,103 @@ -/* */ package com.archive.common.utils.file; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import java.io.ByteArrayInputStream; -/* */ import java.io.ByteArrayOutputStream; -/* */ import java.io.FileInputStream; -/* */ import java.io.InputStream; -/* */ import java.net.URL; -/* */ import java.net.URLConnection; -/* */ import java.util.Arrays; -/* */ import org.apache.poi.util.IOUtils; -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class ImageUtils -/* */ { -/* 24 */ private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.file.ImageUtils.class); -/* */ -/* */ -/* */ public static byte[] getImage(String imagePath) { -/* 28 */ InputStream is = getFile(imagePath); -/* */ -/* */ try { -/* 31 */ return IOUtils.toByteArray(is); -/* */ } -/* 33 */ catch (Exception e) { -/* */ -/* 35 */ log.error("图片加载异常 {}", e); -/* 36 */ return null; -/* */ } -/* */ finally { -/* */ -/* 40 */ IOUtils.closeQuietly(is); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ public static InputStream getFile(String imagePath) { -/* */ try { -/* 48 */ byte[] result = readFile(imagePath); -/* 49 */ result = Arrays.copyOf(result, result.length); -/* 50 */ return new ByteArrayInputStream(result); -/* */ } -/* 52 */ catch (Exception e) { -/* */ -/* 54 */ log.error("获取图片异常 {}", e); -/* */ -/* 56 */ return null; -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static byte[] readFile(String url) { -/* 67 */ InputStream in = null; -/* 68 */ ByteArrayOutputStream baos = null; -/* */ -/* */ try { -/* 71 */ if (url.startsWith("http")) { -/* */ -/* */ -/* 74 */ URL urlObj = new URL(url); -/* 75 */ URLConnection urlConnection = urlObj.openConnection(); -/* 76 */ urlConnection.setConnectTimeout(30000); -/* 77 */ urlConnection.setReadTimeout(60000); -/* 78 */ urlConnection.setDoInput(true); -/* 79 */ in = urlConnection.getInputStream(); -/* */ -/* */ } -/* */ else { -/* */ -/* 84 */ String localPath = ArchiveConfig.getInstance().getProfile(); -/* 85 */ String downloadPath = localPath + StringUtils.substringAfter(url, "/profile"); -/* 86 */ in = new FileInputStream(downloadPath); -/* */ } -/* 88 */ return IOUtils.toByteArray(in); -/* */ } -/* 90 */ catch (Exception e) { -/* */ -/* 92 */ log.error("获取文件路径异常 {}", e); -/* 93 */ return null; -/* */ } -/* */ finally { -/* */ -/* 97 */ IOUtils.closeQuietly(baos); -/* */ } -/* */ } -/* */ } + package com.archive.common.utils.file; + + import com.archive.common.utils.StringUtils; + import com.archive.framework.config.ArchiveConfig; + import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; + import java.io.FileInputStream; + import java.io.InputStream; + import java.net.URL; + import java.net.URLConnection; + import java.util.Arrays; + import org.apache.poi.util.IOUtils; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + + + + + + + public class ImageUtils + { + private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.file.ImageUtils.class); + + + public static byte[] getImage(String imagePath) { + InputStream is = getFile(imagePath); + + try { + return IOUtils.toByteArray(is); + } + catch (Exception e) { + + log.error("图片加载异常 {}", e); + return null; + } + finally { + + IOUtils.closeQuietly(is); + } + } + + + + public static InputStream getFile(String imagePath) { + try { + byte[] result = readFile(imagePath); + result = Arrays.copyOf(result, result.length); + return new ByteArrayInputStream(result); + } + catch (Exception e) { + + log.error("获取图片异常 {}", e); + + return null; + } + } + + + + + + + + public static byte[] readFile(String url) { + InputStream in = null; + ByteArrayOutputStream baos = null; + + try { + if (url.startsWith("http")) { + + + URL urlObj = new URL(url); + URLConnection urlConnection = urlObj.openConnection(); + urlConnection.setConnectTimeout(30000); + urlConnection.setReadTimeout(60000); + urlConnection.setDoInput(true); + in = urlConnection.getInputStream(); + + } + else { + + String localPath = ArchiveConfig.getInstance().getProfile(); + String downloadPath = localPath + StringUtils.substringAfter(url, "/profile"); + in = new FileInputStream(downloadPath); + } + return IOUtils.toByteArray(in); + } + catch (Exception e) { + + log.error("获取文件路径异常 {}", e); + return null; + } + finally { + + IOUtils.closeQuietly(baos); + } + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\file\ImageUtils.class diff --git a/src/main/java/com/archive/common/utils/html/HTMLFilter.java b/src/main/java/com/archive/common/utils/html/HTMLFilter.java index 74f6ad8..8bdec56 100644 --- a/src/main/java/com/archive/common/utils/html/HTMLFilter.java +++ b/src/main/java/com/archive/common/utils/html/HTMLFilter.java @@ -1,573 +1,573 @@ -/* */ package com.archive.common.utils.html; -/* */ -/* */ import java.util.ArrayList; -/* */ import java.util.Collections; -/* */ import java.util.HashMap; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import java.util.concurrent.ConcurrentHashMap; -/* */ import java.util.concurrent.ConcurrentMap; -/* */ import java.util.regex.Matcher; -/* */ import java.util.regex.Pattern; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public final class HTMLFilter -/* */ { -/* */ private static final int REGEX_FLAGS_SI = 34; -/* 24 */ private static final Pattern P_COMMENTS = Pattern.compile("", 32); -/* 25 */ private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", 34); -/* 26 */ private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", 32); -/* 27 */ private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", 34); -/* 28 */ private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", 34); -/* 29 */ private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", 34); -/* 30 */ private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", 34); -/* 31 */ private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", 34); -/* 32 */ private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); -/* 33 */ private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); -/* 34 */ private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); -/* 35 */ private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); -/* 36 */ private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", 32); -/* 37 */ private static final Pattern P_END_ARROW = Pattern.compile("^>"); -/* 38 */ private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); -/* 39 */ private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); -/* 40 */ private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); -/* 41 */ private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); -/* 42 */ private static final Pattern P_AMP = Pattern.compile("&"); -/* 43 */ private static final Pattern P_QUOTE = Pattern.compile("\""); -/* 44 */ private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); -/* 45 */ private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); -/* 46 */ private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); -/* */ -/* */ -/* 49 */ private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); -/* 50 */ private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); -/* */ -/* */ -/* */ -/* */ -/* */ private final Map> vAllowed; -/* */ -/* */ -/* */ -/* 59 */ private final Map vTagCounts = new HashMap<>(); -/* */ -/* */ -/* */ -/* */ private final String[] vSelfClosingTags; -/* */ -/* */ -/* */ -/* */ private final String[] vNeedClosingTags; -/* */ -/* */ -/* */ -/* */ private final String[] vDisallowed; -/* */ -/* */ -/* */ -/* */ private final String[] vProtocolAtts; -/* */ -/* */ -/* */ -/* */ private final String[] vAllowedProtocols; -/* */ -/* */ -/* */ -/* */ private final String[] vRemoveBlanks; -/* */ -/* */ -/* */ -/* */ private final String[] vAllowedEntities; -/* */ -/* */ -/* */ -/* */ private final boolean stripComment; -/* */ -/* */ -/* */ -/* */ private final boolean encodeQuotes; -/* */ -/* */ -/* */ -/* */ private final boolean alwaysMakeTags; -/* */ -/* */ -/* */ -/* */ -/* */ public HTMLFilter() { -/* 105 */ this.vAllowed = new HashMap<>(); -/* */ -/* 107 */ ArrayList a_atts = new ArrayList<>(); -/* 108 */ a_atts.add("href"); -/* 109 */ a_atts.add("target"); -/* 110 */ this.vAllowed.put("a", a_atts); -/* */ -/* 112 */ ArrayList img_atts = new ArrayList<>(); -/* 113 */ img_atts.add("src"); -/* 114 */ img_atts.add("width"); -/* 115 */ img_atts.add("height"); -/* 116 */ img_atts.add("alt"); -/* 117 */ this.vAllowed.put("img", img_atts); -/* */ -/* 119 */ ArrayList no_atts = new ArrayList<>(); -/* 120 */ this.vAllowed.put("b", no_atts); -/* 121 */ this.vAllowed.put("strong", no_atts); -/* 122 */ this.vAllowed.put("i", no_atts); -/* 123 */ this.vAllowed.put("em", no_atts); -/* */ -/* 125 */ this.vSelfClosingTags = new String[] { "img" }; -/* 126 */ this.vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; -/* 127 */ this.vDisallowed = new String[0]; -/* 128 */ this.vAllowedProtocols = new String[] { "http", "mailto", "https" }; -/* 129 */ this.vProtocolAtts = new String[] { "src", "href" }; -/* 130 */ this.vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; -/* 131 */ this.vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; -/* 132 */ this.stripComment = true; -/* 133 */ this.encodeQuotes = true; -/* 134 */ this.alwaysMakeTags = false; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public HTMLFilter(Map conf) { -/* 146 */ assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; -/* 147 */ assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; -/* 148 */ assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; -/* 149 */ assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; -/* 150 */ assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; -/* 151 */ assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; -/* 152 */ assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; -/* 153 */ assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; -/* */ -/* 155 */ this.vAllowed = Collections.unmodifiableMap((HashMap)conf.get("vAllowed")); -/* 156 */ this.vSelfClosingTags = (String[])conf.get("vSelfClosingTags"); -/* 157 */ this.vNeedClosingTags = (String[])conf.get("vNeedClosingTags"); -/* 158 */ this.vDisallowed = (String[])conf.get("vDisallowed"); -/* 159 */ this.vAllowedProtocols = (String[])conf.get("vAllowedProtocols"); -/* 160 */ this.vProtocolAtts = (String[])conf.get("vProtocolAtts"); -/* 161 */ this.vRemoveBlanks = (String[])conf.get("vRemoveBlanks"); -/* 162 */ this.vAllowedEntities = (String[])conf.get("vAllowedEntities"); -/* 163 */ this.stripComment = conf.containsKey("stripComment") ? ((Boolean)conf.get("stripComment")).booleanValue() : true; -/* 164 */ this.encodeQuotes = conf.containsKey("encodeQuotes") ? ((Boolean)conf.get("encodeQuotes")).booleanValue() : true; -/* 165 */ this.alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? ((Boolean)conf.get("alwaysMakeTags")).booleanValue() : true; -/* */ } -/* */ -/* */ -/* */ private void reset() { -/* 170 */ this.vTagCounts.clear(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ public static String chr(int decimal) { -/* 177 */ return String.valueOf((char)decimal); -/* */ } -/* */ -/* */ -/* */ public static String htmlSpecialChars(String s) { -/* 182 */ String result = s; -/* 183 */ result = regexReplace(P_AMP, "&", result); -/* 184 */ result = regexReplace(P_QUOTE, """, result); -/* 185 */ result = regexReplace(P_LEFT_ARROW, "<", result); -/* 186 */ result = regexReplace(P_RIGHT_ARROW, ">", result); -/* 187 */ return result; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public String filter(String input) { -/* 200 */ reset(); -/* 201 */ String s = input; -/* */ -/* 203 */ s = escapeComments(s); -/* */ -/* 205 */ s = balanceHTML(s); -/* */ -/* 207 */ s = checkTags(s); -/* */ -/* 209 */ s = processRemoveBlanks(s); -/* */ -/* */ -/* */ -/* 213 */ return s; -/* */ } -/* */ -/* */ -/* */ public boolean isAlwaysMakeTags() { -/* 218 */ return this.alwaysMakeTags; -/* */ } -/* */ -/* */ -/* */ public boolean isStripComments() { -/* 223 */ return this.stripComment; -/* */ } -/* */ -/* */ -/* */ private String escapeComments(String s) { -/* 228 */ Matcher m = P_COMMENTS.matcher(s); -/* 229 */ StringBuffer buf = new StringBuffer(); -/* 230 */ if (m.find()) { -/* */ -/* 232 */ String match = m.group(1); -/* 233 */ m.appendReplacement(buf, Matcher.quoteReplacement("")); -/* */ } -/* 235 */ m.appendTail(buf); -/* */ -/* 237 */ return buf.toString(); -/* */ } -/* */ -/* */ -/* */ private String balanceHTML(String s) { -/* 242 */ if (this.alwaysMakeTags) { -/* */ -/* */ -/* */ -/* */ -/* 247 */ s = regexReplace(P_END_ARROW, "", s); -/* */ -/* 249 */ s = regexReplace(P_BODY_TO_END, "<$1>", s); -/* 250 */ s = regexReplace(P_XML_CONTENT, "$1<$2", s); -/* */ -/* */ -/* */ } -/* */ else { -/* */ -/* */ -/* */ -/* 258 */ s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); -/* 259 */ s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* 266 */ s = regexReplace(P_BOTH_ARROWS, "", s); -/* */ } -/* */ -/* 269 */ return s; -/* */ } -/* */ -/* */ -/* */ private String checkTags(String s) { -/* 274 */ Matcher m = P_TAGS.matcher(s); -/* */ -/* 276 */ StringBuffer buf = new StringBuffer(); -/* 277 */ while (m.find()) { -/* */ -/* 279 */ String replaceStr = m.group(1); -/* 280 */ replaceStr = processTag(replaceStr); -/* 281 */ m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); -/* */ } -/* 283 */ m.appendTail(buf); -/* */ -/* */ -/* */ -/* 287 */ StringBuilder sBuilder = new StringBuilder(buf.toString()); -/* 288 */ for (String key : this.vTagCounts.keySet()) { -/* */ -/* 290 */ for (int ii = 0; ii < ((Integer)this.vTagCounts.get(key)).intValue(); ii++) -/* */ { -/* 292 */ sBuilder.append(""); -/* */ } -/* */ } -/* 295 */ s = sBuilder.toString(); -/* */ -/* 297 */ return s; -/* */ } -/* */ -/* */ -/* */ private String processRemoveBlanks(String s) { -/* 302 */ String result = s; -/* 303 */ for (String tag : this.vRemoveBlanks) { -/* */ -/* 305 */ if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) -/* */ { -/* 307 */ P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); -/* */ } -/* 309 */ result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); -/* 310 */ if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) -/* */ { -/* 312 */ P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); -/* */ } -/* 314 */ result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); -/* */ } -/* */ -/* 317 */ return result; -/* */ } -/* */ -/* */ -/* */ private static String regexReplace(Pattern regex_pattern, String replacement, String s) { -/* 322 */ Matcher m = regex_pattern.matcher(s); -/* 323 */ return m.replaceAll(replacement); -/* */ } -/* */ -/* */ -/* */ -/* */ private String processTag(String s) { -/* 329 */ Matcher m = P_END_TAG.matcher(s); -/* 330 */ if (m.find()) { -/* */ -/* 332 */ String name = m.group(1).toLowerCase(); -/* 333 */ if (allowed(name)) -/* */ { -/* 335 */ if (false == inArray(name, this.vSelfClosingTags)) -/* */ { -/* 337 */ if (this.vTagCounts.containsKey(name)) { -/* */ -/* 339 */ this.vTagCounts.put(name, Integer.valueOf(((Integer)this.vTagCounts.get(name)).intValue() - 1)); -/* 340 */ return ""; -/* */ } -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* 347 */ m = P_START_TAG.matcher(s); -/* 348 */ if (m.find()) { -/* */ -/* 350 */ String name = m.group(1).toLowerCase(); -/* 351 */ String body = m.group(2); -/* 352 */ String ending = m.group(3); -/* */ -/* */ -/* 355 */ if (allowed(name)) { -/* */ -/* 357 */ StringBuilder params = new StringBuilder(); -/* */ -/* 359 */ Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); -/* 360 */ Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); -/* 361 */ List paramNames = new ArrayList<>(); -/* 362 */ List paramValues = new ArrayList<>(); -/* 363 */ while (m2.find()) { -/* */ -/* 365 */ paramNames.add(m2.group(1)); -/* 366 */ paramValues.add(m2.group(3)); -/* */ } -/* 368 */ while (m3.find()) { -/* */ -/* 370 */ paramNames.add(m3.group(1)); -/* 371 */ paramValues.add(m3.group(3)); -/* */ } -/* */ -/* */ -/* 375 */ for (int ii = 0; ii < paramNames.size(); ii++) { -/* */ -/* 377 */ String paramName = ((String)paramNames.get(ii)).toLowerCase(); -/* 378 */ String paramValue = paramValues.get(ii); -/* */ -/* */ -/* */ -/* */ -/* */ -/* 384 */ if (allowedAttribute(name, paramName)) { -/* */ -/* 386 */ if (inArray(paramName, this.vProtocolAtts)) -/* */ { -/* 388 */ paramValue = processParamProtocol(paramValue); -/* */ } -/* 390 */ params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); -/* */ } -/* */ } -/* */ -/* 394 */ if (inArray(name, this.vSelfClosingTags)) -/* */ { -/* 396 */ ending = " /"; -/* */ } -/* */ -/* 399 */ if (inArray(name, this.vNeedClosingTags)) -/* */ { -/* 401 */ ending = ""; -/* */ } -/* */ -/* 404 */ if (ending == null || ending.length() < 1) { -/* */ -/* 406 */ if (this.vTagCounts.containsKey(name)) -/* */ { -/* 408 */ this.vTagCounts.put(name, Integer.valueOf(((Integer)this.vTagCounts.get(name)).intValue() + 1)); -/* */ } -/* */ else -/* */ { -/* 412 */ this.vTagCounts.put(name, Integer.valueOf(1)); -/* */ } -/* */ -/* */ } else { -/* */ -/* 417 */ ending = " /"; -/* */ } -/* 419 */ return "<" + name + params + ending + ">"; -/* */ } -/* */ -/* */ -/* 423 */ return ""; -/* */ } -/* */ -/* */ -/* */ -/* 428 */ m = P_COMMENT.matcher(s); -/* 429 */ if (!this.stripComment && m.find()) -/* */ { -/* 431 */ return "<" + m.group() + ">"; -/* */ } -/* */ -/* 434 */ return ""; -/* */ } -/* */ -/* */ -/* */ private String processParamProtocol(String s) { -/* 439 */ s = decodeEntities(s); -/* 440 */ Matcher m = P_PROTOCOL.matcher(s); -/* 441 */ if (m.find()) { -/* */ -/* 443 */ String protocol = m.group(1); -/* 444 */ if (!inArray(protocol, this.vAllowedProtocols)) { -/* */ -/* */ -/* 447 */ s = "#" + s.substring(protocol.length() + 1); -/* 448 */ if (s.startsWith("#//")) -/* */ { -/* 450 */ s = "#" + s.substring(3); -/* */ } -/* */ } -/* */ } -/* */ -/* 455 */ return s; -/* */ } -/* */ -/* */ -/* */ private String decodeEntities(String s) { -/* 460 */ StringBuffer buf = new StringBuffer(); -/* */ -/* 462 */ Matcher m = P_ENTITY.matcher(s); -/* 463 */ while (m.find()) { -/* */ -/* 465 */ String match = m.group(1); -/* 466 */ int decimal = Integer.decode(match).intValue(); -/* 467 */ m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); -/* */ } -/* 469 */ m.appendTail(buf); -/* 470 */ s = buf.toString(); -/* */ -/* 472 */ buf = new StringBuffer(); -/* 473 */ m = P_ENTITY_UNICODE.matcher(s); -/* 474 */ while (m.find()) { -/* */ -/* 476 */ String match = m.group(1); -/* 477 */ int decimal = Integer.valueOf(match, 16).intValue(); -/* 478 */ m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); -/* */ } -/* 480 */ m.appendTail(buf); -/* 481 */ s = buf.toString(); -/* */ -/* 483 */ buf = new StringBuffer(); -/* 484 */ m = P_ENCODE.matcher(s); -/* 485 */ while (m.find()) { -/* */ -/* 487 */ String match = m.group(1); -/* 488 */ int decimal = Integer.valueOf(match, 16).intValue(); -/* 489 */ m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); -/* */ } -/* 491 */ m.appendTail(buf); -/* 492 */ s = buf.toString(); -/* */ -/* 494 */ s = validateEntities(s); -/* 495 */ return s; -/* */ } -/* */ -/* */ -/* */ private String validateEntities(String s) { -/* 500 */ StringBuffer buf = new StringBuffer(); -/* */ -/* */ -/* 503 */ Matcher m = P_VALID_ENTITIES.matcher(s); -/* 504 */ while (m.find()) { -/* */ -/* 506 */ String one = m.group(1); -/* 507 */ String two = m.group(2); -/* 508 */ m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); -/* */ } -/* 510 */ m.appendTail(buf); -/* */ -/* 512 */ return encodeQuotes(buf.toString()); -/* */ } -/* */ -/* */ -/* */ private String encodeQuotes(String s) { -/* 517 */ if (this.encodeQuotes) { -/* */ -/* 519 */ StringBuffer buf = new StringBuffer(); -/* 520 */ Matcher m = P_VALID_QUOTES.matcher(s); -/* 521 */ while (m.find()) { -/* */ -/* 523 */ String one = m.group(1); -/* 524 */ String two = m.group(2); -/* 525 */ String three = m.group(3); -/* */ -/* 527 */ m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); -/* */ } -/* 529 */ m.appendTail(buf); -/* 530 */ return buf.toString(); -/* */ } -/* */ -/* */ -/* 534 */ return s; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ private String checkEntity(String preamble, String term) { -/* 541 */ return (";".equals(term) && isValidEntity(preamble)) ? ('&' + preamble) : ("&" + preamble); -/* */ } -/* */ -/* */ -/* */ private boolean isValidEntity(String entity) { -/* 546 */ return inArray(entity, this.vAllowedEntities); -/* */ } -/* */ -/* */ -/* */ private static boolean inArray(String s, String[] array) { -/* 551 */ for (String item : array) { -/* */ -/* 553 */ if (item != null && item.equals(s)) -/* */ { -/* 555 */ return true; -/* */ } -/* */ } -/* 558 */ return false; -/* */ } -/* */ -/* */ -/* */ private boolean allowed(String name) { -/* 563 */ return ((this.vAllowed.isEmpty() || this.vAllowed.containsKey(name)) && !inArray(name, this.vDisallowed)); -/* */ } -/* */ -/* */ -/* */ private boolean allowedAttribute(String name, String paramName) { -/* 568 */ return (allowed(name) && (this.vAllowed.isEmpty() || ((List)this.vAllowed.get(name)).contains(paramName))); -/* */ } -/* */ } + package com.archive.common.utils.html; + + import java.util.ArrayList; + import java.util.Collections; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import java.util.concurrent.ConcurrentHashMap; + import java.util.concurrent.ConcurrentMap; + import java.util.regex.Matcher; + import java.util.regex.Pattern; + + + + + + + + + + public final class HTMLFilter + { + private static final int REGEX_FLAGS_SI = 34; + private static final Pattern P_COMMENTS = Pattern.compile("", 32); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", 34); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", 32); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", 34); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", 34); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", 34); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", 34); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", 34); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", 32); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); + + + + + private final Map> vAllowed; + + + + private final Map vTagCounts = new HashMap<>(); + + + + private final String[] vSelfClosingTags; + + + + private final String[] vNeedClosingTags; + + + + private final String[] vDisallowed; + + + + private final String[] vProtocolAtts; + + + + private final String[] vAllowedProtocols; + + + + private final String[] vRemoveBlanks; + + + + private final String[] vAllowedEntities; + + + + private final boolean stripComment; + + + + private final boolean encodeQuotes; + + + + private final boolean alwaysMakeTags; + + + + + public HTMLFilter() { + this.vAllowed = new HashMap<>(); + + ArrayList a_atts = new ArrayList<>(); + a_atts.add("href"); + a_atts.add("target"); + this.vAllowed.put("a", a_atts); + + ArrayList img_atts = new ArrayList<>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + this.vAllowed.put("img", img_atts); + + ArrayList no_atts = new ArrayList<>(); + this.vAllowed.put("b", no_atts); + this.vAllowed.put("strong", no_atts); + this.vAllowed.put("i", no_atts); + this.vAllowed.put("em", no_atts); + + this.vSelfClosingTags = new String[] { "img" }; + this.vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; + this.vDisallowed = new String[0]; + this.vAllowedProtocols = new String[] { "http", "mailto", "https" }; + this.vProtocolAtts = new String[] { "src", "href" }; + this.vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; + this.vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + this.stripComment = true; + this.encodeQuotes = true; + this.alwaysMakeTags = false; + } + + + + + + + + + + public HTMLFilter(Map conf) { + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + this.vAllowed = Collections.unmodifiableMap((HashMap)conf.get("vAllowed")); + this.vSelfClosingTags = (String[])conf.get("vSelfClosingTags"); + this.vNeedClosingTags = (String[])conf.get("vNeedClosingTags"); + this.vDisallowed = (String[])conf.get("vDisallowed"); + this.vAllowedProtocols = (String[])conf.get("vAllowedProtocols"); + this.vProtocolAtts = (String[])conf.get("vProtocolAtts"); + this.vRemoveBlanks = (String[])conf.get("vRemoveBlanks"); + this.vAllowedEntities = (String[])conf.get("vAllowedEntities"); + this.stripComment = conf.containsKey("stripComment") ? ((Boolean)conf.get("stripComment")).booleanValue() : true; + this.encodeQuotes = conf.containsKey("encodeQuotes") ? ((Boolean)conf.get("encodeQuotes")).booleanValue() : true; + this.alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? ((Boolean)conf.get("alwaysMakeTags")).booleanValue() : true; + } + + + private void reset() { + this.vTagCounts.clear(); + } + + + + + public static String chr(int decimal) { + return String.valueOf((char)decimal); + } + + + public static String htmlSpecialChars(String s) { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + + + + + + + + + + public String filter(String input) { + reset(); + String s = input; + + s = escapeComments(s); + + s = balanceHTML(s); + + s = checkTags(s); + + s = processRemoveBlanks(s); + + + + return s; + } + + + public boolean isAlwaysMakeTags() { + return this.alwaysMakeTags; + } + + + public boolean isStripComments() { + return this.stripComment; + } + + + private String escapeComments(String s) { + Matcher m = P_COMMENTS.matcher(s); + StringBuffer buf = new StringBuffer(); + if (m.find()) { + + String match = m.group(1); + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + + private String balanceHTML(String s) { + if (this.alwaysMakeTags) { + + + + + s = regexReplace(P_END_ARROW, "", s); + + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + + } + else { + + + + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + + + + + + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + + private String checkTags(String s) { + Matcher m = P_TAGS.matcher(s); + + StringBuffer buf = new StringBuffer(); + while (m.find()) { + + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + + + StringBuilder sBuilder = new StringBuilder(buf.toString()); + for (String key : this.vTagCounts.keySet()) { + + for (int ii = 0; ii < ((Integer)this.vTagCounts.get(key)).intValue(); ii++) + { + sBuilder.append(""); + } + } + s = sBuilder.toString(); + + return s; + } + + + private String processRemoveBlanks(String s) { + String result = s; + for (String tag : this.vRemoveBlanks) { + + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) + { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) + { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + + private static String regexReplace(Pattern regex_pattern, String replacement, String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + + + private String processTag(String s) { + Matcher m = P_END_TAG.matcher(s); + if (m.find()) { + + String name = m.group(1).toLowerCase(); + if (allowed(name)) + { + if (false == inArray(name, this.vSelfClosingTags)) + { + if (this.vTagCounts.containsKey(name)) { + + this.vTagCounts.put(name, Integer.valueOf(((Integer)this.vTagCounts.get(name)).intValue() - 1)); + return ""; + } + } + } + } + + + m = P_START_TAG.matcher(s); + if (m.find()) { + + String name = m.group(1).toLowerCase(); + String body = m.group(2); + String ending = m.group(3); + + + if (allowed(name)) { + + StringBuilder params = new StringBuilder(); + + Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + List paramNames = new ArrayList<>(); + List paramValues = new ArrayList<>(); + while (m2.find()) { + + paramNames.add(m2.group(1)); + paramValues.add(m2.group(3)); + } + while (m3.find()) { + + paramNames.add(m3.group(1)); + paramValues.add(m3.group(3)); + } + + + for (int ii = 0; ii < paramNames.size(); ii++) { + + String paramName = ((String)paramNames.get(ii)).toLowerCase(); + String paramValue = paramValues.get(ii); + + + + + + if (allowedAttribute(name, paramName)) { + + if (inArray(paramName, this.vProtocolAtts)) + { + paramValue = processParamProtocol(paramValue); + } + params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + } + } + + if (inArray(name, this.vSelfClosingTags)) + { + ending = " /"; + } + + if (inArray(name, this.vNeedClosingTags)) + { + ending = ""; + } + + if (ending == null || ending.length() < 1) { + + if (this.vTagCounts.containsKey(name)) + { + this.vTagCounts.put(name, Integer.valueOf(((Integer)this.vTagCounts.get(name)).intValue() + 1)); + } + else + { + this.vTagCounts.put(name, Integer.valueOf(1)); + } + + } else { + + ending = " /"; + } + return "<" + name + params + ending + ">"; + } + + + return ""; + } + + + + m = P_COMMENT.matcher(s); + if (!this.stripComment && m.find()) + { + return "<" + m.group() + ">"; + } + + return ""; + } + + + private String processParamProtocol(String s) { + s = decodeEntities(s); + Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) { + + String protocol = m.group(1); + if (!inArray(protocol, this.vAllowedProtocols)) { + + + s = "#" + s.substring(protocol.length() + 1); + if (s.startsWith("#//")) + { + s = "#" + s.substring(3); + } + } + } + + return s; + } + + + private String decodeEntities(String s) { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) { + + String match = m.group(1); + int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) { + + String match = m.group(1); + int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) { + + String match = m.group(1); + int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + + private String validateEntities(String s) { + StringBuffer buf = new StringBuffer(); + + + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) { + + String one = m.group(1); + String two = m.group(2); + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + + private String encodeQuotes(String s) { + if (this.encodeQuotes) { + + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) { + + String one = m.group(1); + String two = m.group(2); + String three = m.group(3); + + m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); + } + m.appendTail(buf); + return buf.toString(); + } + + + return s; + } + + + + + private String checkEntity(String preamble, String term) { + return (";".equals(term) && isValidEntity(preamble)) ? ('&' + preamble) : ("&" + preamble); + } + + + private boolean isValidEntity(String entity) { + return inArray(entity, this.vAllowedEntities); + } + + + private static boolean inArray(String s, String[] array) { + for (String item : array) { + + if (item != null && item.equals(s)) + { + return true; + } + } + return false; + } + + + private boolean allowed(String name) { + return ((this.vAllowed.isEmpty() || this.vAllowed.containsKey(name)) && !inArray(name, this.vDisallowed)); + } + + + private boolean allowedAttribute(String name, String paramName) { + return (allowed(name) && (this.vAllowed.isEmpty() || ((List)this.vAllowed.get(name)).contains(paramName))); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\html\HTMLFilter.class diff --git a/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyHostnameVerifier.java b/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyHostnameVerifier.java index cb5443c..d6c645d 100644 --- a/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyHostnameVerifier.java +++ b/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyHostnameVerifier.java @@ -1,264 +1,264 @@ -/* */ package com.archive.common.utils.http; -/* */ -/* */ import com.archive.common.utils.http.HttpUtils; -/* */ import javax.net.ssl.HostnameVerifier; -/* */ import javax.net.ssl.SSLSession; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ class TrustAnyHostnameVerifier -/* */ implements HostnameVerifier -/* */ { -/* */ TrustAnyHostnameVerifier() {} -/* */ -/* */ public boolean verify(String hostname, SSLSession session) { -/* 259 */ return true; -/* */ } -/* */ } + package com.archive.common.utils.http; + + import com.archive.common.utils.http.HttpUtils; + import javax.net.ssl.HostnameVerifier; + import javax.net.ssl.SSLSession; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class TrustAnyHostnameVerifier + implements HostnameVerifier + { + TrustAnyHostnameVerifier() {} + + public boolean verify(String hostname, SSLSession session) { + return true; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\http\HttpUtils$TrustAnyHostnameVerifier.class diff --git a/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyTrustManager.java b/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyTrustManager.java index a9aba79..852cf1e 100644 --- a/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyTrustManager.java +++ b/src/main/java/com/archive/common/utils/http/HttpUtils$TrustAnyTrustManager.java @@ -1,255 +1,255 @@ -/* */ package com.archive.common.utils.http; -/* */ -/* */ import com.archive.common.utils.http.HttpUtils; -/* */ import java.security.cert.X509Certificate; -/* */ import javax.net.ssl.X509TrustManager; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ class TrustAnyTrustManager -/* */ implements X509TrustManager -/* */ { -/* */ TrustAnyTrustManager() {} -/* */ -/* */ public void checkClientTrusted(X509Certificate[] chain, String authType) {} -/* */ -/* */ public void checkServerTrusted(X509Certificate[] chain, String authType) {} -/* */ -/* */ public X509Certificate[] getAcceptedIssuers() { -/* 250 */ return new X509Certificate[0]; -/* */ } -/* */ } + package com.archive.common.utils.http; + + import com.archive.common.utils.http.HttpUtils; + import java.security.cert.X509Certificate; + import javax.net.ssl.X509TrustManager; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class TrustAnyTrustManager + implements X509TrustManager + { + TrustAnyTrustManager() {} + + public void checkClientTrusted(X509Certificate[] chain, String authType) {} + + public void checkServerTrusted(X509Certificate[] chain, String authType) {} + + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\http\HttpUtils$TrustAnyTrustManager.class diff --git a/src/main/java/com/archive/common/utils/http/HttpUtils.java b/src/main/java/com/archive/common/utils/http/HttpUtils.java index 6a36a8b..13bc161 100644 --- a/src/main/java/com/archive/common/utils/http/HttpUtils.java +++ b/src/main/java/com/archive/common/utils/http/HttpUtils.java @@ -1,286 +1,286 @@ -/* */ package com.archive.common.utils.http; -/* */ -/* */ import java.io.BufferedReader; -/* */ import java.io.IOException; -/* */ import java.io.InputStream; -/* */ import java.io.InputStreamReader; -/* */ import java.io.PrintWriter; -/* */ import java.net.ConnectException; -/* */ import java.net.SocketTimeoutException; -/* */ import java.net.URL; -/* */ import java.net.URLConnection; -/* */ import java.security.SecureRandom; -/* */ import javax.net.ssl.HostnameVerifier; -/* */ import javax.net.ssl.HttpsURLConnection; -/* */ import javax.net.ssl.SSLContext; -/* */ import javax.net.ssl.TrustManager; -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class HttpUtils -/* */ { -/* 30 */ private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.http.HttpUtils.class); -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String sendGet(String url, String param) { -/* 41 */ return sendGet(url, param, "UTF-8"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String sendGet(String url, String param, String contentType) { -/* 54 */ StringBuilder result = new StringBuilder(); -/* 55 */ BufferedReader in = null; -/* */ -/* */ try { -/* 58 */ String urlNameString = url + "?" + param; -/* 59 */ log.info("sendGet - {}", urlNameString); -/* 60 */ URL realUrl = new URL(urlNameString); -/* 61 */ URLConnection connection = realUrl.openConnection(); -/* 62 */ connection.setRequestProperty("accept", "*/*"); -/* 63 */ connection.setRequestProperty("connection", "Keep-Alive"); -/* 64 */ connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); -/* 65 */ connection.connect(); -/* 66 */ in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); -/* */ String line; -/* 68 */ while ((line = in.readLine()) != null) -/* */ { -/* 70 */ result.append(line); -/* */ } -/* 72 */ log.info("recv - {}", result); -/* */ } -/* 74 */ catch (ConnectException e) { -/* */ -/* 76 */ log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); -/* */ } -/* 78 */ catch (SocketTimeoutException e) { -/* */ -/* 80 */ log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); -/* */ } -/* 82 */ catch (IOException e) { -/* */ -/* 84 */ log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); -/* */ } -/* 86 */ catch (Exception e) { -/* */ -/* 88 */ log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); -/* */ } finally { -/* */ -/* */ -/* */ try { -/* */ -/* 94 */ if (in != null) -/* */ { -/* 96 */ in.close(); -/* */ } -/* */ } -/* 99 */ catch (Exception ex) { -/* */ -/* 101 */ log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); -/* */ } -/* */ } -/* 104 */ return result.toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String sendPost(String url, String param) { -/* 116 */ PrintWriter out = null; -/* 117 */ BufferedReader in = null; -/* 118 */ StringBuilder result = new StringBuilder(); -/* */ -/* */ try { -/* 121 */ String urlNameString = url; -/* 122 */ log.info("sendPost - {}", urlNameString); -/* 123 */ URL realUrl = new URL(urlNameString); -/* 124 */ URLConnection conn = realUrl.openConnection(); -/* 125 */ conn.setRequestProperty("accept", "*/*"); -/* 126 */ conn.setRequestProperty("connection", "Keep-Alive"); -/* 127 */ conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); -/* 128 */ conn.setRequestProperty("Accept-Charset", "utf-8"); -/* 129 */ conn.setRequestProperty("contentType", "utf-8"); -/* 130 */ conn.setDoOutput(true); -/* 131 */ conn.setDoInput(true); -/* 132 */ out = new PrintWriter(conn.getOutputStream()); -/* 133 */ out.print(param); -/* 134 */ out.flush(); -/* 135 */ in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); -/* */ String line; -/* 137 */ while ((line = in.readLine()) != null) -/* */ { -/* 139 */ result.append(line); -/* */ } -/* 141 */ log.info("recv - {}", result); -/* */ } -/* 143 */ catch (ConnectException e) { -/* */ -/* 145 */ log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); -/* */ } -/* 147 */ catch (SocketTimeoutException e) { -/* */ -/* 149 */ log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); -/* */ } -/* 151 */ catch (IOException e) { -/* */ -/* 153 */ log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); -/* */ } -/* 155 */ catch (Exception e) { -/* */ -/* 157 */ log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); -/* */ } finally { -/* */ -/* */ -/* */ try { -/* */ -/* 163 */ if (out != null) -/* */ { -/* 165 */ out.close(); -/* */ } -/* 167 */ if (in != null) -/* */ { -/* 169 */ in.close(); -/* */ } -/* */ } -/* 172 */ catch (IOException ex) { -/* */ -/* 174 */ log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); -/* */ } -/* */ } -/* 177 */ return result.toString(); -/* */ } -/* */ -/* */ -/* */ public static String sendSSLPost(String url, String param) { -/* 182 */ StringBuilder result = new StringBuilder(); -/* 183 */ String urlNameString = url + "?" + param; -/* */ -/* */ try { -/* 186 */ log.info("sendSSLPost - {}", urlNameString); -/* 187 */ SSLContext sc = SSLContext.getInstance("SSL"); -/* 188 */ sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); -/* 189 */ URL console = new URL(urlNameString); -/* 190 */ HttpsURLConnection conn = (HttpsURLConnection)console.openConnection(); -/* 191 */ conn.setRequestProperty("accept", "*/*"); -/* 192 */ conn.setRequestProperty("connection", "Keep-Alive"); -/* 193 */ conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); -/* 194 */ conn.setRequestProperty("Accept-Charset", "utf-8"); -/* 195 */ conn.setRequestProperty("contentType", "utf-8"); -/* 196 */ conn.setDoOutput(true); -/* 197 */ conn.setDoInput(true); -/* */ -/* 199 */ conn.setSSLSocketFactory(sc.getSocketFactory()); -/* 200 */ conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); -/* 201 */ conn.connect(); -/* 202 */ InputStream is = conn.getInputStream(); -/* 203 */ BufferedReader br = new BufferedReader(new InputStreamReader(is)); -/* 204 */ String ret = ""; -/* 205 */ while ((ret = br.readLine()) != null) { -/* */ -/* 207 */ if (ret != null && !ret.trim().equals("")) -/* */ { -/* 209 */ result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); -/* */ } -/* */ } -/* 212 */ log.info("recv - {}", result); -/* 213 */ conn.disconnect(); -/* 214 */ br.close(); -/* */ } -/* 216 */ catch (ConnectException e) { -/* */ -/* 218 */ log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); -/* */ } -/* 220 */ catch (SocketTimeoutException e) { -/* */ -/* 222 */ log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); -/* */ } -/* 224 */ catch (IOException e) { -/* */ -/* 226 */ log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); -/* */ } -/* 228 */ catch (Exception e) { -/* */ -/* 230 */ log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); -/* */ } -/* 232 */ return result.toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean urlWhetherReachable(String urlString, int timeOutMillSeconds) { -/* 270 */ boolean flag = true; -/* */ -/* */ try { -/* 273 */ URL url = new URL(urlString); -/* 274 */ URLConnection co = url.openConnection(); -/* 275 */ co.setConnectTimeout(timeOutMillSeconds); -/* 276 */ co.connect(); -/* 277 */ } catch (Exception e1) { -/* 278 */ System.out.println(urlString + "连接请求超时!"); -/* 279 */ flag = false; -/* */ } -/* 281 */ return flag; -/* */ } -/* */ } + package com.archive.common.utils.http; + + import java.io.BufferedReader; + import java.io.IOException; + import java.io.InputStream; + import java.io.InputStreamReader; + import java.io.PrintWriter; + import java.net.ConnectException; + import java.net.SocketTimeoutException; + import java.net.URL; + import java.net.URLConnection; + import java.security.SecureRandom; + import javax.net.ssl.HostnameVerifier; + import javax.net.ssl.HttpsURLConnection; + import javax.net.ssl.SSLContext; + import javax.net.ssl.TrustManager; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + + + + + + + + + public class HttpUtils + { + private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.http.HttpUtils.class); + + + + + + + + + + public static String sendGet(String url, String param) { + return sendGet(url, param, "UTF-8"); + } + + + + + + + + + + + public static String sendGet(String url, String param, String contentType) { + StringBuilder result = new StringBuilder(); + BufferedReader in = null; + + try { + String urlNameString = url + "?" + param; + log.info("sendGet - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection connection = realUrl.openConnection(); + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + connection.connect(); + in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) { + + log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) { + + log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) { + + log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) { + + log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); + } finally { + + + try { + + if (in != null) + { + in.close(); + } + } + catch (Exception ex) { + + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + + + + + + + + + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + StringBuilder result = new StringBuilder(); + + try { + String urlNameString = url; + log.info("sendPost - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection conn = realUrl.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + out = new PrintWriter(conn.getOutputStream()); + out.print(param); + out.flush(); + in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) { + + log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) { + + log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) { + + log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) { + + log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); + } finally { + + + try { + + if (out != null) + { + out.close(); + } + if (in != null) + { + in.close(); + } + } + catch (IOException ex) { + + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + + public static String sendSSLPost(String url, String param) { + StringBuilder result = new StringBuilder(); + String urlNameString = url + "?" + param; + + try { + log.info("sendSSLPost - {}", urlNameString); + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); + URL console = new URL(urlNameString); + HttpsURLConnection conn = (HttpsURLConnection)console.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + + conn.setSSLSocketFactory(sc.getSocketFactory()); + conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); + conn.connect(); + InputStream is = conn.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String ret = ""; + while ((ret = br.readLine()) != null) { + + if (ret != null && !ret.trim().equals("")) + { + result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); + } + } + log.info("recv - {}", result); + conn.disconnect(); + br.close(); + } + catch (ConnectException e) { + + log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) { + + log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) { + + log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) { + + log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); + } + return result.toString(); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public static boolean urlWhetherReachable(String urlString, int timeOutMillSeconds) { + boolean flag = true; + + try { + URL url = new URL(urlString); + URLConnection co = url.openConnection(); + co.setConnectTimeout(timeOutMillSeconds); + co.connect(); + } catch (Exception e1) { + System.out.println(urlString + "连接请求超时!"); + flag = false; + } + return flag; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\http\HttpUtils.class diff --git a/src/main/java/com/archive/common/utils/uuid/IdUtils.java b/src/main/java/com/archive/common/utils/uuid/IdUtils.java index ede8052..6659189 100644 --- a/src/main/java/com/archive/common/utils/uuid/IdUtils.java +++ b/src/main/java/com/archive/common/utils/uuid/IdUtils.java @@ -1,52 +1,52 @@ -/* */ package com.archive.common.utils.uuid; -/* */ -/* */ import com.archive.common.utils.uuid.UUID; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class IdUtils -/* */ { -/* */ public static String randomUUID() { -/* 17 */ return UUID.randomUUID().toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String simpleUUID() { -/* 27 */ return UUID.randomUUID().toString(true); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String fastUUID() { -/* 37 */ return UUID.fastUUID().toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String fastSimpleUUID() { -/* 47 */ return UUID.fastUUID().toString(true); -/* */ } -/* */ } + package com.archive.common.utils.uuid; + + import com.archive.common.utils.uuid.UUID; + + + + + + + + + + + public class IdUtils + { + public static String randomUUID() { + return UUID.randomUUID().toString(); + } + + + + + + + + public static String simpleUUID() { + return UUID.randomUUID().toString(true); + } + + + + + + + + public static String fastUUID() { + return UUID.fastUUID().toString(); + } + + + + + + + + public static String fastSimpleUUID() { + return UUID.fastUUID().toString(true); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\util\\uuid\IdUtils.class diff --git a/src/main/java/com/archive/framework/config/FilterConfig.java b/src/main/java/com/archive/framework/config/FilterConfig.java index 18733f3..89f03f7 100644 --- a/src/main/java/com/archive/framework/config/FilterConfig.java +++ b/src/main/java/com/archive/framework/config/FilterConfig.java @@ -1,51 +1,51 @@ -/* */ package com.archive.framework.config + package com.archive.framework.config ; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.xss.XssFilter; -/* */ import com.google.common.collect.Maps; -/* */ import java.util.Map; -/* */ import javax.servlet.DispatcherType; -/* */ import javax.servlet.Filter; -/* */ import org.springframework.beans.factory.annotation.Value; -/* */ import org.springframework.boot.web.servlet.FilterRegistrationBean; -/* */ import org.springframework.context.annotation.Bean; -/* */ import org.springframework.context.annotation.Configuration; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Configuration -/* */ public class FilterConfig -/* */ { -/* */ @Value("${xss.enabled}") -/* */ private String enabled; -/* */ @Value("${xss.excludes}") -/* */ private String excludes; -/* */ @Value("${xss.urlPatterns}") -/* */ private String urlPatterns; -/* */ -/* */ @Bean -/* */ public FilterRegistrationBean xssFilterRegistration() { -/* 34 */ FilterRegistrationBean registration = new FilterRegistrationBean(); -/* 35 */ registration.setDispatcherTypes(DispatcherType.REQUEST, new DispatcherType[0]); -/* 36 */ registration.setFilter((Filter)new XssFilter()); -/* 37 */ registration.addUrlPatterns(StringUtils.split(this.urlPatterns, ",")); -/* 38 */ registration.setName("xssFilter"); -/* 39 */ registration.setOrder(2147483647); -/* 40 */ Map initParameters = Maps.newHashMap(); -/* 41 */ initParameters.put("excludes", this.excludes); -/* 42 */ initParameters.put("enabled", this.enabled); -/* 43 */ registration.setInitParameters(initParameters); -/* 44 */ return registration; -/* */ } -/* */ } + + import com.archive.common.utils.StringUtils; + import com.archive.common.xss.XssFilter; + import com.google.common.collect.Maps; + import java.util.Map; + import javax.servlet.DispatcherType; + import javax.servlet.Filter; + import org.springframework.beans.factory.annotation.Value; + import org.springframework.boot.web.servlet.FilterRegistrationBean; + import org.springframework.context.annotation.Bean; + import org.springframework.context.annotation.Configuration; + + + + + + + + + + @Configuration + public class FilterConfig + { + @Value("${xss.enabled}") + private String enabled; + @Value("${xss.excludes}") + private String excludes; + @Value("${xss.urlPatterns}") + private String urlPatterns; + + @Bean + public FilterRegistrationBean xssFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setDispatcherTypes(DispatcherType.REQUEST, new DispatcherType[0]); + registration.setFilter((Filter)new XssFilter()); + registration.addUrlPatterns(StringUtils.split(this.urlPatterns, ",")); + registration.setName("xssFilter"); + registration.setOrder(2147483647); + Map initParameters = Maps.newHashMap(); + initParameters.put("excludes", this.excludes); + initParameters.put("enabled", this.enabled); + registration.setInitParameters(initParameters); + return registration; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\FilterConfig.class diff --git a/src/main/java/com/archive/framework/config/GenConfig.java b/src/main/java/com/archive/framework/config/GenConfig.java index b492db3..e1c9726 100644 --- a/src/main/java/com/archive/framework/config/GenConfig.java +++ b/src/main/java/com/archive/framework/config/GenConfig.java @@ -1,71 +1,71 @@ -/* */ package com.archive.framework.config + package com.archive.framework.config ; -/* */ -/* */ import org.springframework.boot.context.properties.ConfigurationProperties; -/* */ import org.springframework.stereotype.Component; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Component -/* */ @ConfigurationProperties(prefix = "gen") -/* */ public class GenConfig -/* */ { -/* */ public static String author; -/* */ public static String packageName; -/* */ public static boolean autoRemovePre; -/* */ public static String tablePrefix; -/* */ -/* */ public static String getAuthor() { -/* 29 */ return author; -/* */ } -/* */ -/* */ -/* */ public void setAuthor(String author) { -/* 34 */ com.archive.framework.config.GenConfig.author = author; -/* */ } -/* */ -/* */ -/* */ public static String getPackageName() { -/* 39 */ return packageName; -/* */ } -/* */ -/* */ -/* */ public void setPackageName(String packageName) { -/* 44 */ com.archive.framework.config.GenConfig.packageName = packageName; -/* */ } -/* */ -/* */ -/* */ public static boolean getAutoRemovePre() { -/* 49 */ return autoRemovePre; -/* */ } -/* */ -/* */ -/* */ public void setAutoRemovePre(boolean autoRemovePre) { -/* 54 */ com.archive.framework.config.GenConfig.autoRemovePre = autoRemovePre; -/* */ } -/* */ -/* */ -/* */ public static String getTablePrefix() { -/* 59 */ return tablePrefix; -/* */ } -/* */ -/* */ -/* */ public void setTablePrefix(String tablePrefix) { -/* 64 */ com.archive.framework.config.GenConfig.tablePrefix = tablePrefix; -/* */ } -/* */ } + + import org.springframework.boot.context.properties.ConfigurationProperties; + import org.springframework.stereotype.Component; + + + + + + + + + + + + + + + @Component + @ConfigurationProperties(prefix = "gen") + public class GenConfig + { + public static String author; + public static String packageName; + public static boolean autoRemovePre; + public static String tablePrefix; + + public static String getAuthor() { + return author; + } + + + public void setAuthor(String author) { + com.archive.framework.config.GenConfig.author = author; + } + + + public static String getPackageName() { + return packageName; + } + + + public void setPackageName(String packageName) { + com.archive.framework.config.GenConfig.packageName = packageName; + } + + + public static boolean getAutoRemovePre() { + return autoRemovePre; + } + + + public void setAutoRemovePre(boolean autoRemovePre) { + com.archive.framework.config.GenConfig.autoRemovePre = autoRemovePre; + } + + + public static String getTablePrefix() { + return tablePrefix; + } + + + public void setTablePrefix(String tablePrefix) { + com.archive.framework.config.GenConfig.tablePrefix = tablePrefix; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\GenConfig.class diff --git a/src/main/java/com/archive/framework/config/I18nConfig.java b/src/main/java/com/archive/framework/config/I18nConfig.java index d04f603..0f07bf8 100644 --- a/src/main/java/com/archive/framework/config/I18nConfig.java +++ b/src/main/java/com/archive/framework/config/I18nConfig.java @@ -1,47 +1,47 @@ -/* */ package com.archive.framework.config + package com.archive.framework.config ; -/* */ -/* */ import java.util.Locale; -/* */ import org.springframework.context.annotation.Bean; -/* */ import org.springframework.context.annotation.Configuration; -/* */ import org.springframework.web.servlet.HandlerInterceptor; -/* */ import org.springframework.web.servlet.LocaleResolver; -/* */ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -/* */ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -/* */ import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; -/* */ import org.springframework.web.servlet.i18n.SessionLocaleResolver; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Configuration -/* */ public class I18nConfig -/* */ implements WebMvcConfigurer -/* */ { -/* */ @Bean -/* */ public LocaleResolver localeResolver() { -/* 23 */ SessionLocaleResolver slr = new SessionLocaleResolver(); -/* */ -/* 25 */ slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE); -/* 26 */ return (LocaleResolver)slr; -/* */ } -/* */ -/* */ -/* */ @Bean -/* */ public LocaleChangeInterceptor localeChangeInterceptor() { -/* 32 */ LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); -/* */ -/* 34 */ lci.setParamName("lang"); -/* 35 */ return lci; -/* */ } -/* */ -/* */ -/* */ -/* */ public void addInterceptors(InterceptorRegistry registry) { -/* 41 */ registry.addInterceptor((HandlerInterceptor)localeChangeInterceptor()); -/* */ } -/* */ } + + import java.util.Locale; + import org.springframework.context.annotation.Bean; + import org.springframework.context.annotation.Configuration; + import org.springframework.web.servlet.HandlerInterceptor; + import org.springframework.web.servlet.LocaleResolver; + import org.springframework.web.servlet.config.annotation.InterceptorRegistry; + import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; + import org.springframework.web.servlet.i18n.SessionLocaleResolver; + + + + + + @Configuration + public class I18nConfig + implements WebMvcConfigurer + { + @Bean + public LocaleResolver localeResolver() { + SessionLocaleResolver slr = new SessionLocaleResolver(); + + slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE); + return (LocaleResolver)slr; + } + + + @Bean + public LocaleChangeInterceptor localeChangeInterceptor() { + LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); + + lci.setParamName("lang"); + return lci; + } + + + + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor((HandlerInterceptor)localeChangeInterceptor()); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\I18nConfig.class diff --git a/src/main/java/com/archive/framework/web/exception/GlobalExceptionHandler.java b/src/main/java/com/archive/framework/web/exception/GlobalExceptionHandler.java index 439ed04..39a7664 100644 --- a/src/main/java/com/archive/framework/web/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/archive/framework/web/exception/GlobalExceptionHandler.java @@ -1,121 +1,121 @@ -/* */ package com.archive.framework.web.exception + package com.archive.framework.web.exception ; -/* */ -/* */ import com.archive.common.exception.BusinessException; -/* */ import com.archive.common.exception.DemoModeException; -/* */ import com.archive.common.utils.ServletUtils; -/* */ import com.archive.common.utils.security.PermissionUtils; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import javax.servlet.http.HttpServletRequest; -/* */ import org.apache.shiro.authz.AuthorizationException; -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ import org.springframework.validation.BindException; -/* */ import org.springframework.validation.ObjectError; -/* */ import org.springframework.web.HttpRequestMethodNotSupportedException; -/* */ import org.springframework.web.bind.annotation.ExceptionHandler; -/* */ import org.springframework.web.bind.annotation.RestControllerAdvice; -/* */ import org.springframework.web.servlet.ModelAndView; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RestControllerAdvice -/* */ public class GlobalExceptionHandler -/* */ { -/* 26 */ private static final Logger log = LoggerFactory.getLogger(com.archive.framework.web.exception.GlobalExceptionHandler.class); -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({AuthorizationException.class}) -/* */ public Object handleAuthorizationException(HttpServletRequest request, AuthorizationException e) { -/* 34 */ log.error(e.getMessage(), (Throwable)e); -/* 35 */ if (ServletUtils.isAjaxRequest(request)) -/* */ { -/* 37 */ return AjaxResult.error(PermissionUtils.getMsg(e.getMessage())); -/* */ } -/* */ -/* */ -/* 41 */ ModelAndView modelAndView = new ModelAndView(); -/* 42 */ modelAndView.setViewName("error/unauth"); -/* 43 */ return modelAndView; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({HttpRequestMethodNotSupportedException.class}) -/* */ public AjaxResult handleException(HttpRequestMethodNotSupportedException e) { -/* 53 */ log.error(e.getMessage(), (Throwable)e); -/* 54 */ return AjaxResult.error("不支持' " + e.getMethod() + "'请求"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({RuntimeException.class}) -/* */ public AjaxResult notFount(RuntimeException e) { -/* 63 */ log.error("运行时异常:", e); -/* 64 */ return AjaxResult.error("运行时异常:" + e.getMessage()); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({Exception.class}) -/* */ public AjaxResult handleException(Exception e) { -/* 73 */ log.error(e.getMessage(), e); -/* 74 */ return AjaxResult.error("服务器错误,请联系管理员"); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({BusinessException.class}) -/* */ public Object businessException(HttpServletRequest request, BusinessException e) { -/* 83 */ log.error(e.getMessage(), (Throwable)e); -/* 84 */ if (ServletUtils.isAjaxRequest(request)) -/* */ { -/* 86 */ return AjaxResult.error(e.getMessage()); -/* */ } -/* */ -/* */ -/* 90 */ ModelAndView modelAndView = new ModelAndView(); -/* 91 */ modelAndView.addObject("errorMessage", e.getMessage()); -/* 92 */ modelAndView.setViewName("error/business"); -/* 93 */ return modelAndView; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({BindException.class}) -/* */ public AjaxResult validatedBindException(BindException e) { -/* 103 */ log.error(e.getMessage(), (Throwable)e); -/* 104 */ String message = ((ObjectError)e.getAllErrors().get(0)).getDefaultMessage(); -/* 105 */ return AjaxResult.error(message); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @ExceptionHandler({DemoModeException.class}) -/* */ public AjaxResult demoModeException(DemoModeException e) { -/* 114 */ return AjaxResult.error("演示模式,不允许操作"); -/* */ } -/* */ } + + import com.archive.common.exception.BusinessException; + import com.archive.common.exception.DemoModeException; + import com.archive.common.utils.ServletUtils; + import com.archive.common.utils.security.PermissionUtils; + import com.archive.framework.web.domain.AjaxResult; + import javax.servlet.http.HttpServletRequest; + import org.apache.shiro.authz.AuthorizationException; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + import org.springframework.validation.BindException; + import org.springframework.validation.ObjectError; + import org.springframework.web.HttpRequestMethodNotSupportedException; + import org.springframework.web.bind.annotation.ExceptionHandler; + import org.springframework.web.bind.annotation.RestControllerAdvice; + import org.springframework.web.servlet.ModelAndView; + + + + + + @RestControllerAdvice + public class GlobalExceptionHandler + { + private static final Logger log = LoggerFactory.getLogger(com.archive.framework.web.exception.GlobalExceptionHandler.class); + + + + + + @ExceptionHandler({AuthorizationException.class}) + public Object handleAuthorizationException(HttpServletRequest request, AuthorizationException e) { + log.error(e.getMessage(), (Throwable)e); + if (ServletUtils.isAjaxRequest(request)) + { + return AjaxResult.error(PermissionUtils.getMsg(e.getMessage())); + } + + + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("error/unauth"); + return modelAndView; + } + + + + + + + @ExceptionHandler({HttpRequestMethodNotSupportedException.class}) + public AjaxResult handleException(HttpRequestMethodNotSupportedException e) { + log.error(e.getMessage(), (Throwable)e); + return AjaxResult.error("不支持' " + e.getMethod() + "'请求"); + } + + + + + + @ExceptionHandler({RuntimeException.class}) + public AjaxResult notFount(RuntimeException e) { + log.error("运行时异常:", e); + return AjaxResult.error("运行时异常:" + e.getMessage()); + } + + + + + + @ExceptionHandler({Exception.class}) + public AjaxResult handleException(Exception e) { + log.error(e.getMessage(), e); + return AjaxResult.error("服务器错误,请联系管理员"); + } + + + + + + @ExceptionHandler({BusinessException.class}) + public Object businessException(HttpServletRequest request, BusinessException e) { + log.error(e.getMessage(), (Throwable)e); + if (ServletUtils.isAjaxRequest(request)) + { + return AjaxResult.error(e.getMessage()); + } + + + ModelAndView modelAndView = new ModelAndView(); + modelAndView.addObject("errorMessage", e.getMessage()); + modelAndView.setViewName("error/business"); + return modelAndView; + } + + + + + + + @ExceptionHandler({BindException.class}) + public AjaxResult validatedBindException(BindException e) { + log.error(e.getMessage(), (Throwable)e); + String message = ((ObjectError)e.getAllErrors().get(0)).getDefaultMessage(); + return AjaxResult.error(message); + } + + + + + + @ExceptionHandler({DemoModeException.class}) + public AjaxResult demoModeException(DemoModeException e) { + return AjaxResult.error("演示模式,不允许操作"); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\web\exception\GlobalExceptionHandler.class diff --git a/src/main/java/com/archive/project/common/service/ExecuteSqlServiceImpl.java b/src/main/java/com/archive/project/common/service/ExecuteSqlServiceImpl.java index 33d5fcc..4a3a282 100644 --- a/src/main/java/com/archive/project/common/service/ExecuteSqlServiceImpl.java +++ b/src/main/java/com/archive/project/common/service/ExecuteSqlServiceImpl.java @@ -1,102 +1,102 @@ -/* */ package com.archive.project.common.service + package com.archive.project.common.service ; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.project.common.mapper.ExecuteSqlMapper; -/* */ import com.archive.project.common.service.IExecuteSqlService; -/* */ import java.util.LinkedHashMap; -/* */ import java.util.List; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.jdbc.core.JdbcTemplate; -/* */ import org.springframework.stereotype.Service; -/* */ -/* */ @Service -/* */ public class ExecuteSqlServiceImpl -/* */ implements IExecuteSqlService -/* */ { -/* */ @Autowired -/* */ private ExecuteSqlMapper executeSqlMapper; -/* */ @Autowired -/* */ public JdbcTemplate jdbcTemplate; -/* */ -/* */ public String getSingle(String sql) { -/* 22 */ List> selectResult = this.executeSqlMapper.select(sql); -/* 23 */ if (selectResult.isEmpty() || selectResult.get(0) == null) { -/* 24 */ return ""; -/* */ } -/* 26 */ return ((LinkedHashMap)selectResult.get(0)).values().iterator().next().toString(); -/* */ } -/* */ -/* */ -/* */ -/* */ public List> queryList(String sql) { -/* 32 */ return this.executeSqlMapper.select(sql); -/* */ } -/* */ -/* */ -/* */ public LinkedHashMap getOne(String sql) { -/* 37 */ return this.executeSqlMapper.select(sql).get(0); -/* */ } -/* */ -/* */ -/* */ public boolean insert(String sql) { -/* */ try { -/* 43 */ this.executeSqlMapper.insert(sql); -/* 44 */ return true; -/* 45 */ } catch (Exception e) { -/* 46 */ e.printStackTrace(); -/* 47 */ return false; -/* */ } -/* */ } -/* */ -/* */ -/* */ public boolean batchInsert(List sql) { -/* 53 */ return insert(StringUtils.join(sql, ';')); -/* */ } -/* */ -/* */ -/* */ public boolean update(String sql) { -/* */ try { -/* 59 */ this.executeSqlMapper.update(sql); -/* 60 */ return true; -/* 61 */ } catch (Exception e) { -/* 62 */ e.printStackTrace(); -/* 63 */ return false; -/* */ } -/* */ } -/* */ -/* */ -/* */ public boolean batchUpdate(List sql) { -/* 69 */ return update(StringUtils.join(sql, ';')); -/* */ } -/* */ -/* */ -/* */ public boolean delete(String sql) { -/* */ try { -/* 75 */ this.executeSqlMapper.delete(sql); -/* 76 */ return true; -/* 77 */ } catch (Exception e) { -/* 78 */ e.printStackTrace(); -/* 79 */ return false; -/* */ } -/* */ } -/* */ -/* */ -/* */ public boolean batchDelete(List sql) { -/* 85 */ return delete(StringUtils.join(sql, ';')); -/* */ } -/* */ -/* */ -/* */ public void jdbcTemplateExecute(String sql) throws Exception { -/* 90 */ this.jdbcTemplate.execute(sql); -/* */ } -/* */ -/* */ -/* */ public Integer jdbcTemplateQueryCount(String sql) { -/* 95 */ return (Integer)this.jdbcTemplate.queryForObject(sql, Integer.class); -/* */ } -/* */ } + + import com.archive.common.utils.StringUtils; + import com.archive.project.common.mapper.ExecuteSqlMapper; + import com.archive.project.common.service.IExecuteSqlService; + import java.util.LinkedHashMap; + import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.jdbc.core.JdbcTemplate; + import org.springframework.stereotype.Service; + + @Service + public class ExecuteSqlServiceImpl + implements IExecuteSqlService + { + @Autowired + private ExecuteSqlMapper executeSqlMapper; + @Autowired + public JdbcTemplate jdbcTemplate; + + public String getSingle(String sql) { + List> selectResult = this.executeSqlMapper.select(sql); + if (selectResult.isEmpty() || selectResult.get(0) == null) { + return ""; + } + return ((LinkedHashMap)selectResult.get(0)).values().iterator().next().toString(); + } + + + + public List> queryList(String sql) { + return this.executeSqlMapper.select(sql); + } + + + public LinkedHashMap getOne(String sql) { + return this.executeSqlMapper.select(sql).get(0); + } + + + public boolean insert(String sql) { + try { + this.executeSqlMapper.insert(sql); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + + public boolean batchInsert(List sql) { + return insert(StringUtils.join(sql, ';')); + } + + + public boolean update(String sql) { + try { + this.executeSqlMapper.update(sql); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + + public boolean batchUpdate(List sql) { + return update(StringUtils.join(sql, ';')); + } + + + public boolean delete(String sql) { + try { + this.executeSqlMapper.delete(sql); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + + public boolean batchDelete(List sql) { + return delete(StringUtils.join(sql, ';')); + } + + + public void jdbcTemplateExecute(String sql) throws Exception { + this.jdbcTemplate.execute(sql); + } + + + public Integer jdbcTemplateQueryCount(String sql) { + return (Integer)this.jdbcTemplate.queryForObject(sql, Integer.class); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\common\service\ExecuteSqlServiceImpl.class diff --git a/src/main/java/com/archive/project/dajs/gsbdr/controller/GsbdrController.java b/src/main/java/com/archive/project/dajs/gsbdr/controller/GsbdrController.java index db7aa8c..6dd8f5d 100644 --- a/src/main/java/com/archive/project/dajs/gsbdr/controller/GsbdrController.java +++ b/src/main/java/com/archive/project/dajs/gsbdr/controller/GsbdrController.java @@ -1,64 +1,64 @@ -/* */ package com.archive.project.dajs.gsbdr.controller + package com.archive.project.dajs.gsbdr.controller ; -/* */ -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.page.TableDataInfo; -/* */ import com.archive.project.dajs.gsbdr.service.IGsbdrService; -/* */ import java.io.IOException; -/* */ import java.util.ArrayList; -/* */ import java.util.List; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/dajs/gsbdr"}) -/* */ public class GsbdrController -/* */ extends BaseController -/* */ { -/* 31 */ private String prefix = "dajs/gsbdr"; -/* */ -/* */ -/* */ @Autowired -/* */ private IGsbdrService gsbdrService; -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"dajs:gsbdr"}) -/* */ @GetMapping -/* */ public String gsbdr(ModelMap mmap) { -/* 42 */ return this.prefix + "/gsbdr"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/list"}) -/* */ @ResponseBody -/* */ public TableDataInfo list(String key, int page, int size) throws IOException { -/* 54 */ startPage(); -/* */ -/* 56 */ List list = new ArrayList(); -/* 57 */ return getDataTable(list); -/* */ } -/* */ } + + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.page.TableDataInfo; + import com.archive.project.dajs.gsbdr.service.IGsbdrService; + import java.io.IOException; + import java.util.ArrayList; + import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + + + + + + + @Controller + @RequestMapping({"/dajs/gsbdr"}) + public class GsbdrController + extends BaseController + { + private String prefix = "dajs/gsbdr"; + + + @Autowired + private IGsbdrService gsbdrService; + + + + @RequiresPermissions({"dajs:gsbdr"}) + @GetMapping + public String gsbdr(ModelMap mmap) { + return this.prefix + "/gsbdr"; + } + + + + + + + + @GetMapping({"/list"}) + @ResponseBody + public TableDataInfo list(String key, int page, int size) throws IOException { + startPage(); + + List list = new ArrayList(); + return getDataTable(list); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\dajs\gsbdr\controller\GsbdrController.class diff --git a/src/main/java/com/archive/project/system/user/controller/IndexController.java b/src/main/java/com/archive/project/system/user/controller/IndexController.java index 29fa0ee..e9ee2b9 100644 --- a/src/main/java/com/archive/project/system/user/controller/IndexController.java +++ b/src/main/java/com/archive/project/system/user/controller/IndexController.java @@ -1,164 +1,164 @@ -/* */ package com.archive.project.system.user.controller + package com.archive.project.system.user.controller ; -/* */ -/* */ import com.archive.common.utils.CookieUtils; -/* */ import com.archive.common.utils.DateUtils; -/* */ import com.archive.common.utils.ServletUtils; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.framework.config.ArchiveConfig; -/* */ import com.archive.framework.shiro.service.PasswordService; -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.project.system.config.service.IConfigService; -/* */ import com.archive.project.system.menu.domain.Menu; -/* */ import com.archive.project.system.menu.service.IMenuService; -/* */ import com.archive.project.system.user.domain.User; -/* */ import java.util.Date; -/* */ import java.util.List; -/* */ import javax.servlet.http.Cookie; -/* */ import javax.servlet.http.HttpServletResponse; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.PathVariable; -/* */ import org.springframework.web.bind.annotation.PostMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ public class IndexController -/* */ extends BaseController -/* */ { -/* */ @Autowired -/* */ private IMenuService menuService; -/* */ @Autowired -/* */ private IConfigService configService; -/* */ @Autowired -/* */ private PasswordService passwordService; -/* */ @Autowired -/* */ private ArchiveConfig archiveConfig; -/* */ -/* */ @GetMapping({"/index"}) -/* */ public String index(ModelMap mmap) { -/* 53 */ String systemName = this.configService.selectConfigByKey("archive.SystemName"); -/* */ -/* 55 */ User user = getSysUser(); -/* */ -/* 57 */ List menus = this.menuService.selectMenusByUser(user); -/* 58 */ mmap.put("menus", menus); -/* 59 */ mmap.put("user", user); -/* 60 */ mmap.put("sideTheme", this.configService.selectConfigByKey("sys.index.sideTheme")); -/* 61 */ mmap.put("skinName", this.configService.selectConfigByKey("sys.index.skinName")); -/* 62 */ mmap.put("ignoreFooter", this.configService.selectConfigByKey("sys.index.ignoreFooter")); -/* 63 */ mmap.put("copyrightYear", this.archiveConfig.getCopyrightYear()); -/* 64 */ mmap.put("demoEnabled", Boolean.valueOf(this.archiveConfig.isDemoEnabled())); -/* 65 */ mmap.put("isDefaultModifyPwd", Boolean.valueOf(initPasswordIsModify(user.getPwdUpdateDate()))); -/* 66 */ mmap.put("isPasswordExpired", Boolean.valueOf(passwordIsExpiration(user.getPwdUpdateDate()))); -/* 67 */ mmap.put("SystemName", systemName); -/* */ -/* 69 */ String menuStyle = this.configService.selectConfigByKey("sys.index.menuStyle"); -/* */ -/* 71 */ String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle; -/* */ -/* */ -/* 74 */ Cookie[] cookies = ServletUtils.getRequest().getCookies(); -/* 75 */ for (Cookie cookie : cookies) { -/* */ -/* 77 */ if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName())) { -/* */ -/* 79 */ indexStyle = cookie.getValue(); -/* */ break; -/* */ } -/* */ } -/* 83 */ String webIndex = "topnav".equalsIgnoreCase(indexStyle) ? "index-topnav" : "index"; -/* 84 */ return webIndex; -/* */ } -/* */ -/* */ -/* */ -/* */ @GetMapping({"/lockscreen"}) -/* */ public String lockscreen(ModelMap mmap) { -/* 91 */ mmap.put("user", getSysUser()); -/* 92 */ ServletUtils.getSession().setAttribute("lockscreen", Boolean.valueOf(true)); -/* 93 */ return "lock"; -/* */ } -/* */ -/* */ -/* */ -/* */ @PostMapping({"/unlockscreen"}) -/* */ @ResponseBody -/* */ public AjaxResult unlockscreen(String password) { -/* 101 */ User user = getSysUser(); -/* 102 */ if (StringUtils.isNull(user)) -/* */ { -/* 104 */ return AjaxResult.error("服务器超时,请重新登陆"); -/* */ } -/* 106 */ if (this.passwordService.matches(user, password)) { -/* */ -/* 108 */ ServletUtils.getSession().removeAttribute("lockscreen"); -/* 109 */ return AjaxResult.success(); -/* */ } -/* 111 */ return AjaxResult.error("密码不正确,请重新输入。"); -/* */ } -/* */ -/* */ -/* */ -/* */ @GetMapping({"/system/switchSkin"}) -/* */ public String switchSkin() { -/* 118 */ return "skin"; -/* */ } -/* */ -/* */ -/* */ -/* */ @GetMapping({"/system/menuStyle/{style}"}) -/* */ public void menuStyle(@PathVariable String style, HttpServletResponse response) { -/* 125 */ CookieUtils.setCookie(response, "nav-style", style); -/* */ } -/* */ -/* */ -/* */ -/* */ @GetMapping({"/system/main"}) -/* */ public String main(ModelMap mmap) { -/* 132 */ mmap.put("version", this.archiveConfig.getVersion()); -/* 133 */ return "main"; -/* */ } -/* */ -/* */ -/* */ -/* */ public boolean initPasswordIsModify(Date pwdUpdateDate) { -/* 139 */ Integer initPasswordModify = Convert.toInt(this.configService.selectConfigByKey("sys.account.initPasswordModify")); -/* 140 */ return (initPasswordModify != null && initPasswordModify.intValue() == 1 && pwdUpdateDate == null); -/* */ } -/* */ -/* */ -/* */ -/* */ public boolean passwordIsExpiration(Date pwdUpdateDate) { -/* 146 */ Integer passwordValidateDays = Convert.toInt(this.configService.selectConfigByKey("sys.account.passwordValidateDays")); -/* 147 */ if (passwordValidateDays != null && passwordValidateDays.intValue() > 0) { -/* */ -/* 149 */ if (StringUtils.isNull(pwdUpdateDate)) -/* */ { -/* */ -/* 152 */ return true; -/* */ } -/* 154 */ Date nowDate = DateUtils.getNowDate(); -/* 155 */ return (DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidateDays.intValue()); -/* */ } -/* 157 */ return false; -/* */ } -/* */ } + + import com.archive.common.utils.CookieUtils; + import com.archive.common.utils.DateUtils; + import com.archive.common.utils.ServletUtils; + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.text.Convert; + import com.archive.framework.config.ArchiveConfig; + import com.archive.framework.shiro.service.PasswordService; + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.domain.AjaxResult; + import com.archive.project.system.config.service.IConfigService; + import com.archive.project.system.menu.domain.Menu; + import com.archive.project.system.menu.service.IMenuService; + import com.archive.project.system.user.domain.User; + import java.util.Date; + import java.util.List; + import javax.servlet.http.Cookie; + import javax.servlet.http.HttpServletResponse; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.PostMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + + + + + + + + @Controller + public class IndexController + extends BaseController + { + @Autowired + private IMenuService menuService; + @Autowired + private IConfigService configService; + @Autowired + private PasswordService passwordService; + @Autowired + private ArchiveConfig archiveConfig; + + @GetMapping({"/index"}) + public String index(ModelMap mmap) { + String systemName = this.configService.selectConfigByKey("archive.SystemName"); + + User user = getSysUser(); + + List menus = this.menuService.selectMenusByUser(user); + mmap.put("menus", menus); + mmap.put("user", user); + mmap.put("sideTheme", this.configService.selectConfigByKey("sys.index.sideTheme")); + mmap.put("skinName", this.configService.selectConfigByKey("sys.index.skinName")); + mmap.put("ignoreFooter", this.configService.selectConfigByKey("sys.index.ignoreFooter")); + mmap.put("copyrightYear", this.archiveConfig.getCopyrightYear()); + mmap.put("demoEnabled", Boolean.valueOf(this.archiveConfig.isDemoEnabled())); + mmap.put("isDefaultModifyPwd", Boolean.valueOf(initPasswordIsModify(user.getPwdUpdateDate()))); + mmap.put("isPasswordExpired", Boolean.valueOf(passwordIsExpiration(user.getPwdUpdateDate()))); + mmap.put("SystemName", systemName); + + String menuStyle = this.configService.selectConfigByKey("sys.index.menuStyle"); + + String indexStyle = ServletUtils.checkAgentIsMobile(ServletUtils.getRequest().getHeader("User-Agent")) ? "index" : menuStyle; + + + Cookie[] cookies = ServletUtils.getRequest().getCookies(); + for (Cookie cookie : cookies) { + + if (StringUtils.isNotEmpty(cookie.getName()) && "nav-style".equalsIgnoreCase(cookie.getName())) { + + indexStyle = cookie.getValue(); + break; + } + } + String webIndex = "topnav".equalsIgnoreCase(indexStyle) ? "index-topnav" : "index"; + return webIndex; + } + + + + @GetMapping({"/lockscreen"}) + public String lockscreen(ModelMap mmap) { + mmap.put("user", getSysUser()); + ServletUtils.getSession().setAttribute("lockscreen", Boolean.valueOf(true)); + return "lock"; + } + + + + @PostMapping({"/unlockscreen"}) + @ResponseBody + public AjaxResult unlockscreen(String password) { + User user = getSysUser(); + if (StringUtils.isNull(user)) + { + return AjaxResult.error("服务器超时,请重新登陆"); + } + if (this.passwordService.matches(user, password)) { + + ServletUtils.getSession().removeAttribute("lockscreen"); + return AjaxResult.success(); + } + return AjaxResult.error("密码不正确,请重新输入。"); + } + + + + @GetMapping({"/system/switchSkin"}) + public String switchSkin() { + return "skin"; + } + + + + @GetMapping({"/system/menuStyle/{style}"}) + public void menuStyle(@PathVariable String style, HttpServletResponse response) { + CookieUtils.setCookie(response, "nav-style", style); + } + + + + @GetMapping({"/system/main"}) + public String main(ModelMap mmap) { + mmap.put("version", this.archiveConfig.getVersion()); + return "main"; + } + + + + public boolean initPasswordIsModify(Date pwdUpdateDate) { + Integer initPasswordModify = Convert.toInt(this.configService.selectConfigByKey("sys.account.initPasswordModify")); + return (initPasswordModify != null && initPasswordModify.intValue() == 1 && pwdUpdateDate == null); + } + + + + public boolean passwordIsExpiration(Date pwdUpdateDate) { + Integer passwordValidateDays = Convert.toInt(this.configService.selectConfigByKey("sys.account.passwordValidateDays")); + if (passwordValidateDays != null && passwordValidateDays.intValue() > 0) { + + if (StringUtils.isNull(pwdUpdateDate)) + { + + return true; + } + Date nowDate = DateUtils.getNowDate(); + return (DateUtils.differentDaysByMillisecond(nowDate, pwdUpdateDate) > passwordValidateDays.intValue()); + } + return false; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\syste\\user\controller\IndexController.class diff --git a/src/main/java/com/archive/project/tool/gen/controller/GenController.java b/src/main/java/com/archive/project/tool/gen/controller/GenController.java index f7390a8..03422cf 100644 --- a/src/main/java/com/archive/project/tool/gen/controller/GenController.java +++ b/src/main/java/com/archive/project/tool/gen/controller/GenController.java @@ -1,256 +1,256 @@ -/* */ package com.archive.project.tool.gen.controller + package com.archive.project.tool.gen.controller ; -/* */ -/* */ import com.alibaba.fastjson.JSON; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.framework.aspectj.lang.annotation.Log; -/* */ import com.archive.framework.aspectj.lang.enums.BusinessType; -/* */ import com.archive.framework.web.controller.BaseController; -/* */ import com.archive.framework.web.domain.AjaxResult; -/* */ import com.archive.framework.web.domain.CxSelect; -/* */ import com.archive.framework.web.page.TableDataInfo; -/* */ import com.archive.project.tool.gen.domain.GenTable; -/* */ import com.archive.project.tool.gen.domain.GenTableColumn; -/* */ import com.archive.project.tool.gen.service.IGenTableColumnService; -/* */ import com.archive.project.tool.gen.service.IGenTableService; -/* */ import java.io.IOException; -/* */ import java.io.OutputStream; -/* */ import java.util.ArrayList; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import javax.servlet.http.HttpServletResponse; -/* */ import org.apache.commons.io.IOUtils; -/* */ import org.apache.shiro.authz.annotation.RequiresPermissions; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Controller; -/* */ import org.springframework.ui.ModelMap; -/* */ import org.springframework.validation.annotation.Validated; -/* */ import org.springframework.web.bind.annotation.GetMapping; -/* */ import org.springframework.web.bind.annotation.PathVariable; -/* */ import org.springframework.web.bind.annotation.PostMapping; -/* */ import org.springframework.web.bind.annotation.RequestMapping; -/* */ import org.springframework.web.bind.annotation.ResponseBody; -/* */ -/* */ -/* */ -/* */ -/* */ @Controller -/* */ @RequestMapping({"/tool/gen"}) -/* */ public class GenController -/* */ extends BaseController -/* */ { -/* 42 */ private String prefix = "tool/gen"; -/* */ -/* */ @Autowired -/* */ private IGenTableService genTableService; -/* */ -/* */ @Autowired -/* */ private IGenTableColumnService genTableColumnService; -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:view"}) -/* */ @GetMapping -/* */ public String gen() { -/* 54 */ return this.prefix + "/gen"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:list"}) -/* */ @PostMapping({"/list"}) -/* */ @ResponseBody -/* */ public TableDataInfo genList(GenTable genTable) { -/* 65 */ startPage(); -/* 66 */ List list = this.genTableService.selectGenTableList(genTable); -/* 67 */ return getDataTable(list); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:list"}) -/* */ @PostMapping({"/db/list"}) -/* */ @ResponseBody -/* */ public TableDataInfo dataList(GenTable genTable) { -/* 78 */ startPage(); -/* 79 */ List list = this.genTableService.selectDbTableList(genTable); -/* 80 */ return getDataTable(list); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:list"}) -/* */ @PostMapping({"/column/list"}) -/* */ @ResponseBody -/* */ public TableDataInfo columnList(GenTableColumn genTableColumn) { -/* 91 */ TableDataInfo dataInfo = new TableDataInfo(); -/* 92 */ List list = this.genTableColumnService.selectGenTableColumnListByTableId(genTableColumn); -/* 93 */ dataInfo.setRows(list); -/* 94 */ dataInfo.setTotal(list.size()); -/* 95 */ return dataInfo; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:list"}) -/* */ @GetMapping({"/importTable"}) -/* */ public String importTable() { -/* 105 */ return this.prefix + "/importTable"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:list"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.IMPORT) -/* */ @PostMapping({"/importTable"}) -/* */ @ResponseBody -/* */ public AjaxResult importTableSave(String tables) { -/* 117 */ String[] tableNames = Convert.toStrArray(tables); -/* */ -/* 119 */ List tableList = this.genTableService.selectDbTableListByNames(tableNames); -/* 120 */ this.genTableService.importGenTable(tableList); -/* 121 */ return AjaxResult.success(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @GetMapping({"/edit/{tableId}"}) -/* */ public String edit(@PathVariable("tableId") Long tableId, ModelMap mmap) { -/* 130 */ GenTable table = this.genTableService.selectGenTableById(tableId); -/* 131 */ List genTables = this.genTableService.selectGenTableAll(); -/* 132 */ List cxSelect = new ArrayList<>(); -/* 133 */ for (GenTable genTable : genTables) { -/* */ -/* 135 */ if (!StringUtils.equals(table.getTableName(), genTable.getTableName())) { -/* */ -/* 137 */ CxSelect cxTable = new CxSelect(genTable.getTableName(), genTable.getTableName() + ':' + genTable.getTableComment()); -/* 138 */ List cxColumns = new ArrayList<>(); -/* 139 */ for (GenTableColumn tableColumn : genTable.getColumns()) -/* */ { -/* 141 */ cxColumns.add(new CxSelect(tableColumn.getColumnName(), tableColumn.getColumnName() + ':' + tableColumn.getColumnComment())); -/* */ } -/* 143 */ cxTable.setS(cxColumns); -/* 144 */ cxSelect.add(cxTable); -/* */ } -/* */ } -/* 147 */ mmap.put("table", table); -/* 148 */ mmap.put("data", JSON.toJSON(cxSelect)); -/* 149 */ return this.prefix + "/edit"; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:edit"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.UPDATE) -/* */ @PostMapping({"/edit"}) -/* */ @ResponseBody -/* */ public AjaxResult editSave(@Validated GenTable genTable) { -/* 161 */ this.genTableService.validateEdit(genTable); -/* 162 */ this.genTableService.updateGenTable(genTable); -/* 163 */ return AjaxResult.success(); -/* */ } -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:remove"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.DELETE) -/* */ @PostMapping({"/remove"}) -/* */ @ResponseBody -/* */ public AjaxResult remove(String ids) { -/* 172 */ this.genTableService.deleteGenTableByIds(ids); -/* 173 */ return AjaxResult.success(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:preview"}) -/* */ @GetMapping({"/preview/{tableId}"}) -/* */ @ResponseBody -/* */ public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException { -/* 184 */ Map dataMap = this.genTableService.previewCode(tableId); -/* 185 */ return AjaxResult.success(dataMap); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:code"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.GENCODE) -/* */ @GetMapping({"/download/{tableName}"}) -/* */ public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { -/* 196 */ byte[] data = this.genTableService.downloadCode(tableName); -/* 197 */ genCode(response, data); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:code"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.GENCODE) -/* */ @GetMapping({"/genCode/{tableName}"}) -/* */ @ResponseBody -/* */ public AjaxResult genCode(@PathVariable("tableName") String tableName) { -/* 209 */ this.genTableService.generatorCode(tableName); -/* 210 */ return AjaxResult.success(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:edit"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.UPDATE) -/* */ @GetMapping({"/synchDb/{tableName}"}) -/* */ @ResponseBody -/* */ public AjaxResult synchDb(@PathVariable("tableName") String tableName) { -/* 222 */ this.genTableService.synchDb(tableName); -/* 223 */ return AjaxResult.success(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @RequiresPermissions({"tool:gen:code"}) -/* */ @Log(title = "代码生成", businessType = BusinessType.GENCODE) -/* */ @GetMapping({"/batchGenCode"}) -/* */ @ResponseBody -/* */ public void batchGenCode(HttpServletResponse response, String tables) throws IOException { -/* 235 */ String[] tableNames = Convert.toStrArray(tables); -/* 236 */ byte[] data = this.genTableService.downloadCode(tableNames); -/* 237 */ genCode(response, data); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void genCode(HttpServletResponse response, byte[] data) throws IOException { -/* 245 */ response.reset(); -/* 246 */ response.setHeader("Content-Disposition", "attachment; filename=\"archive.zip\""); -/* 247 */ response.addHeader("Content-Length", "" + data.length); -/* 248 */ response.setContentType("application/octet-stream; charset=UTF-8"); -/* 249 */ IOUtils.write(data, (OutputStream)response.getOutputStream()); -/* */ } -/* */ } + + import com.alibaba.fastjson.JSON; + import com.archive.common.utils.StringUtils; + import com.archive.common.utils.text.Convert; + import com.archive.framework.aspectj.lang.annotation.Log; + import com.archive.framework.aspectj.lang.enums.BusinessType; + import com.archive.framework.web.controller.BaseController; + import com.archive.framework.web.domain.AjaxResult; + import com.archive.framework.web.domain.CxSelect; + import com.archive.framework.web.page.TableDataInfo; + import com.archive.project.tool.gen.domain.GenTable; + import com.archive.project.tool.gen.domain.GenTableColumn; + import com.archive.project.tool.gen.service.IGenTableColumnService; + import com.archive.project.tool.gen.service.IGenTableService; + import java.io.IOException; + import java.io.OutputStream; + import java.util.ArrayList; + import java.util.List; + import java.util.Map; + import javax.servlet.http.HttpServletResponse; + import org.apache.commons.io.IOUtils; + import org.apache.shiro.authz.annotation.RequiresPermissions; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; + import org.springframework.ui.ModelMap; + import org.springframework.validation.annotation.Validated; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.PostMapping; + import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.ResponseBody; + + + + + @Controller + @RequestMapping({"/tool/gen"}) + public class GenController + extends BaseController + { + private String prefix = "tool/gen"; + + @Autowired + private IGenTableService genTableService; + + @Autowired + private IGenTableColumnService genTableColumnService; + + + @RequiresPermissions({"tool:gen:view"}) + @GetMapping + public String gen() { + return this.prefix + "/gen"; + } + + + + + + @RequiresPermissions({"tool:gen:list"}) + @PostMapping({"/list"}) + @ResponseBody + public TableDataInfo genList(GenTable genTable) { + startPage(); + List list = this.genTableService.selectGenTableList(genTable); + return getDataTable(list); + } + + + + + + @RequiresPermissions({"tool:gen:list"}) + @PostMapping({"/db/list"}) + @ResponseBody + public TableDataInfo dataList(GenTable genTable) { + startPage(); + List list = this.genTableService.selectDbTableList(genTable); + return getDataTable(list); + } + + + + + + @RequiresPermissions({"tool:gen:list"}) + @PostMapping({"/column/list"}) + @ResponseBody + public TableDataInfo columnList(GenTableColumn genTableColumn) { + TableDataInfo dataInfo = new TableDataInfo(); + List list = this.genTableColumnService.selectGenTableColumnListByTableId(genTableColumn); + dataInfo.setRows(list); + dataInfo.setTotal(list.size()); + return dataInfo; + } + + + + + + @RequiresPermissions({"tool:gen:list"}) + @GetMapping({"/importTable"}) + public String importTable() { + return this.prefix + "/importTable"; + } + + + + + + @RequiresPermissions({"tool:gen:list"}) + @Log(title = "代码生成", businessType = BusinessType.IMPORT) + @PostMapping({"/importTable"}) + @ResponseBody + public AjaxResult importTableSave(String tables) { + String[] tableNames = Convert.toStrArray(tables); + + List tableList = this.genTableService.selectDbTableListByNames(tableNames); + this.genTableService.importGenTable(tableList); + return AjaxResult.success(); + } + + + + + + @GetMapping({"/edit/{tableId}"}) + public String edit(@PathVariable("tableId") Long tableId, ModelMap mmap) { + GenTable table = this.genTableService.selectGenTableById(tableId); + List genTables = this.genTableService.selectGenTableAll(); + List cxSelect = new ArrayList<>(); + for (GenTable genTable : genTables) { + + if (!StringUtils.equals(table.getTableName(), genTable.getTableName())) { + + CxSelect cxTable = new CxSelect(genTable.getTableName(), genTable.getTableName() + ':' + genTable.getTableComment()); + List cxColumns = new ArrayList<>(); + for (GenTableColumn tableColumn : genTable.getColumns()) + { + cxColumns.add(new CxSelect(tableColumn.getColumnName(), tableColumn.getColumnName() + ':' + tableColumn.getColumnComment())); + } + cxTable.setS(cxColumns); + cxSelect.add(cxTable); + } + } + mmap.put("table", table); + mmap.put("data", JSON.toJSON(cxSelect)); + return this.prefix + "/edit"; + } + + + + + + @RequiresPermissions({"tool:gen:edit"}) + @Log(title = "代码生成", businessType = BusinessType.UPDATE) + @PostMapping({"/edit"}) + @ResponseBody + public AjaxResult editSave(@Validated GenTable genTable) { + this.genTableService.validateEdit(genTable); + this.genTableService.updateGenTable(genTable); + return AjaxResult.success(); + } + + + @RequiresPermissions({"tool:gen:remove"}) + @Log(title = "代码生成", businessType = BusinessType.DELETE) + @PostMapping({"/remove"}) + @ResponseBody + public AjaxResult remove(String ids) { + this.genTableService.deleteGenTableByIds(ids); + return AjaxResult.success(); + } + + + + + + @RequiresPermissions({"tool:gen:preview"}) + @GetMapping({"/preview/{tableId}"}) + @ResponseBody + public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException { + Map dataMap = this.genTableService.previewCode(tableId); + return AjaxResult.success(dataMap); + } + + + + + + @RequiresPermissions({"tool:gen:code"}) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping({"/download/{tableName}"}) + public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { + byte[] data = this.genTableService.downloadCode(tableName); + genCode(response, data); + } + + + + + + @RequiresPermissions({"tool:gen:code"}) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping({"/genCode/{tableName}"}) + @ResponseBody + public AjaxResult genCode(@PathVariable("tableName") String tableName) { + this.genTableService.generatorCode(tableName); + return AjaxResult.success(); + } + + + + + + @RequiresPermissions({"tool:gen:edit"}) + @Log(title = "代码生成", businessType = BusinessType.UPDATE) + @GetMapping({"/synchDb/{tableName}"}) + @ResponseBody + public AjaxResult synchDb(@PathVariable("tableName") String tableName) { + this.genTableService.synchDb(tableName); + return AjaxResult.success(); + } + + + + + + @RequiresPermissions({"tool:gen:code"}) + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping({"/batchGenCode"}) + @ResponseBody + public void batchGenCode(HttpServletResponse response, String tables) throws IOException { + String[] tableNames = Convert.toStrArray(tables); + byte[] data = this.genTableService.downloadCode(tableNames); + genCode(response, data); + } + + + + + + private void genCode(HttpServletResponse response, byte[] data) throws IOException { + response.reset(); + response.setHeader("Content-Disposition", "attachment; filename=\"archive.zip\""); + response.addHeader("Content-Length", "" + data.length); + response.setContentType("application/octet-stream; charset=UTF-8"); + IOUtils.write(data, (OutputStream)response.getOutputStream()); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\gen\controller\GenController.class diff --git a/src/main/java/com/archive/project/tool/gen/domain/GenTable.java b/src/main/java/com/archive/project/tool/gen/domain/GenTable.java index dfdecfc..86f4591 100644 --- a/src/main/java/com/archive/project/tool/gen/domain/GenTable.java +++ b/src/main/java/com/archive/project/tool/gen/domain/GenTable.java @@ -1,377 +1,377 @@ -/* */ package com.archive.project.tool.gen.domain + package com.archive.project.tool.gen.domain ; -/* */ -/* */ import com.archive.common.constant.GenConstants; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.framework.web.domain.BaseEntity; -/* */ import com.archive.project.tool.gen.domain.GenTableColumn; -/* */ import java.util.List; -/* */ import javax.validation.Valid; -/* */ import javax.validation.constraints.NotBlank; -/* */ import org.apache.commons.lang3.ArrayUtils; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class GenTable -/* */ extends BaseEntity -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ private Long tableId; -/* */ @NotBlank(message = "表名称不能为空") -/* */ private String tableName; -/* */ @NotBlank(message = "表描述不能为空") -/* */ private String tableComment; -/* */ private String subTableName; -/* */ private String subTableFkName; -/* */ @NotBlank(message = "实体类名称不能为空") -/* */ private String className; -/* */ private String tplCategory; -/* */ @NotBlank(message = "生成包路径不能为空") -/* */ private String packageName; -/* */ @NotBlank(message = "生成模块名不能为空") -/* */ private String moduleName; -/* */ @NotBlank(message = "生成业务名不能为空") -/* */ private String businessName; -/* */ @NotBlank(message = "生成功能名不能为空") -/* */ private String functionName; -/* */ @NotBlank(message = "作者不能为空") -/* */ private String functionAuthor; -/* */ private String genType; -/* */ private String genPath; -/* */ private GenTableColumn pkColumn; -/* */ private com.archive.project.tool.gen.domain.GenTable subTable; -/* */ @Valid -/* */ private List columns; -/* */ private String options; -/* */ private String treeCode; -/* */ private String treeParentCode; -/* */ private String treeName; -/* */ private String parentMenuId; -/* */ private String parentMenuName; -/* */ -/* */ public Long getTableId() { -/* 100 */ return this.tableId; -/* */ } -/* */ -/* */ -/* */ public void setTableId(Long tableId) { -/* 105 */ this.tableId = tableId; -/* */ } -/* */ -/* */ -/* */ public String getTableName() { -/* 110 */ return this.tableName; -/* */ } -/* */ -/* */ -/* */ public void setTableName(String tableName) { -/* 115 */ this.tableName = tableName; -/* */ } -/* */ -/* */ -/* */ public String getTableComment() { -/* 120 */ return this.tableComment; -/* */ } -/* */ -/* */ -/* */ public void setTableComment(String tableComment) { -/* 125 */ this.tableComment = tableComment; -/* */ } -/* */ -/* */ -/* */ public String getSubTableName() { -/* 130 */ return this.subTableName; -/* */ } -/* */ -/* */ -/* */ public void setSubTableName(String subTableName) { -/* 135 */ this.subTableName = subTableName; -/* */ } -/* */ -/* */ -/* */ public String getSubTableFkName() { -/* 140 */ return this.subTableFkName; -/* */ } -/* */ -/* */ -/* */ public void setSubTableFkName(String subTableFkName) { -/* 145 */ this.subTableFkName = subTableFkName; -/* */ } -/* */ -/* */ -/* */ public String getClassName() { -/* 150 */ return this.className; -/* */ } -/* */ -/* */ -/* */ public void setClassName(String className) { -/* 155 */ this.className = className; -/* */ } -/* */ -/* */ -/* */ public String getTplCategory() { -/* 160 */ return this.tplCategory; -/* */ } -/* */ -/* */ -/* */ public void setTplCategory(String tplCategory) { -/* 165 */ this.tplCategory = tplCategory; -/* */ } -/* */ -/* */ -/* */ public String getPackageName() { -/* 170 */ return this.packageName; -/* */ } -/* */ -/* */ -/* */ public void setPackageName(String packageName) { -/* 175 */ this.packageName = packageName; -/* */ } -/* */ -/* */ -/* */ public String getModuleName() { -/* 180 */ return this.moduleName; -/* */ } -/* */ -/* */ -/* */ public void setModuleName(String moduleName) { -/* 185 */ this.moduleName = moduleName; -/* */ } -/* */ -/* */ -/* */ public String getBusinessName() { -/* 190 */ return this.businessName; -/* */ } -/* */ -/* */ -/* */ public void setBusinessName(String businessName) { -/* 195 */ this.businessName = businessName; -/* */ } -/* */ -/* */ -/* */ public String getFunctionName() { -/* 200 */ return this.functionName; -/* */ } -/* */ -/* */ -/* */ public void setFunctionName(String functionName) { -/* 205 */ this.functionName = functionName; -/* */ } -/* */ -/* */ -/* */ public String getFunctionAuthor() { -/* 210 */ return this.functionAuthor; -/* */ } -/* */ -/* */ -/* */ public void setFunctionAuthor(String functionAuthor) { -/* 215 */ this.functionAuthor = functionAuthor; -/* */ } -/* */ -/* */ -/* */ public String getGenType() { -/* 220 */ return this.genType; -/* */ } -/* */ -/* */ -/* */ public void setGenType(String genType) { -/* 225 */ this.genType = genType; -/* */ } -/* */ -/* */ -/* */ public String getGenPath() { -/* 230 */ return this.genPath; -/* */ } -/* */ -/* */ -/* */ public void setGenPath(String genPath) { -/* 235 */ this.genPath = genPath; -/* */ } -/* */ -/* */ -/* */ public GenTableColumn getPkColumn() { -/* 240 */ return this.pkColumn; -/* */ } -/* */ -/* */ -/* */ public void setPkColumn(GenTableColumn pkColumn) { -/* 245 */ this.pkColumn = pkColumn; -/* */ } -/* */ -/* */ -/* */ public com.archive.project.tool.gen.domain.GenTable getSubTable() { -/* 250 */ return this.subTable; -/* */ } -/* */ -/* */ -/* */ public void setSubTable(com.archive.project.tool.gen.domain.GenTable subTable) { -/* 255 */ this.subTable = subTable; -/* */ } -/* */ -/* */ -/* */ public List getColumns() { -/* 260 */ return this.columns; -/* */ } -/* */ -/* */ -/* */ public void setColumns(List columns) { -/* 265 */ this.columns = columns; -/* */ } -/* */ -/* */ -/* */ public String getOptions() { -/* 270 */ return this.options; -/* */ } -/* */ -/* */ -/* */ public void setOptions(String options) { -/* 275 */ this.options = options; -/* */ } -/* */ -/* */ -/* */ public String getTreeCode() { -/* 280 */ return this.treeCode; -/* */ } -/* */ -/* */ -/* */ public void setTreeCode(String treeCode) { -/* 285 */ this.treeCode = treeCode; -/* */ } -/* */ -/* */ -/* */ public String getTreeParentCode() { -/* 290 */ return this.treeParentCode; -/* */ } -/* */ -/* */ -/* */ public void setTreeParentCode(String treeParentCode) { -/* 295 */ this.treeParentCode = treeParentCode; -/* */ } -/* */ -/* */ -/* */ public String getTreeName() { -/* 300 */ return this.treeName; -/* */ } -/* */ -/* */ -/* */ public void setTreeName(String treeName) { -/* 305 */ this.treeName = treeName; -/* */ } -/* */ -/* */ -/* */ public String getParentMenuId() { -/* 310 */ return this.parentMenuId; -/* */ } -/* */ -/* */ -/* */ public void setParentMenuId(String parentMenuId) { -/* 315 */ this.parentMenuId = parentMenuId; -/* */ } -/* */ -/* */ -/* */ public String getParentMenuName() { -/* 320 */ return this.parentMenuName; -/* */ } -/* */ -/* */ -/* */ public void setParentMenuName(String parentMenuName) { -/* 325 */ this.parentMenuName = parentMenuName; -/* */ } -/* */ -/* */ -/* */ public boolean isSub() { -/* 330 */ return isSub(this.tplCategory); -/* */ } -/* */ -/* */ -/* */ public static boolean isSub(String tplCategory) { -/* 335 */ return (tplCategory != null && StringUtils.equals("sub", tplCategory)); -/* */ } -/* */ -/* */ -/* */ public boolean isTree() { -/* 340 */ return isTree(this.tplCategory); -/* */ } -/* */ -/* */ -/* */ public static boolean isTree(String tplCategory) { -/* 345 */ return (tplCategory != null && StringUtils.equals("tree", tplCategory)); -/* */ } -/* */ -/* */ -/* */ public boolean isCrud() { -/* 350 */ return isCrud(this.tplCategory); -/* */ } -/* */ -/* */ -/* */ public static boolean isCrud(String tplCategory) { -/* 355 */ return (tplCategory != null && StringUtils.equals("crud", tplCategory)); -/* */ } -/* */ -/* */ -/* */ public boolean isSuperColumn(String javaField) { -/* 360 */ return isSuperColumn(this.tplCategory, javaField); -/* */ } -/* */ -/* */ -/* */ public static boolean isSuperColumn(String tplCategory, String javaField) { -/* 365 */ if (isTree(tplCategory)) -/* */ { -/* 367 */ return StringUtils.equalsAnyIgnoreCase(javaField, -/* 368 */ (CharSequence[])ArrayUtils.addAll((Object[])GenConstants.TREE_ENTITY, (Object[])GenConstants.BASE_ENTITY)); -/* */ } -/* 370 */ return StringUtils.equalsAnyIgnoreCase(javaField, (CharSequence[])GenConstants.BASE_ENTITY); -/* */ } -/* */ } + + import com.archive.common.constant.GenConstants; + import com.archive.common.utils.StringUtils; + import com.archive.framework.web.domain.BaseEntity; + import com.archive.project.tool.gen.domain.GenTableColumn; + import java.util.List; + import javax.validation.Valid; + import javax.validation.constraints.NotBlank; + import org.apache.commons.lang3.ArrayUtils; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class GenTable + extends BaseEntity + { + private static final long serialVersionUID = 1L; + private Long tableId; + @NotBlank(message = "表名称不能为空") + private String tableName; + @NotBlank(message = "表描述不能为空") + private String tableComment; + private String subTableName; + private String subTableFkName; + @NotBlank(message = "实体类名称不能为空") + private String className; + private String tplCategory; + @NotBlank(message = "生成包路径不能为空") + private String packageName; + @NotBlank(message = "生成模块名不能为空") + private String moduleName; + @NotBlank(message = "生成业务名不能为空") + private String businessName; + @NotBlank(message = "生成功能名不能为空") + private String functionName; + @NotBlank(message = "作者不能为空") + private String functionAuthor; + private String genType; + private String genPath; + private GenTableColumn pkColumn; + private com.archive.project.tool.gen.domain.GenTable subTable; + @Valid + private List columns; + private String options; + private String treeCode; + private String treeParentCode; + private String treeName; + private String parentMenuId; + private String parentMenuName; + + public Long getTableId() { + return this.tableId; + } + + + public void setTableId(Long tableId) { + this.tableId = tableId; + } + + + public String getTableName() { + return this.tableName; + } + + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + + public String getTableComment() { + return this.tableComment; + } + + + public void setTableComment(String tableComment) { + this.tableComment = tableComment; + } + + + public String getSubTableName() { + return this.subTableName; + } + + + public void setSubTableName(String subTableName) { + this.subTableName = subTableName; + } + + + public String getSubTableFkName() { + return this.subTableFkName; + } + + + public void setSubTableFkName(String subTableFkName) { + this.subTableFkName = subTableFkName; + } + + + public String getClassName() { + return this.className; + } + + + public void setClassName(String className) { + this.className = className; + } + + + public String getTplCategory() { + return this.tplCategory; + } + + + public void setTplCategory(String tplCategory) { + this.tplCategory = tplCategory; + } + + + public String getPackageName() { + return this.packageName; + } + + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + + public String getModuleName() { + return this.moduleName; + } + + + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } + + + public String getBusinessName() { + return this.businessName; + } + + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + + public String getFunctionName() { + return this.functionName; + } + + + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + + public String getFunctionAuthor() { + return this.functionAuthor; + } + + + public void setFunctionAuthor(String functionAuthor) { + this.functionAuthor = functionAuthor; + } + + + public String getGenType() { + return this.genType; + } + + + public void setGenType(String genType) { + this.genType = genType; + } + + + public String getGenPath() { + return this.genPath; + } + + + public void setGenPath(String genPath) { + this.genPath = genPath; + } + + + public GenTableColumn getPkColumn() { + return this.pkColumn; + } + + + public void setPkColumn(GenTableColumn pkColumn) { + this.pkColumn = pkColumn; + } + + + public com.archive.project.tool.gen.domain.GenTable getSubTable() { + return this.subTable; + } + + + public void setSubTable(com.archive.project.tool.gen.domain.GenTable subTable) { + this.subTable = subTable; + } + + + public List getColumns() { + return this.columns; + } + + + public void setColumns(List columns) { + this.columns = columns; + } + + + public String getOptions() { + return this.options; + } + + + public void setOptions(String options) { + this.options = options; + } + + + public String getTreeCode() { + return this.treeCode; + } + + + public void setTreeCode(String treeCode) { + this.treeCode = treeCode; + } + + + public String getTreeParentCode() { + return this.treeParentCode; + } + + + public void setTreeParentCode(String treeParentCode) { + this.treeParentCode = treeParentCode; + } + + + public String getTreeName() { + return this.treeName; + } + + + public void setTreeName(String treeName) { + this.treeName = treeName; + } + + + public String getParentMenuId() { + return this.parentMenuId; + } + + + public void setParentMenuId(String parentMenuId) { + this.parentMenuId = parentMenuId; + } + + + public String getParentMenuName() { + return this.parentMenuName; + } + + + public void setParentMenuName(String parentMenuName) { + this.parentMenuName = parentMenuName; + } + + + public boolean isSub() { + return isSub(this.tplCategory); + } + + + public static boolean isSub(String tplCategory) { + return (tplCategory != null && StringUtils.equals("sub", tplCategory)); + } + + + public boolean isTree() { + return isTree(this.tplCategory); + } + + + public static boolean isTree(String tplCategory) { + return (tplCategory != null && StringUtils.equals("tree", tplCategory)); + } + + + public boolean isCrud() { + return isCrud(this.tplCategory); + } + + + public static boolean isCrud(String tplCategory) { + return (tplCategory != null && StringUtils.equals("crud", tplCategory)); + } + + + public boolean isSuperColumn(String javaField) { + return isSuperColumn(this.tplCategory, javaField); + } + + + public static boolean isSuperColumn(String tplCategory, String javaField) { + if (isTree(tplCategory)) + { + return StringUtils.equalsAnyIgnoreCase(javaField, + (CharSequence[])ArrayUtils.addAll((Object[])GenConstants.TREE_ENTITY, (Object[])GenConstants.BASE_ENTITY)); + } + return StringUtils.equalsAnyIgnoreCase(javaField, (CharSequence[])GenConstants.BASE_ENTITY); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\gen\domain\GenTable.class diff --git a/src/main/java/com/archive/project/tool/gen/domain/GenTableColumn.java b/src/main/java/com/archive/project/tool/gen/domain/GenTableColumn.java index 7f7d754..2137fcf 100644 --- a/src/main/java/com/archive/project/tool/gen/domain/GenTableColumn.java +++ b/src/main/java/com/archive/project/tool/gen/domain/GenTableColumn.java @@ -1,377 +1,377 @@ -/* */ package com.archive.project.tool.gen.domain + package com.archive.project.tool.gen.domain ; -/* */ -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.framework.web.domain.BaseEntity; -/* */ import javax.validation.constraints.NotBlank; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class GenTableColumn -/* */ extends BaseEntity -/* */ { -/* */ private static final long serialVersionUID = 1L; -/* */ private Long columnId; -/* */ private Long tableId; -/* */ private String columnName; -/* */ private String columnComment; -/* */ private String columnType; -/* */ private String javaType; -/* */ @NotBlank(message = "Java属性不能为空") -/* */ private String javaField; -/* */ private String isPk; -/* */ private String isIncrement; -/* */ private String isRequired; -/* */ private String isInsert; -/* */ private String isEdit; -/* */ private String isList; -/* */ private String isQuery; -/* */ private String queryType; -/* */ private String htmlType; -/* */ private String dictType; -/* */ private Integer sort; -/* */ -/* */ public void setColumnId(Long columnId) { -/* 73 */ this.columnId = columnId; -/* */ } -/* */ -/* */ -/* */ public Long getColumnId() { -/* 78 */ return this.columnId; -/* */ } -/* */ -/* */ -/* */ public void setTableId(Long tableId) { -/* 83 */ this.tableId = tableId; -/* */ } -/* */ -/* */ -/* */ public Long getTableId() { -/* 88 */ return this.tableId; -/* */ } -/* */ -/* */ -/* */ public void setColumnName(String columnName) { -/* 93 */ this.columnName = columnName; -/* */ } -/* */ -/* */ -/* */ public String getColumnName() { -/* 98 */ return this.columnName; -/* */ } -/* */ -/* */ -/* */ public void setColumnComment(String columnComment) { -/* 103 */ this.columnComment = columnComment; -/* */ } -/* */ -/* */ -/* */ public String getColumnComment() { -/* 108 */ return this.columnComment; -/* */ } -/* */ -/* */ -/* */ public void setColumnType(String columnType) { -/* 113 */ this.columnType = columnType; -/* */ } -/* */ -/* */ -/* */ public String getColumnType() { -/* 118 */ return this.columnType; -/* */ } -/* */ -/* */ -/* */ public void setJavaType(String javaType) { -/* 123 */ this.javaType = javaType; -/* */ } -/* */ -/* */ -/* */ public String getJavaType() { -/* 128 */ return this.javaType; -/* */ } -/* */ -/* */ -/* */ public void setJavaField(String javaField) { -/* 133 */ this.javaField = javaField; -/* */ } -/* */ -/* */ -/* */ public String getJavaField() { -/* 138 */ return this.javaField; -/* */ } -/* */ -/* */ -/* */ public String getCapJavaField() { -/* 143 */ return StringUtils.capitalize(this.javaField); -/* */ } -/* */ -/* */ -/* */ public void setIsPk(String isPk) { -/* 148 */ this.isPk = isPk; -/* */ } -/* */ -/* */ -/* */ public String getIsPk() { -/* 153 */ return this.isPk; -/* */ } -/* */ -/* */ -/* */ public boolean isPk() { -/* 158 */ return isPk(this.isPk); -/* */ } -/* */ -/* */ -/* */ public boolean isPk(String isPk) { -/* 163 */ return (isPk != null && StringUtils.equals("1", isPk)); -/* */ } -/* */ -/* */ -/* */ public String getIsIncrement() { -/* 168 */ return this.isIncrement; -/* */ } -/* */ -/* */ -/* */ public void setIsIncrement(String isIncrement) { -/* 173 */ this.isIncrement = isIncrement; -/* */ } -/* */ -/* */ -/* */ public boolean isIncrement() { -/* 178 */ return isIncrement(this.isIncrement); -/* */ } -/* */ -/* */ -/* */ public boolean isIncrement(String isIncrement) { -/* 183 */ return (isIncrement != null && StringUtils.equals("1", isIncrement)); -/* */ } -/* */ -/* */ -/* */ public void setIsRequired(String isRequired) { -/* 188 */ this.isRequired = isRequired; -/* */ } -/* */ -/* */ -/* */ public String getIsRequired() { -/* 193 */ return this.isRequired; -/* */ } -/* */ -/* */ -/* */ public boolean isRequired() { -/* 198 */ return isRequired(this.isRequired); -/* */ } -/* */ -/* */ -/* */ public boolean isRequired(String isRequired) { -/* 203 */ return (isRequired != null && StringUtils.equals("1", isRequired)); -/* */ } -/* */ -/* */ -/* */ public void setIsInsert(String isInsert) { -/* 208 */ this.isInsert = isInsert; -/* */ } -/* */ -/* */ -/* */ public String getIsInsert() { -/* 213 */ return this.isInsert; -/* */ } -/* */ -/* */ -/* */ public boolean isInsert() { -/* 218 */ return isInsert(this.isInsert); -/* */ } -/* */ -/* */ -/* */ public boolean isInsert(String isInsert) { -/* 223 */ return (isInsert != null && StringUtils.equals("1", isInsert)); -/* */ } -/* */ -/* */ -/* */ public void setIsEdit(String isEdit) { -/* 228 */ this.isEdit = isEdit; -/* */ } -/* */ -/* */ -/* */ public String getIsEdit() { -/* 233 */ return this.isEdit; -/* */ } -/* */ -/* */ -/* */ public boolean isEdit() { -/* 238 */ return isInsert(this.isEdit); -/* */ } -/* */ -/* */ -/* */ public boolean isEdit(String isEdit) { -/* 243 */ return (isEdit != null && StringUtils.equals("1", isEdit)); -/* */ } -/* */ -/* */ -/* */ public void setIsList(String isList) { -/* 248 */ this.isList = isList; -/* */ } -/* */ -/* */ -/* */ public String getIsList() { -/* 253 */ return this.isList; -/* */ } -/* */ -/* */ -/* */ public boolean isList() { -/* 258 */ return isList(this.isList); -/* */ } -/* */ -/* */ -/* */ public boolean isList(String isList) { -/* 263 */ return (isList != null && StringUtils.equals("1", isList)); -/* */ } -/* */ -/* */ -/* */ public void setIsQuery(String isQuery) { -/* 268 */ this.isQuery = isQuery; -/* */ } -/* */ -/* */ -/* */ public String getIsQuery() { -/* 273 */ return this.isQuery; -/* */ } -/* */ -/* */ -/* */ public boolean isQuery() { -/* 278 */ return isQuery(this.isQuery); -/* */ } -/* */ -/* */ -/* */ public boolean isQuery(String isQuery) { -/* 283 */ return (isQuery != null && StringUtils.equals("1", isQuery)); -/* */ } -/* */ -/* */ -/* */ public void setQueryType(String queryType) { -/* 288 */ this.queryType = queryType; -/* */ } -/* */ -/* */ -/* */ public String getQueryType() { -/* 293 */ return this.queryType; -/* */ } -/* */ -/* */ -/* */ public String getHtmlType() { -/* 298 */ return this.htmlType; -/* */ } -/* */ -/* */ -/* */ public void setHtmlType(String htmlType) { -/* 303 */ this.htmlType = htmlType; -/* */ } -/* */ -/* */ -/* */ public void setDictType(String dictType) { -/* 308 */ this.dictType = dictType; -/* */ } -/* */ -/* */ -/* */ public String getDictType() { -/* 313 */ return this.dictType; -/* */ } -/* */ -/* */ -/* */ public void setSort(Integer sort) { -/* 318 */ this.sort = sort; -/* */ } -/* */ -/* */ -/* */ public Integer getSort() { -/* 323 */ return this.sort; -/* */ } -/* */ -/* */ -/* */ public boolean isSuperColumn() { -/* 328 */ return isSuperColumn(this.javaField); -/* */ } -/* */ -/* */ -/* */ public static boolean isSuperColumn(String javaField) { -/* 333 */ return StringUtils.equalsAnyIgnoreCase(javaField, new CharSequence[] { "createBy", "createTime", "updateBy", "updateTime", "remark", "parentName", "parentId", "orderNum", "ancestors" }); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public boolean isUsableColumn() { -/* 342 */ return isUsableColumn(this.javaField); -/* */ } -/* */ -/* */ -/* */ -/* */ public static boolean isUsableColumn(String javaField) { -/* 348 */ return StringUtils.equalsAnyIgnoreCase(javaField, new CharSequence[] { "parentId", "orderNum", "remark" }); -/* */ } -/* */ -/* */ -/* */ public String readConverterExp() { -/* 353 */ String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); -/* 354 */ StringBuffer sb = new StringBuffer(); -/* 355 */ if (StringUtils.isNotEmpty(remarks)) { -/* */ -/* 357 */ for (String value : remarks.split(" ")) { -/* */ -/* 359 */ if (StringUtils.isNotEmpty(value)) { -/* */ -/* 361 */ Object startStr = value.subSequence(0, 1); -/* 362 */ String endStr = value.substring(1); -/* 363 */ sb.append("").append(startStr).append("=").append(endStr).append(","); -/* */ } -/* */ } -/* 366 */ return sb.deleteCharAt(sb.length() - 1).toString(); -/* */ } -/* */ -/* */ -/* 370 */ return this.columnComment; -/* */ } -/* */ } + + import com.archive.common.utils.StringUtils; + import com.archive.framework.web.domain.BaseEntity; + import javax.validation.constraints.NotBlank; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public class GenTableColumn + extends BaseEntity + { + private static final long serialVersionUID = 1L; + private Long columnId; + private Long tableId; + private String columnName; + private String columnComment; + private String columnType; + private String javaType; + @NotBlank(message = "Java属性不能为空") + private String javaField; + private String isPk; + private String isIncrement; + private String isRequired; + private String isInsert; + private String isEdit; + private String isList; + private String isQuery; + private String queryType; + private String htmlType; + private String dictType; + private Integer sort; + + public void setColumnId(Long columnId) { + this.columnId = columnId; + } + + + public Long getColumnId() { + return this.columnId; + } + + + public void setTableId(Long tableId) { + this.tableId = tableId; + } + + + public Long getTableId() { + return this.tableId; + } + + + public void setColumnName(String columnName) { + this.columnName = columnName; + } + + + public String getColumnName() { + return this.columnName; + } + + + public void setColumnComment(String columnComment) { + this.columnComment = columnComment; + } + + + public String getColumnComment() { + return this.columnComment; + } + + + public void setColumnType(String columnType) { + this.columnType = columnType; + } + + + public String getColumnType() { + return this.columnType; + } + + + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + + public String getJavaType() { + return this.javaType; + } + + + public void setJavaField(String javaField) { + this.javaField = javaField; + } + + + public String getJavaField() { + return this.javaField; + } + + + public String getCapJavaField() { + return StringUtils.capitalize(this.javaField); + } + + + public void setIsPk(String isPk) { + this.isPk = isPk; + } + + + public String getIsPk() { + return this.isPk; + } + + + public boolean isPk() { + return isPk(this.isPk); + } + + + public boolean isPk(String isPk) { + return (isPk != null && StringUtils.equals("1", isPk)); + } + + + public String getIsIncrement() { + return this.isIncrement; + } + + + public void setIsIncrement(String isIncrement) { + this.isIncrement = isIncrement; + } + + + public boolean isIncrement() { + return isIncrement(this.isIncrement); + } + + + public boolean isIncrement(String isIncrement) { + return (isIncrement != null && StringUtils.equals("1", isIncrement)); + } + + + public void setIsRequired(String isRequired) { + this.isRequired = isRequired; + } + + + public String getIsRequired() { + return this.isRequired; + } + + + public boolean isRequired() { + return isRequired(this.isRequired); + } + + + public boolean isRequired(String isRequired) { + return (isRequired != null && StringUtils.equals("1", isRequired)); + } + + + public void setIsInsert(String isInsert) { + this.isInsert = isInsert; + } + + + public String getIsInsert() { + return this.isInsert; + } + + + public boolean isInsert() { + return isInsert(this.isInsert); + } + + + public boolean isInsert(String isInsert) { + return (isInsert != null && StringUtils.equals("1", isInsert)); + } + + + public void setIsEdit(String isEdit) { + this.isEdit = isEdit; + } + + + public String getIsEdit() { + return this.isEdit; + } + + + public boolean isEdit() { + return isInsert(this.isEdit); + } + + + public boolean isEdit(String isEdit) { + return (isEdit != null && StringUtils.equals("1", isEdit)); + } + + + public void setIsList(String isList) { + this.isList = isList; + } + + + public String getIsList() { + return this.isList; + } + + + public boolean isList() { + return isList(this.isList); + } + + + public boolean isList(String isList) { + return (isList != null && StringUtils.equals("1", isList)); + } + + + public void setIsQuery(String isQuery) { + this.isQuery = isQuery; + } + + + public String getIsQuery() { + return this.isQuery; + } + + + public boolean isQuery() { + return isQuery(this.isQuery); + } + + + public boolean isQuery(String isQuery) { + return (isQuery != null && StringUtils.equals("1", isQuery)); + } + + + public void setQueryType(String queryType) { + this.queryType = queryType; + } + + + public String getQueryType() { + return this.queryType; + } + + + public String getHtmlType() { + return this.htmlType; + } + + + public void setHtmlType(String htmlType) { + this.htmlType = htmlType; + } + + + public void setDictType(String dictType) { + this.dictType = dictType; + } + + + public String getDictType() { + return this.dictType; + } + + + public void setSort(Integer sort) { + this.sort = sort; + } + + + public Integer getSort() { + return this.sort; + } + + + public boolean isSuperColumn() { + return isSuperColumn(this.javaField); + } + + + public static boolean isSuperColumn(String javaField) { + return StringUtils.equalsAnyIgnoreCase(javaField, new CharSequence[] { "createBy", "createTime", "updateBy", "updateTime", "remark", "parentName", "parentId", "orderNum", "ancestors" }); + } + + + + + + + public boolean isUsableColumn() { + return isUsableColumn(this.javaField); + } + + + + public static boolean isUsableColumn(String javaField) { + return StringUtils.equalsAnyIgnoreCase(javaField, new CharSequence[] { "parentId", "orderNum", "remark" }); + } + + + public String readConverterExp() { + String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); + StringBuffer sb = new StringBuffer(); + if (StringUtils.isNotEmpty(remarks)) { + + for (String value : remarks.split(" ")) { + + if (StringUtils.isNotEmpty(value)) { + + Object startStr = value.subSequence(0, 1); + String endStr = value.substring(1); + sb.append("").append(startStr).append("=").append(endStr).append(","); + } + } + return sb.deleteCharAt(sb.length() - 1).toString(); + } + + + return this.columnComment; + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\gen\domain\GenTableColumn.class diff --git a/src/main/java/com/archive/project/tool/gen/service/GenTableColumnServiceImpl.java b/src/main/java/com/archive/project/tool/gen/service/GenTableColumnServiceImpl.java index 21514c8..e965310 100644 --- a/src/main/java/com/archive/project/tool/gen/service/GenTableColumnServiceImpl.java +++ b/src/main/java/com/archive/project/tool/gen/service/GenTableColumnServiceImpl.java @@ -1,73 +1,73 @@ -/* */ package com.archive.project.tool.gen.service + package com.archive.project.tool.gen.service ; -/* */ -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.project.tool.gen.domain.GenTableColumn; -/* */ import com.archive.project.tool.gen.mapper.GenTableColumnMapper; -/* */ import com.archive.project.tool.gen.service.IGenTableColumnService; -/* */ import java.util.List; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class GenTableColumnServiceImpl -/* */ implements IGenTableColumnService -/* */ { -/* */ @Autowired -/* */ private GenTableColumnMapper genTableColumnMapper; -/* */ -/* */ public List selectGenTableColumnListByTableId(GenTableColumn genTableColumn) { -/* 30 */ return this.genTableColumnMapper.selectGenTableColumnListByTableId(genTableColumn); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int insertGenTableColumn(GenTableColumn genTableColumn) { -/* 42 */ return this.genTableColumnMapper.insertGenTableColumn(genTableColumn); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int updateGenTableColumn(GenTableColumn genTableColumn) { -/* 54 */ return this.genTableColumnMapper.updateGenTableColumn(genTableColumn); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public int deleteGenTableColumnByIds(String ids) { -/* 66 */ return this.genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); -/* */ } -/* */ } + + import com.archive.common.utils.text.Convert; + import com.archive.project.tool.gen.domain.GenTableColumn; + import com.archive.project.tool.gen.mapper.GenTableColumnMapper; + import com.archive.project.tool.gen.service.IGenTableColumnService; + import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + + + + + + + + + + + + + @Service + public class GenTableColumnServiceImpl + implements IGenTableColumnService + { + @Autowired + private GenTableColumnMapper genTableColumnMapper; + + public List selectGenTableColumnListByTableId(GenTableColumn genTableColumn) { + return this.genTableColumnMapper.selectGenTableColumnListByTableId(genTableColumn); + } + + + + + + + + + + public int insertGenTableColumn(GenTableColumn genTableColumn) { + return this.genTableColumnMapper.insertGenTableColumn(genTableColumn); + } + + + + + + + + + + public int updateGenTableColumn(GenTableColumn genTableColumn) { + return this.genTableColumnMapper.updateGenTableColumn(genTableColumn); + } + + + + + + + + + + public int deleteGenTableColumnByIds(String ids) { + return this.genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\gen\service\GenTableColumnServiceImpl.class diff --git a/src/main/java/com/archive/project/tool/gen/service/GenTableServiceImpl.java b/src/main/java/com/archive/project/tool/gen/service/GenTableServiceImpl.java index b4efec5..eeadf26 100644 --- a/src/main/java/com/archive/project/tool/gen/service/GenTableServiceImpl.java +++ b/src/main/java/com/archive/project/tool/gen/service/GenTableServiceImpl.java @@ -1,507 +1,507 @@ -/* */ package com.archive.project.tool.gen.service + package com.archive.project.tool.gen.service ; -/* */ -/* */ import com.alibaba.fastjson.JSON; -/* */ import com.alibaba.fastjson.JSONObject; -/* */ import com.archive.common.exception.BusinessException; -/* */ import com.archive.common.utils.StringUtils; -/* */ -/* */ import com.archive.common.utils.security.ShiroUtils; -/* */ import com.archive.common.utils.text.Convert; -/* */ import com.archive.project.tool.gen.domain.GenTable; -/* */ import com.archive.project.tool.gen.domain.GenTableColumn; -/* */ import com.archive.project.tool.gen.mapper.GenTableColumnMapper; -/* */ import com.archive.project.tool.gen.mapper.GenTableMapper; -/* */ import com.archive.project.tool.gen.service.IGenTableService; -/* */ import com.archive.project.tool.gen.util.GenUtils; -/* */ import com.archive.project.tool.gen.util.VelocityInitializer; -/* */ import com.archive.project.tool.gen.util.VelocityUtils; -/* */ import java.io.ByteArrayOutputStream; -/* */ import java.io.File; -/* */ import java.io.IOException; -/* */ import java.io.StringWriter; -/* */ import java.util.LinkedHashMap; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import java.util.stream.Collectors; -/* */ import java.util.zip.ZipEntry; -/* */ import java.util.zip.ZipOutputStream; -/* */ import org.apache.commons.io.FileUtils; + + import com.alibaba.fastjson.JSON; + import com.alibaba.fastjson.JSONObject; + import com.archive.common.exception.BusinessException; + import com.archive.common.utils.StringUtils; + + import com.archive.common.utils.security.ShiroUtils; + import com.archive.common.utils.text.Convert; + import com.archive.project.tool.gen.domain.GenTable; + import com.archive.project.tool.gen.domain.GenTableColumn; + import com.archive.project.tool.gen.mapper.GenTableColumnMapper; + import com.archive.project.tool.gen.mapper.GenTableMapper; + import com.archive.project.tool.gen.service.IGenTableService; + import com.archive.project.tool.gen.util.GenUtils; + import com.archive.project.tool.gen.util.VelocityInitializer; + import com.archive.project.tool.gen.util.VelocityUtils; + import java.io.ByteArrayOutputStream; + import java.io.File; + import java.io.IOException; + import java.io.StringWriter; + import java.util.LinkedHashMap; + import java.util.List; + import java.util.Map; + import java.util.stream.Collectors; + import java.util.zip.ZipEntry; + import java.util.zip.ZipOutputStream; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -/* */ import org.apache.velocity.Template; -/* */ import org.apache.velocity.VelocityContext; -/* */ import org.apache.velocity.app.Velocity; -/* */ import org.apache.velocity.context.Context; -/* */ import org.slf4j.Logger; -/* */ import org.slf4j.LoggerFactory; -/* */ import org.springframework.beans.factory.annotation.Autowired; -/* */ import org.springframework.stereotype.Service; -/* */ import org.springframework.transaction.annotation.Transactional; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Service -/* */ public class GenTableServiceImpl -/* */ implements IGenTableService -/* */ { -/* 48 */ private static final Logger log = LoggerFactory.getLogger(com.archive.project.tool.gen.service.GenTableServiceImpl.class); -/* */ -/* */ -/* */ -/* */ -/* */ @Autowired -/* */ private GenTableMapper genTableMapper; -/* */ -/* */ -/* */ -/* */ @Autowired -/* */ private GenTableColumnMapper genTableColumnMapper; -/* */ -/* */ -/* */ -/* */ @Override -/* */ public GenTable selectGenTableById(Long id) { -/* 65 */ GenTable genTable = this.genTableMapper.selectGenTableById(id); -/* 66 */ setTableFromOptions(genTable); -/* 67 */ return genTable; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public List selectGenTableList(GenTable genTable) { -/* 79 */ return this.genTableMapper.selectGenTableList(genTable); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public List selectDbTableList(GenTable genTable) { -/* 91 */ return this.genTableMapper.selectDbTableList(genTable); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public List selectDbTableListByNames(String[] tableNames) { -/* 103 */ return this.genTableMapper.selectDbTableListByNames(tableNames); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public List selectGenTableAll() { -/* 114 */ return this.genTableMapper.selectGenTableAll(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ @Transactional -/* */ public void updateGenTable(GenTable genTable) { -/* 127 */ String options = JSON.toJSONString(genTable.getParams()); -/* 128 */ genTable.setOptions(options); -/* 129 */ int row = this.genTableMapper.updateGenTable(genTable); -/* 130 */ if (row > 0) -/* */ { -/* 132 */ for (GenTableColumn cenTableColumn : genTable.getColumns()) -/* */ { -/* 134 */ this.genTableColumnMapper.updateGenTableColumn(cenTableColumn); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ @Transactional -/* */ public void deleteGenTableByIds(String ids) { -/* 149 */ this.genTableMapper.deleteGenTableByIds(Convert.toLongArray(ids)); -/* 150 */ this.genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ @Transactional -/* */ public void importGenTable(List tableList) { -/* 162 */ String operName = ShiroUtils.getLoginName(); -/* */ -/* */ try { -/* 165 */ for (GenTable table : tableList) { -/* */ -/* 167 */ String tableName = table.getTableName(); -/* 168 */ GenUtils.initTable(table, operName); -/* 169 */ int row = this.genTableMapper.insertGenTable(table); -/* 170 */ if (row > 0) { -/* */ -/* */ -/* 173 */ List genTableColumns = this.genTableColumnMapper.selectDbTableColumnsByName(tableName); -/* 174 */ for (GenTableColumn column : genTableColumns) -/* */ { -/* 176 */ GenUtils.initColumnField(column, table); -/* 177 */ this.genTableColumnMapper.insertGenTableColumn(column); -/* */ } -/* */ -/* */ } -/* */ } -/* 182 */ } catch (Exception e) { -/* */ -/* 184 */ throw new BusinessException("导入失败:" + e.getMessage()); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public Map previewCode(Long tableId) { -/* 197 */ Map dataMap = new LinkedHashMap<>(); -/* */ -/* 199 */ GenTable table = this.genTableMapper.selectGenTableById(tableId); -/* */ -/* 201 */ setSubTable(table); -/* */ -/* 203 */ setPkColumn(table); -/* 204 */ VelocityInitializer.initVelocity(); -/* */ -/* 206 */ VelocityContext context = VelocityUtils.prepareContext(table); -/* */ -/* */ -/* 209 */ List templates = VelocityUtils.getTemplateList(table.getTplCategory()); -/* 210 */ for (String template : templates) { -/* */ -/* */ -/* 213 */ StringWriter sw = new StringWriter(); -/* 214 */ Template tpl = Velocity.getTemplate(template, "UTF-8"); -/* 215 */ tpl.merge((Context)context, sw); -/* 216 */ dataMap.put(template, sw.toString()); -/* */ } -/* 218 */ return dataMap; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public byte[] downloadCode(String tableName) { -/* 230 */ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); -/* 231 */ ZipOutputStream zip = new ZipOutputStream(outputStream); -/* 232 */ generatorCode(tableName, zip); -/* 233 */ IOUtils.closeQuietly(zip); -/* 234 */ return outputStream.toByteArray(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public void generatorCode(String tableName) { -/* 246 */ GenTable table = this.genTableMapper.selectGenTableByName(tableName); -/* */ -/* 248 */ setSubTable(table); -/* */ -/* 250 */ setPkColumn(table); -/* */ -/* 252 */ VelocityInitializer.initVelocity(); -/* */ -/* 254 */ VelocityContext context = VelocityUtils.prepareContext(table); -/* */ -/* */ -/* 257 */ List templates = VelocityUtils.getTemplateList(table.getTplCategory()); -/* 258 */ for (String template : templates) { -/* */ -/* 260 */ if (!StringUtils.contains(template, "sql.vm")) { -/* */ -/* */ -/* 263 */ StringWriter sw = new StringWriter(); -/* 264 */ Template tpl = Velocity.getTemplate(template, "UTF-8"); -/* 265 */ tpl.merge((Context)context, sw); -/* */ -/* */ try { -/* 268 */ String path = getGenPath(table, template); -/* 269 */ FileUtils.writeStringToFile(new File(path), sw.toString(), "UTF-8"); -/* */ } -/* 271 */ catch (IOException e) { -/* */ -/* 273 */ throw new BusinessException("渲染模板失败,表名:" + table.getTableName()); -/* */ } -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ @Transactional -/* */ public void synchDb(String tableName) { -/* 288 */ GenTable table = this.genTableMapper.selectGenTableByName(tableName); -/* 289 */ List tableColumns = table.getColumns(); -/* 290 */ List tableColumnNames = (List)tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); -/* */ -/* 292 */ List dbTableColumns = this.genTableColumnMapper.selectDbTableColumnsByName(tableName); -/* 293 */ if (StringUtils.isEmpty(dbTableColumns)) -/* */ { -/* 295 */ throw new BusinessException("同步数据失败,原表结构不存在"); -/* */ } -/* 297 */ List dbTableColumnNames = (List)dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); -/* */ -/* 299 */ dbTableColumns.forEach(column -> { -/* */ if (!tableColumnNames.contains(column.getColumnName())) { -/* */ GenUtils.initColumnField(column, table); -/* */ -/* */ this.genTableColumnMapper.insertGenTableColumn(column); -/* */ } -/* */ }); -/* */ -/* 307 */ List delColumns = (List)tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); -/* 308 */ if (StringUtils.isNotEmpty(delColumns)) -/* */ { -/* 310 */ this.genTableColumnMapper.deleteGenTableColumns(delColumns); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public byte[] downloadCode(String[] tableNames) { -/* 323 */ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); -/* 324 */ ZipOutputStream zip = new ZipOutputStream(outputStream); -/* 325 */ for (String tableName : tableNames) -/* */ { -/* 327 */ generatorCode(tableName, zip); -/* */ } -/* 329 */ IOUtils.closeQuietly(zip); -/* 330 */ return outputStream.toByteArray(); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ private void generatorCode(String tableName, ZipOutputStream zip) { -/* 339 */ GenTable table = this.genTableMapper.selectGenTableByName(tableName); -/* */ -/* 341 */ setSubTable(table); -/* */ -/* 343 */ setPkColumn(table); -/* */ -/* 345 */ VelocityInitializer.initVelocity(); -/* */ -/* 347 */ VelocityContext context = VelocityUtils.prepareContext(table); -/* */ -/* */ -/* 350 */ List templates = VelocityUtils.getTemplateList(table.getTplCategory()); -/* 351 */ for (String template : templates) { -/* */ -/* */ -/* 354 */ StringWriter sw = new StringWriter(); -/* 355 */ Template tpl = Velocity.getTemplate(template, "UTF-8"); -/* 356 */ tpl.merge((Context)context, sw); -/* */ -/* */ -/* */ try { -/* 360 */ zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); -/* 361 */ IOUtils.write(sw.toString(), zip, "UTF-8"); -/* 362 */ IOUtils.closeQuietly(sw); -/* 363 */ zip.flush(); -/* 364 */ zip.closeEntry(); -/* */ } -/* 366 */ catch (IOException e) { -/* */ -/* 368 */ log.error("渲染模板失败,表名:" + table.getTableName(), e); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ @Override -/* */ public void validateEdit(GenTable genTable) { -/* 381 */ if ("tree".equals(genTable.getTplCategory())) { -/* */ -/* 383 */ String options = JSON.toJSONString(genTable.getParams()); -/* 384 */ JSONObject paramsObj = JSONObject.parseObject(options); -/* 385 */ if (StringUtils.isEmpty(paramsObj.getString("treeCode"))) -/* */ { -/* 387 */ throw new BusinessException("树编码字段不能为空"); -/* */ } -/* 389 */ if (StringUtils.isEmpty(paramsObj.getString("treeParentCode"))) -/* */ { -/* 391 */ throw new BusinessException("树父编码字段不能为空"); -/* */ } -/* 393 */ if (StringUtils.isEmpty(paramsObj.getString("treeName"))) -/* */ { -/* 395 */ throw new BusinessException("树名称字段不能为空"); -/* */ } -/* */ } -/* 398 */ else if ("sub".equals(genTable.getTplCategory())) { -/* */ -/* 400 */ if (StringUtils.isEmpty(genTable.getSubTableName())) -/* */ { -/* 402 */ throw new BusinessException("关联子表的表名不能为空"); -/* */ } -/* 404 */ if (StringUtils.isEmpty(genTable.getSubTableFkName())) -/* */ { -/* 406 */ throw new BusinessException("子表关联的外键名不能为空"); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setPkColumn(GenTable table) { -/* 418 */ for (GenTableColumn column : table.getColumns()) { -/* */ -/* 420 */ if (column.isPk()) { -/* */ -/* 422 */ table.setPkColumn(column); -/* */ break; -/* */ } -/* */ } -/* 426 */ if (StringUtils.isNull(table.getPkColumn())) -/* */ { -/* 428 */ table.setPkColumn(table.getColumns().get(0)); -/* */ } -/* 430 */ if ("sub".equals(table.getTplCategory())) { -/* */ -/* 432 */ for (GenTableColumn column : table.getSubTable().getColumns()) { -/* */ -/* 434 */ if (column.isPk()) { -/* */ -/* 436 */ table.getSubTable().setPkColumn(column); -/* */ break; -/* */ } -/* */ } -/* 440 */ if (StringUtils.isNull(table.getSubTable().getPkColumn())) -/* */ { -/* 442 */ table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); -/* */ } -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setSubTable(GenTable table) { -/* 454 */ String subTableName = table.getSubTableName(); -/* 455 */ if (StringUtils.isNotEmpty(subTableName)) -/* */ { -/* 457 */ table.setSubTable(this.genTableMapper.selectGenTableByName(subTableName)); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public void setTableFromOptions(GenTable genTable) { -/* 468 */ JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); -/* 469 */ if (StringUtils.isNotNull(paramsObj)) { -/* */ -/* 471 */ String treeCode = paramsObj.getString("treeCode"); -/* 472 */ String treeParentCode = paramsObj.getString("treeParentCode"); -/* 473 */ String treeName = paramsObj.getString("treeName"); -/* 474 */ String parentMenuId = paramsObj.getString("parentMenuId"); -/* 475 */ String parentMenuName = paramsObj.getString("parentMenuName"); -/* */ -/* 477 */ genTable.setTreeCode(treeCode); -/* 478 */ genTable.setTreeParentCode(treeParentCode); -/* 479 */ genTable.setTreeName(treeName); -/* 480 */ genTable.setParentMenuId(parentMenuId); -/* 481 */ genTable.setParentMenuName(parentMenuName); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getGenPath(GenTable table, String template) { -/* 494 */ String genPath = table.getGenPath(); -/* 495 */ if (StringUtils.equals(genPath, "/")) -/* */ { -/* 497 */ return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); -/* */ } -/* 499 */ return genPath + File.separator + VelocityUtils.getFileName(template, table); -/* */ } -/* */ } + import org.apache.velocity.Template; + import org.apache.velocity.VelocityContext; + import org.apache.velocity.app.Velocity; + import org.apache.velocity.context.Context; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + import org.springframework.transaction.annotation.Transactional; + + + + + + + @Service + public class GenTableServiceImpl + implements IGenTableService + { + private static final Logger log = LoggerFactory.getLogger(com.archive.project.tool.gen.service.GenTableServiceImpl.class); + + + + + @Autowired + private GenTableMapper genTableMapper; + + + + @Autowired + private GenTableColumnMapper genTableColumnMapper; + + + + @Override + public GenTable selectGenTableById(Long id) { + GenTable genTable = this.genTableMapper.selectGenTableById(id); + setTableFromOptions(genTable); + return genTable; + } + + + + + + + + + @Override + public List selectGenTableList(GenTable genTable) { + return this.genTableMapper.selectGenTableList(genTable); + } + + + + + + + + + @Override + public List selectDbTableList(GenTable genTable) { + return this.genTableMapper.selectDbTableList(genTable); + } + + + + + + + + + @Override + public List selectDbTableListByNames(String[] tableNames) { + return this.genTableMapper.selectDbTableListByNames(tableNames); + } + + + + + + + + @Override + public List selectGenTableAll() { + return this.genTableMapper.selectGenTableAll(); + } + + + + + + + + + @Override + @Transactional + public void updateGenTable(GenTable genTable) { + String options = JSON.toJSONString(genTable.getParams()); + genTable.setOptions(options); + int row = this.genTableMapper.updateGenTable(genTable); + if (row > 0) + { + for (GenTableColumn cenTableColumn : genTable.getColumns()) + { + this.genTableColumnMapper.updateGenTableColumn(cenTableColumn); + } + } + } + + + + + + + + + @Override + @Transactional + public void deleteGenTableByIds(String ids) { + this.genTableMapper.deleteGenTableByIds(Convert.toLongArray(ids)); + this.genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); + } + + + + + + + + @Override + @Transactional + public void importGenTable(List tableList) { + String operName = ShiroUtils.getLoginName(); + + try { + for (GenTable table : tableList) { + + String tableName = table.getTableName(); + GenUtils.initTable(table, operName); + int row = this.genTableMapper.insertGenTable(table); + if (row > 0) { + + + List genTableColumns = this.genTableColumnMapper.selectDbTableColumnsByName(tableName); + for (GenTableColumn column : genTableColumns) + { + GenUtils.initColumnField(column, table); + this.genTableColumnMapper.insertGenTableColumn(column); + } + + } + } + } catch (Exception e) { + + throw new BusinessException("导入失败:" + e.getMessage()); + } + } + + + + + + + + + @Override + public Map previewCode(Long tableId) { + Map dataMap = new LinkedHashMap<>(); + + GenTable table = this.genTableMapper.selectGenTableById(tableId); + + setSubTable(table); + + setPkColumn(table); + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) { + + + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + tpl.merge((Context)context, sw); + dataMap.put(template, sw.toString()); + } + return dataMap; + } + + + + + + + + + @Override + public byte[] downloadCode(String tableName) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + generatorCode(tableName, zip); + IOUtils.closeQuietly(zip); + return outputStream.toByteArray(); + } + + + + + + + + + @Override + public void generatorCode(String tableName) { + GenTable table = this.genTableMapper.selectGenTableByName(tableName); + + setSubTable(table); + + setPkColumn(table); + + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) { + + if (!StringUtils.contains(template, "sql.vm")) { + + + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + tpl.merge((Context)context, sw); + + try { + String path = getGenPath(table, template); + FileUtils.writeStringToFile(new File(path), sw.toString(), "UTF-8"); + } + catch (IOException e) { + + throw new BusinessException("渲染模板失败,表名:" + table.getTableName()); + } + } + } + } + + + + + + + + @Override + @Transactional + public void synchDb(String tableName) { + GenTable table = this.genTableMapper.selectGenTableByName(tableName); + List tableColumns = table.getColumns(); + List tableColumnNames = (List)tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); + + List dbTableColumns = this.genTableColumnMapper.selectDbTableColumnsByName(tableName); + if (StringUtils.isEmpty(dbTableColumns)) + { + throw new BusinessException("同步数据失败,原表结构不存在"); + } + List dbTableColumnNames = (List)dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); + + dbTableColumns.forEach(column -> { + if (!tableColumnNames.contains(column.getColumnName())) { + GenUtils.initColumnField(column, table); + + this.genTableColumnMapper.insertGenTableColumn(column); + } + }); + + List delColumns = (List)tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); + if (StringUtils.isNotEmpty(delColumns)) + { + this.genTableColumnMapper.deleteGenTableColumns(delColumns); + } + } + + + + + + + + + @Override + public byte[] downloadCode(String[] tableNames) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + for (String tableName : tableNames) + { + generatorCode(tableName, zip); + } + IOUtils.closeQuietly(zip); + return outputStream.toByteArray(); + } + + + + + + + private void generatorCode(String tableName, ZipOutputStream zip) { + GenTable table = this.genTableMapper.selectGenTableByName(tableName); + + setSubTable(table); + + setPkColumn(table); + + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) { + + + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, "UTF-8"); + tpl.merge((Context)context, sw); + + + try { + zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); + IOUtils.write(sw.toString(), zip, "UTF-8"); + IOUtils.closeQuietly(sw); + zip.flush(); + zip.closeEntry(); + } + catch (IOException e) { + + log.error("渲染模板失败,表名:" + table.getTableName(), e); + } + } + } + + + + + + + + @Override + public void validateEdit(GenTable genTable) { + if ("tree".equals(genTable.getTplCategory())) { + + String options = JSON.toJSONString(genTable.getParams()); + JSONObject paramsObj = JSONObject.parseObject(options); + if (StringUtils.isEmpty(paramsObj.getString("treeCode"))) + { + throw new BusinessException("树编码字段不能为空"); + } + if (StringUtils.isEmpty(paramsObj.getString("treeParentCode"))) + { + throw new BusinessException("树父编码字段不能为空"); + } + if (StringUtils.isEmpty(paramsObj.getString("treeName"))) + { + throw new BusinessException("树名称字段不能为空"); + } + } + else if ("sub".equals(genTable.getTplCategory())) { + + if (StringUtils.isEmpty(genTable.getSubTableName())) + { + throw new BusinessException("关联子表的表名不能为空"); + } + if (StringUtils.isEmpty(genTable.getSubTableFkName())) + { + throw new BusinessException("子表关联的外键名不能为空"); + } + } + } + + + + + + + + public void setPkColumn(GenTable table) { + for (GenTableColumn column : table.getColumns()) { + + if (column.isPk()) { + + table.setPkColumn(column); + break; + } + } + if (StringUtils.isNull(table.getPkColumn())) + { + table.setPkColumn(table.getColumns().get(0)); + } + if ("sub".equals(table.getTplCategory())) { + + for (GenTableColumn column : table.getSubTable().getColumns()) { + + if (column.isPk()) { + + table.getSubTable().setPkColumn(column); + break; + } + } + if (StringUtils.isNull(table.getSubTable().getPkColumn())) + { + table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); + } + } + } + + + + + + + + public void setSubTable(GenTable table) { + String subTableName = table.getSubTableName(); + if (StringUtils.isNotEmpty(subTableName)) + { + table.setSubTable(this.genTableMapper.selectGenTableByName(subTableName)); + } + } + + + + + + + + public void setTableFromOptions(GenTable genTable) { + JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); + if (StringUtils.isNotNull(paramsObj)) { + + String treeCode = paramsObj.getString("treeCode"); + String treeParentCode = paramsObj.getString("treeParentCode"); + String treeName = paramsObj.getString("treeName"); + String parentMenuId = paramsObj.getString("parentMenuId"); + String parentMenuName = paramsObj.getString("parentMenuName"); + + genTable.setTreeCode(treeCode); + genTable.setTreeParentCode(treeParentCode); + genTable.setTreeName(treeName); + genTable.setParentMenuId(parentMenuId); + genTable.setParentMenuName(parentMenuName); + } + } + + + + + + + + + + public static String getGenPath(GenTable table, String template) { + String genPath = table.getGenPath(); + if (StringUtils.equals(genPath, "/")) + { + return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); + } + return genPath + File.separator + VelocityUtils.getFileName(template, table); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\gen\service\GenTableServiceImpl.class diff --git a/src/main/java/com/archive/project/tool/gen/util/GenUtils.java b/src/main/java/com/archive/project/tool/gen/util/GenUtils.java index 5545f67..168395a 100644 --- a/src/main/java/com/archive/project/tool/gen/util/GenUtils.java +++ b/src/main/java/com/archive/project/tool/gen/util/GenUtils.java @@ -1,257 +1,257 @@ -/* */ package com.archive.project.tool.gen.util + package com.archive.project.tool.gen.util ; -/* */ -/* */ import com.archive.common.constant.GenConstants; -/* */ import com.archive.common.utils.StringUtils; -/* */ import com.archive.framework.config.GenConfig; -/* */ import com.archive.project.tool.gen.domain.GenTable; -/* */ import com.archive.project.tool.gen.domain.GenTableColumn; -/* */ import java.util.Arrays; -/* */ import org.apache.commons.lang3.RegExUtils; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public class GenUtils -/* */ { -/* */ public static void initTable(GenTable genTable, String operName) { -/* 23 */ genTable.setClassName(convertClassName(genTable.getTableName())); -/* 24 */ genTable.setPackageName(GenConfig.getPackageName()); -/* 25 */ genTable.setModuleName(getModuleName(GenConfig.getPackageName())); -/* 26 */ genTable.setBusinessName(getBusinessName(genTable.getTableName())); -/* 27 */ genTable.setFunctionName(replaceText(genTable.getTableComment())); -/* 28 */ genTable.setFunctionAuthor(GenConfig.getAuthor()); -/* 29 */ genTable.setCreateBy(operName); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static void initColumnField(GenTableColumn column, GenTable table) { -/* 37 */ String dataType = getDbType(column.getColumnType()); -/* 38 */ String columnName = column.getColumnName(); -/* 39 */ column.setTableId(table.getTableId()); -/* 40 */ column.setCreateBy(table.getCreateBy()); -/* */ -/* 42 */ column.setJavaField(StringUtils.toCamelCase(columnName)); -/* */ -/* 44 */ column.setJavaType("String"); -/* */ -/* 46 */ if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { -/* */ -/* */ -/* 49 */ Integer columnLength = getColumnLength(column.getColumnType()); -/* 50 */ String htmlType = (columnLength.intValue() >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) ? "textarea" : "input"; -/* 51 */ column.setHtmlType(htmlType); -/* */ } -/* 53 */ else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) { -/* */ -/* 55 */ column.setJavaType("Date"); -/* 56 */ column.setHtmlType("datetime"); -/* */ } -/* 58 */ else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { -/* */ -/* 60 */ column.setHtmlType("input"); -/* */ -/* */ -/* 63 */ String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); -/* 64 */ if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { -/* */ -/* 66 */ column.setJavaType("BigDecimal"); -/* */ -/* */ } -/* 69 */ else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) { -/* */ -/* 71 */ column.setJavaType("Integer"); -/* */ -/* */ } -/* */ else { -/* */ -/* 76 */ column.setJavaType("Long"); -/* */ } -/* */ } -/* */ -/* */ -/* 81 */ column.setIsInsert("1"); -/* */ -/* */ -/* 84 */ if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) -/* */ { -/* 86 */ column.setIsEdit("1"); -/* */ } -/* */ -/* 89 */ if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) -/* */ { -/* 91 */ column.setIsList("1"); -/* */ } -/* */ -/* 94 */ if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) -/* */ { -/* 96 */ column.setIsQuery("1"); -/* */ } -/* */ -/* */ -/* 100 */ if (StringUtils.endsWithIgnoreCase(columnName, "name")) -/* */ { -/* 102 */ column.setQueryType("LIKE"); -/* */ } -/* */ -/* 105 */ if (StringUtils.endsWithIgnoreCase(columnName, "status")) { -/* */ -/* 107 */ column.setHtmlType("radio"); -/* */ -/* */ } -/* 110 */ else if (StringUtils.endsWithIgnoreCase(columnName, "type") || -/* 111 */ StringUtils.endsWithIgnoreCase(columnName, "sex")) { -/* */ -/* 113 */ column.setHtmlType("select"); -/* */ -/* */ } -/* 116 */ else if (StringUtils.endsWithIgnoreCase(columnName, "file")) { -/* */ -/* 118 */ column.setHtmlType("upload"); -/* */ -/* */ } -/* 121 */ else if (StringUtils.endsWithIgnoreCase(columnName, "content")) { -/* */ -/* 123 */ column.setHtmlType("summernote"); -/* */ } -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static boolean arraysContains(String[] arr, String targetValue) { -/* 136 */ return Arrays.asList(arr).contains(targetValue); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getModuleName(String packageName) { -/* 147 */ int lastIndex = packageName.lastIndexOf("."); -/* 148 */ int nameLength = packageName.length(); -/* 149 */ String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); -/* 150 */ return moduleName; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getBusinessName(String tableName) { -/* 161 */ int lastIndex = tableName.lastIndexOf("_"); -/* 162 */ int nameLength = tableName.length(); -/* 163 */ String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); -/* 164 */ return businessName; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String convertClassName(String tableName) { -/* 175 */ boolean autoRemovePre = GenConfig.getAutoRemovePre(); -/* 176 */ String tablePrefix = GenConfig.getTablePrefix(); -/* 177 */ if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { -/* */ -/* 179 */ String[] searchList = StringUtils.split(tablePrefix, ","); -/* 180 */ tableName = replaceFirst(tableName, searchList); -/* */ } -/* 182 */ return StringUtils.convertToCamelCase(tableName); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String replaceFirst(String replacementm, String[] searchList) { -/* 194 */ String text = replacementm; -/* 195 */ for (String searchString : searchList) { -/* */ -/* 197 */ if (replacementm.startsWith(searchString)) { -/* */ -/* 199 */ text = replacementm.replaceFirst(searchString, ""); -/* */ break; -/* */ } -/* */ } -/* 203 */ return text; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String replaceText(String text) { -/* 214 */ return RegExUtils.replaceAll(text, "(?:表|Tale)", ""); -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static String getDbType(String columnType) { -/* 225 */ if (StringUtils.indexOf(columnType, "(") > 0) -/* */ { -/* 227 */ return StringUtils.substringBefore(columnType, "("); -/* */ } -/* */ -/* */ -/* 231 */ return columnType; -/* */ } -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public static Integer getColumnLength(String columnType) { -/* 243 */ if (StringUtils.indexOf(columnType, "(") > 0) { -/* */ -/* 245 */ String length = StringUtils.substringBetween(columnType, "(", ")"); -/* 246 */ return Integer.valueOf(length); -/* */ } -/* */ -/* */ -/* 250 */ return Integer.valueOf(0); -/* */ } -/* */ } + + import com.archive.common.constant.GenConstants; + import com.archive.common.utils.StringUtils; + import com.archive.framework.config.GenConfig; + import com.archive.project.tool.gen.domain.GenTable; + import com.archive.project.tool.gen.domain.GenTableColumn; + import java.util.Arrays; + import org.apache.commons.lang3.RegExUtils; + + + + + + + + + + + public class GenUtils + { + public static void initTable(GenTable genTable, String operName) { + genTable.setClassName(convertClassName(genTable.getTableName())); + genTable.setPackageName(GenConfig.getPackageName()); + genTable.setModuleName(getModuleName(GenConfig.getPackageName())); + genTable.setBusinessName(getBusinessName(genTable.getTableName())); + genTable.setFunctionName(replaceText(genTable.getTableComment())); + genTable.setFunctionAuthor(GenConfig.getAuthor()); + genTable.setCreateBy(operName); + } + + + + + + public static void initColumnField(GenTableColumn column, GenTable table) { + String dataType = getDbType(column.getColumnType()); + String columnName = column.getColumnName(); + column.setTableId(table.getTableId()); + column.setCreateBy(table.getCreateBy()); + + column.setJavaField(StringUtils.toCamelCase(columnName)); + + column.setJavaType("String"); + + if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { + + + Integer columnLength = getColumnLength(column.getColumnType()); + String htmlType = (columnLength.intValue() >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) ? "textarea" : "input"; + column.setHtmlType(htmlType); + } + else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) { + + column.setJavaType("Date"); + column.setHtmlType("datetime"); + } + else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { + + column.setHtmlType("input"); + + + String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); + if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { + + column.setJavaType("BigDecimal"); + + } + else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) { + + column.setJavaType("Integer"); + + } + else { + + column.setJavaType("Long"); + } + } + + + column.setIsInsert("1"); + + + if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) + { + column.setIsEdit("1"); + } + + if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) + { + column.setIsList("1"); + } + + if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) + { + column.setIsQuery("1"); + } + + + if (StringUtils.endsWithIgnoreCase(columnName, "name")) + { + column.setQueryType("LIKE"); + } + + if (StringUtils.endsWithIgnoreCase(columnName, "status")) { + + column.setHtmlType("radio"); + + } + else if (StringUtils.endsWithIgnoreCase(columnName, "type") || + StringUtils.endsWithIgnoreCase(columnName, "sex")) { + + column.setHtmlType("select"); + + } + else if (StringUtils.endsWithIgnoreCase(columnName, "file")) { + + column.setHtmlType("upload"); + + } + else if (StringUtils.endsWithIgnoreCase(columnName, "content")) { + + column.setHtmlType("summernote"); + } + } + + + + + + + + + + public static boolean arraysContains(String[] arr, String targetValue) { + return Arrays.asList(arr).contains(targetValue); + } + + + + + + + + + public static String getModuleName(String packageName) { + int lastIndex = packageName.lastIndexOf("."); + int nameLength = packageName.length(); + String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); + return moduleName; + } + + + + + + + + + public static String getBusinessName(String tableName) { + int lastIndex = tableName.lastIndexOf("_"); + int nameLength = tableName.length(); + String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); + return businessName; + } + + + + + + + + + public static String convertClassName(String tableName) { + boolean autoRemovePre = GenConfig.getAutoRemovePre(); + String tablePrefix = GenConfig.getTablePrefix(); + if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { + + String[] searchList = StringUtils.split(tablePrefix, ","); + tableName = replaceFirst(tableName, searchList); + } + return StringUtils.convertToCamelCase(tableName); + } + + + + + + + + + + public static String replaceFirst(String replacementm, String[] searchList) { + String text = replacementm; + for (String searchString : searchList) { + + if (replacementm.startsWith(searchString)) { + + text = replacementm.replaceFirst(searchString, ""); + break; + } + } + return text; + } + + + + + + + + + public static String replaceText(String text) { + return RegExUtils.replaceAll(text, "(?:表|Tale)", ""); + } + + + + + + + + + public static String getDbType(String columnType) { + if (StringUtils.indexOf(columnType, "(") > 0) + { + return StringUtils.substringBefore(columnType, "("); + } + + + return columnType; + } + + + + + + + + + + public static Integer getColumnLength(String columnType) { + if (StringUtils.indexOf(columnType, "(") > 0) { + + String length = StringUtils.substringBetween(columnType, "(", ")"); + return Integer.valueOf(length); + } + + + return Integer.valueOf(0); + } + } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\tool\ge\\util\GenUtils.class