1414import org .springframework .security .access .prepost .PreAuthorize ;
1515import org .springframework .security .core .Authentication ;
1616import org .springframework .transaction .annotation .Transactional ;
17+ import org .springframework .web .bind .annotation .GetMapping ;
18+ import org .springframework .web .bind .annotation .PostMapping ;
1719import org .springframework .web .bind .annotation .RequestMapping ;
18- import org .springframework .web .bind .annotation .RequestMethod ;
1920import org .springframework .web .bind .annotation .RequestParam ;
2021import org .springframework .web .bind .annotation .RestController ;
2122
2223import java .io .IOException ;
2324import java .io .Serializable ;
2425import java .util .Map ;
2526
26- import static org .springframework .http .MediaType .APPLICATION_JSON_UTF8_VALUE ;
27+ import static org .springframework .http .MediaType .APPLICATION_JSON_VALUE ;
2728
2829
2930@ RestController
@@ -37,9 +38,9 @@ public class ClansController {
3738
3839 @ ApiOperation ("Grab data about yourself and the clan" )
3940 @ ApiResponses (value = {
40- @ ApiResponse (code = 200 , message = "Success with JSON { player: {id: ?, login: ?}, clan: { id: ?, name: ?, tag: ?}}" ),
41- @ ApiResponse (code = 400 , message = "Bad Request" )})
42- @ RequestMapping (path = "/me" , method = RequestMethod . GET , produces = APPLICATION_JSON_UTF8_VALUE )
41+ @ ApiResponse (code = 200 , message = "Success with JSON { player: {id: ?, login: ?}, clan: { id: ?, name: ?, tag: ?}}" ),
42+ @ ApiResponse (code = 400 , message = "Bad Request" )})
43+ @ GetMapping (path = "/me" , produces = APPLICATION_JSON_VALUE )
4344 public MeResult me (Authentication authentication ) {
4445 Player player = playerService .getPlayer (authentication );
4546
@@ -55,9 +56,9 @@ public MeResult me(Authentication authentication) {
5556 // a: the new clan with the leader membership, b: the leader membership with the new clan
5657 @ ApiOperation ("Create a clan with correct leader, founder and clan membership" )
5758 @ ApiResponses (value = {
58- @ ApiResponse (code = 200 , message = "Success with JSON { id: ?, type: 'clan'}" ),
59- @ ApiResponse (code = 400 , message = "Bad Request" )})
60- @ RequestMapping (path = "/create" , method = RequestMethod . POST , produces = APPLICATION_JSON_UTF8_VALUE )
59+ @ ApiResponse (code = 200 , message = "Success with JSON { id: ?, type: 'clan'}" ),
60+ @ ApiResponse (code = 400 , message = "Bad Request" )})
61+ @ PostMapping (path = "/create" , produces = APPLICATION_JSON_VALUE )
6162 @ PreAuthorize ("hasRole('ROLE_USER')" )
6263 @ Transactional
6364 public Map <String , Serializable > createClan (@ RequestParam (value = "name" ) String name ,
@@ -71,28 +72,24 @@ public Map<String, Serializable> createClan(@RequestParam(value = "name") String
7172
7273 @ ApiOperation ("Generate invitation link" )
7374 @ ApiResponses (value = {
74- @ ApiResponse (code = 200 , message = "Success with JSON { jwtToken: ? }" ),
75- @ ApiResponse (code = 400 , message = "Bad Request" )})
76- @ RequestMapping (path = "/generateInvitationLink" ,
77- method = RequestMethod .GET ,
78- produces = APPLICATION_JSON_UTF8_VALUE )
75+ @ ApiResponse (code = 200 , message = "Success with JSON { jwtToken: ? }" ),
76+ @ ApiResponse (code = 400 , message = "Bad Request" )})
77+ @ GetMapping (path = "/generateInvitationLink" , produces = APPLICATION_JSON_VALUE )
7978 public Map <String , Serializable > generateInvitationLink (
80- @ RequestParam (value = "clanId" ) int clanId ,
81- @ RequestParam (value = "playerId" ) int newMemberId ,
82- Authentication authentication ) throws IOException {
79+ @ RequestParam (value = "clanId" ) int clanId ,
80+ @ RequestParam (value = "playerId" ) int newMemberId ,
81+ Authentication authentication ) throws IOException {
8382 Player player = playerService .getPlayer (authentication );
8483 String jwtToken = clanService .generatePlayerInvitationToken (player , newMemberId , clanId );
8584 return ImmutableMap .of ("jwtToken" , jwtToken );
8685 }
8786
8887 @ ApiOperation ("Check invitation link and add Member to Clan" )
89- @ RequestMapping (path = "/joinClan" ,
90- method = RequestMethod .POST ,
91- produces = APPLICATION_JSON_UTF8_VALUE )
88+ @ PostMapping (path = "/joinClan" , produces = APPLICATION_JSON_VALUE )
9289 @ Transactional
9390 public void joinClan (
94- @ RequestParam (value = "token" ) String stringToken ,
95- Authentication authentication ) throws IOException {
91+ @ RequestParam (value = "token" ) String stringToken ,
92+ Authentication authentication ) throws IOException {
9693 clanService .acceptPlayerInvitationToken (stringToken , authentication );
9794 }
9895}
0 commit comments