From 28ae829103d299d4b251fe719f031a4dc96313f2 Mon Sep 17 00:00:00 2001 From: lvmoney <365619103@qq.com> Date: Sun, 27 Oct 2019 21:28:52 +0800 Subject: [PATCH 01/13] =?UTF-8?q?xxljob=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java index 147dcae..b0e7155 100644 --- a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java +++ b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java @@ -37,7 +37,7 @@ public class BaseMongoServiceImpl implements BaseMongoService { private MongoTemplate mongoTemplate; private static final String SORT_DESC = "desc"; - private static final String SORT_ASC = "desc"; + private static final String SORT_ASC = "asc"; @Override public void save(BaseMongoVo baseVo) { -- Gitee From 1290dce08e23959726beaebaeb7ba5f471b5fa63 Mon Sep 17 00:00:00 2001 From: lvmoney <365619103@qq.com> Date: Sun, 27 Oct 2019 21:31:34 +0800 Subject: [PATCH 02/13] mongo --- .../com/lvmoney/mongo/service/BaseMongoService.java | 11 +++++++++++ .../mongo/service/impl/BaseMongoServiceImpl.java | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/BaseMongoService.java b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/BaseMongoService.java index f699902..8add5cd 100644 --- a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/BaseMongoService.java +++ b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/BaseMongoService.java @@ -30,6 +30,17 @@ public interface BaseMongoService { */ void save(BaseMongoVo baseVo); + /** + * 指定集合保存数据对象 + * + * @param baseVo: data mongo的mo collectionName 集合名 + * @return: void + * @author: lvmoney /XXXXXX科技有限公司 + * @date: 2019/9/9 19:34 + */ + + void saveByCollectionName(BaseMongoVo baseVo); + /** * 根据数据对象中的id删除数据,集合为数据对象中 * diff --git a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java index b0e7155..96e4935 100644 --- a/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java +++ b/frame-mongo-support/src/main/java/com/lvmoney/mongo/service/impl/BaseMongoServiceImpl.java @@ -44,12 +44,8 @@ public class BaseMongoServiceImpl implements BaseMongoService { mongoTemplate.save(baseVo.getData()); } - /** - * @param baseVo data mongo的mo collectionName 集合名 - * @param baseVo 2019年1月10日上午10:01:11 - * @describe:指定集合保存数据对象 - * @author: lvmoney /xxxx科技有限公司 - */ + + @Override public void saveByCollectionName(BaseMongoVo baseVo) { mongoTemplate.save(baseVo.getData(), baseVo.getCollectionName()); } -- Gitee From c25886c9f3376ff80fcc5183b55d05db2ac1653b Mon Sep 17 00:00:00 2001 From: lvmoney <365619103@qq.com> Date: Sun, 27 Oct 2019 21:34:40 +0800 Subject: [PATCH 03/13] readme.md --- frame-redis-support/readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame-redis-support/readme.md b/frame-redis-support/readme.md index fbc3c5d..a4c79c0 100644 --- a/frame-redis-support/readme.md +++ b/frame-redis-support/readme.md @@ -1,8 +1,8 @@ 1、为了更好的通过redis desktop查看redis数据,在RedisConfig配置了redis key和value的 -序列化方式 +序列化方式 2、经过测试发现,如果redis的value 实体嵌套了,那么反序列话要报错,所以如果有嵌套建议 -value 通过JsonUtil序列化(jsonString)后存到redis,取出值以后再转化成对应的实体对象 -3、不配置1desktop看着很乱,但是实体嵌套的问题没有,value存什么实体,取什么就行。 -4、着重注意一下redisConfig的说明 +value 通过JsonUtil序列化(jsonString)后存到redis,取出值以后再转化成对应的实体对象 +3、不配置1desktop看着很乱,但是实体嵌套的问题没有,value存什么实体,取什么就行。 +4、着重注意一下redisConfig的说明 5、有时候redis数据有版本的控制,例如:一天的数据一个版本,各个服务间调用不同版本的数据。 建议在业务系统考虑,在key_version,在查询的时候获得要得版本号,根据key构造key_version再到redis请求 \ No newline at end of file -- Gitee From e38b458b099b02f04e77e0ca9acc4508e6b0597d Mon Sep 17 00:00:00 2001 From: lvmoney Date: Mon, 28 Oct 2019 09:49:26 +0800 Subject: [PATCH 04/13] readme.md --- frame-k8s-support/frame-base-support/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/frame-k8s-support/frame-base-support/readme.md b/frame-k8s-support/frame-base-support/readme.md index a53788e..ef1caff 100644 --- a/frame-k8s-support/frame-base-support/readme.md +++ b/frame-k8s-support/frame-base-support/readme.md @@ -54,5 +54,6 @@ management: www.provider.com需要通过HostAliases 配置prometheus的hosts 15、istio的https,通过配置gateway去实现,请查看操作手册 +16、拓展k8s,ssh,yaml完全可以做一个网页版的k8s管理自己服务的平台 -- Gitee From 8a17b8cd20f07203768c07f9c00f21933f7081c2 Mon Sep 17 00:00:00 2001 From: lvmoney Date: Mon, 28 Oct 2019 09:56:46 +0800 Subject: [PATCH 05/13] readme.md --- frame-k8s-support/frame-base-support/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame-k8s-support/frame-base-support/readme.md b/frame-k8s-support/frame-base-support/readme.md index ef1caff..4447b01 100644 --- a/frame-k8s-support/frame-base-support/readme.md +++ b/frame-k8s-support/frame-base-support/readme.md @@ -45,7 +45,7 @@ management: (参考了istio默认的配置) 如果服务太多放到一个job下也不是很好,可以根据namespace(__meta_kubernetes_namespace通过regex通配符去匹配)来新建不同的job(job_name), 3) 安装alertmanager参考操作手册 -4) 简单的使用不推荐: +4) 简单的使用不推荐: - job_name: 'springboot_prometheus' scrape_interval: 5s metrics_path: '/actuator/prometheus' -- Gitee From cbd6b5b836dde53bafdf1fb7848a38d7952e8224 Mon Sep 17 00:00:00 2001 From: lvmoney Date: Tue, 29 Oct 2019 18:18:26 +0800 Subject: [PATCH 06/13] robots --- .../com/lvmoney/k8s/base/util/YamlUtil.java | 1 - frame-robots-support/pom.xml | 20 +++++ .../robots/application/RobotsApplication.java | 24 ++++++ .../robots/constant/RobotsConstant.java | 20 +++++ .../robots/controller/AllowController.java | 77 +++++++++++++++++++ .../java/com/lvmoney/robots/ro/RobotsRo.java | 27 +++++++ .../lvmoney/robots/service/RobotsService.java | 53 +++++++++++++ .../service/impl/RobotsServiceImpl.java | 49 ++++++++++++ .../java/com/lvmoney/robots/vo/Robots.java | 24 ++++++ .../com/lvmoney/robots/vo/RobotsDisallow.java | 25 ++++++ .../xxljob/application/XxljobApplication.java | 0 .../lvmoney}/xxljob/config/XxlJobConfig.java | 0 .../lvmoney}/xxljob/handler/TestHandler.java | 0 pom.xml | 1 + 14 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 frame-robots-support/pom.xml create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/application/RobotsApplication.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/constant/RobotsConstant.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/controller/AllowController.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/ro/RobotsRo.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/service/RobotsService.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/service/impl/RobotsServiceImpl.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/vo/Robots.java create mode 100644 frame-robots-support/src/main/java/com/lvmoney/robots/vo/RobotsDisallow.java rename frame-xxljob-support/src/main/java/{ => com/lvmoney}/xxljob/application/XxljobApplication.java (100%) rename frame-xxljob-support/src/main/java/{ => com/lvmoney}/xxljob/config/XxlJobConfig.java (100%) rename frame-xxljob-support/src/main/java/{ => com/lvmoney}/xxljob/handler/TestHandler.java (100%) diff --git a/frame-k8s-support/frame-base-support/src/main/java/com/lvmoney/k8s/base/util/YamlUtil.java b/frame-k8s-support/frame-base-support/src/main/java/com/lvmoney/k8s/base/util/YamlUtil.java index 5b7e9c0..f599d91 100644 --- a/frame-k8s-support/frame-base-support/src/main/java/com/lvmoney/k8s/base/util/YamlUtil.java +++ b/frame-k8s-support/frame-base-support/src/main/java/com/lvmoney/k8s/base/util/YamlUtil.java @@ -53,7 +53,6 @@ public class YamlUtil { } else if (fileName.exists() && !yamlBuild.isCover()) { return; } - StringWriter sw = new StringWriter(); Yaml yaml = new Yaml(dumperOptions); FileWriter fw = null; try { diff --git a/frame-robots-support/pom.xml b/frame-robots-support/pom.xml new file mode 100644 index 0000000..70c365f --- /dev/null +++ b/frame-robots-support/pom.xml @@ -0,0 +1,20 @@ + + + + frame + com.lvmoney + 0.0.1-SNAPSHOT + + 4.0.0 + + frame-robots-support + + + com.lvmoney + frame-redis-support + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/application/RobotsApplication.java b/frame-robots-support/src/main/java/com/lvmoney/robots/application/RobotsApplication.java new file mode 100644 index 0000000..23432b9 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/application/RobotsApplication.java @@ -0,0 +1,24 @@ +package com.lvmoney.robots.application;/** + * 描述: + * 包名:com.lvmoney.xxljob.application + * 版本信息: 版本1.0 + * 日期:2019/10/25 + * Copyright XXXXXX科技有限公司 + */ + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/25 17:58 + */ +@SpringBootApplication(scanBasePackages = {"com.lvmoney.**"}) +public class RobotsApplication { + public static void main(String[] args) { + SpringApplication.run(RobotsApplication.class, args); + } + +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/constant/RobotsConstant.java b/frame-robots-support/src/main/java/com/lvmoney/robots/constant/RobotsConstant.java new file mode 100644 index 0000000..0973038 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/constant/RobotsConstant.java @@ -0,0 +1,20 @@ +package com.lvmoney.robots.constant;/** + * 描述: + * 包名:com.lvmoney.robots.constant + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 16:50 + */ +public class RobotsConstant { + /** + * robots redis key + */ + public static final String ROBOTS_KEY = "robots_key"; +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/controller/AllowController.java b/frame-robots-support/src/main/java/com/lvmoney/robots/controller/AllowController.java new file mode 100644 index 0000000..202c29b --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/controller/AllowController.java @@ -0,0 +1,77 @@ +package com.lvmoney.robots.controller;/** + * 描述: + * 包名:com.lvmoney.robots.controller + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import com.lvmoney.robots.ro.RobotsRo; +import com.lvmoney.robots.service.RobotsService; +import com.lvmoney.robots.vo.Robots; +import com.lvmoney.robots.vo.RobotsDisallow; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 15:48 + */ +@RestController +public class AllowController { + @Autowired + RobotsService robotsService; + private static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n"); + private static final String USER_AGENT = "User-agent:"; + private static final String DISALLOW = "Disallow:"; + + @GetMapping("/robots.txt") + public void robotsTxt(HttpServletResponse response) throws IOException { + + Robots robots = new Robots(); + robots.setUserAgent("*"); + List disallow = new ArrayList() {{ + add(new RobotsDisallow("/question/tag/")); + add(new RobotsDisallow("/answer/*/edit")); + }}; + robots.setDisallow(disallow); + RobotsRo robotsRo1 = new RobotsRo(); + robotsRo1.setRobots(new ArrayList() {{ + add(robots); + }}); + robotsService.saveRobots(robotsRo1); + Writer writer = response.getWriter(); + List robotsList = robotsService.getRobots(); + robotsList.stream().forEach(e -> { + try { + writer.append(USER_AGENT).append(e.getUserAgent()).append(LINE_SEPARATOR); + e.getDisallow().stream().forEach(e1 -> { + try { + writer.append(DISALLOW).append(e1.getDisallow()).append(LINE_SEPARATOR); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + ); + } catch (IOException ex) { + ex.printStackTrace(); + } + }); + + } + + @GetMapping("/robots/create") + public void createRobotsTxt() { + + } + +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/ro/RobotsRo.java b/frame-robots-support/src/main/java/com/lvmoney/robots/ro/RobotsRo.java new file mode 100644 index 0000000..0aaefdd --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/ro/RobotsRo.java @@ -0,0 +1,27 @@ +package com.lvmoney.robots.ro;/** + * 描述: + * 包名:com.lvmoney.robots.ro + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import com.lvmoney.robots.vo.Robots; +import com.lvmoney.robots.vo.RobotsDisallow; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 16:09 + */ +@Data +public class RobotsRo implements Serializable { + private static final long serialVersionUID = 2888030780915746867L; + private List robots; + private Long expired; +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/service/RobotsService.java b/frame-robots-support/src/main/java/com/lvmoney/robots/service/RobotsService.java new file mode 100644 index 0000000..c6ad7d4 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/service/RobotsService.java @@ -0,0 +1,53 @@ +package com.lvmoney.robots.service;/** + * 描述: + * 包名:com.lvmoney.robots.service + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import com.lvmoney.robots.ro.RobotsRo; +import com.lvmoney.robots.vo.Robots; + +import java.util.List; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 16:22 + */ +public interface RobotsService { + /** + * 保存robots + * + * @param robotsRo: + * @throws + * @return: void + * @author: lvmoney /XXXXXX科技有限公司 + * @date: 2019/10/29 16:24 + */ + void saveRobots(RobotsRo robotsRo); + + /** + * 创建robots.txt + * + * @throws + * @return: void + * @author: lvmoney /XXXXXX科技有限公司 + * @date: 2019/10/29 16:54 + */ + void buildRobotsTxt(); + + /** + * 从redis获得robots + * + * @throws + * @return: com.lvmoney.robots.ro.RobotsRo + * @author: lvmoney /XXXXXX科技有限公司 + * @date: 2019/10/29 17:03 + */ + List getRobots(); + + +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/service/impl/RobotsServiceImpl.java b/frame-robots-support/src/main/java/com/lvmoney/robots/service/impl/RobotsServiceImpl.java new file mode 100644 index 0000000..f0b6ab2 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/service/impl/RobotsServiceImpl.java @@ -0,0 +1,49 @@ +package com.lvmoney.robots.service.impl;/** + * 描述: + * 包名:com.lvmoney.robots.service.impl + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.lvmoney.redis.service.BaseRedisService; +import com.lvmoney.robots.constant.RobotsConstant; +import com.lvmoney.robots.ro.RobotsRo; +import com.lvmoney.robots.service.RobotsService; +import com.lvmoney.robots.vo.Robots; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 16:22 + */ +@Service +public class RobotsServiceImpl implements RobotsService { + @Autowired + private BaseRedisService baseRedisService; + + @Override + public void saveRobots(RobotsRo robotsRo) { + baseRedisService.setString(RobotsConstant.ROBOTS_KEY, robotsRo); + } + + @Override + public void buildRobotsTxt() { + + } + + @Override + public List getRobots() { + Object obj = baseRedisService.getString(RobotsConstant.ROBOTS_KEY); + RobotsRo robotsRo = JSON.parseObject(obj.toString(), new TypeReference() { + }); + return robotsRo.getRobots(); + } +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/vo/Robots.java b/frame-robots-support/src/main/java/com/lvmoney/robots/vo/Robots.java new file mode 100644 index 0000000..ae1e265 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/vo/Robots.java @@ -0,0 +1,24 @@ +package com.lvmoney.robots.vo;/** + * 描述: + * 包名:com.lvmoney.robots.vo + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 17:39 + */ +@Data +public class Robots implements Serializable { + private String userAgent; + private List disallow; +} diff --git a/frame-robots-support/src/main/java/com/lvmoney/robots/vo/RobotsDisallow.java b/frame-robots-support/src/main/java/com/lvmoney/robots/vo/RobotsDisallow.java new file mode 100644 index 0000000..42ce5d0 --- /dev/null +++ b/frame-robots-support/src/main/java/com/lvmoney/robots/vo/RobotsDisallow.java @@ -0,0 +1,25 @@ +package com.lvmoney.robots.vo;/** + * 描述: + * 包名:com.lvmoney.robots.vo + * 版本信息: 版本1.0 + * 日期:2019/10/29 + * Copyright XXXXXX科技有限公司 + */ + + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +/** + * @describe: + * @author: lvmoney/XXXXXX科技有限公司 + * @version:v1.0 2019/10/29 16:11 + */ +@Data +@AllArgsConstructor +public class RobotsDisallow implements Serializable { + private static final long serialVersionUID = -7461384084485604369L; + private String disallow; +} diff --git a/frame-xxljob-support/src/main/java/xxljob/application/XxljobApplication.java b/frame-xxljob-support/src/main/java/com/lvmoney/xxljob/application/XxljobApplication.java similarity index 100% rename from frame-xxljob-support/src/main/java/xxljob/application/XxljobApplication.java rename to frame-xxljob-support/src/main/java/com/lvmoney/xxljob/application/XxljobApplication.java diff --git a/frame-xxljob-support/src/main/java/xxljob/config/XxlJobConfig.java b/frame-xxljob-support/src/main/java/com/lvmoney/xxljob/config/XxlJobConfig.java similarity index 100% rename from frame-xxljob-support/src/main/java/xxljob/config/XxlJobConfig.java rename to frame-xxljob-support/src/main/java/com/lvmoney/xxljob/config/XxlJobConfig.java diff --git a/frame-xxljob-support/src/main/java/xxljob/handler/TestHandler.java b/frame-xxljob-support/src/main/java/com/lvmoney/xxljob/handler/TestHandler.java similarity index 100% rename from frame-xxljob-support/src/main/java/xxljob/handler/TestHandler.java rename to frame-xxljob-support/src/main/java/com/lvmoney/xxljob/handler/TestHandler.java diff --git a/pom.xml b/pom.xml index 8dbdbd2..9ff90fa 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ frame-repeatsubmit-support frame-https-support frame-xxljob-support + frame-robots-support