Skip to content

Commit 81eca63

Browse files
committed
ApiBoot Resource Load 自动删除、添加、更新等示例
1 parent dd654ea commit 81eca63

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

api-boot-samples/api-boot-sample-resource-load/src/main/java/org/minbox/framework/api/boot/sample/ResourceLoadSampleService.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.minbox.framework.api.boot.plugin.resource.load.annotation.ResourceField;
2222
import org.minbox.framework.api.boot.plugin.resource.load.annotation.ResourceFields;
2323
import org.minbox.framework.api.boot.plugin.resource.load.annotation.ResourceLoad;
24+
import org.minbox.framework.api.boot.plugin.resource.load.enums.ResourceStoreEvent;
2425
import org.springframework.stereotype.Service;
2526

2627
import java.util.ArrayList;
@@ -39,6 +40,52 @@
3940
*/
4041
@Service
4142
public class ResourceLoadSampleService {
43+
44+
/**
45+
* 添加用户自动更新资源示例
46+
*
47+
* @param userInfo
48+
* @param shortImage
49+
* @param headImage
50+
*/
51+
@ResourceLoad(event = ResourceStoreEvent.UPDATE)
52+
@ResourceFields({
53+
@ResourceField(name = "#p2", source = "#p0.userId", type = "HEAD_IMAGE"),
54+
@ResourceField(name = "#p1", source = "#p0.userId", type = "SHORT_IMAGE")
55+
})
56+
public void updateUser(SampleUserInfo userInfo, List<String> shortImage, String headImage) {
57+
58+
}
59+
/**
60+
* 添加用户自动添加资源示例
61+
*
62+
* @param userInfo
63+
* @param shortImage
64+
* @param headImage
65+
*/
66+
@ResourceLoad(event = ResourceStoreEvent.INSERT)
67+
@ResourceFields({
68+
@ResourceField(name = "#p2", source = "#p0.userId", type = "HEAD_IMAGE"),
69+
@ResourceField(name = "#p1", source = "#p0.userId", type = "SHORT_IMAGE")
70+
})
71+
public void insertUser(SampleUserInfo userInfo, List<String> shortImage, String headImage) {
72+
73+
}
74+
75+
/**
76+
* 自动删除资源示例
77+
*
78+
* @param userId 用户编号(资源业务逻辑编号)
79+
*/
80+
@ResourceLoad(event = ResourceStoreEvent.DELETE)
81+
@ResourceFields({
82+
@ResourceField(name = "headImage", source = "#p0", type = "HEAD_IMAGE"),
83+
@ResourceField(name = "shortImage", source = "#p0", type = "SHORT_IMAGE")
84+
})
85+
public void deleteUser(String userId) {
86+
// 删除用户逻辑
87+
}
88+
4289
/**
4390
* 返回值为单个对象的示例
4491
*

api-boot-samples/api-boot-sample-resource-load/src/main/java/org/minbox/framework/api/boot/sample/ResourceLoadService.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,19 @@ public List<String> loadResourceUrl(String sourceFieldValue, String resourceType
5050
logger.info("资源类型:{}", resourceType);
5151
return Arrays.asList(new String[]{"http://test.oss.com/111.png"});
5252
}
53+
54+
@Override
55+
public void addResource(String sourceFieldValue, String resourceType, List<String> resourceUrls) throws ApiBootException {
56+
logger.info("添加资源,业务逻辑编号:{},资源类型:{},资源路径集合:{}", sourceFieldValue, resourceType, resourceUrls);
57+
}
58+
59+
@Override
60+
public void deleteResource(String sourceFieldValue, String resourceType) throws ApiBootException {
61+
logger.info("删除资源,业务逻辑编号:{},资源类型:{}", sourceFieldValue, resourceType);
62+
}
63+
64+
@Override
65+
public void updateResource(String sourceFieldValue, String resourceType, List<String> resourceUrls) throws ApiBootException {
66+
logger.info("更新资源,业务逻辑编号:{},资源类型:{},资源路径集合:{}", sourceFieldValue, resourceType, resourceUrls);
67+
}
5368
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
spring:
22
application:
33
name: api-boot-sample-resource-load
4+
redis:
5+
password: 123456

0 commit comments

Comments
 (0)