forked from xhgit/webup-cloud
Show the current hosting publication requirements
This commit is contained in:
1 parent
1f25bbd1f9
commit
ffb36e3e24
4 files changed
+96
-15
No files matched your search
@@ -142,6 +142,12 @@ public class HostingController {
|
||||
return hosting.subscription(who.id(), project);
|
||||
}
|
||||
|
||||
@GetMapping("/projects/{project}/publication-status")
|
||||
public Object publicationStatus(
|
||||
@AuthenticationPrincipal SecurityConfig.Identity who, @PathVariable UUID project) {
|
||||
return hosting.publicationStatus(who.id(), project);
|
||||
}
|
||||
|
||||
@GetMapping("/projects/{project}/services")
|
||||
public Object services(
|
||||
@AuthenticationPrincipal SecurityConfig.Identity who, @PathVariable UUID project) {
|
||||
|
||||
@@ -114,6 +114,15 @@ public class HostingService {
|
||||
return list.isEmpty() ? Map.of("status", "NONE") : list.getFirst();
|
||||
}
|
||||
|
||||
public Map<String, Object> publicationStatus(UUID user, UUID project) {
|
||||
var row = own(user, project);
|
||||
return Map.of(
|
||||
"reviewStatus",
|
||||
operations.reviewStatus(project),
|
||||
"archived",
|
||||
"ARCHIVED".equals(row.get("status")));
|
||||
}
|
||||
|
||||
void checkQuota(UUID project, Map<String, Object> plan) {
|
||||
var sums =
|
||||
db.queryForMap(
|
||||
|
||||
@@ -92,9 +92,19 @@ public class RuntimeOperationService {
|
||||
lease);
|
||||
}
|
||||
|
||||
public void checkAllowed(UUID project) {
|
||||
public String reviewStatus(UUID project) {
|
||||
var list = db.queryForList("SELECT status FROM project_moderation WHERE project_id=?", project);
|
||||
if (list.isEmpty() || !"APPROVED".equals(list.getFirst().get("status")))
|
||||
throw new ApiError.Failure(403, "网站未审核通过或已被封禁,不能执行运行操作");
|
||||
return list.isEmpty() ? "PENDING" : list.getFirst().get("status").toString();
|
||||
}
|
||||
|
||||
public void checkAllowed(UUID project) {
|
||||
String message =
|
||||
switch (reviewStatus(project)) {
|
||||
case "APPROVED" -> null;
|
||||
case "REJECTED" -> "网站审核未通过,请联系管理员核对";
|
||||
case "BANNED" -> "网站已被封禁,请联系管理员";
|
||||
default -> "网站正在等待管理员审核,通过后才能发布";
|
||||
};
|
||||
if (message != null) throw new ApiError.Failure(403, message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user