Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
杨图强
ewaytek-deepseek
Commits
0487b6d5
Commit
0487b6d5
authored
Aug 28, 2025
by
何处是我家
Browse files
提交
parents
Changes
148
Hide whitespace changes
Inline
Side-by-side
.gitattributes
0 → 100644
View file @
0487b6d5
/mvnw text eol=lf
*.cmd text eol=crlf
.gitignore
0 → 100644
View file @
0487b6d5
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
.mvn/wrapper/maven-wrapper.properties
0 → 100644
View file @
0487b6d5
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion
=
3.3.2
distributionType
=
only-script
distributionUrl
=
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
ewaytek-deepseek-common/pom.xml
0 → 100644
View file @
0487b6d5
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.ewaytek.deepseek
</groupId>
<artifactId>
ewaytek-deepseek
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</parent>
<artifactId>
ewaytek-deepseek-common
</artifactId>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Spring框架基本的核心工具 -->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
</dependency>
<!-- SpringWeb模块 -->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
</dependency>
<!-- 自定义验证注解 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
<!--常用工具类 -->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<!-- JSON工具类 -->
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>
com.alibaba.fastjson2
</groupId>
<artifactId>
fastjson2
</artifactId>
</dependency>
<!-- io常用工具类 -->
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
</dependency>
<!-- yml解析器 -->
<dependency>
<groupId>
org.yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
</dependency>
<!-- Token生成与解析-->
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
</dependency>
<!-- Jaxb -->
<dependency>
<groupId>
javax.xml.bind
</groupId>
<artifactId>
jaxb-api
</artifactId>
</dependency>
<!-- redis 缓存操作 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<!-- pool 对象池 -->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-pool2
</artifactId>
</dependency>
<!-- 解析客户端操作系统、浏览器等 -->
<dependency>
<groupId>
eu.bitwalker
</groupId>
<artifactId>
UserAgentUtils
</artifactId>
</dependency>
<!-- servlet包 -->
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
</project>
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/annotation/Excel.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.math.BigDecimal
;
import
com.ewaytek.deepseek.common.utils.poi.ExcelHandlerAdapter
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
/**
* 自定义导出Excel数据注解
*
* @author ruoyi
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
FIELD
)
public
@interface
Excel
{
/**
* 导出时在excel中排序
*/
public
int
sort
()
default
Integer
.
MAX_VALUE
;
/**
* 导出到Excel中的名字.
*/
public
String
name
()
default
""
;
/**
* 日期格式, 如: yyyy-MM-dd
*/
public
String
dateFormat
()
default
""
;
/**
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
*/
public
String
dictType
()
default
""
;
/**
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
*/
public
String
readConverterExp
()
default
""
;
/**
* 分隔符,读取字符串组内容
*/
public
String
separator
()
default
","
;
/**
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
*/
public
int
scale
()
default
-
1
;
/**
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
*/
public
int
roundingMode
()
default
BigDecimal
.
ROUND_HALF_EVEN
;
/**
* 导出时在excel中每个列的高度
*/
public
double
height
()
default
14
;
/**
* 导出时在excel中每个列的宽度
*/
public
double
width
()
default
16
;
/**
* 文字后缀,如% 90 变成90%
*/
public
String
suffix
()
default
""
;
/**
* 当值为空时,字段的默认值
*/
public
String
defaultValue
()
default
""
;
/**
* 提示信息
*/
public
String
prompt
()
default
""
;
/**
* 是否允许内容换行
*/
public
boolean
wrapText
()
default
false
;
/**
* 设置只能选择不能输入的列内容.
*/
public
String
[]
combo
()
default
{};
/**
* 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
*/
public
boolean
comboReadDict
()
default
false
;
/**
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
*/
public
boolean
needMerge
()
default
false
;
/**
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
*/
public
boolean
isExport
()
default
true
;
/**
* 另一个类中的属性名称,支持多级获取,以小数点隔开
*/
public
String
targetAttr
()
default
""
;
/**
* 是否自动统计数据,在最后追加一行统计数据总和
*/
public
boolean
isStatistics
()
default
false
;
/**
* 导出类型(0数字 1字符串 2图片)
*/
public
ColumnType
cellType
()
default
ColumnType
.
STRING
;
/**
* 导出列头背景颜色
*/
public
IndexedColors
headerBackgroundColor
()
default
IndexedColors
.
GREY_50_PERCENT
;
/**
* 导出列头字体颜色
*/
public
IndexedColors
headerColor
()
default
IndexedColors
.
WHITE
;
/**
* 导出单元格背景颜色
*/
public
IndexedColors
backgroundColor
()
default
IndexedColors
.
WHITE
;
/**
* 导出单元格字体颜色
*/
public
IndexedColors
color
()
default
IndexedColors
.
BLACK
;
/**
* 导出字段对齐方式
*/
public
HorizontalAlignment
align
()
default
HorizontalAlignment
.
CENTER
;
/**
* 自定义数据处理器
*/
public
Class
<?>
handler
()
default
ExcelHandlerAdapter
.
class
;
/**
* 自定义数据处理器参数
*/
public
String
[]
args
()
default
{};
/**
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
*/
Type
type
()
default
Type
.
ALL
;
public
enum
Type
{
ALL
(
0
),
EXPORT
(
1
),
IMPORT
(
2
);
private
final
int
value
;
Type
(
int
value
)
{
this
.
value
=
value
;
}
public
int
value
()
{
return
this
.
value
;
}
}
public
enum
ColumnType
{
NUMERIC
(
0
),
STRING
(
1
),
IMAGE
(
2
),
TEXT
(
3
);
private
final
int
value
;
ColumnType
(
int
value
)
{
this
.
value
=
value
;
}
public
int
value
()
{
return
this
.
value
;
}
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/annotation/Excels.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* Excel注解集
*
* @author ruoyi
*/
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Excels
{
public
Excel
[]
value
();
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/bean/base/ApiResponse.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.bean.base
;
import
com.ewaytek.deepseek.common.enums.ErrorCode
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.Serializable
;
import
java.util.Objects
;
/**
* 一般http响应对象
*
* @author lhx
* @Date 2023/1/23 21:23
*/
@Data
@Slf4j
@NoArgsConstructor
@AllArgsConstructor
//从对象的字段生成hashCode和equals实现,callSuper = false指的是不调用父类的方法
@EqualsAndHashCode
(
callSuper
=
false
)
//@ApiModel(value = "响应对象(单数据)", description = "响应对象(单数据)")
public
class
ApiResponse
<
T
>
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* 错误码前缀
*/
public
static
int
prefixErrorCode
;
/**
* 响应编码:0成功;-1系统异常;
*/
// @ApiModelProperty(value = "响应编码", notes = "0成功;其他:错误,详见错误编码")
private
int
code
;
/**
* 响应结果描述
*/
// @ApiModelProperty(value = "错误描述", notes = "错误描述")
private
String
msg
;
/**
* 业务数据
*/
// @ApiModelProperty(value = "业务数据")
private
T
data
;
private
String
trace
;
/**
* 无业务数据的成功响应
*
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
success
()
{
return
success
(
null
);
}
/**
* 带业务数据的成功响应
*
* @param data
* @param <T>
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
success
(
T
data
)
{
return
success
(
data
,
ErrorCode
.
SUCCESS
.
getErrcode
(),
ErrorCode
.
SUCCESS
.
getErrmsg
());
}
@JsonIgnore
public
boolean
belongSuccess
()
{
return
Objects
.
equals
(
ErrorCode
.
SUCCESS
.
getErrcode
(),
this
.
code
);
}
@JsonIgnore
public
boolean
belongError
()
{
return
!
Objects
.
equals
(
ErrorCode
.
SUCCESS
.
getErrcode
(),
this
.
code
);
}
/**
* 带业务数据的成功响应
*
* @param data
* @param <T>
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
success
(
T
data
,
String
msg
)
{
return
success
(
data
,
ErrorCode
.
SUCCESS
.
getErrcode
(),
msg
);
}
/**
* 带业务数据的成功响应
*
* @param data
* @param <T>
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
success
(
T
data
,
int
code
,
String
msg
)
{
ApiResponse
<
T
>
response
=
new
ApiResponse
<
T
>();
response
.
setCode
(
code
);
response
.
setMsg
(
msg
);
response
.
setData
(
data
);
return
response
;
}
/**
* 响应失败
*
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
fail
()
{
return
fail
(
ErrorCode
.
INTERNAL_ERR
.
getErrcode
(),
ErrorCode
.
INTERNAL_ERR
.
getErrmsg
());
}
/**
* 响应失败
*
* @param responseCode
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
fail
(
ErrorCode
responseCode
)
{
return
fail
(
responseCode
.
getErrcode
(),
responseCode
.
getErrmsg
());
}
/**
* 响应失败
*
* @param msg
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
fail
(
String
msg
)
{
return
fail
(
ErrorCode
.
FAIL
.
getErrcode
(),
msg
);
}
/**
* 响应失败
*
* @param failCode
* @param msg
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
fail
(
int
failCode
,
String
msg
)
{
ApiResponse
<
T
>
response
=
new
ApiResponse
<
T
>();
response
.
setCode
(
prefixErrorCode
+
failCode
);
response
.
setMsg
(
msg
);
log
.
info
(
"响应失败,返回报文为{}"
,
response
.
toString
());
return
response
;
}
/**
* 响应失败
*
* @param data 响应出错的数据
* @param failCode
* @param msg
* @return
*/
public
static
<
T
>
ApiResponse
<
T
>
fail
(
T
data
,
int
failCode
,
String
msg
)
{
ApiResponse
<
T
>
response
=
new
ApiResponse
<
T
>();
response
.
setCode
(
prefixErrorCode
+
failCode
);
response
.
setMsg
(
msg
);
response
.
setData
(
data
);
log
.
info
(
"响应失败,返回报文为{}"
,
response
.
toString
());
return
response
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/config/DeepseekConfig.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* 读取项目相关配置
*
* @author admin
*/
@Component
@ConfigurationProperties
(
prefix
=
"robot"
)
public
class
DeepseekConfig
{
/**
* 上传路径
*/
private
static
String
profile
;
/**
* 获取地址开关
*/
private
static
boolean
addressEnabled
;
/**
* 项目名称
*/
private
String
name
;
/**
* 版本
*/
private
String
version
;
/**
* 版权年份
*/
private
String
copyrightYear
;
public
static
String
getProfile
()
{
return
profile
;
}
public
void
setProfile
(
String
profile
)
{
DeepseekConfig
.
profile
=
profile
;
}
public
static
boolean
isAddressEnabled
()
{
return
addressEnabled
;
}
public
void
setAddressEnabled
(
boolean
addressEnabled
)
{
DeepseekConfig
.
addressEnabled
=
addressEnabled
;
}
/**
* 获取导入上传路径
*/
public
static
String
getImportPath
()
{
return
getProfile
()
+
"/import"
;
}
/**
* 获取头像上传路径
*/
public
static
String
getAvatarPath
()
{
return
getProfile
()
+
"/avatar"
;
}
/**
* 获取下载路径
*/
public
static
String
getDownloadPath
()
{
return
getProfile
()
+
"/download/"
;
}
/**
* 获取上传路径
*/
public
static
String
getUploadPath
()
{
return
getProfile
()
+
"/upload"
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getCopyrightYear
()
{
return
copyrightYear
;
}
public
void
setCopyrightYear
(
String
copyrightYear
)
{
this
.
copyrightYear
=
copyrightYear
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/config/ExecutorConfig.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.config
;
import
com.ewaytek.deepseek.common.utils.Threads
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
@Configuration
public
class
ExecutorConfig
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ExecutorConfig
.
class
);
// 核心线程池大小
private
int
corePoolSize
=
10
;
// 最大可创建的线程数
private
int
maxPoolSize
=
10
;
// 队列最大长度
private
int
queueCapacity
=
500
;
// 线程池维护线程所允许的空闲时间
private
int
keepAliveSeconds
=
300
;
@Bean
(
name
=
"threadPoolTaskExecutor"
)
public
ThreadPoolTaskExecutor
threadPoolTaskExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setMaxPoolSize
(
maxPoolSize
);
executor
.
setCorePoolSize
(
corePoolSize
);
executor
.
setQueueCapacity
(
queueCapacity
);
executor
.
setKeepAliveSeconds
(
keepAliveSeconds
);
// 线程池对拒绝任务(无线程可用)的处理策略
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
return
executor
;
}
/**
* 执行周期性或定时任务
*/
@Bean
(
name
=
"scheduledExecutorService"
)
protected
ScheduledExecutorService
scheduledExecutorService
()
{
return
new
ScheduledThreadPoolExecutor
(
corePoolSize
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
())
{
@Override
protected
void
afterExecute
(
Runnable
r
,
Throwable
t
)
{
super
.
afterExecute
(
r
,
t
);
Threads
.
printException
(
r
,
t
);
}
};
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/CacheConstants.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
/**
* 缓存的key 常量
*
* @author admin
*/
public
class
CacheConstants
{
/**
* 登录用户 redis key
*/
public
static
final
String
LOGIN_TOKEN_KEY
=
"login_tokens:"
;
/**
* 验证码 redis key
*/
public
static
final
String
CAPTCHA_CODE_KEY
=
"captcha_codes:"
;
/**
* 参数管理 cache key
*/
public
static
final
String
SYS_CONFIG_KEY
=
"sys_config:"
;
/**
* 字典管理 cache key
*/
public
static
final
String
SYS_DICT_KEY
=
"sys_dict:"
;
/**
* 防重提交 redis key
*/
public
static
final
String
REPEAT_SUBMIT_KEY
=
"repeat_submit:"
;
/**
* 限流 redis key
*/
public
static
final
String
RATE_LIMIT_KEY
=
"rate_limit:"
;
/**
* 登录账户密码错误次数 redis key
*/
public
static
final
String
PWD_ERR_CNT_KEY
=
"pwd_err_cnt:"
;
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/Constants.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
import
java.util.Locale
;
/**
* 通用常量信息
*
* @author admin
*/
public
class
Constants
{
/**
* UTF-8 字符集
*/
public
static
final
String
UTF8
=
"UTF-8"
;
/**
* GBK 字符集
*/
public
static
final
String
GBK
=
"GBK"
;
/**
* 系统语言
*/
public
static
final
Locale
DEFAULT_LOCALE
=
Locale
.
SIMPLIFIED_CHINESE
;
/**
* www主域
*/
public
static
final
String
WWW
=
"www."
;
/**
* http请求
*/
public
static
final
String
HTTP
=
"http://"
;
/**
* https请求
*/
public
static
final
String
HTTPS
=
"https://"
;
/**
* 通用成功标识
*/
public
static
final
String
SUCCESS
=
"0"
;
/**
* 通用失败标识
*/
public
static
final
String
FAIL
=
"1"
;
/**
* 登录成功
*/
public
static
final
String
LOGIN_SUCCESS
=
"Success"
;
/**
* 注销
*/
public
static
final
String
LOGOUT
=
"Logout"
;
/**
* 注册
*/
public
static
final
String
REGISTER
=
"Register"
;
/**
* 登录失败
*/
public
static
final
String
LOGIN_FAIL
=
"Error"
;
/**
* 所有权限标识
*/
public
static
final
String
ALL_PERMISSION
=
"*:*:*"
;
/**
* 管理员角色权限标识
*/
public
static
final
String
SUPER_ADMIN
=
"admin"
;
/**
* 角色权限分隔符
*/
public
static
final
String
ROLE_DELIMETER
=
","
;
/**
* 权限标识分隔符
*/
public
static
final
String
PERMISSION_DELIMETER
=
","
;
/**
* 验证码有效期(分钟)
*/
public
static
final
Integer
CAPTCHA_EXPIRATION
=
2
;
/**
* 令牌
*/
public
static
final
String
TOKEN
=
"token"
;
/**
* 令牌前缀
*/
public
static
final
String
TOKEN_PREFIX
=
"Bearer "
;
/**
* 令牌前缀
*/
public
static
final
String
LOGIN_USER_KEY
=
"login_user_key"
;
/**
* 用户ID
*/
public
static
final
String
JWT_USERID
=
"userid"
;
/**
* 用户头像
*/
public
static
final
String
JWT_AVATAR
=
"avatar"
;
/**
* 创建时间
*/
public
static
final
String
JWT_CREATED
=
"created"
;
/**
* 用户权限
*/
public
static
final
String
JWT_AUTHORITIES
=
"authorities"
;
/**
* 资源映射路径 前缀
*/
public
static
final
String
RESOURCE_PREFIX
=
"/profile"
;
/**
* RMI 远程方法调用
*/
public
static
final
String
LOOKUP_RMI
=
"rmi:"
;
/**
* LDAP 远程方法调用
*/
public
static
final
String
LOOKUP_LDAP
=
"ldap:"
;
/**
* LDAPS 远程方法调用
*/
public
static
final
String
LOOKUP_LDAPS
=
"ldaps:"
;
/**
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
*/
public
static
final
String
[]
JSON_WHITELIST_STR
=
{
"org.springframework"
,
"com.robot"
};
/**
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
*/
public
static
final
String
[]
JOB_WHITELIST_STR
=
{
"com.robot.framework.task"
};
/**
* 定时任务违规的字符
*/
public
static
final
String
[]
JOB_ERROR_STR
=
{
"java.net.URL"
,
"javax.naming.InitialContext"
,
"org.yaml.snakeyaml"
,
"org.springframework"
,
"org.apache"
,
"com.robot.common.utils.file"
,
"com.robot.framework.config"
,
"com.robot.project.tool"
};
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/GenConstants.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
/**
* 代码生成通用常量
*
* @author admin
*/
public
class
GenConstants
{
/**
* 单表(增删改查)
*/
public
static
final
String
TPL_CRUD
=
"crud"
;
/**
* 树表(增删改查)
*/
public
static
final
String
TPL_TREE
=
"tree"
;
/**
* 主子表(增删改查)
*/
public
static
final
String
TPL_SUB
=
"sub"
;
/**
* 树编码字段
*/
public
static
final
String
TREE_CODE
=
"treeCode"
;
/**
* 树父编码字段
*/
public
static
final
String
TREE_PARENT_CODE
=
"treeParentCode"
;
/**
* 树名称字段
*/
public
static
final
String
TREE_NAME
=
"treeName"
;
/**
* 上级菜单ID字段
*/
public
static
final
String
PARENT_MENU_ID
=
"parentMenuId"
;
/**
* 上级菜单名称字段
*/
public
static
final
String
PARENT_MENU_NAME
=
"parentMenuName"
;
/**
* 数据库字符串类型
*/
public
static
final
String
[]
COLUMNTYPE_STR
=
{
"char"
,
"varchar"
,
"nvarchar"
,
"varchar2"
};
/**
* 数据库文本类型
*/
public
static
final
String
[]
COLUMNTYPE_TEXT
=
{
"tinytext"
,
"text"
,
"mediumtext"
,
"longtext"
};
/**
* 数据库时间类型
*/
public
static
final
String
[]
COLUMNTYPE_TIME
=
{
"datetime"
,
"time"
,
"date"
,
"timestamp"
};
/**
* 数据库数字类型
*/
public
static
final
String
[]
COLUMNTYPE_NUMBER
=
{
"tinyint"
,
"smallint"
,
"mediumint"
,
"int"
,
"number"
,
"integer"
,
"bit"
,
"bigint"
,
"float"
,
"double"
,
"decimal"
};
/**
* 页面不需要编辑字段
*/
public
static
final
String
[]
COLUMNNAME_NOT_EDIT
=
{
"id"
,
"create_by"
,
"create_time"
,
"del_flag"
};
/**
* 页面不需要显示的列表字段
*/
public
static
final
String
[]
COLUMNNAME_NOT_LIST
=
{
"id"
,
"create_by"
,
"create_time"
,
"del_flag"
,
"update_by"
,
"update_time"
};
/**
* 页面不需要查询字段
*/
public
static
final
String
[]
COLUMNNAME_NOT_QUERY
=
{
"id"
,
"create_by"
,
"create_time"
,
"del_flag"
,
"update_by"
,
"update_time"
,
"remark"
};
/**
* Entity基类字段
*/
public
static
final
String
[]
BASE_ENTITY
=
{
"createBy"
,
"createTime"
,
"updateBy"
,
"updateTime"
,
"remark"
};
/**
* Tree基类字段
*/
public
static
final
String
[]
TREE_ENTITY
=
{
"parentName"
,
"parentId"
,
"orderNum"
,
"ancestors"
,
"children"
};
/**
* 文本框
*/
public
static
final
String
HTML_INPUT
=
"input"
;
/**
* 文本域
*/
public
static
final
String
HTML_TEXTAREA
=
"textarea"
;
/**
* 下拉框
*/
public
static
final
String
HTML_SELECT
=
"select"
;
/**
* 单选框
*/
public
static
final
String
HTML_RADIO
=
"radio"
;
/**
* 复选框
*/
public
static
final
String
HTML_CHECKBOX
=
"checkbox"
;
/**
* 日期控件
*/
public
static
final
String
HTML_DATETIME
=
"datetime"
;
/**
* 图片上传控件
*/
public
static
final
String
HTML_IMAGE_UPLOAD
=
"imageUpload"
;
/**
* 文件上传控件
*/
public
static
final
String
HTML_FILE_UPLOAD
=
"fileUpload"
;
/**
* 富文本控件
*/
public
static
final
String
HTML_EDITOR
=
"editor"
;
/**
* 字符串类型
*/
public
static
final
String
TYPE_STRING
=
"String"
;
/**
* 整型
*/
public
static
final
String
TYPE_INTEGER
=
"Integer"
;
/**
* 长整型
*/
public
static
final
String
TYPE_LONG
=
"Long"
;
/**
* 浮点型
*/
public
static
final
String
TYPE_DOUBLE
=
"Double"
;
/**
* 高精度计算类型
*/
public
static
final
String
TYPE_BIGDECIMAL
=
"BigDecimal"
;
/**
* 时间类型
*/
public
static
final
String
TYPE_DATE
=
"Date"
;
/**
* 模糊查询
*/
public
static
final
String
QUERY_LIKE
=
"LIKE"
;
/**
* 相等查询
*/
public
static
final
String
QUERY_EQ
=
"EQ"
;
/**
* 需要
*/
public
static
final
String
REQUIRE
=
"1"
;
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/HttpStatus.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
/**
* 返回状态码
*
* @author admin
*/
public
class
HttpStatus
{
/**
* 操作成功
*/
public
static
final
int
SUCCESS
=
200
;
/**
* 对象创建成功
*/
public
static
final
int
CREATED
=
201
;
/**
* 请求已经被接受
*/
public
static
final
int
ACCEPTED
=
202
;
/**
* 操作已经执行成功,但是没有返回数据
*/
public
static
final
int
NO_CONTENT
=
204
;
/**
* 资源已被移除
*/
public
static
final
int
MOVED_PERM
=
301
;
/**
* 重定向
*/
public
static
final
int
SEE_OTHER
=
303
;
/**
* 资源没有被修改
*/
public
static
final
int
NOT_MODIFIED
=
304
;
/**
* 参数列表错误(缺少,格式不匹配)
*/
public
static
final
int
BAD_REQUEST
=
400
;
/**
* 未授权
*/
public
static
final
int
UNAUTHORIZED
=
401
;
/**
* 访问受限,授权过期
*/
public
static
final
int
FORBIDDEN
=
403
;
/**
* 资源,服务未找到
*/
public
static
final
int
NOT_FOUND
=
404
;
/**
* 不允许的http方法
*/
public
static
final
int
BAD_METHOD
=
405
;
/**
* 资源冲突,或者资源被锁
*/
public
static
final
int
CONFLICT
=
409
;
/**
* 不支持的数据,媒体类型
*/
public
static
final
int
UNSUPPORTED_TYPE
=
415
;
/**
* 系统内部错误
*/
public
static
final
int
ERROR
=
500
;
/**
* 接口未实现
*/
public
static
final
int
NOT_IMPLEMENTED
=
501
;
/**
* 系统警告消息
*/
public
static
final
int
WARN
=
601
;
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/ScheduleConstants.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
/**
* 任务调度通用常量
*
* @author admin
*/
public
class
ScheduleConstants
{
public
static
final
String
TASK_CLASS_NAME
=
"TASK_CLASS_NAME"
;
/**
* 执行目标key
*/
public
static
final
String
TASK_PROPERTIES
=
"TASK_PROPERTIES"
;
/**
* 默认
*/
public
static
final
String
MISFIRE_DEFAULT
=
"0"
;
/**
* 立即触发执行
*/
public
static
final
String
MISFIRE_IGNORE_MISFIRES
=
"1"
;
/**
* 触发一次执行
*/
public
static
final
String
MISFIRE_FIRE_AND_PROCEED
=
"2"
;
/**
* 不触发立即执行
*/
public
static
final
String
MISFIRE_DO_NOTHING
=
"3"
;
public
enum
Status
{
/**
* 正常
*/
NORMAL
(
"0"
),
/**
* 暂停
*/
PAUSE
(
"1"
);
private
final
String
value
;
Status
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getValue
()
{
return
value
;
}
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/constant/UserConstants.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.constant
;
/**
* 用户常量信息
*
* @author admin
*/
public
class
UserConstants
{
/**
* 平台内系统用户的唯一标志
*/
public
static
final
String
SYS_USER
=
"SYS_USER"
;
/**
* 正常状态
*/
public
static
final
String
NORMAL
=
"0"
;
/**
* 异常状态
*/
public
static
final
String
EXCEPTION
=
"1"
;
/**
* 用户封禁状态
*/
public
static
final
String
USER_DISABLE
=
"1"
;
/**
* 角色封禁状态
*/
public
static
final
String
ROLE_DISABLE
=
"1"
;
/**
* 部门正常状态
*/
public
static
final
String
DEPT_NORMAL
=
"0"
;
/**
* 部门停用状态
*/
public
static
final
String
DEPT_DISABLE
=
"1"
;
/**
* 字典正常状态
*/
public
static
final
String
DICT_NORMAL
=
"0"
;
/**
* 是否为系统默认(是)
*/
public
static
final
String
YES
=
"Y"
;
/**
* 是否菜单外链(是)
*/
public
static
final
String
YES_FRAME
=
"0"
;
/**
* 是否菜单外链(否)
*/
public
static
final
String
NO_FRAME
=
"1"
;
/**
* 菜单类型(目录)
*/
public
static
final
String
TYPE_DIR
=
"M"
;
/**
* 菜单类型(菜单)
*/
public
static
final
String
TYPE_MENU
=
"C"
;
/**
* 菜单类型(按钮)
*/
public
static
final
String
TYPE_BUTTON
=
"F"
;
/**
* Layout组件标识
*/
public
final
static
String
LAYOUT
=
"Layout"
;
/**
* ParentView组件标识
*/
public
final
static
String
PARENT_VIEW
=
"ParentView"
;
/**
* InnerLink组件标识
*/
public
final
static
String
INNER_LINK
=
"InnerLink"
;
/**
* 校验是否唯一的返回标识
*/
public
final
static
boolean
UNIQUE
=
true
;
public
final
static
boolean
NOT_UNIQUE
=
false
;
/**
* 用户名长度限制
*/
public
static
final
int
USERNAME_MIN_LENGTH
=
2
;
public
static
final
int
USERNAME_MAX_LENGTH
=
20
;
/**
* 密码长度限制
*/
public
static
final
int
PASSWORD_MIN_LENGTH
=
5
;
public
static
final
int
PASSWORD_MAX_LENGTH
=
20
;
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/core/text/CharsetKit.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.core.text
;
import
com.ewaytek.deepseek.common.utils.StringUtils
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
/**
* 字符集工具类
*
* @author admin
*/
public
class
CharsetKit
{
/**
* ISO-8859-1
*/
public
static
final
String
ISO_8859_1
=
"ISO-8859-1"
;
/**
* UTF-8
*/
public
static
final
String
UTF_8
=
"UTF-8"
;
/**
* GBK
*/
public
static
final
String
GBK
=
"GBK"
;
/**
* ISO-8859-1
*/
public
static
final
Charset
CHARSET_ISO_8859_1
=
StandardCharsets
.
ISO_8859_1
;
/**
* UTF-8
*/
public
static
final
Charset
CHARSET_UTF_8
=
StandardCharsets
.
UTF_8
;
/**
* GBK
*/
public
static
final
Charset
CHARSET_GBK
=
Charset
.
forName
(
GBK
);
/**
* 转换为Charset对象
*
* @param charset 字符集,为空则返回默认字符集
* @return Charset
*/
public
static
Charset
charset
(
String
charset
)
{
return
StringUtils
.
isEmpty
(
charset
)
?
Charset
.
defaultCharset
()
:
Charset
.
forName
(
charset
);
}
/**
* 转换字符串的字符集编码
*
* @param source 字符串
* @param srcCharset 源字符集,默认ISO-8859-1
* @param destCharset 目标字符集,默认UTF-8
* @return 转换后的字符集
*/
public
static
String
convert
(
String
source
,
String
srcCharset
,
String
destCharset
)
{
return
convert
(
source
,
Charset
.
forName
(
srcCharset
),
Charset
.
forName
(
destCharset
));
}
/**
* 转换字符串的字符集编码
*
* @param source 字符串
* @param srcCharset 源字符集,默认ISO-8859-1
* @param destCharset 目标字符集,默认UTF-8
* @return 转换后的字符集
*/
public
static
String
convert
(
String
source
,
Charset
srcCharset
,
Charset
destCharset
)
{
if
(
null
==
srcCharset
)
{
srcCharset
=
StandardCharsets
.
ISO_8859_1
;
}
if
(
null
==
destCharset
)
{
destCharset
=
StandardCharsets
.
UTF_8
;
}
if
(
StringUtils
.
isEmpty
(
source
)
||
srcCharset
.
equals
(
destCharset
))
{
return
source
;
}
return
new
String
(
source
.
getBytes
(
srcCharset
),
destCharset
);
}
/**
* @return 系统字符集编码
*/
public
static
String
systemCharset
()
{
return
Charset
.
defaultCharset
().
name
();
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/core/text/Convert.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.core.text
;
import
com.ewaytek.deepseek.common.utils.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.math.RoundingMode
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.text.NumberFormat
;
import
java.util.Set
;
/**
* 类型转换器
*
* @author admin
*/
public
class
Convert
{
/**
* 转换为字符串<br>
* 如果给定的值为null,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
String
toStr
(
Object
value
,
String
defaultValue
)
{
if
(
null
==
value
)
{
return
defaultValue
;
}
if
(
value
instanceof
String
)
{
return
(
String
)
value
;
}
return
value
.
toString
();
}
/**
* 转换为字符串<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
String
toStr
(
Object
value
)
{
return
toStr
(
value
,
null
);
}
/**
* 转换为字符<br>
* 如果给定的值为null,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Character
toChar
(
Object
value
,
Character
defaultValue
)
{
if
(
null
==
value
)
{
return
defaultValue
;
}
if
(
value
instanceof
Character
)
{
return
(
Character
)
value
;
}
final
String
valueStr
=
toStr
(
value
,
null
);
return
StringUtils
.
isEmpty
(
valueStr
)
?
defaultValue
:
valueStr
.
charAt
(
0
);
}
/**
* 转换为字符<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Character
toChar
(
Object
value
)
{
return
toChar
(
value
,
null
);
}
/**
* 转换为byte<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Byte
toByte
(
Object
value
,
Byte
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Byte
)
{
return
(
Byte
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
byteValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
Byte
.
parseByte
(
valueStr
);
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为byte<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Byte
toByte
(
Object
value
)
{
return
toByte
(
value
,
null
);
}
/**
* 转换为Short<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Short
toShort
(
Object
value
,
Short
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Short
)
{
return
(
Short
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
shortValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
Short
.
parseShort
(
valueStr
.
trim
());
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为Short<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Short
toShort
(
Object
value
)
{
return
toShort
(
value
,
null
);
}
/**
* 转换为Number<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Number
toNumber
(
Object
value
,
Number
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Number
)
{
return
(
Number
)
value
;
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
NumberFormat
.
getInstance
().
parse
(
valueStr
);
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为Number<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Number
toNumber
(
Object
value
)
{
return
toNumber
(
value
,
null
);
}
/**
* 转换为int<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Integer
toInt
(
Object
value
,
Integer
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Integer
)
{
return
(
Integer
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
intValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
Integer
.
parseInt
(
valueStr
.
trim
());
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为int<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Integer
toInt
(
Object
value
)
{
return
toInt
(
value
,
null
);
}
/**
* 转换为Integer数组<br>
*
* @param str 被转换的值
* @return 结果
*/
public
static
Integer
[]
toIntArray
(
String
str
)
{
return
toIntArray
(
","
,
str
);
}
/**
* 转换为Long数组<br>
*
* @param str 被转换的值
* @return 结果
*/
public
static
Long
[]
toLongArray
(
String
str
)
{
return
toLongArray
(
","
,
str
);
}
/**
* 转换为Integer数组<br>
*
* @param split 分隔符
* @param split 被转换的值
* @return 结果
*/
public
static
Integer
[]
toIntArray
(
String
split
,
String
str
)
{
if
(
StringUtils
.
isEmpty
(
str
))
{
return
new
Integer
[]{};
}
String
[]
arr
=
str
.
split
(
split
);
final
Integer
[]
ints
=
new
Integer
[
arr
.
length
];
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
final
Integer
v
=
toInt
(
arr
[
i
],
0
);
ints
[
i
]
=
v
;
}
return
ints
;
}
/**
* 转换为Long数组<br>
*
* @param split 分隔符
* @param str 被转换的值
* @return 结果
*/
public
static
Long
[]
toLongArray
(
String
split
,
String
str
)
{
if
(
StringUtils
.
isEmpty
(
str
))
{
return
new
Long
[]{};
}
String
[]
arr
=
str
.
split
(
split
);
final
Long
[]
longs
=
new
Long
[
arr
.
length
];
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
final
Long
v
=
toLong
(
arr
[
i
],
null
);
longs
[
i
]
=
v
;
}
return
longs
;
}
/**
* 转换为String数组<br>
*
* @param str 被转换的值
* @return 结果
*/
public
static
String
[]
toStrArray
(
String
str
)
{
if
(
StringUtils
.
isEmpty
(
str
))
{
return
new
String
[]{};
}
return
toStrArray
(
","
,
str
);
}
/**
* 转换为String数组<br>
*
* @param split 分隔符
* @param split 被转换的值
* @return 结果
*/
public
static
String
[]
toStrArray
(
String
split
,
String
str
)
{
return
str
.
split
(
split
);
}
/**
* 转换为long<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Long
toLong
(
Object
value
,
Long
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Long
)
{
return
(
Long
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
longValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
// 支持科学计数法
return
new
BigDecimal
(
valueStr
.
trim
()).
longValue
();
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为long<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Long
toLong
(
Object
value
)
{
return
toLong
(
value
,
null
);
}
/**
* 转换为double<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Double
toDouble
(
Object
value
,
Double
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Double
)
{
return
(
Double
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
doubleValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
// 支持科学计数法
return
new
BigDecimal
(
valueStr
.
trim
()).
doubleValue
();
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为double<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Double
toDouble
(
Object
value
)
{
return
toDouble
(
value
,
null
);
}
/**
* 转换为Float<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Float
toFloat
(
Object
value
,
Float
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Float
)
{
return
(
Float
)
value
;
}
if
(
value
instanceof
Number
)
{
return
((
Number
)
value
).
floatValue
();
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
Float
.
parseFloat
(
valueStr
.
trim
());
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为Float<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Float
toFloat
(
Object
value
)
{
return
toFloat
(
value
,
null
);
}
/**
* 转换为boolean<br>
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
Boolean
toBool
(
Object
value
,
Boolean
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
Boolean
)
{
return
(
Boolean
)
value
;
}
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
valueStr
=
valueStr
.
trim
().
toLowerCase
();
switch
(
valueStr
)
{
case
"true"
:
case
"yes"
:
case
"ok"
:
case
"1"
:
return
true
;
case
"false"
:
case
"no"
:
case
"0"
:
return
false
;
default
:
return
defaultValue
;
}
}
/**
* 转换为boolean<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
Boolean
toBool
(
Object
value
)
{
return
toBool
(
value
,
null
);
}
/**
* 转换为Enum对象<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
*
* @param clazz Enum的Class
* @param value 值
* @param defaultValue 默认值
* @return Enum
*/
public
static
<
E
extends
Enum
<
E
>>
E
toEnum
(
Class
<
E
>
clazz
,
Object
value
,
E
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
clazz
.
isAssignableFrom
(
value
.
getClass
()))
{
@SuppressWarnings
(
"unchecked"
)
E
myE
=
(
E
)
value
;
return
myE
;
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
Enum
.
valueOf
(
clazz
,
valueStr
);
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为Enum对象<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
*
* @param clazz Enum的Class
* @param value 值
* @return Enum
*/
public
static
<
E
extends
Enum
<
E
>>
E
toEnum
(
Class
<
E
>
clazz
,
Object
value
)
{
return
toEnum
(
clazz
,
value
,
null
);
}
/**
* 转换为BigInteger<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
BigInteger
toBigInteger
(
Object
value
,
BigInteger
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
BigInteger
)
{
return
(
BigInteger
)
value
;
}
if
(
value
instanceof
Long
)
{
return
BigInteger
.
valueOf
((
Long
)
value
);
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
new
BigInteger
(
valueStr
);
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为BigInteger<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
BigInteger
toBigInteger
(
Object
value
)
{
return
toBigInteger
(
value
,
null
);
}
/**
* 转换为BigDecimal<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public
static
BigDecimal
toBigDecimal
(
Object
value
,
BigDecimal
defaultValue
)
{
if
(
value
==
null
)
{
return
defaultValue
;
}
if
(
value
instanceof
BigDecimal
)
{
return
(
BigDecimal
)
value
;
}
if
(
value
instanceof
Long
)
{
return
new
BigDecimal
((
Long
)
value
);
}
if
(
value
instanceof
Double
)
{
return
BigDecimal
.
valueOf
((
Double
)
value
);
}
if
(
value
instanceof
Integer
)
{
return
new
BigDecimal
((
Integer
)
value
);
}
final
String
valueStr
=
toStr
(
value
,
null
);
if
(
StringUtils
.
isEmpty
(
valueStr
))
{
return
defaultValue
;
}
try
{
return
new
BigDecimal
(
valueStr
);
}
catch
(
Exception
e
)
{
return
defaultValue
;
}
}
/**
* 转换为BigDecimal<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
* @param value 被转换的值
* @return 结果
*/
public
static
BigDecimal
toBigDecimal
(
Object
value
)
{
return
toBigDecimal
(
value
,
null
);
}
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
* @param obj 对象
* @return 字符串
*/
public
static
String
utf8Str
(
Object
obj
)
{
return
str
(
obj
,
CharsetKit
.
CHARSET_UTF_8
);
}
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
* @param obj 对象
* @param charsetName 字符集
* @return 字符串
*/
public
static
String
str
(
Object
obj
,
String
charsetName
)
{
return
str
(
obj
,
Charset
.
forName
(
charsetName
));
}
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
* @param obj 对象
* @param charset 字符集
* @return 字符串
*/
public
static
String
str
(
Object
obj
,
Charset
charset
)
{
if
(
null
==
obj
)
{
return
null
;
}
if
(
obj
instanceof
String
)
{
return
(
String
)
obj
;
}
else
if
(
obj
instanceof
byte
[])
{
return
str
((
byte
[])
obj
,
charset
);
}
else
if
(
obj
instanceof
Byte
[])
{
return
str
(
obj
,
charset
);
}
else
if
(
obj
instanceof
ByteBuffer
)
{
return
str
((
ByteBuffer
)
obj
,
charset
);
}
return
obj
.
toString
();
}
/**
* 将byte数组转为字符串
*
* @param bytes byte数组
* @param charset 字符集
* @return 字符串
*/
public
static
String
str
(
byte
[]
bytes
,
String
charset
)
{
return
str
(
bytes
,
StringUtils
.
isEmpty
(
charset
)
?
Charset
.
defaultCharset
()
:
Charset
.
forName
(
charset
));
}
/**
* 解码字节码
*
* @param data 字符串
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
* @return 解码后的字符串
*/
public
static
String
str
(
byte
[]
data
,
Charset
charset
)
{
if
(
data
==
null
)
{
return
null
;
}
if
(
null
==
charset
)
{
return
new
String
(
data
);
}
return
new
String
(
data
,
charset
);
}
/**
* 将编码的byteBuffer数据转换为字符串
*
* @param data 数据
* @param charset 字符集,如果为空使用当前系统字符集
* @return 字符串
*/
public
static
String
str
(
ByteBuffer
data
,
String
charset
)
{
if
(
data
==
null
)
{
return
null
;
}
return
str
(
data
,
Charset
.
forName
(
charset
));
}
/**
* 将编码的byteBuffer数据转换为字符串
*
* @param data 数据
* @param charset 字符集,如果为空使用当前系统字符集
* @return 字符串
*/
public
static
String
str
(
ByteBuffer
data
,
Charset
charset
)
{
if
(
null
==
charset
)
{
charset
=
Charset
.
defaultCharset
();
}
return
charset
.
decode
(
data
).
toString
();
}
// ----------------------------------------------------------------------- 全角半角转换
/**
* 半角转全角
*
* @param input String.
* @return 全角字符串.
*/
public
static
String
toSBC
(
String
input
)
{
return
toSBC
(
input
,
null
);
}
/**
* 半角转全角
*
* @param input String
* @param notConvertSet 不替换的字符集合
* @return 全角字符串.
*/
public
static
String
toSBC
(
String
input
,
Set
<
Character
>
notConvertSet
)
{
char
[]
c
=
input
.
toCharArray
();
for
(
int
i
=
0
;
i
<
c
.
length
;
i
++)
{
if
(
null
!=
notConvertSet
&&
notConvertSet
.
contains
(
c
[
i
]))
{
// 跳过不替换的字符
continue
;
}
if
(
c
[
i
]
==
' '
)
{
c
[
i
]
=
'\u3000'
;
}
else
if
(
c
[
i
]
<
'\
177
'
)
{
c
[
i
]
=
(
char
)
(
c
[
i
]
+
65248
);
}
}
return
new
String
(
c
);
}
/**
* 全角转半角
*
* @param input String.
* @return 半角字符串
*/
public
static
String
toDBC
(
String
input
)
{
return
toDBC
(
input
,
null
);
}
/**
* 替换全角为半角
*
* @param text 文本
* @param notConvertSet 不替换的字符集合
* @return 替换后的字符
*/
public
static
String
toDBC
(
String
text
,
Set
<
Character
>
notConvertSet
)
{
char
[]
c
=
text
.
toCharArray
();
for
(
int
i
=
0
;
i
<
c
.
length
;
i
++)
{
if
(
null
!=
notConvertSet
&&
notConvertSet
.
contains
(
c
[
i
]))
{
// 跳过不替换的字符
continue
;
}
if
(
c
[
i
]
==
'\u3000'
)
{
c
[
i
]
=
' '
;
}
else
if
(
c
[
i
]
>
'\
uFF00
'
&&
c
[
i
]
<
'\
uFF5F
'
)
{
c
[
i
]
=
(
char
)
(
c
[
i
]
-
65248
);
}
}
String
returnString
=
new
String
(
c
);
return
returnString
;
}
/**
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
*
* @param n 数字
* @return 中文大写数字
*/
public
static
String
digitUppercase
(
double
n
)
{
String
[]
fraction
=
{
"角"
,
"分"
};
String
[]
digit
=
{
"零"
,
"壹"
,
"贰"
,
"叁"
,
"肆"
,
"伍"
,
"陆"
,
"柒"
,
"捌"
,
"玖"
};
String
[][]
unit
=
{{
"元"
,
"万"
,
"亿"
},
{
""
,
"拾"
,
"佰"
,
"仟"
}};
String
head
=
n
<
0
?
"负"
:
""
;
n
=
Math
.
abs
(
n
);
String
s
=
""
;
for
(
int
i
=
0
;
i
<
fraction
.
length
;
i
++)
{
// 优化double计算精度丢失问题
BigDecimal
nNum
=
new
BigDecimal
(
n
);
BigDecimal
decimal
=
new
BigDecimal
(
10
);
BigDecimal
scale
=
nNum
.
multiply
(
decimal
).
setScale
(
2
,
RoundingMode
.
HALF_EVEN
);
double
d
=
scale
.
doubleValue
();
s
+=
(
digit
[(
int
)
(
Math
.
floor
(
d
*
Math
.
pow
(
10
,
i
))
%
10
)]
+
fraction
[
i
]).
replaceAll
(
"(零.)+"
,
""
);
}
if
(
s
.
length
()
<
1
)
{
s
=
"整"
;
}
int
integerPart
=
(
int
)
Math
.
floor
(
n
);
for
(
int
i
=
0
;
i
<
unit
[
0
].
length
&&
integerPart
>
0
;
i
++)
{
String
p
=
""
;
for
(
int
j
=
0
;
j
<
unit
[
1
].
length
&&
n
>
0
;
j
++)
{
p
=
digit
[
integerPart
%
10
]
+
unit
[
1
][
j
]
+
p
;
integerPart
=
integerPart
/
10
;
}
s
=
p
.
replaceAll
(
"(零.)*零$"
,
""
).
replaceAll
(
"^$"
,
"零"
)
+
unit
[
0
][
i
]
+
s
;
}
return
head
+
s
.
replaceAll
(
"(零.)*零元"
,
"元"
).
replaceFirst
(
"(零.)+"
,
""
).
replaceAll
(
"(零.)+"
,
"零"
).
replaceAll
(
"^整$"
,
"零元整"
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/core/text/StrFormatter.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.core.text
;
import
com.ewaytek.deepseek.common.utils.StringUtils
;
/**
* 字符串格式化
*
* @author admin
*/
public
class
StrFormatter
{
public
static
final
String
EMPTY_JSON
=
"{}"
;
public
static
final
char
C_BACKSLASH
=
'\\'
;
public
static
final
char
C_DELIM_START
=
'{'
;
public
static
final
char
C_DELIM_END
=
'}'
;
/**
* 格式化字符串<br>
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
* 例:<br>
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
*
* @param strPattern 字符串模板
* @param argArray 参数列表
* @return 结果
*/
public
static
String
format
(
final
String
strPattern
,
final
Object
...
argArray
)
{
if
(
StringUtils
.
isEmpty
(
strPattern
)
||
StringUtils
.
isEmpty
(
argArray
))
{
return
strPattern
;
}
final
int
strPatternLength
=
strPattern
.
length
();
// 初始化定义好的长度以获得更好的性能
StringBuilder
sbuf
=
new
StringBuilder
(
strPatternLength
+
50
);
int
handledPosition
=
0
;
int
delimIndex
;
// 占位符所在位置
for
(
int
argIndex
=
0
;
argIndex
<
argArray
.
length
;
argIndex
++)
{
delimIndex
=
strPattern
.
indexOf
(
EMPTY_JSON
,
handledPosition
);
if
(
delimIndex
==
-
1
)
{
if
(
handledPosition
==
0
)
{
return
strPattern
;
}
else
{
// 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
sbuf
.
append
(
strPattern
,
handledPosition
,
strPatternLength
);
return
sbuf
.
toString
();
}
}
else
{
if
(
delimIndex
>
0
&&
strPattern
.
charAt
(
delimIndex
-
1
)
==
C_BACKSLASH
)
{
if
(
delimIndex
>
1
&&
strPattern
.
charAt
(
delimIndex
-
2
)
==
C_BACKSLASH
)
{
// 转义符之前还有一个转义符,占位符依旧有效
sbuf
.
append
(
strPattern
,
handledPosition
,
delimIndex
-
1
);
sbuf
.
append
(
Convert
.
utf8Str
(
argArray
[
argIndex
]));
handledPosition
=
delimIndex
+
2
;
}
else
{
// 占位符被转义
argIndex
--;
sbuf
.
append
(
strPattern
,
handledPosition
,
delimIndex
-
1
);
sbuf
.
append
(
C_DELIM_START
);
handledPosition
=
delimIndex
+
1
;
}
}
else
{
// 正常占位符
sbuf
.
append
(
strPattern
,
handledPosition
,
delimIndex
);
sbuf
.
append
(
Convert
.
utf8Str
(
argArray
[
argIndex
]));
handledPosition
=
delimIndex
+
2
;
}
}
}
// 加入最后一个占位符后所有的字符
sbuf
.
append
(
strPattern
,
handledPosition
,
strPattern
.
length
());
return
sbuf
.
toString
();
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/enums/ErrorCode.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.enums
;
/**
* @author lhx
* @Description ErrorCode自定义错误码
* @date: 2023/3/26 11:24
* @return
**/
public
enum
ErrorCode
implements
IErrorCode
{
SUCCESS
(
0
,
"成功"
),
USER_NOT_AUTH
(
401
,
"未授权访问,请重新登录"
),
USERTOKEN_EXCEPTION
(
40101
,
"获取userExt信息为空!"
),
USERTOKENPRE_EXCEPTION
(
40102
,
"userExt解析异常!"
),
USERTOKENPRE_LEVEL_EXCEPTION
(
40103
,
"注册用户需满足核验等级为L2及以上,请先完成核验等级升级"
),
USERTOK_EXPIRE_EXCEPTION
(
40104
,
"无效token或已过期"
),
USER_DELETE_EXCEPTION
(
40105
,
"该账号已被删除,如有疑问,请联系贵公司账号管理员或联系平台客服"
),
USER_CHANGE_AUTH
(
40106
,
"该账号权限发生变化,请重新登录,如有疑问,请联系管理员"
),
USER_NOT_AUTH_EXECPTION
(
40111
,
"权限不足,请联系管理员"
),
REQ_EXECPTION
(
40112
,
"您所访问的页面请求中有违反安全规则元素存在,拒绝访问!"
),
USERAUTH_EXCEPTION
(
403
,
"用户[%s]请求服务端口时[%s]权限验证失败!"
),
FILE_D_EXCEPTION
(
1001
,
"文件不存在!"
),
INTERNAL_ERR
(
102
,
"业务处理异常"
),
JSON_FORMAT_ERR
(
105
,
"json数据格式不正确"
),
FAIL
(
115
,
"操作失败"
),
SYSTEM_EXCEPTION
(
116
,
"系统异常"
),
PARAMS_INVALID
(
106
,
"参数不合法"
),
USER_ACCOUT_NOTEXSIT
(
6101
,
"账号不存在"
),
USER_ACCOUT_DISABLE
(
6102
,
"该账号已被禁用"
),
RESOURCE_NOT_FOUND
(
7100
,
"资源不存在"
),
PATH_NOT_FOUND
(
7101
,
"访问路径不存在: %s"
),
// 请求应从manualpre服务端进来,禁止直接访问当前服务
ACCESS_FORBIDDEN
(
8100
,
"access forbidden"
),
;
private
final
Integer
errcode
;
private
final
String
errmsg
;
ErrorCode
(
int
errcode
,
String
errmsg
)
{
this
.
errcode
=
errcode
;
this
.
errmsg
=
errmsg
;
}
@Override
public
Integer
getErrcode
()
{
return
errcode
;
}
@Override
public
String
getErrmsg
()
{
return
errmsg
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/enums/IErrorCode.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.enums
;
/**
* @author: lhx
* @date: 2023/3/17 14:09
* @Description:
*/
public
interface
IErrorCode
{
/**
* 获取异常码
*
* @return
*/
Integer
getErrcode
();
/**
* 获取异常描述
*
* @return
*/
String
getErrmsg
();
}
Prev
1
2
3
4
5
…
8
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment