-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
类似与 TTL 的控制,文件导出后即清空 ,使用方完全不需要采用缓存的方式
- Loading branch information
Showing
14 changed files
with
156 additions
and
90 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
9 changes: 0 additions & 9 deletions
9
src/main/java/com/pig4cloud/plugin/excel/handler/DefaultDictDataProvider.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/com/pig4cloud/plugin/excel/handler/DictCacheClearAnalysisEventListener.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,24 @@ | ||
package com.pig4cloud.plugin.excel.handler; | ||
|
||
import com.alibaba.excel.context.AnalysisContext; | ||
import com.alibaba.excel.read.listener.ReadListener; | ||
import com.pig4cloud.plugin.excel.converters.DictTypeConvert; | ||
|
||
/** | ||
* dict cache clear analysis 事件监听器 | ||
* | ||
* @author lengleng | ||
* @date 2024/08/31 | ||
*/ | ||
public class DictCacheClearAnalysisEventListener implements ReadListener<Object> { | ||
|
||
@Override | ||
public void invoke(Object o, AnalysisContext analysisContext) { | ||
} | ||
|
||
@Override | ||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { | ||
DictTypeConvert.cache.clear(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/pig4cloud/plugin/excel/handler/DictCacheClearSheetWriteHandler.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,24 @@ | ||
package com.pig4cloud.plugin.excel.handler; | ||
|
||
import com.alibaba.excel.write.handler.WorkbookWriteHandler; | ||
import com.alibaba.excel.write.handler.context.WorkbookWriteHandlerContext; | ||
import com.pig4cloud.plugin.excel.converters.DictTypeConvert; | ||
|
||
/** | ||
* dict 缓存清空 | ||
* | ||
* @author lengleng | ||
* @date 2024/08/31 | ||
*/ | ||
public class DictCacheClearSheetWriteHandler implements WorkbookWriteHandler { | ||
|
||
/** | ||
* Called after all operations on the workbook have been completed | ||
* @param context | ||
*/ | ||
@Override | ||
public void afterWorkbookDispose(WorkbookWriteHandlerContext context) { | ||
DictTypeConvert.cache.clear(); | ||
} | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
src/test/java/com/pig4cloud/plugin/excel/enums/DictDataProviderImpl.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,24 @@ | ||
package com.pig4cloud.plugin.excel.enums; | ||
|
||
import com.pig4cloud.plugin.excel.handler.DictDataProvider; | ||
import com.pig4cloud.plugin.excel.vo.DictEnum; | ||
|
||
/** | ||
* @author lengleng | ||
* @date 2024/8/31 | ||
*/ | ||
// @Service | ||
public class DictDataProviderImpl implements DictDataProvider { | ||
|
||
/** | ||
* 获取 dict | ||
* @param type 类型 | ||
* @return {@link DictEnum[] } | ||
*/ | ||
@Override | ||
public DictEnum[] getDict(String type) { | ||
// 查询数据库组装返回对应的字典数据 | ||
return DictEnum.builder().add("1", "男").add("0", "女").build(); | ||
} | ||
|
||
} |
Oops, something went wrong.