Yangyz 2 years ago
parent
commit
f67769b558

+ 1 - 1
Dockerfile

@@ -2,5 +2,5 @@ FROM openjdk:8-alpine
 MAINTAINER Yyz
 COPY ./target/dist /root/server
 WORKDIR /root/server/burialPoint
-ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","burialPoint-1.0-SNAPSHOT.jar"]
 

+ 1 - 0
README.md

@@ -0,0 +1 @@
+

+ 18 - 33
src/main/java/com/benyun/config/CorsConfig.java

@@ -1,6 +1,5 @@
 package com.benyun.config;
 
-import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.cors.CorsConfiguration;
@@ -8,37 +7,23 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 import org.springframework.web.filter.CorsFilter;
 
 /**
-  * 跨域前后端配置类
-  * 赵毅梵
-  * 2021/9/8
-  **/
+ * @author: Cheng
+ * @date: 2019/8/14 17:15
+ */
 @Configuration
-@Slf4j
 public class CorsConfig {
-  @Bean
-  public CorsFilter corsFilter() {
-    // 1.添加CORS配置信息
-    CorsConfiguration config = new CorsConfiguration();
-    // 放行哪些原始域
-    config.addAllowedOrigin("*");
-    // 是否发送Cookie信息
-    config.setAllowCredentials(true);
-    // 放行哪些原始域(请求方式)
-    config.addAllowedMethod("*");
-    // 放行哪些原始域(头部信息)
-    config.addAllowedHeader("*");
-    // 暴露哪些头部信息(因为跨域访问默认不能获取全部头部信息)
-    // config.addExposedHeader("*");
-    config.addExposedHeader("Content-Type");
-    config.addExposedHeader( "X-Requested-With");
-    config.addExposedHeader("accept");
-    config.addExposedHeader("Origin");
-    config.addExposedHeader( "Access-Control-Request-Method");
-    config.addExposedHeader("Access-Control-Request-Headers");
-    // 2.添加映射路径
-    UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
-    configSource.registerCorsConfiguration("/**", config);
-    // 3.返回新的CorsFilter.
-    return new CorsFilter(configSource);
-  }
-}
+
+    @Bean
+    public CorsFilter corsFilter() {
+        final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        final CorsConfiguration config = new CorsConfiguration();
+        config.setAllowCredentials(true); // 允许cookies跨域
+        config.addAllowedOriginPattern("*");// #允许向该服务器提交请求的URI,*表示全部允许,在SpringMVC中,如果设成*,会自动转成当前请求头中的Origin
+        config.addAllowedHeader("*");// #允许访问的头信息,*表示全部
+        config.setMaxAge(18000L);// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
+        config.addAllowedMethod("*");// 允许提交请求的方法,*表示全部允许
+        source.registerCorsConfiguration("/**", config);
+
+        return new CorsFilter(source);
+    }
+}

+ 12 - 1
src/main/java/com/benyun/controller/ApplyController.java

@@ -19,7 +19,6 @@ import java.util.List;
 @RestController
 @RequestMapping("apply")
 @RequiredArgsConstructor(onConstructor_ = {@Autowired})
-@CrossOrigin
 public class ApplyController {
     /**
      * 服务对象
@@ -114,4 +113,16 @@ public class ApplyController {
     public Result<ApplyEventVo> queryApplyEventByUUId(@RequestParam("uuid") String uuid) {
         return Result.success(applyService.queryApplyEventByUUId(uuid));
     }
+
+    /**
+     * 复制事件
+     * @param target 目标应用
+     * @param from 拷贝应用
+     * @return
+     */
+    @PostMapping("/copyFrom")
+    public Result copyFrom(String target,String from){
+        applyService.copyFrom(target,from);
+        return Result.success();
+    }
 }

+ 0 - 1
src/main/java/com/benyun/controller/EventController.java

@@ -20,7 +20,6 @@ import java.util.List;
 @RestController
 @RequestMapping("event")
 @RequiredArgsConstructor(onConstructor_ = {@Autowired})
-@CrossOrigin
 public class EventController {
     /**
      * 服务对象

+ 0 - 1
src/main/java/com/benyun/controller/EventLogController.java

@@ -24,7 +24,6 @@ import java.util.Map;
 @RestController
 @RequestMapping("eventLog")
 @RequiredArgsConstructor(onConstructor_ = {@Autowired})
-@CrossOrigin
 public class EventLogController {
     /**
      * 服务对象

+ 0 - 1
src/main/java/com/benyun/controller/UserController.java

@@ -18,7 +18,6 @@ import java.util.List;
 @RestController
 @RequestMapping("user")
 @RequiredArgsConstructor(onConstructor_ = {@Autowired})
-@CrossOrigin
 public class UserController {
     /**
      * 服务对象

+ 2 - 2
src/main/java/com/benyun/entity/Event.java

@@ -3,6 +3,7 @@ package com.benyun.entity;
 
 import lombok.*;
 import org.beetl.sql.core.TailBean;
+import org.beetl.sql.core.annotatoin.AssignID;
 import org.beetl.sql.core.annotatoin.Table;
 import org.beetl.sql.core.annotatoin.AutoID;
 import java.math.BigDecimal;
@@ -25,12 +26,11 @@ public class Event extends TailBean {
     /**
      * 事件ID
      */
-    @AutoID
+    @AssignID
     private String id;
     /**
      * 应用ID
      */
-    @AutoID
     private String applyId;
     /**
      * 事件名称

+ 5 - 2
src/main/java/com/benyun/service/ApplyService.java

@@ -29,7 +29,7 @@ public interface ApplyService {
      * @return 成功返回true,失败返回false
      */
     boolean updateById(Apply apply);
-    
+
     /**
      * 根据主键删除记录
      *
@@ -37,7 +37,7 @@ public interface ApplyService {
      * @return 成功返回true,反之返回false
      */
     boolean deleteById(String id);
-    
+
     /**
      * 分页查询
      * @param pageQuery 封装分页条件的分页对象
@@ -49,4 +49,7 @@ public interface ApplyService {
     ApplyEventVo queryApplyEventByUUId(String uuid);
 
     List<Apply> queryList(String applyName);
+
+    void copyFrom(String target, String from);
+
 }

+ 20 - 0
src/main/java/com/benyun/service/impl/ApplyServiceImpl.java

@@ -4,7 +4,9 @@ package com.benyun.service.impl;
 import cn.hutool.core.util.StrUtil;
 import com.benyun.boot.core.vo.Result;
 import com.benyun.dao.ApplyDao;
+import com.benyun.dao.EventDao;
 import com.benyun.entity.Apply;
+import com.benyun.entity.Event;
 import com.benyun.service.ApplyService;
 import com.benyun.vo.ApplyEventVo;
 import lombok.RequiredArgsConstructor;
@@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
@@ -27,6 +30,7 @@ import java.util.UUID;
 public class ApplyServiceImpl implements ApplyService {
 
     private final ApplyDao applyDao;
+    private final EventDao eventDao;
 
     @Override
     public Apply queryById(String id) {
@@ -43,6 +47,22 @@ public class ApplyServiceImpl implements ApplyService {
         return applyDao.createLambdaQuery().andLike(Apply::getApplyName, "%" + (StrUtil.isNotBlank(applyName)? applyName: "") + "%").select();
     }
 
+    @Override
+    public void copyFrom(String target, String from) {
+        List<Event> select = eventDao.createLambdaQuery()
+                .andEq(Event::getApplyId, from)
+                .select();
+
+        ArrayList<Event> list = new ArrayList<>();
+        for (Event event : select) {
+            event.setId(target+"@"+event.getEventCode());
+            event.setApplyId(target);
+            list.add(event);
+        }
+        eventDao.insertBatch(list);
+
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void insert(Apply apply) {

+ 1 - 1
src/main/resources/sql/EventLog.md

@@ -46,4 +46,4 @@ and a.apply_name like #applyName#
 @if(!isEmpty(eventName)){
 and e.event_name like #eventName#
 @}
-ORDER BY el.id decs
+ORDER BY el.id desc