11package org .lowcoder .api .application ;
22
3+ import io .sentry .protocol .App ;
34import lombok .RequiredArgsConstructor ;
45import org .lowcoder .api .application .view .*;
56import org .lowcoder .api .framework .view .PageResponseView ;
1314import org .lowcoder .domain .application .model .ApplicationRequestType ;
1415import org .lowcoder .domain .application .model .ApplicationStatus ;
1516import org .lowcoder .domain .application .model .ApplicationType ;
17+ import org .lowcoder .domain .application .service .ApplicationRecordService ;
1618import org .lowcoder .domain .folder .service .FolderElementRelationService ;
1719import org .lowcoder .domain .permission .model .ResourceRole ;
1820import org .springframework .web .bind .annotation .PathVariable ;
2224import reactor .core .publisher .Mono ;
2325
2426import java .util .List ;
27+ import java .util .Objects ;
2528
2629import static org .apache .commons .collections4 .SetUtils .emptyIfNull ;
2730import static org .lowcoder .plugin .api .event .LowcoderEvent .EventType .*;
@@ -38,6 +41,7 @@ public class ApplicationController implements ApplicationEndpoints {
3841 private final SessionUserService sessionUserService ;
3942 private final GidService gidService ;
4043 private final FolderElementRelationService folderElementRelationService ;
44+ private final ApplicationRecordService applicationRecordService ;
4145
4246 @ Override
4347 public Mono <ResponseView <ApplicationView >> create (@ RequestBody CreateApplicationRequest createApplicationRequest ) {
@@ -130,9 +134,27 @@ public Mono<ResponseView<ApplicationView>> update(@PathVariable String applicati
130134
131135 @ Override
132136 public Mono <ResponseView <ApplicationView >> publish (@ PathVariable String applicationId ,
133- @ RequestBody ApplicationPublishRequest applicationPublishRequest ) {
137+ @ RequestBody ( required = false ) ApplicationPublishRequest applicationPublishRequest ) {
134138 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 ))))
136158 .map (ResponseView ::success ));
137159 }
138160
0 commit comments