-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
524 additions
and
350 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package com.faforever.api.clan.result; | ||
|
||
import com.faforever.api.data.domain.Clan; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class ClanResult { | ||
private final int id; | ||
private final Integer id; | ||
private final String tag; | ||
private final String name; | ||
|
||
public static ClanResult of(Clan clan) { | ||
return new ClanResult(clan.getId(), clan.getTag(), clan.getName()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/faforever/api/clan/result/InvitationResult.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,14 @@ | ||
package com.faforever.api.clan.result; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class InvitationResult { | ||
private final long expire; | ||
private final ClanResult clan; | ||
private final PlayerResult newMember; | ||
|
||
public boolean isExpired() { | ||
return expire < System.currentTimeMillis(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/faforever/api/clan/result/PlayerResult.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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package com.faforever.api.clan.result; | ||
|
||
import com.faforever.api.data.domain.Player; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class PlayerResult { | ||
private final int id; | ||
private final String login; | ||
|
||
public static PlayerResult of(Player newMember) { | ||
return new PlayerResult(newMember.getId(), newMember.getLogin()); | ||
} | ||
} |
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,25 @@ | ||
package com.faforever.api.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
@EnableWebMvc | ||
@Configuration | ||
public class MvcConfig extends WebMvcConfigurerAdapter { | ||
|
||
@Override | ||
public void addViewControllers(ViewControllerRegistry registry) { | ||
registry.addViewController("/login").setViewName("login"); | ||
registry.setOrder(Ordered.HIGHEST_PRECEDENCE); | ||
} | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | ||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/faforever/api/config/elide/ElideSwaggerController.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,47 @@ | ||
package com.faforever.api.config.elide; | ||
|
||
import com.faforever.api.data.DataController; | ||
import com.yahoo.elide.contrib.swagger.SwaggerBuilder; | ||
import com.yahoo.elide.core.EntityDictionary; | ||
import io.swagger.models.Info; | ||
import io.swagger.models.Swagger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import springfox.documentation.annotations.ApiIgnore; | ||
import springfox.documentation.spring.web.json.Json; | ||
import springfox.documentation.spring.web.json.JsonSerializer; | ||
|
||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | ||
|
||
@Controller | ||
public class ElideSwaggerController { | ||
|
||
private JsonSerializer jsonSerializer; | ||
private EntityDictionary entityDictionary; | ||
|
||
@Autowired | ||
public ElideSwaggerController(JsonSerializer jsonSerializer, EntityDictionary entityDictionary) { | ||
this.jsonSerializer = jsonSerializer; | ||
this.entityDictionary = entityDictionary; | ||
} | ||
|
||
@ApiIgnore | ||
@RequestMapping(value = "/elide/docs", | ||
method = RequestMethod.GET, produces = {APPLICATION_JSON_VALUE}) | ||
public | ||
@ResponseBody | ||
ResponseEntity<Json> getDocumentation() { | ||
Info info = new Info().title("Elide JSON API").version("1.0"); | ||
SwaggerBuilder builder = new SwaggerBuilder(entityDictionary, info); | ||
Swagger document = builder.build() | ||
.basePath(DataController.PATH_PREFIX); | ||
|
||
return new ResponseEntity<Json>(jsonSerializer.toJson(document), HttpStatus.OK); | ||
} | ||
|
||
} |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/faforever/api/config/swagger/ElideSwaggerResourceProvider.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,29 @@ | ||
package com.faforever.api.config.swagger; | ||
|
||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.stereotype.Component; | ||
import springfox.documentation.spring.web.DocumentationCache; | ||
import springfox.documentation.swagger.web.InMemorySwaggerResourcesProvider; | ||
import springfox.documentation.swagger.web.SwaggerResource; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@Primary | ||
public class ElideSwaggerResourceProvider extends InMemorySwaggerResourcesProvider { | ||
public ElideSwaggerResourceProvider(DocumentationCache documentationCache) { | ||
super(documentationCache); | ||
} | ||
|
||
@Override | ||
public List<SwaggerResource> get() { | ||
final List<SwaggerResource> swaggerResources = super.get(); | ||
|
||
SwaggerResource swaggerResource = new SwaggerResource(); | ||
swaggerResource.setName("data"); | ||
swaggerResource.setLocation("/elide/docs"); | ||
swaggerResource.setSwaggerVersion("2.0"); | ||
swaggerResources.add(swaggerResource); | ||
return swaggerResources; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/faforever/api/data/domain/AbstractEntity.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,35 @@ | ||
package com.faforever.api.data.domain; | ||
|
||
import lombok.Setter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.MappedSuperclass; | ||
import java.time.OffsetDateTime; | ||
|
||
@MappedSuperclass | ||
@Setter | ||
public abstract class AbstractEntity { | ||
private Integer id; | ||
private OffsetDateTime createTime; | ||
private OffsetDateTime updateTime; | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
@Column(name = "create_time") | ||
public OffsetDateTime getCreateTime() { | ||
return createTime; | ||
} | ||
|
||
@Column(name = "update_time") | ||
public OffsetDateTime getUpdateTime() { | ||
return updateTime; | ||
} | ||
} |
Oops, something went wrong.