lichen 10 ماه پیش
والد
کامیت
ebfca7da33
36فایلهای تغییر یافته به همراه1070 افزوده شده و 335 حذف شده
  1. 1 0
      pom.xml
  2. 1 1
      springboot-knife/src/main/java/org/example/lc/config/SwaggerConfig.java
  3. 20 0
      springboot-ldaptive/pom.xml
  4. 28 197
      springboot-ldaptive/src/main/java/org/example/lc/config/RabbitConfig.java
  5. 86 0
      springboot-ldaptive/src/main/java/org/example/lc/controller/MqController.java
  6. 0 33
      springboot-ldaptive/src/main/java/org/example/lc/controller/OneSendMultiRecverController.java
  7. 0 29
      springboot-ldaptive/src/main/java/org/example/lc/controller/TopicExchangeController.java
  8. 30 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/ApplyInfo.java
  9. 23 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/ApplyResource.java
  10. 22 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/QuitInfo.java
  11. 23 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/QuitResource.java
  12. 37 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/RecoveryInfo.java
  13. 23 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/RecoveryResource.java
  14. 20 0
      springboot-ldaptive/src/main/java/org/example/lc/pojo/enums/ResourceEnum.java
  15. 69 0
      springboot-ldaptive/src/main/java/org/example/lc/service/MainService.java
  16. 38 0
      springboot-ldaptive/src/main/java/org/example/lc/service/ResourceService.java
  17. 34 0
      springboot-ldaptive/src/main/java/org/example/lc/service/mq/ApplyResourceReceiver.java
  18. 35 0
      springboot-ldaptive/src/main/java/org/example/lc/service/mq/QuitReceiver.java
  19. 35 0
      springboot-ldaptive/src/main/java/org/example/lc/service/mq/RecoveryResourceReceiver.java
  20. 18 0
      springboot-ldaptive/src/main/java/org/example/lc/service/mq/Sender.java
  21. 38 0
      springboot-ldaptive/src/main/java/org/example/lc/service/resource/GitServiceImpl.java
  22. 37 0
      springboot-ldaptive/src/main/java/org/example/lc/service/resource/JenkinsServiceImpl.java
  23. 39 0
      springboot-ldaptive/src/main/java/org/example/lc/service/resource/LdapServiceImpl.java
  24. 0 22
      springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicMessageReceiver.java
  25. 0 22
      springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicMessagesReceiver.java
  26. 0 30
      springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicSender.java
  27. 42 0
      springboot-ldaptive/src/main/java/org/example/lc/utlis/JsonUtil.java
  28. 4 1
      springboot-ldaptive/src/main/resources/application.properties
  29. 51 0
      springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample.java
  30. 48 0
      springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample2.java
  31. 39 0
      springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample3.java
  32. 72 0
      springboot-poi-tl/pom.xml
  33. 14 0
      springboot-poi-tl/src/main/java/org/example/lc/PoitlApplication.java
  34. 31 0
      springboot-poi-tl/src/main/java/org/example/lc/config/SwaggerConfig.java
  35. 25 0
      springboot-poi-tl/src/main/java/org/example/lc/controller/HelloController.java
  36. 87 0
      springboot-poi-tl/src/test/java/org/example/lc/MarkdownToWordExample.java

+ 1 - 0
pom.xml

@@ -15,5 +15,6 @@
         <module>springboot-jdbc-mysql</module>
         <module>springboot-ldaptive</module>
         <module>springboot-tabula</module>
+        <module>springboot-poi-tl</module>
     </modules>
 </project>

+ 1 - 1
springboot-knife/src/main/java/org/example/lc/config/SwaggerConfig.java

@@ -24,7 +24,7 @@ public class SwaggerConfig {
     private ApiInfo apiInfo() {
         return new ApiInfoBuilder().title("SpringBoot整合Knife") // 标题
                 .description("api接口的文档整理,支持在线测试") // 描述
-                .contact(new Contact("vector.wang", "http://blog.wangxc.club/", "vector4wang@qq.com"))
+                .contact(new Contact("李辰", "", "lichen1986@aliyun.com"))
                 .version("1.0") // 版本号
                 .build();
     }

+ 20 - 0
springboot-ldaptive/pom.xml

@@ -80,5 +80,25 @@
             <version>2.5.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.13.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.13.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.13.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version>
+        </dependency>
     </dependencies>
 </project>

+ 28 - 197
springboot-ldaptive/src/main/java/org/example/lc/config/RabbitConfig.java

@@ -1,6 +1,6 @@
 package org.example.lc.config;
 
-import org.springframework.amqp.core.*;
+import org.springframework.amqp.core.Queue;
 import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
 import org.springframework.amqp.rabbit.connection.ConnectionFactory;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -32,226 +32,57 @@ public class RabbitConfig {
 	@Value("${rabbitmq.virtual-host}")
 	private String virtualHost;
 
+	@Value("${queue.name.apply}")
+	private String applyQueue;
 
+	@Value("${queue.name.recovery}")
+	private String recoveryQueue;
 
-	@Bean
-	public ConnectionFactory connFactory() {
-		CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
-		connectionFactory.setHost(host);
-		connectionFactory.setPort(port);
-		connectionFactory.setUsername(username);
-		connectionFactory.setPassword(password);
-		connectionFactory.setVirtualHost(virtualHost);
-		connectionFactory.setPublisherConfirms(publisherConfirm); //必须要设置
-		return connectionFactory;
-	}
-
-	//////////////////////////////针对消息 delay queue////////////////////////////////
-	/**
-	 * 发送到该队列的message会在一段时间后过期进入到delay_process_queue
-	 * 每个message可以控制自己的失效时间
-	 */
-	public final static String DELAY_QUEUE_MSG = "delay_queue";
-
-	/**
-	 * DLX
-	 */
-	public final static String DELAY_EXCHANGE_NAME = "delay_exchange";
-
-
-	/**
-	 * 正常消费的队列
-	 */
-	public final static String PROCESS_QUEUE = "process_queue";
-
-	/**
-	 * 正常队列对应的exchange
-	 */
-	public final static String PROCESS_EXCHANGE_NAME = "process_exchange";
-
-
-	public static String ROUTING_KEY = "delay";
-
-	/**
-	 * 延迟队列 exchange
-	 * @return
-	 */
-	@Bean
-	public DirectExchange delayExchange() {
-		return new DirectExchange(DELAY_EXCHANGE_NAME);
-	}
-
-	@Bean
-	public DirectExchange processExchange() {
-		return new DirectExchange(PROCESS_EXCHANGE_NAME);
-	}
-
-	/**
-	 * 存放延迟消息的队列 最后将会转发给exchange(实际消费队列对应的)
-	 * @return
-	 */
-	@Bean
-    Queue delayQueue4Msg(){
-		return QueueBuilder.durable(DELAY_QUEUE_MSG)
-				.withArgument("x-dead-letter-exchange", PROCESS_EXCHANGE_NAME) // DLX,dead letter发送到的exchange
-				.withArgument("x-dead-letter-routing-key", ROUTING_KEY) // dead letter携带的routing key
-				.build();
-	}
-
-	@Bean
-	public Queue processQueue() {
-		return QueueBuilder.durable(PROCESS_QUEUE)
-				.build();
-	}
-
-
-
-	/**
-	 * 将延迟队列与exchange绑定,即到达指定时间之后需要转交给queue消费
-	 * @return
-	 */
-	@Bean
-    Binding delayBinding() {
-		return BindingBuilder.bind(delayQueue4Msg())
-				.to(delayExchange())
-				.with(ROUTING_KEY);
-	}
+	@Value("${queue.name.quit}")
+	private String quitQueue;
 
 	@Bean
-    Binding queueBinding() {
-		return BindingBuilder.bind(processQueue())
-				.to(processExchange())
-				.with(ROUTING_KEY);
+	public String applyQueueName() {
+		return applyQueue;
 	}
 
-	//////////////////////////////delay////////////////////////////////
-
-
-	//////////////////////////////针对队列delay////////////////////////////////
-
-	/**
-	 * 针对队列设置过期时间的队列
-	 */
-	public final static String DELAY_QUEUE_NAME = "delay_queue_queue";
-
-	public final static String DELAY_QUEUE_EXCHANGE_NAME = "delay_queue_exchange";
-
 	@Bean
-	public DirectExchange delayQueueExchange() {
-		return new DirectExchange(DELAY_QUEUE_EXCHANGE_NAME);
+	public String recoveryQueueName() {
+		return recoveryQueue;
 	}
 
-	/**
-	 * 存放消息的延迟队列 最后将会转发给exchange(实际消费队列对应的)
-	 * @return
-	 */
 	@Bean
-	public Queue delayQueue4Queue() {
-		return QueueBuilder.durable(DELAY_QUEUE_NAME)
-				.withArgument("x-dead-letter-exchange", PROCESS_EXCHANGE_NAME) // DLX
-				.withArgument("x-dead-letter-routing-key", ROUTING_KEY) // dead letter携带的routing key
-				.withArgument("x-message-ttl", 3000) // 设置队列的过期时间
-				.build();
+	public String quitQueueName() {
+		return quitQueue;
 	}
 
 	@Bean
-    Binding delayQueueBind() {
-		return BindingBuilder.bind(delayQueue4Queue())
-				.to(delayQueueExchange())
-				.with(ROUTING_KEY);
+	public Queue initApplyQueue() {
+		return new Queue(applyQueue);
 	}
 
-
-
 	@Bean
-	public Queue helloQueue() {
-		return new Queue("helloQueue");
+	public Queue initRecoveryQueue() {
+		return new Queue(recoveryQueue);
 	}
 
 	@Bean
-	public Queue msgQueue() {
-		return new Queue("msgQueue");
+	public Queue initQuitQueue() {
+		return new Queue(quitQueue);
 	}
 
-	//===============以下是验证topic Exchange的队列==========
 	@Bean
-	public Queue queueMessage() {
-		return new Queue("topic.message");
-	}
-
-	@Bean
-	public Queue queueMessages() {
-		return new Queue("topic.messages");
-	}
-	//===============以上是验证topic Exchange的队列==========
-
-
-	//===============以下是验证Fanout Exchange的队列==========
-	@Bean
-	public Queue AMessage() {
-		return new Queue("fanout.A");
-	}
-
-	@Bean
-	public Queue BMessage() {
-		return new Queue("fanout.B");
-	}
-
-	@Bean
-	public Queue CMessage() {
-		return new Queue("fanout.C");
-	}
-	//===============以上是验证Fanout Exchange的队列==========
-
-
-	@Bean
-    TopicExchange exchange() {
-		return new TopicExchange("exchange");
-	}
-
-	@Bean
-    FanoutExchange fanoutExchange() {
-		return new FanoutExchange("fanoutExchange");
-	}
-
-	/**
-	 * 将队列topic.message与exchange绑定,binding_key为topic.message,就是完全匹配
-	 * @param queueMessage
-	 * @param exchange
-	 * @return
-	 */
-	@Bean
-    Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
-		return BindingBuilder.bind(queueMessage).to(exchange).with("topic.message");
-	}
-
-	/**
-	 * 将队列topic.messages与exchange绑定,binding_key为topic.#,模糊匹配
-	 * @param queueMessages
-	 * @param exchange
-	 * @return
-	 */
-	@Bean
-    Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange) {
-		return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#");
-	}
-
-	@Bean
-    Binding bindingExchangeA(Queue AMessage, FanoutExchange fanoutExchange) {
-		return BindingBuilder.bind(AMessage).to(fanoutExchange);
-	}
-
-	@Bean
-    Binding bindingExchangeB(Queue BMessage, FanoutExchange fanoutExchange) {
-		return BindingBuilder.bind(BMessage).to(fanoutExchange);
-	}
-
-	@Bean
-    Binding bindingExchangeC(Queue CMessage, FanoutExchange fanoutExchange) {
-		return BindingBuilder.bind(CMessage).to(fanoutExchange);
+	public ConnectionFactory connFactory() {
+		CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
+		connectionFactory.setHost(host);
+		connectionFactory.setPort(port);
+		connectionFactory.setUsername(username);
+		connectionFactory.setPassword(password);
+		connectionFactory.setVirtualHost(virtualHost);
+		connectionFactory.setPublisherConfirms(publisherConfirm); //必须要设置
+		return connectionFactory;
 	}
 
-
 	@Bean
 	@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 	//必须是prototype类型

+ 86 - 0
springboot-ldaptive/src/main/java/org/example/lc/controller/MqController.java

@@ -0,0 +1,86 @@
+package org.example.lc.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.example.lc.pojo.domain.ApplyResource;
+import org.example.lc.pojo.domain.QuitResource;
+import org.example.lc.pojo.domain.RecoveryResource;
+import org.example.lc.service.mq.Sender;
+import org.example.lc.service.onesendmultirecver.HelloOneSender;
+import org.example.lc.utlis.JsonUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * Created with IDEA
+ * User: vector
+ * Data: 2017/7/7
+ * Time: 17:06
+ * Description:
+ */
+@RestController
+@RequestMapping("/rabbit2")
+@Api(value = "MqController", tags = "模拟发送mq消息")
+public class MqController {
+    @Autowired
+    private HelloOneSender helloSender1;
+
+    @Autowired
+    private Sender sender;
+
+    @Value("${queue.name.apply}")
+    private String applyQueueName;
+
+    @Value("${queue.name.recovery}")
+    private String recoveryQueueName;
+
+    @Value("${queue.name.quit}")
+    private String quitQueueName;
+
+    @ApiOperation("单生产者-多消费者")
+    @RequestMapping(value = "/oneToMany", method = RequestMethod.GET)
+    public void oneToMany() {
+        for (int i = 0; i < 10; i++) {
+            helloSender1.send("hellomsg:" + i);
+        }
+    }
+
+    /**
+     * 含义为:只是给员工授予git、jenkins的登录权限,不包含git、jenkins里面的仓库权限、项目权限等
+     * 在ldap中新增用户,用于登录git、jenkins时进行验证
+     * 记录操作流水
+     * @param resource
+     * @return
+     */
+    @ApiOperation("员工资源申请流程")
+    @PostMapping("/apply")
+    public Boolean send(@Valid @RequestBody ApplyResource resource) {
+        sender.send(applyQueueName, JsonUtil.serialize(resource));
+        return Boolean.TRUE;
+    }
+
+    @ApiOperation("资源回收流程")
+    @PostMapping("/recovery")
+    public Boolean recovery(@Valid @RequestBody RecoveryResource resource) {
+        sender.send(recoveryQueueName, JsonUtil.serialize(resource));
+        return Boolean.TRUE;
+    }
+
+    /**
+     * 删除ldap账号信息
+     * git用户信息置为失效
+     * jenkins用户置为失效
+     * 记录操作流水
+     * @param resource
+     * @return
+     */
+    @ApiOperation("员工离职资源回收流程")
+    @PostMapping("/quit")
+    public Boolean quit(@Valid @RequestBody QuitResource resource) {
+        sender.send(quitQueueName, JsonUtil.serialize(resource));
+        return Boolean.TRUE;
+    }
+}

+ 0 - 33
springboot-ldaptive/src/main/java/org/example/lc/controller/OneSendMultiRecverController.java

@@ -1,33 +0,0 @@
-package org.example.lc.controller;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.example.lc.service.onesendmultirecver.HelloOneSender;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Created with IDEA
- * User: vector
- * Data: 2017/7/7
- * Time: 17:06
- * Description:
- */
-@RestController
-@RequestMapping("/rabbit2")
-@Api(value = "单生产者-多消费者",description = "")
-public class OneSendMultiRecverController {
-    @Autowired
-    private HelloOneSender helloSender1;
-
-    @ApiOperation("单生产者-多消费者")
-    @RequestMapping(value = "/oneToMany",method = RequestMethod.GET)
-    public void oneToMany() {
-        for(int i=0;i<10;i++){
-            helloSender1.send("hellomsg:"+i);
-        }
-
-    }
-}

+ 0 - 29
springboot-ldaptive/src/main/java/org/example/lc/controller/TopicExchangeController.java

@@ -1,29 +0,0 @@
-package org.example.lc.controller;
-
-import io.swagger.annotations.Api;
-import org.example.lc.service.topicExChange.TopicSender;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @Author: wangxc
- * @GitHub: https://github.com/vector4wang
- * @CSDN: http://blog.csdn.net/qqhjqs?viewmode=contents
- * @BLOG: http://vector4wang.tk
- * @wxid: BMHJQS
- */
-@RestController
-@RequestMapping("/rabbit5")
-@Api(value = "topic exchange类型rabbitmq",description = "")
-public class TopicExchangeController {
-
-    @Autowired
-    private TopicSender topicSender;
-
-    @RequestMapping(value = "/topic",method = RequestMethod.GET)
-    public void topicTest() {
-        topicSender.send();
-    }
-}

+ 30 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/ApplyInfo.java

@@ -0,0 +1,30 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+@ApiModel("用户信息")
+public class ApplyInfo implements Serializable {
+    private static final long serialVersionUID = -9033258006956394218L;
+
+    @ApiModelProperty(value = "用户名", example = "san.zhang001", required = true)
+    @NotNull
+    private String userCode;
+
+    @ApiModelProperty(value = "明文密码", example = "123456", required = true)
+    @NotNull
+    private String password;
+
+    @ApiModelProperty(value = "邮箱", example = "san.zhang001@northking.net", required = true)
+    @NotNull
+    private String mail;
+
+    @ApiModelProperty(value = "业务流水编号,可据此反查申请记录信息", example = "", required = true)
+    @NotNull
+    private String busNo;
+}

+ 23 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/ApplyResource.java

@@ -0,0 +1,23 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ApiModel("资源申请信息封装类")
+public class ApplyResource implements Serializable {
+    private static final long serialVersionUID = 4757361823176562386L;
+
+    @ApiModelProperty(value = "用户信息", required = true)
+    @NotNull
+    private ApplyInfo info;
+
+    @ApiModelProperty(value = "系统编码,枚举值:git、jenkins、ldap", required = true)
+    @NotNull
+    private List<String> systemCodes;
+}

+ 22 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/QuitInfo.java

@@ -0,0 +1,22 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+@ApiModel("用户信息")
+public class QuitInfo implements Serializable {
+    private static final long serialVersionUID = 98684746256426237L;
+
+    @ApiModelProperty(value = "用户名", example = "san.zhang001", required = true)
+    @NotNull
+    private String userCode;
+
+    @ApiModelProperty(value = "业务流水编号,可据此反查申请记录信息", example = "", required = true)
+    @NotNull
+    private String busNo;
+}

+ 23 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/QuitResource.java

@@ -0,0 +1,23 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ApiModel("资源信息封装类")
+public class QuitResource implements Serializable {
+    private static final long serialVersionUID = 7604514161375473554L;
+
+    @ApiModelProperty(value = "用户信息", required = true)
+    @NotNull
+    private QuitInfo info;
+
+    @ApiModelProperty(value = "系统编码,枚举值:git、jenkins、ldap", required = true)
+    @NotNull
+    private List<String> systemCodes;
+}

+ 37 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/RecoveryInfo.java

@@ -0,0 +1,37 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ApiModel("资源回收信息")
+public class RecoveryInfo implements Serializable {
+    private static final long serialVersionUID = 98684746256426237L;
+
+    @ApiModelProperty(value = "用户名", example = "san.zhang001", required = true)
+    @NotNull
+    private String userCode;
+
+    @NotNull
+    private List<Info> infoList;
+
+    @ApiModelProperty(value = "业务流水编号,可据此反查申请记录信息", example = "", required = true)
+    @NotNull
+    private String busNo;
+
+    @ApiModel("资源信息")
+    class Info {
+        @ApiModelProperty(value = "模块名称", example = "nlpmp-dcp", required = true)
+        @NotNull
+        private String name;
+
+        @ApiModelProperty(value = "模块url", example = "http://192.168.84.21:8080/job/nkudp-ui-rapidx", required = true)
+        @NotNull
+        private String url;
+    }
+}

+ 23 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/domain/RecoveryResource.java

@@ -0,0 +1,23 @@
+package org.example.lc.pojo.domain;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ApiModel("资源信息封装类")
+public class RecoveryResource implements Serializable {
+    private static final long serialVersionUID = 7604514161375473554L;
+
+    @ApiModelProperty(value = "用户信息", required = true)
+    @NotNull
+    private RecoveryInfo info;
+
+    @ApiModelProperty(value = "系统编码,枚举值:git、jenkins、ldap", required = true)
+    @NotNull
+    private List<String> systemCodes;
+}

+ 20 - 0
springboot-ldaptive/src/main/java/org/example/lc/pojo/enums/ResourceEnum.java

@@ -0,0 +1,20 @@
+package org.example.lc.pojo.enums;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import lombok.Getter;
+
+@Getter
+public enum ResourceEnum {
+    ldap("ldap","ldap"),
+    git("git","git"),
+    jenkins("jenkins", "jenkins");
+
+    @EnumValue
+    private final String code;
+    private final String desc;
+
+    ResourceEnum(String code, String desc){
+        this.code = code;
+        this.desc = desc;
+    }
+}

+ 69 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/MainService.java

@@ -0,0 +1,69 @@
+package org.example.lc.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyInfo;
+import org.example.lc.pojo.domain.QuitInfo;
+import org.example.lc.pojo.domain.RecoveryInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class MainService {
+
+    private final Map<String, ResourceService> serviceMap;
+
+    @Autowired
+    public MainService(List<ResourceService> services) {
+        this.serviceMap = services.stream()
+                .collect(Collectors.toMap(ResourceService::resourceCode, service -> service));
+    }
+
+    /**
+     * 申请资源
+     *
+     * @param resourceCode
+     * @param info
+     */
+    public void apply(String resourceCode, ApplyInfo info) {
+        ResourceService service = serviceMap.get(resourceCode);
+        if (service != null) {
+            service.apply(info);
+        } else {
+            log.info("No service found for resourceCode:{}", resourceCode);
+        }
+    }
+
+    /**
+     * 回收资源
+     *
+     * @param resourceCode
+     * @param info
+     */
+    public void recovery(String resourceCode, RecoveryInfo info) {
+        ResourceService service = serviceMap.get(resourceCode);
+        if (service != null) {
+            service.recovery(info);
+        } else {
+            log.info("No service found for resourceCode:{}", resourceCode);
+        }
+    }
+
+    /**
+     * 员工离职
+     * @param resourceCode
+     * @param info
+     */
+    public void quit(String resourceCode, QuitInfo info) {
+        ResourceService service = serviceMap.get(resourceCode);
+        if (service != null) {
+            service.cancel(info);
+        } else {
+            log.info("No service found for resourceCode:{}", resourceCode);
+        }
+    }
+}

+ 38 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/ResourceService.java

@@ -0,0 +1,38 @@
+package org.example.lc.service;
+
+import org.example.lc.pojo.domain.ApplyInfo;
+import org.example.lc.pojo.domain.QuitInfo;
+import org.example.lc.pojo.domain.RecoveryInfo;
+import org.example.lc.pojo.response.ResponseBean;
+
+public interface ResourceService {
+    /**
+     * 资源申请
+     *
+     * @param info
+     * @return
+     */
+    ResponseBean<Boolean> apply(ApplyInfo info);
+
+    /**
+     * 资源回收
+     *
+     * @param info
+     * @return
+     */
+    ResponseBean<Boolean> recovery(RecoveryInfo info);
+
+    /**
+     * 注销
+     * @param info
+     * @return
+     */
+    ResponseBean<Boolean> cancel(QuitInfo info);
+
+    /**
+     * 资源类别编码
+     *
+     * @return
+     */
+    String resourceCode();
+}

+ 34 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/mq/ApplyResourceReceiver.java

@@ -0,0 +1,34 @@
+package org.example.lc.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyResource;
+import org.example.lc.service.MainService;
+import org.example.lc.utlis.JsonUtil;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Slf4j
+@Component
+public class ApplyResourceReceiver {
+    @Autowired
+    private MainService mainService;
+
+    @Value("${queue.name.apply}")
+    private String queueName;
+
+    @RabbitListener(queues = "#{@applyQueueName}")
+    public void process(String msg) {
+        log.info("{} receive msg:{}", queueName, msg);
+        ApplyResource resource = JsonUtil.deserialize(msg, ApplyResource.class);
+        if (resource == null || CollectionUtils.isEmpty(resource.getSystemCodes())) {
+            log.error("报文有误");
+            return;
+        }
+        resource.getSystemCodes().stream().forEach(item -> {
+            mainService.apply(item, resource.getInfo());
+        });
+    }
+}

+ 35 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/mq/QuitReceiver.java

@@ -0,0 +1,35 @@
+package org.example.lc.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.QuitResource;
+import org.example.lc.pojo.domain.RecoveryResource;
+import org.example.lc.service.MainService;
+import org.example.lc.utlis.JsonUtil;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Slf4j
+@Component
+public class QuitReceiver {
+    @Autowired
+    private MainService mainService;
+
+    @Value("${queue.name.quit}")
+    private String queueName;
+
+    @RabbitListener(queues = "#{@quitQueueName}")
+    public void process(String msg) {
+        log.info("{} receive msg:{}", queueName, msg);
+        QuitResource resource = JsonUtil.deserialize(msg, QuitResource.class);
+        if (resource == null || CollectionUtils.isEmpty(resource.getSystemCodes())) {
+            log.error("报文有误");
+            return;
+        }
+        resource.getSystemCodes().stream().forEach(item -> {
+            mainService.quit(item, resource.getInfo());
+        });
+    }
+}

+ 35 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/mq/RecoveryResourceReceiver.java

@@ -0,0 +1,35 @@
+package org.example.lc.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyResource;
+import org.example.lc.pojo.domain.RecoveryResource;
+import org.example.lc.service.MainService;
+import org.example.lc.utlis.JsonUtil;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Slf4j
+@Component
+public class RecoveryResourceReceiver {
+    @Autowired
+    private MainService mainService;
+
+    @Value("${queue.name.recovery}")
+    private String queueName;
+
+    @RabbitListener(queues = "#{@recoveryQueueName}")
+    public void process(String msg) {
+        log.info("{} receive msg:{}", queueName, msg);
+        RecoveryResource resource = JsonUtil.deserialize(msg, RecoveryResource.class);
+        if (resource == null || CollectionUtils.isEmpty(resource.getSystemCodes())) {
+            log.error("报文有误");
+            return;
+        }
+        resource.getSystemCodes().stream().forEach(item -> {
+            mainService.recovery(item, resource.getInfo());
+        });
+    }
+}

+ 18 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/mq/Sender.java

@@ -0,0 +1,18 @@
+package org.example.lc.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class Sender {
+    @Autowired
+    private AmqpTemplate rabbitTemplate;
+
+    public void send(String topic, String msg) {
+        log.info("MqSender.send topic:{}, msg:{}", topic, msg);
+        this.rabbitTemplate.convertAndSend(topic, msg);
+    }
+}

+ 38 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/resource/GitServiceImpl.java

@@ -0,0 +1,38 @@
+package org.example.lc.service.resource;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyInfo;
+import org.example.lc.pojo.domain.QuitInfo;
+import org.example.lc.pojo.domain.RecoveryInfo;
+import org.example.lc.pojo.enums.ResourceEnum;
+import org.example.lc.pojo.response.ResponseBean;
+import org.example.lc.service.ResourceService;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class GitServiceImpl implements ResourceService {
+
+    @Override
+    public ResponseBean<Boolean> apply(ApplyInfo info) {
+        log.info("Git开始申请资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> recovery(RecoveryInfo info) {
+        log.info("Git开始回收资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> cancel(QuitInfo info) {
+        log.info("Git开始离职流程");
+        return null;
+    }
+
+    @Override
+    public String resourceCode() {
+        return ResourceEnum.git.getCode();
+    }
+}

+ 37 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/resource/JenkinsServiceImpl.java

@@ -0,0 +1,37 @@
+package org.example.lc.service.resource;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyInfo;
+import org.example.lc.pojo.domain.QuitInfo;
+import org.example.lc.pojo.domain.RecoveryInfo;
+import org.example.lc.pojo.enums.ResourceEnum;
+import org.example.lc.pojo.response.ResponseBean;
+import org.example.lc.service.ResourceService;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class JenkinsServiceImpl implements ResourceService {
+    @Override
+    public ResponseBean<Boolean> apply(ApplyInfo info) {
+        log.info("Jenkins开始申请资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> recovery(RecoveryInfo info) {
+        log.info("Jenkins开始回收资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> cancel(QuitInfo info) {
+        log.info("Jenkins开始离职流程");
+        return null;
+    }
+
+    @Override
+    public String resourceCode() {
+        return ResourceEnum.jenkins.getCode();
+    }
+}

+ 39 - 0
springboot-ldaptive/src/main/java/org/example/lc/service/resource/LdapServiceImpl.java

@@ -0,0 +1,39 @@
+package org.example.lc.service.resource;
+
+import lombok.extern.slf4j.Slf4j;
+import org.example.lc.pojo.domain.ApplyInfo;
+import org.example.lc.pojo.domain.QuitInfo;
+import org.example.lc.pojo.domain.RecoveryInfo;
+import org.example.lc.pojo.enums.ResourceEnum;
+import org.example.lc.pojo.response.ResponseBean;
+import org.example.lc.service.ResourceService;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class LdapServiceImpl implements ResourceService {
+    @Override
+    public ResponseBean<Boolean> apply(ApplyInfo info) {
+        log.info("Ldap开始申请资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> recovery(RecoveryInfo info) {
+        log.info("Ldap开始回收资源");
+        return null;
+    }
+
+    @Override
+    public ResponseBean<Boolean> cancel(QuitInfo info) {
+        log.info("Ldap开始离职流程");
+        return null;
+    }
+
+
+
+    @Override
+    public String resourceCode() {
+        return ResourceEnum.ldap.getCode();
+    }
+}

+ 0 - 22
springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicMessageReceiver.java

@@ -1,22 +0,0 @@
-package org.example.lc.service.topicExChange;
-
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author: wangxc
- * @GitHub: https://github.com/vector4wang
- * @CSDN: http://blog.csdn.net/qqhjqs?viewmode=contents
- * @BLOG: http://vector4wang.tk
- * @wxid: BMHJQS
- */
-@Component
-@RabbitListener(queues = "topic.message")
-public class TopicMessageReceiver {
-
-    @RabbitHandler
-    public void process(String msg) {
-        System.out.println("topicMessageReceiver  : " +msg);
-    }
-}

+ 0 - 22
springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicMessagesReceiver.java

@@ -1,22 +0,0 @@
-package org.example.lc.service.topicExChange;
-
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author: wangxc
- * @GitHub: https://github.com/vector4wang
- * @CSDN: http://blog.csdn.net/qqhjqs?viewmode=contents
- * @BLOG: http://vector4wang.tk
- * @wxid: BMHJQS
- */
-@Component
-@RabbitListener(queues = "topic.messages")
-public class TopicMessagesReceiver {
-
-    @RabbitHandler
-    public void process(String msg) {
-        System.out.println("topicMessagesReceiver  : " +msg);
-    }
-}

+ 0 - 30
springboot-ldaptive/src/main/java/org/example/lc/service/topicExChange/TopicSender.java

@@ -1,30 +0,0 @@
-package org.example.lc.service.topicExChange;
-
-import org.springframework.amqp.core.AmqpTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author: wangxc
- * @GitHub: https://github.com/vector4wang
- * @CSDN: http://blog.csdn.net/qqhjqs?viewmode=contents
- * @BLOG: http://vector4wang.tk
- * @wxid: BMHJQS
- */
-@Component
-public class TopicSender {
-
-    @Autowired
-    private AmqpTemplate rabbitTemplate;
-
-    public void send() {
-        String msg1 = "I am topic.mesaage msg======";
-        System.out.println("sender1 : " + msg1);
-        this.rabbitTemplate.convertAndSend("exchange", "topic.message", msg1);
-
-        String msg2 = "I am topic.mesaages msg########";
-        System.out.println("sender2 : " + msg2);
-        this.rabbitTemplate.convertAndSend("exchange", "topic.messages", msg2);
-    }
-
-}

+ 42 - 0
springboot-ldaptive/src/main/java/org/example/lc/utlis/JsonUtil.java

@@ -0,0 +1,42 @@
+package org.example.lc.utlis;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class JsonUtil {
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
+    /**
+     * 对象序列化
+     *
+     * @param obj
+     * @return
+     */
+    public static String serialize(Object obj) {
+        try {
+            return objectMapper.writeValueAsString(obj);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    /**
+     * 对象反序列化
+     *
+     * @param jsonString
+     * @param clazz
+     * @param <T>
+     * @return
+     */
+    public static <T> T deserialize(String jsonString, Class<T> clazz) {
+        try {
+            return objectMapper.readValue(jsonString, clazz);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+}

+ 4 - 1
springboot-ldaptive/src/main/resources/application.properties

@@ -9,4 +9,7 @@ rabbitmq.port=5672
 rabbitmq.username=guest
 rabbitmq.password=guest
 rabbitmq.publisher-confirms=true
-rabbitmq.virtual-host=/
+rabbitmq.virtual-host=/
+queue.name.apply=applyResourceQueue
+queue.name.recovery=recoveryResourceQueue
+queue.name.quit=quitQueue

+ 51 - 0
springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample.java

@@ -0,0 +1,51 @@
+package org.example.lc;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+public class GiteaApiExample {
+    private static final String GITEA_URL = "http://172.31.161.37:3000";
+    private static final String ADMIN_API_TOKEN = "4e2bac6a5b6ebc1751d706f1588c43e4a6c475c6";
+
+    public static void main(String[] args) {
+        try {
+            String username = "san.zhang003";
+            String email = "san.zhang003@example.com";
+            String password = "123456";
+
+            createUser(username, email, password);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void createUser(String username, String email, String password) throws Exception {
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpPost request = new HttpPost(GITEA_URL + "/api/v1/admin/users");
+            request.setHeader("Content-Type", "application/json");
+            request.setHeader("Authorization", "token " + ADMIN_API_TOKEN);
+
+            String jsonInputString = String.format(
+                    "{\"username\": \"%s\", \"email\": \"%s\", \"password\": \"%s\", \"must_change_password\": true}",
+                    username, email, password
+            );
+
+            request.setEntity(new StringEntity(jsonInputString));
+
+            try (CloseableHttpResponse response = httpClient.execute(request)) {
+                int responseCode = response.getStatusLine().getStatusCode();
+                if (responseCode == 201) { // HTTP Created
+                    System.out.println("User created successfully.");
+                } else {
+                    String responseBody = EntityUtils.toString(response.getEntity());
+                    System.out.println("Failed to create user. Response code: " + responseCode);
+                    System.out.println("Response body: " + responseBody);
+                }
+            }
+        }
+    }
+}

+ 48 - 0
springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample2.java

@@ -0,0 +1,48 @@
+package org.example.lc;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+public class GiteaApiExample2 {
+    private static final String GITEA_URL = "http://172.31.161.37:3000";
+    private static final String ADMIN_API_TOKEN = "4e2bac6a5b6ebc1751d706f1588c43e4a6c475c6";
+
+    public static void main(String[] args) {
+        try {
+            String owner = "root"; // 替换为仓库拥有者的用户名
+            String repo = "test"; // 替换为仓库名称
+            String collaborator = "san.zhang002"; // 替换为被授权用户的用户名
+
+            setUserPermission(owner, repo, collaborator, "write");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void setUserPermission(String owner, String repo, String collaborator, String permission) throws Exception {
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpPut request = new HttpPut(GITEA_URL + "/api/v1/repos/" + owner + "/" + repo + "/collaborators/" + collaborator);
+            request.setHeader("Content-Type", "application/json");
+            request.setHeader("Authorization", "token " + ADMIN_API_TOKEN);
+
+            String jsonInputString = String.format("{\"permission\": \"%s\"}", permission);
+
+            request.setEntity(new StringEntity(jsonInputString));
+
+            try (CloseableHttpResponse response = httpClient.execute(request)) {
+                int responseCode = response.getStatusLine().getStatusCode();
+                if (responseCode == 200) { // HTTP OK
+                    System.out.println("Permission set successfully.");
+                } else {
+                    String responseBody = EntityUtils.toString(response.getEntity());
+                    System.out.println("Failed to set permission. Response code: " + responseCode);
+                    System.out.println("Response body: " + responseBody);
+                }
+            }
+        }
+    }
+}

+ 39 - 0
springboot-ldaptive/src/test/java/org/example/lc/GiteaApiExample3.java

@@ -0,0 +1,39 @@
+package org.example.lc;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+
+public class GiteaApiExample3 {
+    private static final String GITEA_URL = "https://gitea.example.com"; // 替换为你的 Gitea 服务器地址
+    private static final String ADMIN_API_TOKEN = "YOUR_ADMIN_API_TOKEN"; // 替换为你的管理员 API Token
+
+    public static void main(String[] args) {
+        try {
+            String owner = "your_owner"; // 替换为仓库拥有者的用户名
+            String repo = "test"; // 替换为仓库名称
+            String collaborator = "san.zhang002"; // 替换为被删除协作者的用户名
+
+            removeUserPermission(owner, repo, collaborator);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void removeUserPermission(String owner, String repo, String collaborator) throws Exception {
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpDelete request = new HttpDelete(GITEA_URL + "/api/v1/repos/" + owner + "/" + repo + "/collaborators/" + collaborator);
+            request.setHeader("Authorization", "token " + ADMIN_API_TOKEN);
+
+            try (CloseableHttpResponse response = httpClient.execute(request)) {
+                int responseCode = response.getStatusLine().getStatusCode();
+                if (responseCode == 204) { // HTTP No Content
+                    System.out.println("Permission removed successfully.");
+                } else {
+                    System.out.println("Failed to remove permission. Response code: " + responseCode);
+                }
+            }
+        }
+    }
+}

+ 72 - 0
springboot-poi-tl/pom.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>springboot-poi-tl</artifactId>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.6.RELEASE</version>
+    </parent>
+
+    <properties>
+        <swagger.version>2.7.0</swagger.version>
+    </properties>
+
+    <dependencies>
+        <!-- Spring Boot web依赖 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <!-- Knife4j Dependency -->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <version>2.0.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.vladsch.flexmark</groupId>
+            <artifactId>flexmark-all</artifactId>
+            <version>0.62.2</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>5.2.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>5.2.3</version>
+        </dependency>
+        <!-- poi-tl -->
+        <dependency>
+            <groupId>com.deepoove</groupId>
+            <artifactId>poi-tl</artifactId>
+            <version>1.12.0</version>
+        </dependency>
+        <!-- jsoup for HTML parsing (if needed) -->
+        <dependency>
+            <groupId>org.jsoup</groupId>
+            <artifactId>jsoup</artifactId>
+            <version>1.15.3</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 14 - 0
springboot-poi-tl/src/main/java/org/example/lc/PoitlApplication.java

@@ -0,0 +1,14 @@
+package org.example.lc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class PoitlApplication {
+    public static void main(String[] args) {
+
+        // 程序启动入口
+        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
+        SpringApplication.run(PoitlApplication.class, args);
+    }
+}

+ 31 - 0
springboot-poi-tl/src/main/java/org/example/lc/config/SwaggerConfig.java

@@ -0,0 +1,31 @@
+package org.example.lc.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
+                .apis(RequestHandlerSelectors.basePackage("org.example.lc")) //扫描API的包路径
+                .paths(PathSelectors.any()).build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder().title("SpringBoot整合Poi-tl") // 标题
+                .description("api接口的文档整理,支持在线测试") // 描述
+                .contact(new Contact("李辰", "", "lichen1986@aliyun.com"))
+                .version("1.0") // 版本号
+                .build();
+    }
+}

+ 25 - 0
springboot-poi-tl/src/main/java/org/example/lc/controller/HelloController.java

@@ -0,0 +1,25 @@
+package org.example.lc.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * Spring Boot Hello案例
+ *
+ * Created by bysocket on 26/09/2017.
+ */
+@Api(value = "HelloController", tags = {"hello 控制类"})
+@Controller
+public class HelloController {
+
+    @ApiOperation("打招呼")
+    @RequestMapping(value = "/hello",method = RequestMethod.GET)
+    @ResponseBody
+    public String sayHello() {
+        return "Hello,Spring Boot!";
+    }
+}

+ 87 - 0
springboot-poi-tl/src/test/java/org/example/lc/MarkdownToWordExample.java

@@ -0,0 +1,87 @@
+package org.example.lc;
+
+import com.deepoove.poi.XWPFTemplate;
+import com.deepoove.poi.data.DocxRenderData;
+import com.deepoove.poi.data.ParagraphRenderData;
+import com.deepoove.poi.data.TextRenderData;
+import com.vladsch.flexmark.html.HtmlRenderer;
+import com.vladsch.flexmark.parser.Parser;
+import com.vladsch.flexmark.util.data.MutableDataSet;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MarkdownToWordExample {
+
+    public static void main(String[] args) throws Exception {
+        // Markdown to HTML
+        String markdown = "# Hello World\nThis is **Markdown** content!";
+        MutableDataSet options = new MutableDataSet();
+        Parser parser = Parser.builder(options).build();
+        HtmlRenderer renderer = HtmlRenderer.builder(options).build();
+        String html = renderer.render(parser.parse(markdown));
+        System.out.println(html);
+
+
+        String filePath = "C:\\project\\git-repo\\springboot-demo\\springboot-poi-tl\\template.docx";
+
+
+//        // 使用 Jsoup 解析 HTML 并创建 poi-tl 数据
+//        org.jsoup.nodes.Document htmlDoc = Jsoup.parse(html);
+//        Elements elements = htmlDoc.body().children();
+//
+//        List<Object> contents = new ArrayList<>();
+//        for (Element element : elements) {
+//            switch (element.tagName()) {
+//                case "h1":
+//                case "h2":
+//                case "h3":
+//                case "h4":
+//                case "h5":
+//                case "h6":
+//                    contents.add(new ParagraphRenderData(
+//                            TextRenderData.builder()
+//                                    .text(element.text())
+//                                    .bold(true)
+//                                    .fontSize(24 - 2 * Integer.parseInt(element.tagName().substring(1)))
+//                                    .build()));
+//                    break;
+//                case "p":
+//                    contents.add(new ParagraphRenderData(TextRenderData.builder().text(element.text()).build()));
+//                    break;
+//                case "ul":
+//                case "ol":
+//                    for (Element li : element.children()) {
+//                        contents.add(new ParagraphRenderData(TextRenderData.builder().text("• " + li.text()).build()));
+//                    }
+//                    break;
+//                case "code":
+//                    contents.add(new ParagraphRenderData(new TextRenderData(element.text())));
+//                    break;
+//                // 添加其他 HTML 元素的处理
+//            }
+//        }
+//
+//        // 渲染到 Word 模板
+//        Map<String, Object> data = new HashMap<>();
+//        data.put("content", new DocxRenderData(contents));
+//
+//        XWPFTemplate template = XWPFTemplate.compile(filePath).render(data);
+//
+//        // 输出 Word 文件
+//        FileOutputStream out = new FileOutputStream("output.docx");
+//        template.write(out);
+//        out.close();
+//        template.close();
+//    }
+    }
+}