-
Notifications
You must be signed in to change notification settings - Fork 6
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
aaron
committed
Dec 10, 2023
1 parent
71240d1
commit 40d6d05
Showing
20 changed files
with
429 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
[ | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/create", | ||
"method": "POST", | ||
"body": { | ||
"theme": "主题", | ||
"date": "分享日期,如2023-01-01", | ||
"time": "分享时间,如8:00", | ||
"language": "分享语言,0-中文,1英文", | ||
"presenter": "分享人昵称", | ||
"org": "所属组织", | ||
"twitter": "分享人推特", | ||
"sharingDoc": "分享链接", | ||
"label": "标签类别" | ||
}, | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": 111 | ||
} | ||
}, | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/update", | ||
"method": "POST", | ||
"body": { | ||
"id":"分享id,如111", | ||
"theme": "主题", | ||
"date": "分享日期,如2023-01-01", | ||
"time": "分享时间,如8:00", | ||
"language": "分享语言,0-中文,1英文", | ||
"presenter": "分享人昵称", | ||
"org": "所属组织", | ||
"twitter": "分享人推特", | ||
"sharingDoc": "分享链接", | ||
"label": "标签类别" | ||
}, | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": null | ||
} | ||
}, | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/delete?shareId=111", | ||
"method": "POST", | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": null | ||
} | ||
}, | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/all?pageNo=1&pageSize=10", | ||
"method": "GET", | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": { | ||
"data": [ | ||
{ | ||
"id": "分享id", | ||
"theme": "主题", | ||
"date": "分享日期,如2023-01-01", | ||
"time": "分享时间,如8:00", | ||
"language": "分享语言,0-中文,1英文", | ||
"presenter": "分享人昵称", | ||
"org": "所属组织", | ||
"twitter": "分享人推特", | ||
"sharingDoc": "分享链接", | ||
"label": "标签类别", | ||
"locked": "锁定状态", | ||
"meetingType": "会议类别", | ||
"meetingId": "会议编号", | ||
"meetingLink": "会议链接" | ||
} | ||
], | ||
"pagination": { | ||
"totalCount": 0, | ||
"totalPages": 0, | ||
"currentPage": 1, | ||
"currentPageSize": 0, | ||
"hasNext": false | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/{memberId}?pageNo=1&pageSize=10", | ||
"method": "GET", | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": { | ||
"data": [ | ||
{ | ||
"id": "分享id", | ||
"theme": "主题", | ||
"date": "分享日期,如2023-01-01", | ||
"time": "分享时间,如8:00", | ||
"language": "分享语言,0-中文,1英文", | ||
"presenter": "分享人昵称", | ||
"org": "所属组织", | ||
"twitter": "分享人推特", | ||
"sharingDoc": "分享链接", | ||
"label": "标签类别", | ||
"locked": "锁定状态", | ||
"meetingType": "会议类别", | ||
"meetingId": "会议编号", | ||
"meetingLink": "会议链接" | ||
} | ||
], | ||
"pagination": { | ||
"totalCount": 0, | ||
"totalPages": 0, | ||
"currentPage": 1, | ||
"currentPageSize": 0, | ||
"hasNext": false | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "http://81.69.8.95:8080/share/usershare/queryByShareId?shareId=111", | ||
"method": "GET", | ||
"response": | ||
{ | ||
"code": "200", | ||
"msg": "success", | ||
"data": { | ||
"id": "分享id", | ||
"theme": "主题", | ||
"date": "分享日期,如2023-01-01", | ||
"time": "分享时间,如8:00", | ||
"language": "分享语言,0-中文,1英文", | ||
"presenter": "分享人昵称", | ||
"org": "所属组织", | ||
"twitter": "分享人推特", | ||
"sharingDoc": "分享链接", | ||
"label": "标签类别", | ||
"locked": "锁定状态", | ||
"meetingType": "会议类别", | ||
"meetingId": "会议编号", | ||
"meetingLink": "会议链接" | ||
} | ||
} | ||
} | ||
] |
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dl/officialsite/sharing/constant/SharingPostType.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,21 @@ | ||
package com.dl.officialsite.sharing.constant; | ||
|
||
public enum SharingPostType { | ||
|
||
CLASSIC(0); | ||
|
||
private int code; | ||
|
||
SharingPostType(int code){ | ||
this.code = code; | ||
} | ||
|
||
public static SharingPostType codeOf(int code){ | ||
for(SharingPostType postType: SharingPostType.values()){ | ||
if(postType.code == code){ | ||
return postType; | ||
} | ||
} | ||
throw new IllegalArgumentException("SharingPostType "+code); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/dl/officialsite/sharing/handler/IPostHandler.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.dl.officialsite.sharing.handler; | ||
|
||
import com.dl.officialsite.sharing.constant.SharingPostType; | ||
import com.dl.officialsite.sharing.model.bo.PostGenerationInput; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
public interface IPostHandler<T extends PostGenerationInput> { | ||
|
||
void generateOutput(T input, OutputStream os) throws IOException; | ||
|
||
SharingPostType postType(); | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/dl/officialsite/sharing/handler/PostClassicHandler.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.dl.officialsite.sharing.handler; | ||
|
||
import com.dl.officialsite.sharing.constant.SharingPostType; | ||
import com.dl.officialsite.sharing.model.bo.PostClassicalGeneratorInput; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.image.BufferedImage; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
@Component | ||
@Slf4j | ||
public class PostClassicHandler implements IPostHandler<PostClassicalGeneratorInput>{ | ||
@Override | ||
public void generateOutput(PostClassicalGeneratorInput input, OutputStream os) throws IOException { | ||
/** | ||
* 加载模板 | ||
*/ | ||
ClassPathResource classPathResource = new ClassPathResource("post/classic.png"); | ||
try(InputStream ins = classPathResource.getInputStream()){ | ||
BufferedImage image = ImageIO.read(ins); | ||
log.info("image load finished"); | ||
} | ||
|
||
|
||
/** | ||
* 画右上角组织图标 | ||
*/ | ||
|
||
/** | ||
* Presenter | ||
*/ | ||
|
||
/** | ||
* | ||
*/ | ||
} | ||
|
||
@Override | ||
public SharingPostType postType() { | ||
return SharingPostType.CLASSIC; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/dl/officialsite/sharing/manager/PostImageManager.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,48 @@ | ||
package com.dl.officialsite.sharing.manager; | ||
|
||
import com.dl.officialsite.sharing.constant.SharingPostType; | ||
import com.dl.officialsite.sharing.handler.IPostHandler; | ||
import com.dl.officialsite.sharing.model.bo.PostGenerationInput; | ||
import com.dl.officialsite.sharing.model.req.PostGenerateReq; | ||
import com.google.common.base.Preconditions; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* 海报处理器 | ||
*/ | ||
@Component | ||
public class PostImageManager { | ||
|
||
private Map<SharingPostType, IPostHandler> handlers; | ||
|
||
@Autowired | ||
public PostImageManager(List<IPostHandler> handlers){ | ||
this.handlers = new HashMap<>(); | ||
|
||
for(IPostHandler handler: handlers){ | ||
this.handlers.put(handler.postType(), handler); | ||
} | ||
} | ||
|
||
public void generateTemplate(PostGenerateReq req){ | ||
SharingPostType sharingPostType = SharingPostType.codeOf(req.getPostType()); | ||
IPostHandler postHandler = this.handlers.get(sharingPostType); | ||
Preconditions.checkState(postHandler !=null, "post type not found"); | ||
|
||
try{ | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
postHandler.generateOutput(req.getInput(), baos); | ||
} catch (Throwable ex) | ||
{ | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.