添加模板,修改页面

This commit is contained in:
2023-09-13 17:07:19 +08:00
parent 8415c42750
commit dcfc9b5790
25 changed files with 1046 additions and 17 deletions

View File

@@ -103,6 +103,7 @@ public class MulitModuleMavenBuildProjectContributor extends MavenBuildProjectCo
// add submodule in root dependencymanager
for (Module subModule : arch.getSubModules()) {
//this.build.dependencies().add(subModule.getName(),description.getGroupId(),toFinalArtifactId(subModule.getName()),null);
this.build.boms().add(toFinalArtifactId(subModule.getName()),
DependencyBillOfMaterials
.withCoordinates(description.getGroupId(), toFinalArtifactId(subModule.getName()))
@@ -213,7 +214,9 @@ public class MulitModuleMavenBuildProjectContributor extends MavenBuildProjectCo
}
private void addModuleDependency(String subModule) {
this.build.dependencies().add(subModule, Dependency.withCoordinates(description.getGroupId(), subModule));
if(this.build.dependencies().get(subModule) == null){
this.build.dependencies().add(subModule, Dependency.withCoordinates(description.getGroupId(), subModule));
}
}
private int findModulesInsertLine(Path pomFile) throws IOException {

View File

@@ -1,6 +1,46 @@
initializr:
env:
boms:
lombok:
groupId: org.projectlombok
artifactId: lombok
version: 1.18.28
scope: provided
hutool:
groupId: cn.hutool
artifactId: hutool-all
version: 5.8.21
additionalBoms: [ lombok,bouncycastle,compress,email,zxing,logback ]
bouncycastle:
groupId: org.bouncycastle
artifactId: bcprov-jdk15to18
version: 1.69
compress:
groupId: org.apache.commons
artifactId: commons-compress
version: 1.21
email:
groupId: com.sun.mail
artifactId: javax.mail
version: 1.6.2
zxing:
groupId: com.google.zxing
artifactId: core
version: 3.3.3
logback:
groupId: ch.qos.logback
artifactId: logback-classic
version: 1.2.3
# jcraft:
# groupId: com.jcraft
# artifactId: jsch
# version: 0.154
codecentric-spring-boot-admin:
groupId: de.codecentric
artifactId: spring-boot-admin-dependencies
@@ -208,7 +248,150 @@ initializr:
url: https://oss.sonatype.org/content/repositories/snapshots/
releasesEnabled: false
snapshotsEnabled: true
dependencies:
- name: 多模块多web架构组件
#dependencies: hutool, logback
content:
- name: 前端API
id: web-api
codeOnly: true
description: 分层多web架构中前端API基础代码.
archCfg:
model3multiweb:
modules:
webAPI:
code: true
- name: 后端管理API
id: manager-api
codeOnly: true
description: 分层多web架构中后端管理API基础代码.
archCfg:
model3multiweb:
modules:
managerAPI:
code: true
- name: utils 非业务型的常用工具包
id: utils
codeOnly: true
starter: false
bom: hutool
#dependencies: hutool, logback
#requestedDependencies: [hutool,compress]
#requestedDependencies
#dependencies: [hutool,compress,bouncycastle,lombok,logback, email,zxing]
description: utils分层多web架构中非业务型的常用工具包基础代码.
archCfg:
model3multiweb:
modules:
utils:
code: true
- name: service 模块
id: service
codeOnly: true
starter: false
#dependencies: [hutool,compress,bouncycastle,lombok,logback, email,zxing]
description: 分层多web架构中service 模块基础代码.
archCfg:
model3multiweb:
modules:
service:
code: true
- name: dao 模块
id: dao
codeOnly: true
starter: false
description: 分层多web架构中dao 模块基础代码.
archCfg:
model3multiweb:
modules:
dao:
code: true
- name: pojo 模块
id: pojo
codeOnly: true
starter: false
description: 分层多web架构中pojo 模块基础代码.
archCfg:
model3multiweb:
modules:
pojo:
code: true
- name: common 模块
id: common
codeOnly: true
starter: false
bom: logback
#dependencies: [hutool,compress,bouncycastle,lombok,logback, email,zxing]
#dependencies: hutool, logback
description: 分层多web架构中common 模块基础代码.
archCfg:
model3multiweb:
modules:
common:
code: true
# - name: 自定义架构需要用到的组件
# content:
# - name: hutool
# id: hutool
# description: 一个Java基础工具类对文件、流、加密解密、转码、正则、线程、XML等JDK方法进行封装组成各种Util工具类
# groupId: cn.hutool
# artifactId: hutool-all
# version: 5.8.21
# starter: false
# links:
# - rel: reference
# href: https://doc.hutool.cn/pages/index/
# - name: logback
# id: logback
# description: 一个Java基础工具类对文件、流、加密解密、转码、正则、线程、XML等JDK方法进行封装组成各种Util工具类
# groupId: ch.qos.logback
# artifactId: logback-classic
# version: 1.2.3
# starter: false
# links:
# - rel: reference
# href: https://doc.hutool.cn/pages/index/
# - name: compress
# id: compress
# description: 压缩工具
# groupId: org.apache.commons
# artifactId: commons-compress
# version: 1.21
# starter: false
# - name: email
# id: email
# description: email发送
# groupId: com.sun.mail
# artifactId: javax.mail
# version: 1.6.2
# starter: false
# - name: zxing
# id: zxing
# description: 二维码生成与识别
# groupId: com.google.zxing
# artifactId: core
# version: 3.3.3
# starter: false
# - name: bouncycastle
# id: bouncycastle
# description: 国密
# groupId: org.bouncycastle
# artifactId: bcprov-jdk15to18
# version: 1.69
# starter: false
## - name: lombok
## id: lombok
## description: 二维码生成与识别
## groupId: org.projectlombok
## artifactId: lombok
## version: 1.18.28
## scope: provided
## starter: false
- name: Alibaba Cloud
bom: aliyun-spring-boot
content:
@@ -580,13 +763,13 @@ initializr:
id: web-services
description: Facilitates contract-first SOAP development. Allows for the creation of flexible web services using one of the many ways to manipulate XML payloads.
aliases:
- ws
- ws
links:
- rel: guide
href: https://spring.io/guides/gs/producing-web-service/
description: Producing a SOAP web service
- rel: reference
href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#io.webservices
- rel: guide
href: https://spring.io/guides/gs/producing-web-service/
description: Producing a SOAP web service
- rel: reference
href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#io.webservices
- name: Jersey
id: jersey
description: Framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs.
@@ -1715,7 +1898,7 @@ initializr:
- rel: sample
href: https://aka.ms/spring/samples/latest/storage
description: Azure Storage Sample
- name: Google Cloud Platform
- name: Google Cloud Platform1
bom: spring-cloud-gcp
compatibilityRange: "[2.4.0-M1,3.0.0-M1)"
content:
@@ -1759,6 +1942,43 @@ initializr:
- name: cloudshell
id: cloudshell
codeOnly: true
# - name: Web11
# content:
# - name: Spring Web11
# id: layer
# description: 11Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.
# facets:
# - pojo
# - json
# - native
# archCfg:
# microservices:
# modules:
# pojo:
# code: true
# - name: Web22
# content:
# - name: Spring Web11
# id: layer1
# description: 11Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.
# facets:
# - pojo
# - json
# - native
# archCfg:
# model3multiweb:
# modules:
# pojo:
# code: true
# - name: Spring Web22
# id: layer2
# description: 11Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.
# archCfg:
# model3multiweb:
# modules:
# service:
# code: true
types:
- name: Maven Project
id: maven-project
@@ -1817,6 +2037,16 @@ initializr:
id: groovy
default: false
bootVersions:
- name: 3.2.0
id: 3.2.0
- name: 3.1.3
id: 3.1.3
- name: 3.1.2
id: 3.1.2
- name: 3.0.10
id: 3.0.10
- name: 3.0.9
id: 3.0.9
- name: 3.0.2
id: 3.0.2
- name: 2.7.6
@@ -1825,13 +2055,14 @@ initializr:
id: 2.6.13
default: true
- name: 2.4.2
id: 2.4.2
id: 2.4.2architecture
- name: 2.3.12.RELEASE
id: 2.3.12.RELEASE
architecture:
- id: none
name: 单模块
default: true
# default: true
- id: mvc
name: MVC架构
subModules:
@@ -1841,4 +2072,63 @@ initializr:
- name: web
description: web 模块,对应 MVC 的 V 概念,存放视图层的逻辑
- name: service
description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
- id: model3multiweb
default: true
name: 多模块多web架构
#requestedDependencies: [hutool,compress]
# requestedDependencies: Dependency:
# requiredDependency: layer1
subModules:
- name: web-api
description: 前端API
main: true
- name: manager-api
description: 后端管理API
main: true
- name: utils
#requiredDependency: hutool
#dependencies: [hutool,compress,bouncycastle,lombok,logback,compress, mail,zxing]
description: utils 非业务型的常用工具包,各类组件引用基本在此模块,第三方组件包必须在此模块中包装后再使用,避免组件与业务模块混淆
- name: service
dependModules: pojo,dao
description: service 模块,相对具体的业务逻辑服务层
- name: dao
description: dao 模块,数据访问层
dependModules: pojo
- name: pojo
description: pojo 模块,POJO 专指只有 setter / getter / toString 的简单类,包括 DO / BO / VO 。DO与数据库表结构一一对应不能在DAO层之外出现BODAO与Service之间交互数据以及Service与BO之间交互数据使用VOAPI模块接收控制器数据
- name: common
description: common 通用模块,项目中使用到的基础功能,如配置,数据库,日志记录。
dependModules: pojo
# - id: layer
# name: 分层架构
# subModules:
# - name: start
# description: 入口模块,引导工程启动以及基础配置
# main: true
# - name: web
# description: web 模块,对应 MVC 的 V 概念,存放视图层的逻辑
# - name: service
# description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
# - name: common
# description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
# - name: pojo
# description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
# - id: microservices
# name: 微服务架构1
# #requestedDependencies: layer1
# #requiredDependency: layer2
# subModules:
# - name: start
# description: 入口模块,引导工程启动以及基础配置
# main: true
# - name: web
# description: web 模块,对应 MVC 的 V 概念,存放视图层的逻辑
# - name: service
# # dependModules: layer2
# description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码
# - name: pojo
# description: service 模块,对应 MVC 的 M 概念,存放核心业务逻辑代码

View File

@@ -0,0 +1,8 @@
package {{basePackage}}.common.file;
public class FileUtilCommon {
public FileUtilCommon(){
}
}

View File

@@ -0,0 +1,8 @@
package {{basePackage}}.dao.file;
public class FileUtilDao {
public FileUtilDao(){
}
}

View File

@@ -0,0 +1,8 @@
package {{basePackage}}.pojo.file;
public class FileUtilDao {
public FileUtilDao(){
}
}

View File

@@ -0,0 +1,8 @@
package {{basePackage}}.service.file;
public class FileUtilDao {
public FileUtilDao(){
}
}

View File

@@ -0,0 +1,45 @@
package {{basePackage}}.utils.compress;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.extra.compress.CompressUtil;
import cn.hutool.extra.compress.extractor.Extractor;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import java.io.File;
/**
* dcrenl: 2023-09-07 13:27:41
* 压缩文件操作
*/
public class ZipUtils {
/**
* dcrenl: 2023-09-07 13:40:31
* 压缩目录
* @param sourcePath
* @param compressFilePath
*/
public static void create(String sourcePath, String compressFilePath) {
File compressfile = FileUtil.file(compressFilePath);
File sourceFile = FileUtil.file(sourcePath);
CompressUtil.createArchiver(CharsetUtil.CHARSET_UTF_8, ArchiveStreamFactory.SEVEN_Z, compressfile)
.add(sourceFile)
.finish()
.close();
}
/**
* 解压文件
* @param compressFilePath
* @param releasePath
*/
public static void release(String compressFilePath, String releasePath) {
File compressFile = FileUtil.file(compressFilePath);
File releaseFile = FileUtil.file(releasePath);
Extractor extractor = CompressUtil.createExtractor(CharsetUtil.defaultCharset(), compressFile);
extractor.extract(releaseFile);
}
}

View File

@@ -0,0 +1,77 @@
package {{basePackage}}.utils.crypto;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.SM2;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import java.nio.charset.StandardCharsets;
import java.security.KeyPair;
import java.security.SecureRandom;
/**
* dcrenl: 2023-09-08 16:15:49
* 国密算法
*/
public class SmUtils {
private static final SM2 sm2 = SmUtil.sm2();
/**
* dcrenl: 2023-09-11 9:5:9
* sm4加密密钥密钥长度16位
*/
private static final String k = "ixUaL3m-uXV6qGlN";
private static final SymmetricCrypto sm4 = SmUtil.sm4(k.getBytes(StandardCharsets.UTF_8));
public static String sm2Encrypt(String str) {
return sm2.encryptBase64(str, KeyType.PublicKey);
}
public static String sm2Decrypt(String str) {
return sm2.decryptStr(str, KeyType.PrivateKey);
}
public static String sm2SignHex(String str) {
return sm2.signHex(str);
}
public static boolean sm2VerifyHex(String str, String sign) {
return sm2.verifyHex(str, sign);
}
public static String sm3DigestHex(String str) {
return SmUtil.sm3(str);
}
/**
* dcrenl: 2023-09-08 16:30:58
* sm4加密
* @param str
* @return
*/
public static String sm4Encrypt(String str) {
return sm4.encryptBase64(str);
}
/**
* dcrenl: 2023-09-08 16:31:16
* sm4解密
* @param str
* @return
*/
public static String sm4Decrypt(String str) {
return sm4.decryptStr(str);
}
}

View File

@@ -0,0 +1,48 @@
package {{basePackage}}.utils.date;
import java.util.Date;
import cn.hutool.core.date.DateUtil;
/***
* dcrenl: 2023-09-07 12:52:32
* 使用hutool封装日期处理方法
*/
public class DateUtils {
/**
* dcrenl: 2023-09-07 13:7:30
* 获取当前日期
* @return
*/
public static Date getDate() {
return DateUtil.date();
}
/**
* dcrenl: 2023-09-07 13:7:33
* 字符串转日期
* @param strDate 日期字符串
* @param strFormat 转换格式为空时默认为字符串格式yyyy/MM/dd HH:mm:ss.SSS
* @return
*/
public static Date parse(String strDate, String strFormat) {
if (strFormat.isEmpty())
return DateUtil.parse(strDate);
return DateUtil.parse(strDate, strFormat);
}
/**
* dcrenl: 2023-09-07 13:7:39
* 年龄计算
* @param strDate 出生日期字符串
* @return
*/
public static int getAge(String strDate) {
return DateUtil.ageOfNow(strDate);
}
}

View File

@@ -0,0 +1,23 @@
package {{basePackage}}.utils.file;
import cn.hutool.core.io.FileTypeUtil;
import java.io.File;
/**
* dcrenl: 2023-09-07 13:4:39
* 文件操作类
*/
public class FileUtils {
/**
* dcrenl: 2023-09-07 13:7:13
* 获取文件类型
* @param file
* @return
*/
public static String getFileType(File file) {
return FileTypeUtil.getType(file);
}
}

View File

@@ -0,0 +1,16 @@
package {{basePackage}}.utils.http;
public enum HttpMethod {
GET,
POST,
HEAD,
OPTIONS,
PUT,
DELETE,
TRACE,
CONNECT,
PATCH;
private HttpMethod() {
}
}

View File

@@ -0,0 +1,56 @@
package {{basePackage}}.utils.http;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;
import sun.invoke.empty.Empty;
/**
*
*/
public class HttpUtils {
/**
* dcrenl: 2023-09-08 8:51:55
* Http请求
* @param strUrl 请求的URL
* @param method 请求方式
* @param strBody
* @return
*/
public static HttpResponse getRequest(String strUrl, HttpMethod method, String strBody) {
HttpRequest request = new HttpRequest(strUrl);
HttpResponse response;
//request.setUrl(strUrl);
request.setMethod(Method.valueOf(method.name()));
request.body(strBody);
response = request.execute();
return response;
}
/**
* dcrenl: 2023-09-08 9:17:27
* Http get请求
* @param strUrl
* @return
*/
public static String httpGet(String strUrl) {
return getRequest(strUrl, HttpMethod.GET, "").body();
}
/**
* dcrenl: 2023-09-08 9:17:43
* Http post请求
* @param strUrl
* @param strBody
* @return
*/
public static String httpPost(String strUrl, String strBody) {
return getRequest(strUrl, HttpMethod.POST, strBody).body();
}
}

View File

@@ -0,0 +1,35 @@
package {{basePackage}}.utils.mail;
import lombok.Data;
/**
* Email文件配置
*/
@Data
public class MailConfig {
/**
* 邮件服务器的SMTP地址可选默认为smtp.<发件人邮箱后缀>
*/
private String host;
/**
* 邮件服务器的SMTP端口可选默认25
*/
private int port;
/**
* 发件人(必须正确,否则发送失败)
*/
private String from;
/**
* 用户名,默认为发件人邮箱前缀
*/
private String user;
/**
* # 密码注意某些邮箱需要为SMTP服务单独设置授权码详情查看相关帮助
*/
private String pass;
}

View File

@@ -0,0 +1,32 @@
package {{basePackage}}.utils.mail;
import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import javax.annotation.Resource;
/**
* dcrenl: 2023-09-07 14:56:27
* 邮件处理
*/
public class MailUtils {
public static MailConfig config = new MailConfig();
private static MailAccount account = new MailAccount();
;
public MailUtils() {
account.setHost(config.getHost());
account.setPort(config.getPort());
account.setAuth(true);
account.setFrom(config.getFrom());
account.setUser(config.getUser());
account.setPass(config.getPass());
}
public static void send(String to, String subject, String content, Boolean isHtml) {
MailUtil.send(account, to, subject, content, isHtml);
}
}

View File

@@ -0,0 +1,51 @@
package {{basePackage}}.utils.qrcode;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import java.awt.*;
import java.io.File;
/**
* dcrenl: 2023-09-07 16:58:7
* 二维码操作
*/
public class QrCodeUtils {
/**
* dcrenl: 2023-09-07 17:26:1
* 生成二维码
* @param width 宽度
* @param height 高度
* @param content 内容
* @param filePath 生成文件路径
* @return
*/
public static File createQr(int width, int height, String content, String filePath) {
QrConfig config = new QrConfig(width, height);
// 设置边距,既二维码和背景之间的边距
config.setMargin(3);
// 设置前景色,既二维码颜色(青色)
config.setForeColor(Color.BLACK.getRGB());
// 设置背景色(灰色)
config.setBackColor(Color.WHITE.getRGB());
// 生成二维码到文件,也可以到流
return QrCodeUtil.generate(content, config, FileUtil.file(filePath));
}
/**
* dcrenl: 2023-09-07 17:28:55
* 识别二维码
* @param file 二维码文件
* @return
*/
public static String decode(File file) {
return QrCodeUtil.decode(file);
}
}

View File

@@ -0,0 +1,268 @@
package {{basePackage}}.utils.redis;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
/**
* spring redis 工具类
*
* @author ruoyi
**/
@SuppressWarnings(value = { "unchecked", "rawtypes" })
@Component
public class RedisCache
{
@Autowired
public RedisTemplate redisTemplate;
/**
* 缓存基本的对象Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
*/
public <T> void setCacheObject(final String key, final T value)
{
redisTemplate.opsForValue().set(key, value);
}
/**
* 缓存基本的对象Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
*/
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
{
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param timeout 超时时间
* @return true=设置成功false=设置失败
*/
public boolean expire(final String key, final long timeout)
{
return expire(key, timeout, TimeUnit.SECONDS);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param timeout 超时时间
* @param unit 时间单位
* @return true=设置成功false=设置失败
*/
public boolean expire(final String key, final long timeout, final TimeUnit unit)
{
return redisTemplate.expire(key, timeout, unit);
}
/**
* 获取有效时间
*
* @param key Redis键
* @return 有效时间
*/
public long getExpire(final String key)
{
return redisTemplate.getExpire(key);
}
/**
* 判断 key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public Boolean hasKey(String key)
{
return redisTemplate.hasKey(key);
}
/**
* 获得缓存的基本对象。
*
* @param key 缓存键值
* @return 缓存键值对应的数据
*/
public <T> T getCacheObject(final String key)
{
ValueOperations<String, T> operation = redisTemplate.opsForValue();
return operation.get(key);
}
/**
* 删除单个对象
*
* @param key
*/
public boolean deleteObject(final String key)
{
return redisTemplate.delete(key);
}
/**
* 删除集合对象
*
* @param collection 多个对象
* @return
*/
public boolean deleteObject(final Collection collection)
{
return redisTemplate.delete(collection) > 0;
}
/**
* 缓存List数据
*
* @param key 缓存的键值
* @param dataList 待缓存的List数据
* @return 缓存的对象
*/
public <T> long setCacheList(final String key, final List<T> dataList)
{
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
return count == null ? 0 : count;
}
/**
* 获得缓存的list对象
*
* @param key 缓存的键值
* @return 缓存键值对应的数据
*/
public <T> List<T> getCacheList(final String key)
{
return redisTemplate.opsForList().range(key, 0, -1);
}
/**
* 缓存Set
*
* @param key 缓存键值
* @param dataSet 缓存的数据
* @return 缓存数据的对象
*/
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
{
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
Iterator<T> it = dataSet.iterator();
while (it.hasNext())
{
setOperation.add(it.next());
}
return setOperation;
}
/**
* 获得缓存的set
*
* @param key
* @return
*/
public <T> Set<T> getCacheSet(final String key)
{
return redisTemplate.opsForSet().members(key);
}
/**
* 缓存Map
*
* @param key
* @param dataMap
*/
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
{
if (dataMap != null) {
redisTemplate.opsForHash().putAll(key, dataMap);
}
}
/**
* 获得缓存的Map
*
* @param key
* @return
*/
public <T> Map<String, T> getCacheMap(final String key)
{
return redisTemplate.opsForHash().entries(key);
}
/**
* 往Hash中存入数据
*
* @param key Redis键
* @param hKey Hash键
* @param value 值
*/
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
{
redisTemplate.opsForHash().put(key, hKey, value);
}
/**
* 获取Hash中的数据
*
* @param key Redis键
* @param hKey Hash键
* @return Hash中的对象
*/
public <T> T getCacheMapValue(final String key, final String hKey)
{
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
return opsForHash.get(key, hKey);
}
/**
* 获取多个Hash中的数据
*
* @param key Redis键
* @param hKeys Hash键集合
* @return Hash对象集合
*/
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
{
return redisTemplate.opsForHash().multiGet(key, hKeys);
}
/**
* 删除Hash中的某条数据
*
* @param key Redis键
* @param hKey Hash键
* @return 是否成功
*/
public boolean deleteCacheMapValue(final String key, final String hKey)
{
return redisTemplate.opsForHash().delete(key, hKey) > 0;
}
/**
* 获得缓存的基本对象列表
*
* @param pattern 字符串前缀
* @return 对象列表
*/
public Collection<String> keys(final String pattern)
{
return redisTemplate.keys(pattern);
}
}

View File

@@ -0,0 +1,52 @@
package {{basePackage}}.utils.str;
import cn.hutool.extra.pinyin.PinyinUtil;
/**
* dcrenl: 2023-09-07 13:18:28
* 字符串处理
*/
public class strUtils {
/**
* dcrenl: 2023-09-07 13:18:46
* 获取字符串拼音全拼
* @param str
* @return
*/
public static String getPinyin(String str) {
return PinyinUtil.getPinyin(str);
}
/**
* dcrenl: 2023-09-07 13:18:46
* 获取字符串拼音全拼
* @param str
* @param separator 分割符
* @return
*/
public static String getPinyin(String str, String separator) {
return PinyinUtil.getPinyin(str, separator);
}
/**
* dcrenl: 2023-09-07 13:23:0
* 获取简拼
* @param str
* @return
*/
public static String getPY(String str) {
return PinyinUtil.getFirstLetter(str, "");
}
/**
* dcrenl: 2023-09-07 13:23:0
* 获取简拼
* @param str
* @param separator
* @return
*/
public static String getPY(String str, String separator) {
return PinyinUtil.getFirstLetter(str, separator);
}
}