forked from alibaba/SREWorks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: appmanager add global version api
- Loading branch information
Showing
9 changed files
with
91 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...anager-domain/src/main/java/com/alibaba/tesla/appmanager/domain/req/VersionCreateReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.alibaba.tesla.appmanager.domain.req; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class VersionCreateReq { | ||
|
||
private String version; | ||
|
||
private String versionLabel; | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...erver/src/main/java/com/alibaba/tesla/appmanager/server/controller/VersionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.alibaba.tesla.appmanager.server.controller; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.alibaba.tesla.appmanager.api.provider.AppVersionProvider; | ||
import com.alibaba.tesla.appmanager.auth.controller.AppManagerBaseController; | ||
import com.alibaba.tesla.appmanager.domain.dto.AppVersionDTO; | ||
import com.alibaba.tesla.appmanager.domain.req.appversion.AppVersionCreateReq; | ||
import com.alibaba.tesla.common.base.TeslaBaseResult; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.oauth2.provider.OAuth2Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* 版本 Controller | ||
* | ||
* @author qianmo.zm@alibaba-inc.com | ||
*/ | ||
@Tag(name = "版本 API") | ||
@RequestMapping("/versions") | ||
@RestController | ||
@Slf4j | ||
public class VersionController extends AppManagerBaseController { | ||
|
||
@Autowired | ||
private AppVersionProvider appVersionProvider; | ||
|
||
@Operation(summary = "创建全局版本") | ||
@PostMapping | ||
public TeslaBaseResult create( | ||
@RequestBody AppVersionCreateReq request, | ||
@RequestHeader(value = "X-EmpId", required = false) String empId, | ||
OAuth2Authentication auth) { | ||
String operator = getOperator(auth, empId); | ||
|
||
AppVersionDTO version = appVersionProvider.get("", request.getVersion()); | ||
if(version == null) { | ||
AppVersionCreateReq createReq = AppVersionCreateReq.builder() | ||
.appId("") | ||
.version(request.getVersion()) | ||
.versionLabel(request.getVersionLabel()) | ||
.versionProperties(new JSONObject()) | ||
.build(); | ||
AppVersionDTO result = appVersionProvider.create(createReq, operator); | ||
return buildSucceedResult(result); | ||
} else { | ||
return buildSucceedResult(version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters