From 85665ec6d7929b74fbd9c4c1787da7fb7a107f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E8=B6=85?= <1597235486@qq.com> Date: Tue, 25 Apr 2017 23:09:11 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=96=B9=E5=BC=8F=202=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dspring=E9=9D=99=E6=80=81=E6=B3=A8=E5=85=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binux/admin/generate/BigADGenerate.java | 10 +++--- .../admin/generate/CategoryGenerate.java | 31 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/BigADGenerate.java b/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/BigADGenerate.java index b161354..92bcc0d 100644 --- a/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/BigADGenerate.java +++ b/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/BigADGenerate.java @@ -29,8 +29,12 @@ import java.util.Map; @MapperScan(basePackages = "cn.binux.mapper") public class BigADGenerate { + private static TbIndexSlideAdMapper tbIndexSlideAdMapper; + @Autowired - static TbIndexSlideAdMapper indexSlideAdMapper; + public void setTbIndexSlideAdMapper(TbIndexSlideAdMapper tbIndexSlideAdMapper) { + this.tbIndexSlideAdMapper = tbIndexSlideAdMapper; + } public static void main(String[] args) { @@ -86,13 +90,11 @@ public class BigADGenerate { indexSlideAd.setUpdated(new Date()); indexSlideAd.setStatus(1); - indexSlideAdMapper.insert(indexSlideAd); + tbIndexSlideAdMapper.insert(indexSlideAd); } } - - //saveToFastDFS("http://img1.360buyimg.com/da/jfs/t3277/84/6062111341/95397/a6665294/589ac5e0N2f54619b.jpg"); } public static String saveToFastDFS(String destUrl) { diff --git a/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/CategoryGenerate.java b/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/CategoryGenerate.java index 241b6c9..39bdaef 100644 --- a/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/CategoryGenerate.java +++ b/xbin-store-service-admin/src/main/java/cn/binux/admin/generate/CategoryGenerate.java @@ -14,7 +14,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.Date; import java.util.List; @@ -32,11 +34,19 @@ import java.util.Map; @MapperScan(basePackages = "cn.binux.mapper") public class CategoryGenerate { + private static TbCategoryImageMapper tbCategoryImageMapper; + + private static TbCategorySecondaryMapper tbCategorySecondaryMapper; + @Autowired - static TbCategoryImageMapper categoryImageMapper; + public void setTbCategoryImageMapper(TbCategoryImageMapper tbCategoryImageMapper) { + this.tbCategoryImageMapper = tbCategoryImageMapper; + } @Autowired - static TbCategorySecondaryMapper categorySecondaryMapper; + public void setTbCategorySecondaryMapper(TbCategorySecondaryMapper tbCategorySecondaryMapper) { + this.tbCategorySecondaryMapper = tbCategorySecondaryMapper; + } public static void main(String[] args) { @@ -49,7 +59,7 @@ public class CategoryGenerate { InputStream in = null; try { // 文件输入流 - in = new FileInputStream(new File("/Volumes/HGST/IdeaProjects/xbin-store/xbin-store-service-admin/src/main/resources/Category.json")); + in = in = CategoryGenerate.class.getResourceAsStream("/Category.json"); int len; while ((len = in.read(b)) > 0) { // 字符串拼接 @@ -91,8 +101,7 @@ public class CategoryGenerate { categoryImage.setImageUrl(s); categoryImage.setCreated(new Date()); categoryImage.setUpdated(new Date()); - - categoryImageMapper.insert(categoryImage); + tbCategoryImageMapper.insert(categoryImage); } List listp = (List) mapo.get("p"); @@ -111,7 +120,7 @@ public class CategoryGenerate { categoryImage.setCreated(new Date()); categoryImage.setUpdated(new Date()); - categoryImageMapper.insert(categoryImage); + tbCategoryImageMapper.insert(categoryImage); } List map0 = (List) mapo.get("s"); @@ -131,7 +140,7 @@ public class CategoryGenerate { categorySecondary.setCreated(new Date()); categorySecondary.setUpdated(new Date()); - categorySecondaryMapper.insert(categorySecondary); + tbCategorySecondaryMapper.insert(categorySecondary); if (map2 != null && map2.size() > 0) { @@ -151,7 +160,7 @@ public class CategoryGenerate { categorySecondary3.setCreated(new Date()); categorySecondary3.setUpdated(new Date()); - categorySecondaryMapper.insert(categorySecondary3); + tbCategorySecondaryMapper.insert(categorySecondary3); if (map4 != null && map4.size() > 0) { for (int k = 0; k < map4.size(); k++) { @@ -170,7 +179,7 @@ public class CategoryGenerate { categorySecondary4.setCreated(new Date()); categorySecondary4.setUpdated(new Date()); - categorySecondaryMapper.insert(categorySecondary4); + tbCategorySecondaryMapper.insert(categorySecondary4); if (map6 != null && map6.size() > 0) { System.out.println(s5); @@ -197,7 +206,7 @@ public class CategoryGenerate { categorySecondary.setCreated(new Date()); categorySecondary.setUpdated(new Date()); - categorySecondaryMapper.insert(categorySecondary); + tbCategorySecondaryMapper.insert(categorySecondary); } } -- Gitee