Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from MCBanners/mcmarket
- Loading branch information
Showing
30 changed files
with
1,225 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
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
69 changes: 69 additions & 0 deletions
69
src/main/java/com/mcbanners/bannerapi/banner/param/MemberParameter.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,69 @@ | ||
package com.mcbanners.bannerapi.banner.param; | ||
|
||
import com.mcbanners.bannerapi.banner.BannerFontFace; | ||
import com.mcbanners.bannerapi.banner.BannerTextAlign; | ||
import com.mcbanners.bannerapi.util.ParamUtil; | ||
|
||
import java.util.Map; | ||
|
||
public enum MemberParameter implements BannerParameter<Object> { | ||
MEMBER_NAME_X("member_name__x", 104, int.class), | ||
MEMBER_NAME_Y("member_name__y", 22, int.class), | ||
MEMBER_NAME_FONT_SIZE("member_name__font_size", 18, int.class), | ||
MEMBER_NAME_BOLD("member_name__bold", true, boolean.class), | ||
MEMBER_NAME_TEXT_ALIGN("member_name__text_align", BannerTextAlign.LEFT, BannerTextAlign.class), | ||
MEMBER_NAME_FONT_FACE("member_name__font_face", BannerFontFace.SOURCE_SANS_PRO, BannerFontFace.class), | ||
RANK_X("rank__x", 104, int.class), | ||
RANK_Y("rank__y", 37, int.class), | ||
RANK_FONT_SIZE("rank__font_size", 14, int.class), | ||
RANK_BOLD("rank__bold", false, boolean.class), | ||
RANK_TEXT_ALIGN("rank__text_align", BannerTextAlign.LEFT, BannerTextAlign.class), | ||
RANK_FONT_FACE("rank__font_face", BannerFontFace.SOURCE_SANS_PRO, BannerFontFace.class), | ||
JOINED_X("joined__x", 104, int.class), | ||
JOINED_Y("joined__y", 55, int.class), | ||
JOINED_FONT_SIZE("joined__font_size", 14, int.class), | ||
JOINED_BOLD("joined__bold", false, boolean.class), | ||
JOINED_TEXT_ALIGN("joined__text_align", BannerTextAlign.LEFT, BannerTextAlign.class), | ||
JOINED_FONT_FACE("joined__font_face", BannerFontFace.SOURCE_SANS_PRO, BannerFontFace.class), | ||
POSTS_X("posts__x", 104, int.class), | ||
POSTS_Y("posts__y", 72, int.class), | ||
POSTS_FONT_SIZE("posts__font_size", 14, int.class), | ||
POSTS_BOLD("posts__bold", false, boolean.class), | ||
POSTS_TEXT_ALIGN("posts__text_align", BannerTextAlign.LEFT, BannerTextAlign.class), | ||
POSTS_FONT_FACE("posts__font_face", BannerFontFace.SOURCE_SANS_PRO, BannerFontFace.class), | ||
LIKES_X("likes__x", 104, int.class), | ||
LIKES_Y("likes__y", 89, int.class), | ||
LIKES_FONT_SIZE("likes__font_size", 14, int.class), | ||
LIKES_BOLD("likes__bold", false, boolean.class), | ||
LIKES_TEXT_ALIGN("likes__text_align", BannerTextAlign.LEFT, BannerTextAlign.class), | ||
LIKES_FONT_FACE("likes__font_face", BannerFontFace.SOURCE_SANS_PRO, BannerFontFace.class); | ||
|
||
private final String key; | ||
private final Object def; | ||
private final Class<?> type; | ||
|
||
MemberParameter(String key, Object def, Class<?> type) { | ||
this.key = key; | ||
this.def = def; | ||
this.type = type; | ||
} | ||
|
||
public static Map<MemberParameter, Object> parse(Map<String, String> rawParams) { | ||
return ParamUtil.parse(MemberParameter.class, rawParams); | ||
} | ||
|
||
@Override | ||
public String getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public Object getDefault() { | ||
return def; | ||
} | ||
|
||
@Override | ||
public Class<?> getType() { | ||
return type; | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
src/main/java/com/mcbanners/bannerapi/controller/MemberController.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,51 @@ | ||
package com.mcbanners.bannerapi.controller; | ||
|
||
import com.mcbanners.bannerapi.banner.BannerOutputType; | ||
import com.mcbanners.bannerapi.image.BannerImageWriter; | ||
import com.mcbanners.bannerapi.image.layout.MemberLayout; | ||
import com.mcbanners.bannerapi.obj.generic.Member; | ||
import com.mcbanners.bannerapi.service.ServiceBackend; | ||
import com.mcbanners.bannerapi.service.api.MemberService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("member") | ||
public class MemberController { | ||
private final MemberService members; | ||
|
||
@Autowired | ||
public MemberController(MemberService members) { | ||
this.members = members; | ||
} | ||
|
||
@GetMapping(value = "/builtbybit/{id}/isValid", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<Map<String, Boolean>> getIsValid(@PathVariable int id) { | ||
Member member = this.members.getMember(id, ServiceBackend.BUILTBYBIT); | ||
return new ResponseEntity<>(Collections.singletonMap("valid", member != null), HttpStatus.OK); | ||
} | ||
|
||
@GetMapping(value = "/builtbybit/{id}/banner.{outputType}", produces = MediaType.IMAGE_PNG_VALUE) | ||
public ResponseEntity<byte[]> getBanner(@PathVariable int id, @PathVariable BannerOutputType outputType, @RequestParam Map<String, String> raw) { | ||
Member member = this.members.getMember(id, ServiceBackend.BUILTBYBIT); | ||
if (member == null) { | ||
return new ResponseEntity<>(null, HttpStatus.NOT_FOUND); | ||
} | ||
|
||
return draw(member, raw, ServiceBackend.BUILTBYBIT, outputType); | ||
} | ||
|
||
private ResponseEntity<byte[]> draw(Member member, Map<String, String> raw, ServiceBackend backend, BannerOutputType outputType) { | ||
return BannerImageWriter.write(new MemberLayout(member, raw, backend).draw(outputType), outputType); | ||
} | ||
} |
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
Oops, something went wrong.