From aed297a5fbc8df9dab01b28da21f872ee546b43c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 13 十月 2025 16:15:11 +0800
Subject: [PATCH] 2025.10.13 1. 统一调整controller层的返回类型,通过添加全局响应增强器GlobalResponseAdvice来管理返回结果; 2. 新增mybatis-generator自定义插件,实现给数据库实体entity自动添加swagger注解@ApiModel和@ApiModelProperty
---
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
index f10a5be..fefb508 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
@@ -12,9 +12,10 @@
/**
* excel鎶ュ憡妯℃澘鍩虹被
+ * 鍗曚釜鏁版嵁婧�
*/
// FIXME: 2022/7/15 妯℃澘绠�鍖栵細鍙湁琛ㄥご浼氭秹鍙婂崟鍏冩牸鍚堝苟锛岄粯璁よ〃鍐呭涓病鏈夊悎骞�
-abstract class BaseTemplate(val dataSource: DataSource){
+abstract class BaseTemplate(val dataSource: DataSource) : BaseOutputInterface {
//鍒楃粍鍚�
abstract val cols: List<BaseCols>
@@ -24,6 +25,7 @@
//琛ㄥご
val head = mutableListOf<MutableList<ExcelUtil.MyCell>>()
+
//鍐呭
val contents = mutableListOf<MutableList<Any>>()
@@ -33,11 +35,11 @@
dataSource.reset()
//鍚堟垚琛ㄥご
cols.forEach {
- it.combineHead(head,dataSource)
+ it.combineHead(head, dataSource)
}
//鍚堟垚鏁版嵁
dataSource.loop { index, rowData ->
- cols.forEach {col ->
+ cols.forEach { col ->
val r = col.getOneRow(rowData)
if (index >= contents.size) {
contents.add(mutableListOf())
@@ -47,12 +49,12 @@
}
}
- fun toWorkBook(wb: HSSFWorkbook) {
+ override fun toWorkBook(wb: HSSFWorkbook) {
val f = tableFormat()
ExcelUtil.write(f.first, f.second, wb, templateName)
}
- fun toOutputStream(out: OutputStream, sheetName: String? = null) {
+ override fun toOutputStream(out: OutputStream, sheetName: String?) {
val f = tableFormat()
ExcelUtil.write2(out, f.first, f.second, sheetName ?: templateName)
}
@@ -60,7 +62,7 @@
/**
* 杈撳嚭涓烘枃妗�
*/
- fun toFile(path: String) {
+ override fun toFile(path: String) {
val fileName = "${dataSource.areaName()}-${templateName}-${Date().time}.xls"
val out = FileOutputStream(path + fileName)
toOutputStream(out)
@@ -69,12 +71,13 @@
/**
* 琛ㄥご鍜岃〃鍐呭鏍煎紡杞寲
*/
- private fun tableFormat(): Pair<MutableList<Array<Any>>, MutableList<Array<Any>>> {
+ fun tableFormat(): Pair<MutableList<Array<Any>>, MutableList<Array<Any>>> {
val h = mutableListOf<Array<Any>>()
val c = mutableListOf<Array<Any>>()
head.forEach { h.add(it.toTypedArray()) }
contents.forEach { c.add(it.toTypedArray()) }
val index = c[0][0]
+ //鎸夌収绗竴鍒楄繘琛屾帓搴�
if (index is Int) {
c.sortBy {
if (it[0] is Int) {
@@ -91,11 +94,3 @@
return Pair(h, c)
}
}
-
-//鍥哄畾鍒楃粍鍚�
-
-
-//鍩烘湰淇℃伅
-//闂鎵e垎鍒嗗竷
-
-
--
Gitblit v1.9.3