Browse Source

fix:增加部分接口

liaoyitao 1 month ago
parent
commit
6800894f41

+ 4 - 4
pom.xml

@@ -9,10 +9,10 @@
9 9
         <relativePath/> <!-- lookup parent from repository -->
10 10
     </parent>
11 11
     <groupId>com.lqkj</groupId>
12
-    <artifactId>CMLCP-SERVER</artifactId>
13
-    <version>0.0.1-SNAPSHOT</version>
14
-    <name>CMLCP-SERVER</name>
15
-    <description>CMLCP-SERVER</description>
12
+    <artifactId>cmlcp</artifactId>
13
+    <version>1.0.0.${timestamp}</version>
14
+    <name>cmlcp</name>
15
+    <description>IOC低代码平台</description>
16 16
     <url/>
17 17
     <licenses>
18 18
         <license/>

+ 19 - 19
src/main/java/com/lqkj/cmlcp/config/WebConfig.java

@@ -1,19 +1,19 @@
1
-package com.lqkj.cmlcp.config;
2
-
3
-import com.lqkj.cmlcp.filter.RequestUrlLoggingFilter;
4
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
5
-import org.springframework.context.annotation.Bean;
6
-import org.springframework.context.annotation.Configuration;
7
- 
8
-@Configuration
9
-public class WebConfig {
10
- 
11
-    @Bean
12
-    public FilterRegistrationBean<RequestUrlLoggingFilter> loggingFilter() {
13
-        FilterRegistrationBean<RequestUrlLoggingFilter> registrationBean = new FilterRegistrationBean<>();
14
-        registrationBean.setFilter(new RequestUrlLoggingFilter());
15
-        registrationBean.addUrlPatterns("/*");
16
-        registrationBean.setOrder(1);
17
-        return registrationBean;
18
-    }
19
-}
1
+//package com.lqkj.cmlcp.config;
2
+//
3
+//import com.lqkj.cmlcp.filter.RequestUrlLoggingFilter;
4
+//import org.springframework.boot.web.servlet.FilterRegistrationBean;
5
+//import org.springframework.context.annotation.Bean;
6
+//import org.springframework.context.annotation.Configuration;
7
+//
8
+//@Configuration
9
+//public class WebConfig {
10
+//
11
+//    @Bean
12
+//    public FilterRegistrationBean<RequestUrlLoggingFilter> loggingFilter() {
13
+//        FilterRegistrationBean<RequestUrlLoggingFilter> registrationBean = new FilterRegistrationBean<>();
14
+//        registrationBean.setFilter(new RequestUrlLoggingFilter());
15
+//        registrationBean.addUrlPatterns("/*");
16
+//        registrationBean.setOrder(1);
17
+//        return registrationBean;
18
+//    }
19
+//}

+ 57 - 0
src/main/java/com/lqkj/cmlcp/config/WebMvcConfig.java

@@ -0,0 +1,57 @@
1
+package com.lqkj.cmlcp.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.http.CacheControl;
6
+import org.springframework.web.cors.CorsConfiguration;
7
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
8
+import org.springframework.web.filter.CorsFilter;
9
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
10
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
11
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
12
+import org.springframework.web.servlet.mvc.WebContentInterceptor;
13
+
14
+import java.util.List;
15
+import java.util.concurrent.TimeUnit;
16
+
17
+@Configuration
18
+public class WebMvcConfig implements WebMvcConfigurer {
19
+
20
+    /**
21
+     * 静态资源配置
22
+     */
23
+    @Override
24
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
25
+        registry.addResourceHandler("/upload/**")
26
+                .addResourceLocations("file:./upload/")
27
+                .setCacheControl(CacheControl.maxAge(0, TimeUnit.SECONDS));
28
+    }
29
+
30
+    /**
31
+     * 跨域配置
32
+     */
33
+    @Bean
34
+    public CorsFilter corsFilter() {
35
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
36
+        corsConfiguration.setAllowCredentials(true);
37
+        corsConfiguration.addAllowedOriginPattern("*");
38
+        corsConfiguration.setAllowedHeaders(List.of("accept", "authorization", "content-type", "cache-control"));
39
+        corsConfiguration.setAllowedMethods(List.of("POST", "GET", "PUT", "OPTIONS", "DELETE"));
40
+        UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
41
+        urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
42
+        return new CorsFilter(urlBasedCorsConfigurationSource);
43
+    }
44
+
45
+    @Override
46
+    public void addInterceptors(InterceptorRegistry registry) {
47
+        WebContentInterceptor contentInterceptor = new WebContentInterceptor();
48
+        contentInterceptor.setCacheSeconds(0);
49
+        contentInterceptor.setUseExpiresHeader(true);
50
+        contentInterceptor.setUseCacheControlNoStore(false);
51
+        contentInterceptor.setUseCacheControlHeader(true);
52
+        contentInterceptor.setUseCacheControlNoStore(false);
53
+        registry.addInterceptor(contentInterceptor);
54
+    }
55
+
56
+
57
+}

+ 6 - 1
src/main/java/com/lqkj/cmlcp/module/api/controller/ApiInfoController.java

@@ -27,7 +27,7 @@ public class ApiInfoController {
27 27
 
28 28
     @GetMapping("/getAll")
29 29
     public Result getConfig(@RequestParam(required = false, defaultValue = "") String name,
30
-                            @RequestParam(required = true) Integer type) {
30
+                            @RequestParam() Integer type) {
31 31
         return Result.ok(apiInfoService.findAll(name, type));
32 32
     }
33 33
 
@@ -37,4 +37,9 @@ public class ApiInfoController {
37 37
         return Result.ok();
38 38
     }
39 39
 
40
+    @GetMapping("/getApi")
41
+    public Result getApi(@RequestParam Integer id) {
42
+        return Result.ok(apiInfoService.findById(id));
43
+    }
44
+
40 45
 }

+ 1 - 0
src/main/java/com/lqkj/cmlcp/module/api/service/ApiInfoService.java

@@ -12,4 +12,5 @@ public interface ApiInfoService {
12 12
 
13 13
     void delete(List<Integer> ids);
14 14
 
15
+    ApiInfo findById(Integer id);
15 16
 }

+ 5 - 0
src/main/java/com/lqkj/cmlcp/module/api/service/impl/ApiInfoServiceImpl.java

@@ -32,4 +32,9 @@ public class ApiInfoServiceImpl implements ApiInfoService {
32 32
     public void delete(List<Integer> ids) {
33 33
         apiInfoRepository.deleteAllById(ids);
34 34
     }
35
+
36
+    @Override
37
+    public ApiInfo findById(Integer id) {
38
+        return apiInfoRepository.findById(id).get();
39
+    }
35 40
 }

+ 22 - 0
src/main/java/com/lqkj/cmlcp/module/zone/controller/ProjectInfoController.java

@@ -40,4 +40,26 @@ public class ProjectInfoController {
40 40
         projectInfoService.delete(ids);
41 41
         return Result.ok();
42 42
     }
43
+
44
+    /**
45
+     * 获取回收站列表
46
+     * @param name
47
+     * @return
48
+     */
49
+    @PostMapping("/getRBList")
50
+    public Result getRBList(@RequestParam(required = false) String name){
51
+        return Result.ok(projectInfoService.getRBList(name));
52
+    }
53
+
54
+    /**
55
+     * 恢复
56
+     * @param ids
57
+     * @return
58
+     */
59
+    @PostMapping("/restore")
60
+    public Result restore(@RequestBody List<Integer> ids){
61
+        projectInfoService.restoxre(ids);
62
+        return Result.ok();
63
+    }
64
+
43 65
 }

+ 10 - 0
src/main/java/com/lqkj/cmlcp/module/zone/controller/ZoneInfoController.java

@@ -49,4 +49,14 @@ public class ZoneInfoController {
49 49
     public Result getList(@RequestParam Integer projectId) {
50 50
         return Result.ok(zoneInfoService.getList(projectId));
51 51
     }
52
+
53
+    /**
54
+     * 根据id获取态势/作品
55
+     * @param id
56
+     * @return
57
+     */
58
+    @PostMapping("/getZone")
59
+    public Result getZone(@RequestParam Integer id) {
60
+        return Result.ok(zoneInfoService.findById(id));
61
+    }
52 62
 }

+ 23 - 1
src/main/java/com/lqkj/cmlcp/module/zone/repository/ProjectInfoRepository.java

@@ -4,17 +4,39 @@ import com.lqkj.cmlcp.module.zone.domain.ProjectInfo;
4 4
 import org.springframework.data.domain.Page;
5 5
 import org.springframework.data.domain.PageRequest;
6 6
 import org.springframework.data.jpa.repository.JpaRepository;
7
+import org.springframework.data.jpa.repository.Modifying;
7 8
 import org.springframework.data.jpa.repository.Query;
8 9
 import org.springframework.data.repository.query.Param;
9 10
 import org.springframework.stereotype.Component;
10 11
 
12
+import java.util.List;
13
+
11 14
 @Component
12 15
 public interface ProjectInfoRepository extends JpaRepository<ProjectInfo, Integer> {
13 16
 
14 17
     @Query(nativeQuery = true,
15 18
             value = "select * from project_info t where t.is_delete = false " +
16
-                    "and (:projectName = '' or project_name like concat('%', :projectName, '%'))")
19
+                    "and (:projectName = '' or project_name like concat('%', :projectName, '%')) order by update_time DESC ")
17 20
     Page<ProjectInfo> pageQuery(@Param("projectName") String projectName, PageRequest pageRequest);
18 21
 
19 22
     ProjectInfo findByProjectName(String projectName);
23
+
24
+    /**
25
+     * 获取回收站列表
26
+     * @param projectName
27
+     * @return
28
+     */
29
+    @Query(nativeQuery = true,
30
+            value = "select * from project_info t where t.is_delete = true " +
31
+                    "and (:projectName = '' or project_name like concat('%', :projectName, '%'))")
32
+    List<ProjectInfo> getRBList(@Param("projectName") String projectName);
33
+
34
+    /**
35
+     * 恢复项目
36
+     * @param ids
37
+     */
38
+    @Modifying
39
+    @Query(nativeQuery = true,
40
+            value = "update project_info set is_delete = false where id in :ids")
41
+    void restoxre(@Param("ids") List<Integer> ids);
20 42
 }

+ 2 - 2
src/main/java/com/lqkj/cmlcp/module/zone/repository/ZoneInfoRepository.java

@@ -14,8 +14,8 @@ public interface ZoneInfoRepository extends JpaRepository<ZoneInfo, Integer> {
14 14
 
15 15
     @Query(nativeQuery = true,
16 16
             value = "select * from zone_info t where t.is_delete = false " +
17
-            "and (:name = '' or zone_name like concat('%', :name, '%'))")
17
+            "and (:name = '' or zone_name like concat('%', :name, '%')) order by update_time DESC ")
18 18
     Page<ZoneInfo> pageQuery(@Param("name") String name, PageRequest pageRequest);
19 19
 
20
-    ZoneInfo findByZoneName(String zoneName);
20
+    ZoneInfo findByZoneNameAndProjectId(String zoneName, Integer projectId);
21 21
 }

+ 13 - 0
src/main/java/com/lqkj/cmlcp/module/zone/service/ProjectInfoService.java

@@ -11,4 +11,17 @@ public interface ProjectInfoService {
11 11
     void save(ProjectInfo projectInfo);
12 12
 
13 13
     void delete(List<Integer> ids);
14
+
15
+    /**
16
+     * 获取回收站列表
17
+     * @param name
18
+     * @return
19
+     */
20
+    List<ProjectInfo> getRBList(String name);
21
+
22
+    /**
23
+     * 恢复项目
24
+     * @param ids
25
+     */
26
+    void restoxre(List<Integer> ids);
14 27
 }

+ 7 - 0
src/main/java/com/lqkj/cmlcp/module/zone/service/ZoneInfoService.java

@@ -18,4 +18,11 @@ public interface ZoneInfoService{
18 18
      * @return
19 19
      */
20 20
     List<ZoneInfo> getList(Integer projectId);
21
+
22
+    /**
23
+     * 根据id获取作品信息
24
+     * @param id
25
+     * @return
26
+     */
27
+    ZoneInfo findById(Integer id);
21 28
 }

+ 12 - 0
src/main/java/com/lqkj/cmlcp/module/zone/service/impl/ProjectInfoServiceImpl.java

@@ -33,6 +33,7 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
33 33
         if (Objects.nonNull(projectInfo.getId()) && !projectInfo.getId().equals(oldProject.getId())) throw new RuntimeException("项目名称已存在");
34 34
         if (Objects.isNull(projectInfo.getId()) && Objects.nonNull(oldProject)) throw new RuntimeException("项目名称已存在");
35 35
         if (Objects.isNull(projectInfo.getId())) projectInfo.setCreateTime(new Date());
36
+        if (Objects.nonNull(projectInfo.getId())) projectInfo.setCreateTime(projectInfoRepository.findById(projectInfo.getId()).get().getCreateTime());
36 37
         projectInfo.setIsDelete(false);
37 38
         projectInfo.setUpdateTime(new Date());
38 39
         projectInfoRepository.save(projectInfo);
@@ -42,4 +43,15 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
42 43
     public void delete(List<Integer> ids) {
43 44
         projectInfoRepository.deleteAllById(ids);
44 45
     }
46
+
47
+    @Override
48
+    public List<ProjectInfo> getRBList(String name) {
49
+        return projectInfoRepository.getRBList(name);
50
+    }
51
+
52
+    @Transactional
53
+    @Override
54
+    public void restoxre(List<Integer> ids) {
55
+        projectInfoRepository.restoxre(ids);
56
+    }
45 57
 }

+ 9 - 2
src/main/java/com/lqkj/cmlcp/module/zone/service/impl/ZoneInfoServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
9 9
 import org.springframework.data.domain.Example;
10 10
 import org.springframework.data.domain.Page;
11 11
 import org.springframework.data.domain.PageRequest;
12
+import org.springframework.data.domain.Sort;
12 13
 import org.springframework.stereotype.Service;
13 14
 import org.springframework.transaction.annotation.Propagation;
14 15
 import org.springframework.transaction.annotation.Transactional;
@@ -29,11 +30,12 @@ public class ZoneInfoServiceImpl implements ZoneInfoService {
29 30
 
30 31
     @Override
31 32
     public void save(ZoneInfo zoneInfo) {
32
-        ZoneInfo oldzone = zoneInfoRepository.findByZoneName(zoneInfo.getZoneName());
33
+        ZoneInfo oldzone = zoneInfoRepository.findByZoneNameAndProjectId(zoneInfo.getZoneName(), zoneInfo.getProjectId());
33 34
         if (Objects.nonNull(zoneInfo.getId()) && Objects.nonNull(oldzone)
34 35
                 && !oldzone.getId().equals(zoneInfo.getId())) throw new RuntimeException("作品名称已存在");
35 36
         if (Objects.isNull(zoneInfo.getId()) && Objects.nonNull(oldzone)) throw new RuntimeException("作品名称已存在");
36 37
         if (Objects.isNull(zoneInfo.getId())) zoneInfo.setCreateTime(new Date());
38
+        if (Objects.nonNull(zoneInfo.getId())) zoneInfo.setCreateTime(zoneInfoRepository.findById(zoneInfo.getId()).get().getCreateTime());
37 39
         zoneInfo.setIsDelete(false);
38 40
         zoneInfo.setUpdateTime(new Date());
39 41
         zoneInfoRepository.save(zoneInfo);
@@ -52,7 +54,12 @@ public class ZoneInfoServiceImpl implements ZoneInfoService {
52 54
 
53 55
     @Override
54 56
     public List<ZoneInfo> getList(Integer projectId) {
55
-        return zoneInfoRepository.findAll(Example.of(new ZoneInfo(projectId)));
57
+        return zoneInfoRepository.findAll(Example.of(new ZoneInfo(projectId)), Sort.by(Sort.Order.desc("updateTime")));
58
+    }
59
+
60
+    @Override
61
+    public ZoneInfo findById(Integer id) {
62
+        return zoneInfoRepository.findById(id).orElse(null);
56 63
     }
57 64
 
58 65
 }