1
1
package org .lowcoder .api .application ;
2
2
3
+ import io .sentry .protocol .App ;
3
4
import lombok .RequiredArgsConstructor ;
4
5
import org .lowcoder .api .application .view .*;
5
6
import org .lowcoder .api .framework .view .PageResponseView ;
13
14
import org .lowcoder .domain .application .model .ApplicationRequestType ;
14
15
import org .lowcoder .domain .application .model .ApplicationStatus ;
15
16
import org .lowcoder .domain .application .model .ApplicationType ;
17
+ import org .lowcoder .domain .application .service .ApplicationRecordService ;
16
18
import org .lowcoder .domain .folder .service .FolderElementRelationService ;
17
19
import org .lowcoder .domain .permission .model .ResourceRole ;
18
20
import org .springframework .web .bind .annotation .PathVariable ;
22
24
import reactor .core .publisher .Mono ;
23
25
24
26
import java .util .List ;
27
+ import java .util .Objects ;
25
28
26
29
import static org .apache .commons .collections4 .SetUtils .emptyIfNull ;
27
30
import static org .lowcoder .plugin .api .event .LowcoderEvent .EventType .*;
@@ -38,6 +41,7 @@ public class ApplicationController implements ApplicationEndpoints {
38
41
private final SessionUserService sessionUserService ;
39
42
private final GidService gidService ;
40
43
private final FolderElementRelationService folderElementRelationService ;
44
+ private final ApplicationRecordService applicationRecordService ;
41
45
42
46
@ Override
43
47
public Mono <ResponseView <ApplicationView >> create (@ RequestBody CreateApplicationRequest createApplicationRequest ) {
@@ -130,9 +134,27 @@ public Mono<ResponseView<ApplicationView>> update(@PathVariable String applicati
130
134
131
135
@ Override
132
136
public Mono <ResponseView <ApplicationView >> publish (@ PathVariable String applicationId ,
133
- @ RequestBody ApplicationPublishRequest applicationPublishRequest ) {
137
+ @ RequestBody ( required = false ) ApplicationPublishRequest applicationPublishRequest ) {
134
138
return gidService .convertApplicationIdToObjectId (applicationId ).flatMap (appId ->
135
- applicationApiService .publish (appId , applicationPublishRequest )
139
+ applicationRecordService .getLatestRecordByApplicationId (applicationId )
140
+ .map (applicationRecord -> {
141
+ String tag = applicationRecord .getTag (); // Assuming format is 1.0.0
142
+ String newtag = "1.0.0" ;
143
+
144
+ if (tag != null && tag .matches ("\\ d+\\ .\\ d+\\ .\\ d+" )) { // Validate tag format
145
+ String [] parts = tag .split ("\\ ." ); // Split by "."
146
+ int major = Integer .parseInt (parts [0 ]);
147
+ int minor = Integer .parseInt (parts [1 ]);
148
+ int patch = Integer .parseInt (parts [2 ]);
149
+
150
+ patch ++; // Increment the patch version
151
+ newtag = String .format ("%d.%d.%d" , major , minor , patch );
152
+ }
153
+
154
+ return newtag ;
155
+ })
156
+ .switchIfEmpty (Mono .just ("1.0.0" ))
157
+ .flatMap (newtag -> applicationApiService .publish (appId , Objects .requireNonNullElse (applicationPublishRequest , new ApplicationPublishRequest ("" , newtag ))))
136
158
.map (ResponseView ::success ));
137
159
}
138
160
0 commit comments