Skip to content

Commit

Permalink
✨ excel-spring-boot-starter v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvet-s committed Dec 11, 2024
1 parent a720f18 commit 55e979d
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion data/sql/gen/twelvet_gen.sql
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ VALUES (7, 'SQL', '${backendPath}/${className}.sql', 'SQL',
'2023-11-09 14:33:56', '2023-11-10 11:13:07', '0', 'admin', 'admin');
INSERT INTO `gen_template`
VALUES (8, '实体', '${backendPath}/src/main/java/${packagePath}/domain/${ClassName}.java', '实体',
'package ${packageName}.domain;\n\n#foreach ($import in $importList)\nimport ${import};\n#end\nimport com.alibaba.excel.annotation.ExcelProperty;\nimport com.twelvet.framework.core.application.domain.BaseEntity;\nimport org.apache.commons.lang3.builder.ToStringBuilder;\nimport org.apache.commons.lang3.builder.ToStringStyle;\n\nimport io.swagger.v3.oas.annotations.media.Schema;\n#if($table.crud || $table.sub)\n#elseif($table.tree)\nimport com.twelvet.framework.jdbc.web.domain.TreeEntity;\n#end\n\n/**\n * ${functionName}对象 ${tableName}\n *\n * @author ${author}\n * @WebSite twelvet.cn\n * @date ${datetime}\n */\n#if($table.crud || $table.sub)\n#set($Entity=\"BaseEntity\")\n#elseif($table.tree)\n#set($Entity=\"TreeEntity\")\n#end\n@Schema(description =\"${functionName}对象\")\npublic class ${ClassName} extends ${Entity} {\n\n private static final long serialVersionUID = 1L;\n\n#foreach ($column in $columns)\n #if(!$table.isSuperColumn($column.javaField))\n /** $column.columnComment */\n @Schema(description = \"$column.columnComment\")\n #if($column.list)\n #set($parentheseIndex=$column.columnComment.indexOf(\"(\"))\n #if($parentheseIndex != -1)\n #set($comment=$column.columnComment.substring(0, $parentheseIndex))\n #else\n #set($comment=$column.columnComment)\n #end\n #if($parentheseIndex != -1)\n @ExcelProperty(value =\"${comment}($column.readConverterExp())\")\n #elseif($column.javaType == \'Date\')\n @JsonFormat(pattern = \"yyyy-MM-dd\")\n @ExcelProperty(value =\"${comment}\", width = 30, dateFormat = \"yyyy-MM-dd\")\n #else\n @ExcelProperty(value =\"${comment}\")\n #end\n #end\n private $column.javaType $column.javaField;\n\n #end\n#end\n#if($table.sub)\n /** $table.subTable.functionName信息 */\n private List<${subClassName}> ${subclassName}List;\n\n#end\n#foreach ($column in $columns)\n#if(!$table.isSuperColumn($column.javaField))\n#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches(\"[A-Z]\"))\n#set($AttrName=$column.javaField)\n#else\n#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})\n#end\n public void set${AttrName}($column.javaType $column.javaField)\n {\n this.$column.javaField = $column.javaField;\n }\n\n public $column.javaType get${AttrName}()\n {\n return $column.javaField;\n }\n#end\n#end\n\n#if($table.sub)\n public List<${subClassName}> get${subClassName}List()\n {\n return ${subclassName}List;\n }\n\n public void set${subClassName}List(List<${subClassName}> ${subclassName}List)\n {\n this.${subclassName}List = ${subclassName}List;\n }\n\n#end\n @Override\n public String toString() {\n return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)\n#foreach ($column in $columns)\n#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches(\"[A-Z]\"))\n#set($AttrName=$column.javaField)\n#else\n#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})\n#end\n .append(\"${column.javaField}\", get${AttrName}())\n#end\n#if($table.sub)\n .append(\"${subclassName}List\", get${subClassName}List())\n#end\n .toString();\n }\n}\n',
'package ${packageName}.domain;\n\n#foreach ($import in $importList)\nimport ${import};\n#end\nimport cn.idev.excel.annotation.ExcelProperty;\nimport com.twelvet.framework.core.application.domain.BaseEntity;\nimport org.apache.commons.lang3.builder.ToStringBuilder;\nimport org.apache.commons.lang3.builder.ToStringStyle;\n\nimport io.swagger.v3.oas.annotations.media.Schema;\n#if($table.crud || $table.sub)\n#elseif($table.tree)\nimport com.twelvet.framework.jdbc.web.domain.TreeEntity;\n#end\n\n/**\n * ${functionName}对象 ${tableName}\n *\n * @author ${author}\n * @WebSite twelvet.cn\n * @date ${datetime}\n */\n#if($table.crud || $table.sub)\n#set($Entity=\"BaseEntity\")\n#elseif($table.tree)\n#set($Entity=\"TreeEntity\")\n#end\n@Schema(description =\"${functionName}对象\")\npublic class ${ClassName} extends ${Entity} {\n\n private static final long serialVersionUID = 1L;\n\n#foreach ($column in $columns)\n #if(!$table.isSuperColumn($column.javaField))\n /** $column.columnComment */\n @Schema(description = \"$column.columnComment\")\n #if($column.list)\n #set($parentheseIndex=$column.columnComment.indexOf(\"(\"))\n #if($parentheseIndex != -1)\n #set($comment=$column.columnComment.substring(0, $parentheseIndex))\n #else\n #set($comment=$column.columnComment)\n #end\n #if($parentheseIndex != -1)\n @ExcelProperty(value =\"${comment}($column.readConverterExp())\")\n #elseif($column.javaType == \'Date\')\n @JsonFormat(pattern = \"yyyy-MM-dd\")\n @ExcelProperty(value =\"${comment}\", width = 30, dateFormat = \"yyyy-MM-dd\")\n #else\n @ExcelProperty(value =\"${comment}\")\n #end\n #end\n private $column.javaType $column.javaField;\n\n #end\n#end\n#if($table.sub)\n /** $table.subTable.functionName信息 */\n private List<${subClassName}> ${subclassName}List;\n\n#end\n#foreach ($column in $columns)\n#if(!$table.isSuperColumn($column.javaField))\n#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches(\"[A-Z]\"))\n#set($AttrName=$column.javaField)\n#else\n#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})\n#end\n public void set${AttrName}($column.javaType $column.javaField)\n {\n this.$column.javaField = $column.javaField;\n }\n\n public $column.javaType get${AttrName}()\n {\n return $column.javaField;\n }\n#end\n#end\n\n#if($table.sub)\n public List<${subClassName}> get${subClassName}List()\n {\n return ${subclassName}List;\n }\n\n public void set${subClassName}List(List<${subClassName}> ${subclassName}List)\n {\n this.${subclassName}List = ${subclassName}List;\n }\n\n#end\n @Override\n public String toString() {\n return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)\n#foreach ($column in $columns)\n#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches(\"[A-Z]\"))\n#set($AttrName=$column.javaField)\n#else\n#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})\n#end\n .append(\"${column.javaField}\", get${AttrName}())\n#end\n#if($table.sub)\n .append(\"${subclassName}List\", get${subClassName}List())\n#end\n .toString();\n }\n}\n',
'2023-11-09 14:52:04', '2023-11-10 16:18:52', '0', 'admin', 'admin');
INSERT INTO `gen_template`
VALUES (9, 'React页面', '${frontendPath}/react/pages/${moduleName}/${businessName}/index.tsx', 'React页面',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;

import java.net.SocketException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -123,7 +126,7 @@ public Flux<MessageVO> chatStream(MessageDTO messageDTO) {
else { // 无法匹配返回找不到相关信息
MessageVO messageVO = new MessageVO();
messageVO.setContent("知识库未匹配相关问题,请重新提问");
return Flux.just(messageVO);
// return Flux.just(messageVO);
}

// 获取documents里的content
Expand Down Expand Up @@ -152,6 +155,9 @@ public Flux<MessageVO> chatStream(MessageDTO messageDTO) {
// 回复时间必须保证在用户提问时间之前(重新获取时间,并且增加1毫秒),保证排序
LocalDateTime replyNow = LocalDateTime.now().plusNanos(1_000_000);

// ai回复内容
StringBuffer aiContent = new StringBuffer();

return ChatClient
// 自定义使用不同的大模型
.create(chatModel)
Expand All @@ -174,8 +180,22 @@ public Flux<MessageVO> chatStream(MessageDTO messageDTO) {
.chatResponse()
.map(chatResponse -> {
MessageVO messageVO = new MessageVO();
messageVO.setContent(chatResponse.getResult().getOutput().getContent());
String content = chatResponse.getResult().getOutput().getContent();
messageVO.setContent(content);
// 储存AI回复内容
aiContent.append(content);
return messageVO;
})
.doFinally(signalType -> {
if (signalType == SignalType.CANCEL) { // 取消链接时
log.info("AI回复被取消,内容:{}", aiContent);
}
else if (signalType == SignalType.ON_COMPLETE) { // 完成输出时
log.info("AI回复完成,内容:{}", aiContent);
}
else if (signalType == SignalType.ON_ERROR) { // 发生错误时
System.out.println("Stream terminated with an error.");
}
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.ai.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.ai.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.ai.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.ai.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.ai.domain.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.builder.ToStringBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.gen.domain.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.job.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.twelvet.framework.core.application.domain.BaseEntity;
import com.twelvet.framework.core.constants.ScheduleConstants;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.twelvet.api.job.domain;

import com.twelvet.framework.core.application.domain.BaseEntity;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;

import org.apache.commons.lang3.builder.ToStringBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.i18n.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.twelvet.api.system.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import com.twelvet.framework.core.constants.UserConstants;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.twelvet.framework.core.application.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.twelvet.framework.security.domain;

import com.twelvet.api.system.domain.SysRole;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.ExcelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.security.core.GrantedAuthority;
Expand Down

0 comments on commit 55e979d

Please sign in to comment.