";
-// System.out.println(EscapeUtil.clean(html));
-// System.out.println(EscapeUtil.escape(html));
-// System.out.println(EscapeUtil.unescape(html));
-// }
}
diff --git a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/ip/IpUtils.java b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/ip/IpUtils.java
index 87d22d5bf061ff6e3d37ab62319613bb90b9bca8..cc374aec9d18c03bc7a6e06743d663c12343e943 100644
--- a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/ip/IpUtils.java
+++ b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/ip/IpUtils.java
@@ -14,6 +14,11 @@ import java.net.UnknownHostException;
*/
public class IpUtils
{
+ /**
+ * 获取ip地址
+ * @param request
+ * @return
+ */
public static String getIpAddr(HttpServletRequest request)
{
if (request == null)
diff --git a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/Base64.java b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/Base64.java
index ec094db73c42eaf28c294438faa189d8db434e47..06b480cd57b6762aef7bbe6e92b8050892eb9736 100644
--- a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/Base64.java
+++ b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/Base64.java
@@ -3,7 +3,6 @@ package cn.chenc.framework.core.util.security;
/**
* Base64工具类
*
- * @author ruoyi
*/
public final class Base64 {
static private final int BASELENGTH = 128;
diff --git a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/RsaEncryptUtil.java b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/RsaEncryptUtil.java
index 97acb8771a915218f1df79168f69ec6fbce6fe5c..4e70afb1dd881172003007026ca766080dc5a92f 100644
--- a/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/RsaEncryptUtil.java
+++ b/secret-boot-framework-core/src/main/java/cn/chenc/framework/core/util/security/RsaEncryptUtil.java
@@ -18,13 +18,13 @@ import java.util.Map;
*
*/
public class RsaEncryptUtil {
- private static Map
keyMap = new HashMap(); //用于封装随机产生的公钥与私钥
+ private static Map keyMap = new HashMap(); //用于封装随机产生的公钥与私钥
//
/**
* 随机生成密钥对
* @throws NoSuchAlgorithmException
*/
- public static void genKeyPair() throws NoSuchAlgorithmException {
+ public static Map genKeyPair() throws NoSuchAlgorithmException {
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
// 初始化密钥对生成器,密钥大小为96-1024位
@@ -37,8 +37,9 @@ public class RsaEncryptUtil {
// 得到私钥字符串
String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded())));
// 将公钥和私钥保存到Map
- keyMap.put(0,publicKeyString); //0表示公钥
- keyMap.put(1,privateKeyString); //1表示私钥
+ keyMap.put("publicKey",publicKeyString);
+ keyMap.put("privateKey",privateKeyString);
+ return keyMap;
}
/**
* RSA公钥加密
@@ -51,7 +52,7 @@ public class RsaEncryptUtil {
* @throws Exception
* 加密过程中的异常信息
*/
- public static String encrypt( String str, String publicKey ) throws Exception{
+ public static String encryptByPublicKey( String str, String publicKey ) throws Exception{
//base64编码的公钥
byte[] decoded = Base64.decodeBase64(publicKey);
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
@@ -62,6 +63,40 @@ public class RsaEncryptUtil {
return outStr;
}
+ /**
+ * 公钥解密
+ *
+ * @param publicKeyString 公钥
+ * @param text 待解密的信息
+ * @return 解密后的文本
+ */
+ public static String decryptByPublicKey(String publicKeyString, String text) throws Exception {
+ X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyString));
+ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+ PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
+ Cipher cipher = Cipher.getInstance("RSA");
+ cipher.init(Cipher.DECRYPT_MODE, publicKey);
+ byte[] result = cipher.doFinal(Base64.decodeBase64(text));
+ return new String(result);
+ }
+
+ /**
+ * 私钥加密
+ *
+ * @param privateKeyString 私钥
+ * @param text 待加密的信息
+ * @return 加密后的文本
+ */
+ public static String encryptByPrivateKey(String privateKeyString, String text) throws Exception {
+ PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString));
+ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+ PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
+ Cipher cipher = Cipher.getInstance("RSA");
+ cipher.init(Cipher.ENCRYPT_MODE, privateKey);
+ byte[] result = cipher.doFinal(text.getBytes());
+ return Base64.encodeBase64String(result);
+ }
+
/**
* RSA私钥解密
*
diff --git a/secret-boot-framework-demo/common-demo/pom.xml b/secret-boot-framework-demo/common-demo/pom.xml
index 8e8f7300da24fb6b9547f4e22c1ddc66217fcdfe..4ecb17021ca387616952d2d71eebcd094960adcd 100644
--- a/secret-boot-framework-demo/common-demo/pom.xml
+++ b/secret-boot-framework-demo/common-demo/pom.xml
@@ -5,11 +5,10 @@
通用demo
-
4.0.0
-
+ com.gitee.secretopen
common-demo
-
+ 1.0-SNAPSHOT
@@ -108,6 +107,15 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
org.apache.maven.plugins
diff --git a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/SessionConfig.java b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/JwtConfig.java
similarity index 32%
rename from secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/SessionConfig.java
rename to secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/JwtConfig.java
index 8427ea0c30acdd85c70b818533e6fd7a8b0d9df0..ce68a5673916d7b9a95a09706ec3cf5578375c77 100644
--- a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/SessionConfig.java
+++ b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/JwtConfig.java
@@ -1,15 +1,25 @@
package cn.chenc.framework.demo.config;
+import cn.chenc.framework.core.component.JwtTemplate;
+import cn.chenc.framework.core.component.RedisJwtTemplate;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
/**
* @description: TODO
* @author secret
- * @date 2021/4/2 15:18
+ * @date 2021/4/28 17:31
*
*/
@Configuration
-@EnableRedisHttpSession
-public class SessionConfig {
+public class JwtConfig {
+
+ @Bean
+ public JwtTemplate securityJwtTemplate(){
+ JwtTemplate jwtTemplate = new RedisJwtTemplate();
+ return jwtTemplate;
+ }
+
+
+
}
diff --git a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/ThreadPoolConfig.java b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/ThreadPoolConfig.java
index 9ebcc114ed24f1d2612ecd62dbebc91d9316e597..7a032eca4940c8a0dbdd89fe2e696a9d755a6304 100644
--- a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/ThreadPoolConfig.java
+++ b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/ThreadPoolConfig.java
@@ -33,7 +33,7 @@ public class ThreadPoolConfig {
// 线程池维护线程所允许的空闲时间
private int keepAliveSeconds = 300;
- @Bean(name = "threadPoolTaskExecutor")
+ @Bean(name = {"threadPoolTaskExecutor"})
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(maxPoolSize);
diff --git a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/WebMvcConfig.java b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/WebMvcConfig.java
index f0a32413ccb91b0e76832181885bb52af67cf64d..225ec12533fcdb2d82eb1d1af90a6d1ef7f199a5 100644
--- a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/WebMvcConfig.java
+++ b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/config/WebMvcConfig.java
@@ -45,6 +45,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
.excludePathPatterns("/swagger-resources/**",
"/webjars/**", "/v2/**","swagger-ui.html",
"/swagger-ui.html/**",
+ "/static/**",
"/css/**",
"/data/**",
"/images/**",
@@ -54,21 +55,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
}
-
-
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/static/**")
+ registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
- registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
-
-
}
-
}
diff --git a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java
index df8146f1e45187b8707015ee972dd5923a371a6b..1a1f97200a5326289fe55395efe3123e5d3bbf2e 100644
--- a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java
+++ b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java
@@ -1,5 +1,7 @@
package cn.chenc.framework.demo.controller;
+import cn.chenc.framework.core.annotation.PreAuthorize;
+import cn.chenc.framework.core.model.response.AjaxResult;
import cn.chenc.framework.core.model.response.ResponseVO;
import cn.chenc.framework.core.model.response.ResultUtil;
import cn.chenc.framework.demo.entity.User;
@@ -65,5 +67,11 @@ public class UserController {
return ResultUtil.success(user);
}
+ @PreAuthorize(hasPermi = "test")
+ @GetMapping("/testPermission")
+ public AjaxResult testPermission(){
+ return AjaxResult.success();
+ }
+
}
diff --git a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/entity/User.java b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/entity/User.java
index 0573f1311c61cdb4e3fade9946639d2e1c6e3e64..eca74d95141515a3c9807b3e3d12e5581df940fa 100644
--- a/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/entity/User.java
+++ b/secret-boot-framework-demo/common-demo/src/main/java/cn/chenc/framework/demo/entity/User.java
@@ -1,6 +1,6 @@
package cn.chenc.framework.demo.entity;
-import cn.chenc.framework.mybatisplus.model.BaseConditionVO;
+import cn.chenc.framework.mybatisplus.model.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -17,7 +17,7 @@ import java.util.Date;
*
*/
@TableName("user")
-public class User extends BaseConditionVO implements Serializable {
+public class User extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/secret-boot-framework-demo/jpa-demo/pom.xml b/secret-boot-framework-demo/jpa-demo/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3c5319a524eddd3d16cdfda4602e3c2064ee3aba
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/pom.xml
@@ -0,0 +1,126 @@
+
+
+ 4.0.0
+
+ com.gitee.secretopen
+ jpa-demo
+ 1.0-SNAPSHOT
+
+
+
+
+ com.gitee.secretopen
+ secret-boot-framework-dependencies
+ 1.5.0
+ pom
+ import
+
+
+
+
+
+
+ com.gitee.secretopen
+ secret-boot-framework-core
+
+
+ com.gitee.secretopen
+ secret-boot-framework-jpa
+
+
+
+
+
+
+ dev
+
+ true
+
+
+ dev
+
+
+
+ ${project.artifactId}-${project.version}
+
+
+
+
+ test
+
+ test
+
+
+
+ ${project.artifactId}
+
+
+
+
+ prod
+
+ prod
+
+
+
+ ${project.artifactId}
+
+
+
+
+
+
+
+
+ src/main/resources
+
+ application*.yml
+
+
+
+ src/main/resources
+
+ true
+
+ application.yml
+ application-${profileActive}.yml
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ @
+
+ false
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ cn.chenc.framework.demo.CommonDemoApplication
+ JAR
+
+ false
+
+
+
+
+
+
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/JpaDemoApplication.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/JpaDemoApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a2a097adf37bc00923a1ac0944d5128475d61c7
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/JpaDemoApplication.java
@@ -0,0 +1,21 @@
+package cn.chenc.framework.demo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 14:07
+ *
+ */
+@SpringBootApplication
+@EnableTransactionManagement
+public class JpaDemoApplication {
+
+ public static void main(String[] args){
+ SpringApplication.run(JpaDemoApplication.class, args);
+ }
+
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java
new file mode 100644
index 0000000000000000000000000000000000000000..37a423ee92c5c76b0aac7586e3b1f1b8e2386e56
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/controller/UserController.java
@@ -0,0 +1,41 @@
+package cn.chenc.framework.demo.controller;
+
+import cn.chenc.framework.core.model.response.AjaxResult;
+import cn.chenc.framework.demo.entity.UserEntity;
+import cn.chenc.framework.demo.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 16:04
+ *
+ */
+@RestController
+@RequestMapping("/user")
+public class UserController {
+
+ @Autowired
+ private UserService userService;
+
+ @GetMapping("/all")
+ public List queryAll() {
+ return userService.queryAll();
+ }
+
+ @GetMapping("/list")
+ public Page queryUserPageList(UserEntity userEntity){
+ return userService.queryUserPageList(userEntity);
+ }
+
+ @PostMapping
+ public AjaxResult insertUser(@RequestBody UserEntity userEntity){
+ userService.insertUser(userEntity);
+ return AjaxResult.success();
+ }
+
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/dao/UserRepository.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/dao/UserRepository.java
new file mode 100644
index 0000000000000000000000000000000000000000..756c3baf146bb1a78db989d947a9f6cf93a32562
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/dao/UserRepository.java
@@ -0,0 +1,17 @@
+package cn.chenc.framework.demo.dao;
+
+import cn.chenc.framework.demo.entity.UserEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 15:26
+ *
+ */
+public interface UserRepository extends JpaRepository, JpaSpecificationExecutor {
+
+
+
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/entity/UserEntity.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/entity/UserEntity.java
new file mode 100644
index 0000000000000000000000000000000000000000..594090d1b5c9dec6dc6d89b72ca762ff06ef6187
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/entity/UserEntity.java
@@ -0,0 +1,92 @@
+package cn.chenc.framework.demo.entity;
+
+import cn.chenc.framework.jpa.model.BaseEntity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 14:51
+ *
+ */
+@Entity
+@Table(name = "user", schema = "secret_framework")
+public class UserEntity extends BaseEntity implements Serializable {
+
+ @Id
+ @Column(name = "id", nullable = false)
+ private Integer id;
+
+ @Basic
+ @Column(name = "username", nullable = true, length = 255)
+ private String username;
+
+ @Basic
+ @Column(name = "sex", nullable = true)
+ private Integer sex;
+
+ @Basic
+ @Column(name = "birthday", nullable = true)
+ private LocalDateTime birthday;
+
+ @Basic
+ @Column(name = "phone", nullable = true, length = 255)
+ private String phone;
+
+ @Basic
+ @Column(name = "email", nullable = true, length = 255)
+ private String email;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public Integer getSex() {
+ return sex;
+ }
+
+ public void setSex(Integer sex) {
+ this.sex = sex;
+ }
+
+ public LocalDateTime getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(LocalDateTime birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/UserService.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/UserService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d734cffe5fee833044d1df838fd2d8ea45627a54
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/UserService.java
@@ -0,0 +1,21 @@
+package cn.chenc.framework.demo.service;
+
+import cn.chenc.framework.demo.entity.UserEntity;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 15:45
+ *
+ */
+public interface UserService {
+
+ List queryAll();
+
+ Page queryUserPageList(UserEntity userEntity);
+
+ void insertUser(UserEntity userEntity);
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/impl/UserServiceImpl.java b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea759bc060c12cbda431a646257e1549d6a7b530
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/java/cn/chenc/framework/demo/service/impl/UserServiceImpl.java
@@ -0,0 +1,63 @@
+package cn.chenc.framework.demo.service.impl;
+
+import cn.chenc.framework.core.util.StringUtils;
+import cn.chenc.framework.demo.dao.UserRepository;
+import cn.chenc.framework.demo.entity.UserEntity;
+import cn.chenc.framework.demo.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description: TODO
+ * @author secret
+ * @date 2021/5/14 15:47
+ *
+ */
+@Service
+public class UserServiceImpl implements UserService {
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Override
+ public List queryAll() {
+ return userRepository.findAll();
+ }
+
+ @Override
+ public Page queryUserPageList(UserEntity userEntity) {
+ Pageable pageable = PageRequest.of(userEntity.getPageIndex()-1, userEntity.getPageSize());
+ Specification specification=new Specification() {
+ @Override
+ public Predicate toPredicate(Root root, CriteriaQuery> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+ List predicates = new ArrayList<>();
+ if(StringUtils.isNotEmpty(userEntity.getUsername())){
+ Predicate predicate = criteriaBuilder.equal(root.get("username").as(String.class),userEntity.getUsername());
+ predicates.add(predicate);
+ }
+ Predicate[] pre = predicates.toArray(new Predicate[predicates.size()]);
+ return criteriaQuery.where(pre).getRestriction();
+ }
+ };
+ return userRepository.findAll(specification,pageable);
+ }
+
+ @Override
+ @Transactional
+ public void insertUser(UserEntity userEntity) {
+ userRepository.save(userEntity);
+ }
+
+}
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/resources/application-dev.yml b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7b7de87fbed7d2d25ddecb8b3859858eeba381d7
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-dev.yml
@@ -0,0 +1,60 @@
+# Server settings
+server:
+ port: 8080
+ servlet:
+ context-path: /
+spring:
+ datasource:
+ druid:
+ connection-init-sqls: set names utf8mb4
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ initial-size: 5
+ min-idle: 5
+ max-active: 20
+ # 配置获取连接等待超时的时间
+ max-wait: 180000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ time-between-eviction-runs-millis: 180000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ min-evictable-idle-time-millis: 300000
+ test-while-idle: true
+ test-on-borrow: false
+ test-on-return: false
+ type: com.alibaba.druid.pool.DruidDataSource
+ url: jdbc:mysql://127.0.0.1:3306/secret_framework?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT&rewriteBatchedStatements=true
+ username: root
+ password: 111111
+ # Redis数据库索引(默认为0)
+ redis:
+ jedis:
+ pool:
+ # 连接池最大连接数(使用负值表示没有限制)
+ max-active: 8
+ # 连接池最大阻塞等待时间(使用负值表示没有限制)
+ max-wait: -1ms
+ # 连接池中的最大空闲连接
+ max-idle: 8
+ # 连接池中的最小空闲连接
+ min-idle: 0
+ # 连接超时时间(毫秒)
+ timeout: 5000ms
+ # 默认的数据过期时间
+ expire: 2592000
+ jpa:
+ properties:
+ hibernate:
+ hbm2ddl:
+ auto: update
+ dialect: org.hibernate.dialect.MySQL5InnoDBDialect
+ format_sql: true
+ show-sql: true
+
+#日志
+logging:
+ level:
+ root: info
+ org.hibernate.type.descriptor.sql.BasicBinder: trace
+# org.springframework.scheduling: INFO
+
+####################################自定义配置##########################################
+
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/resources/application-prod.yml b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-prod.yml
new file mode 100644
index 0000000000000000000000000000000000000000..058d19ed3478ad714af8ba8bea679974e7d50898
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-prod.yml
@@ -0,0 +1,50 @@
+# Server settings
+server:
+ port: 8080
+ servlet:
+ context-path: /
+spring:
+ datasource:
+ druid:
+ connection-init-sqls: set names utf8mb4
+ driver-class-name: com.mysql.jdbc.Driver
+ initial-size: 5
+ min-idle: 5
+ max-active: 20
+ # 配置获取连接等待超时的时间
+ max-wait: 180000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ time-between-eviction-runs-millis: 180000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ min-evictable-idle-time-millis: 300000
+ test-while-idle: true
+ test-on-borrow: false
+ test-on-return: false
+ type: com.alibaba.druid.pool.DruidDataSource
+ url: jdbc:mysql://127.0.0.1:3306/metadata?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true
+ username: root
+ password: 111111
+ # Redis数据库索引(默认为0)
+ redis:
+ jedis:
+ pool:
+ # 连接池最大连接数(使用负值表示没有限制)
+ max-active: 8
+ # 连接池最大阻塞等待时间(使用负值表示没有限制)
+ max-wait: -1ms
+ # 连接池中的最大空闲连接
+ max-idle: 8
+ # 连接池中的最小空闲连接
+ min-idle: 0
+ # 连接超时时间(毫秒)
+ timeout: 5000ms
+ # 默认的数据过期时间,主要用于shiro权限管理
+ expire: 2592000
+
+#日志
+logging:
+ level:
+ root: info
+
+####################################自定义配置##########################################
+
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/resources/application-test.yml b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-test.yml
new file mode 100644
index 0000000000000000000000000000000000000000..058d19ed3478ad714af8ba8bea679974e7d50898
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/resources/application-test.yml
@@ -0,0 +1,50 @@
+# Server settings
+server:
+ port: 8080
+ servlet:
+ context-path: /
+spring:
+ datasource:
+ druid:
+ connection-init-sqls: set names utf8mb4
+ driver-class-name: com.mysql.jdbc.Driver
+ initial-size: 5
+ min-idle: 5
+ max-active: 20
+ # 配置获取连接等待超时的时间
+ max-wait: 180000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ time-between-eviction-runs-millis: 180000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ min-evictable-idle-time-millis: 300000
+ test-while-idle: true
+ test-on-borrow: false
+ test-on-return: false
+ type: com.alibaba.druid.pool.DruidDataSource
+ url: jdbc:mysql://127.0.0.1:3306/metadata?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true
+ username: root
+ password: 111111
+ # Redis数据库索引(默认为0)
+ redis:
+ jedis:
+ pool:
+ # 连接池最大连接数(使用负值表示没有限制)
+ max-active: 8
+ # 连接池最大阻塞等待时间(使用负值表示没有限制)
+ max-wait: -1ms
+ # 连接池中的最大空闲连接
+ max-idle: 8
+ # 连接池中的最小空闲连接
+ min-idle: 0
+ # 连接超时时间(毫秒)
+ timeout: 5000ms
+ # 默认的数据过期时间,主要用于shiro权限管理
+ expire: 2592000
+
+#日志
+logging:
+ level:
+ root: info
+
+####################################自定义配置##########################################
+
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/resources/application.yml b/secret-boot-framework-demo/jpa-demo/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ef5e12ad03217802c468dee8a6759df6fb8851f9
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+# Server settings
+server:
+ # HTTP请求和响应头的最大量,以字节为单位,默认值为4096字节,超过此长度的部分不予处理,一般8K。解决java.io.EOFException: null问题
+ max-http-header-size: 8192
+ compression:
+ enabled: true
+ min-response-size: 1024
+ mime-types: text/plain,text/css,text/xml,text/javascript,application/json,application/javascript,application/xml,application/xml+rss,application/x-javascript,application/x-httpd-php,image/jpeg,image/gif,image/png
+ tomcat:
+ uri-encoding: UTF-8
+ remoteip:
+ remote-ip-header: X-Forwarded-for
+ protocol-header: X-Forwarded-Proto
+ remote:
+ port-header: X-Forwarded-Port
+ forward-headers-strategy: native
+spring:
+ main:
+ allow-bean-definition-overriding: false
+ application:
+ name: secret-boot-framework-demo
+# mvc:
+# throw-exception-if-no-handler-found: true
+# web:
+# resources:
+# add-mappings: false
+ profiles:
+ active: '@profileActive@'
+#日志
+logging:
+ file:
+ path: ./logs
diff --git a/secret-boot-framework-demo/jpa-demo/src/main/resources/logback-spring.xml b/secret-boot-framework-demo/jpa-demo/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f8c21c4fc830db1d562ef56d70a98aa47f5db56f
--- /dev/null
+++ b/secret-boot-framework-demo/jpa-demo/src/main/resources/logback-spring.xml
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
+
+
+ logback
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ trace
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+ UTF-8
+
+
+
+
+
+
+
+
+
+ ${log.path}/log_debug.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ debug
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/log_info.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ info
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/log_warn.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ warn
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+ ${log.path}/log_error.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/secret-boot-framework-demo/pom.xml b/secret-boot-framework-demo/pom.xml
deleted file mode 100644
index 9fe0ec35a0f1be788a6ef795d10fd909e921da2e..0000000000000000000000000000000000000000
--- a/secret-boot-framework-demo/pom.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- 4.0.0
-
- secret-boot-framework-demo
-
- demo案例
-
-
diff --git a/secret-boot-framework-demo/security-demo/pom.xml b/secret-boot-framework-demo/security-demo/pom.xml
index 9964448d6808c1b0caa9288f37351e6a06e2154d..be2a508da1e7dee816e7bf031fd8081bb0dd1794 100644
--- a/secret-boot-framework-demo/security-demo/pom.xml
+++ b/secret-boot-framework-demo/security-demo/pom.xml
@@ -4,6 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+ security-demo
com.gitee.secretopen
security-demo
1.0-SNAPSHOT
diff --git a/secret-boot-framework-demo/security-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java b/secret-boot-framework-demo/security-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
index 453a2fb71062409dbaa88102b30b6fc4eb2c2ff0..4703a18ff9d5441f137815a499da72c05935ace6 100644
--- a/secret-boot-framework-demo/security-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
+++ b/secret-boot-framework-demo/security-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
@@ -9,10 +9,12 @@ import cn.chenc.framework.demo.entity.User;
import cn.chenc.framework.security.jwt.SecurityJwtTemplate;
import cn.chenc.framework.security.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -59,4 +61,10 @@ public class LoginController {
return AjaxResult.success(loginUser);
}
+ @PreAuthorize("@ss.hasPermi('test')")
+ @GetMapping("/test")
+ public AjaxResult testPermission(){
+ return AjaxResult.success();
+ }
+
}
diff --git a/secret-boot-framework-demo/shiro-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java b/secret-boot-framework-demo/shiro-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
index 3805bdac2e57660950be7c2dd35f4908694a5483..403dbcb1e25615952e77c3d9235c93b9a9ec0687 100644
--- a/secret-boot-framework-demo/shiro-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
+++ b/secret-boot-framework-demo/shiro-demo/src/main/java/cn/chenc/framework/demo/controller/LoginController.java
@@ -73,4 +73,11 @@ public class LoginController {
return AjaxResult.success();
}
+ @ResponseBody
+ @GetMapping("/exception")
+ public AjaxResult exception() throws Exception{
+ throw new Exception();
+ }
+
+
}
diff --git a/secret-boot-framework-dependencies/pom.xml b/secret-boot-framework-dependencies/pom.xml
index a54daf729b4a3241866431f3666100767546598c..bf1aadacb0b491e4e80de60529c910b482305d8a 100644
--- a/secret-boot-framework-dependencies/pom.xml
+++ b/secret-boot-framework-dependencies/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.4.3
+ 2.4.5
4.0.0
@@ -15,35 +15,43 @@
pom
secret-boot-framework-dependencies
+ secret-boot-framework-dependencies
+ https://gitee.com/SecretOpen/secret-boot-framework
+
1.8
1.5.0
2.4.3.RELEASE
- 1.1.21
- 8.0.16
+ 1.2.6
+ 8.0.25
2.8.0
1.4
1.9
3.8.0
- 1.10.9
+ 1.10.10
4.5.13
4.9.1
- 1.18.16
+ 1.18.20
3.0.0
- 30.1-jre
+ 30.1.1-jre
3.4.2
1.13.1
1.21
- 1.0.0-alpha
0.62.2
- 5.5.9
- 2.2.6
+ 5.6.5
+ 2.2.9
0.9.1
1.7.1
+
+ 3.15.4
+
+ 3.2.1
+ 2.9.1
+ 1.6
@@ -121,12 +129,6 @@
okhttp
${okhttp.version}
-
-
- me.zhyd.braum.spring.boot
- braum-spring-boot-starter
- ${braum.version}
-
commons-fileupload
@@ -240,7 +242,132 @@
shiro-spring
${shiro.version}
+
+
+ org.redisson
+ redisson-spring-boot-starter
+ ${redisson.version}
+
+
+
+ Apache License, Version 2.0
+ https://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+ scm:git@gitee.com:SecretOpen/secret-boot-framework.git
+ scm:git@gitee.com:SecretOpen/secret-boot-framework.git
+ git@gitee.com:SecretOpen/secret-boot-framework.git
+
+
+
+
+ secretC
+ 1029693356@qq.com
+ https://gitee.com/SecretOpen
+
+
+
+
+
+
+
+ release
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ ${maven-source-plugin.version}
+
+
+ package
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${maven-javadoc-plugin.version}
+
+ -Xdoclint:none
+
+
+
+ package
+
+ jar
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ ${maven-gpg-plugin.version}
+
+
+
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+
+ sonatype
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+
+ sonatype
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+ true
+
+
+
+
+
+
+ ${project.artifactId}
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ ${java.version}
+ ${java.version}
+ UTF-8
+
+
+
+
+
diff --git a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/config/CustomerDefaultConverterLoader.java b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/config/CustomerDefaultConverterLoader.java
index df7bccf26f800c516f05d05db795fd63db59115a..80d562b694d67faad52b5d1f0672a502c7aa6567 100644
--- a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/config/CustomerDefaultConverterLoader.java
+++ b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/config/CustomerDefaultConverterLoader.java
@@ -89,7 +89,7 @@ public class CustomerDefaultConverterLoader {
private void setConverter(DefaultConverterLoader converters, Field field) throws IllegalAccessException {
if (WRITE_CONVERTER.equalsIgnoreCase(field.getName())) {
Map map = new HashMap<>(32);
- //我的LocalDateTimeConverter
+ //我们扩展的自定义转化器
putWriteConverter(map, new LocalDateTimeConverter());
putAllConverter(map,new NumberToLocalDateTimeConverter());
//以下jar包自带的Converter
@@ -111,7 +111,7 @@ public class CustomerDefaultConverterLoader {
field.set(converters, map);
} else if (ALL_CONVERTER.equalsIgnoreCase(field.getName())) {
Map map = new HashMap<>(64);
- //我的LocalDateTimeConverter
+ //我们扩展的自定义转化器
putAllConverter(map, new LocalDateTimeConverter());
putAllConverter(map,new NumberToLocalDateTimeConverter());
//以下jar包自带的Converter
diff --git a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/LocalDateTimeConverter.java b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/LocalDateTimeConverter.java
index b817bd9a9e8eb8ea9ad6fd8b0fee8b6b7f723e26..5d360a4163994b44f6cf5d5537499d7dd0ceab05 100644
--- a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/LocalDateTimeConverter.java
+++ b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/LocalDateTimeConverter.java
@@ -14,7 +14,7 @@ import java.time.format.DateTimeFormatter;
import java.util.Objects;
/**
- * @description: TODO
+ * @description: 自定义转化器,将String转化为LocalDateTime
* @author 陈_C
* @date 2020/8/26 16:32
*
diff --git a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/NumberToLocalDateTimeConverter.java b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/NumberToLocalDateTimeConverter.java
index b342f156bf4021b9cb31bfa8c71f87e273f701a2..e587381d0773dd437ab13dc2110134d11ec2c68a 100644
--- a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/NumberToLocalDateTimeConverter.java
+++ b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/converters/NumberToLocalDateTimeConverter.java
@@ -18,7 +18,7 @@ import java.util.GregorianCalendar;
import java.util.Objects;
/**
- * @description: TODO
+ * @description: 自定义转化器,将Number转化为LocalDateTime
* @author 陈_C
* @date 2020/8/26 16:32
*
@@ -59,7 +59,7 @@ public class NumberToLocalDateTimeConverter implements Converter
DateTimeFormat annotation = contentProperty.getField().getAnnotation(DateTimeFormat.class);
// LocalDate localDate = LocalDate.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern(Objects.nonNull(annotation) ? annotation.value() : READ_PATTERN));
// LocalDateTime localDateTime = localDate.atStartOfDay();
-
+ //excel中日期是从1900/00/00开始,日期类型数据格式实际上是与1900/00/00之间的天数差
Calendar calendar = new GregorianCalendar(1900,0,0);
Date gregorianDate = calendar.getTime();
String formatExcelDate = DateUtils.format(DateUtils.addDay(gregorianDate, Integer.parseInt(cellData.getNumberValue().toString())), DateUtils.YYYYMMDD);
diff --git a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/listener/ExcelListener.java b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/listener/ExcelListener.java
index 35b24e9f0df574a07521b3b96c5cf4540a2d5115..4bddb5b4e0d106116f155d060abaeee648fe7bf4 100644
--- a/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/listener/ExcelListener.java
+++ b/secret-boot-framework-excel/src/main/java/cn/chenc/framework/excel/listener/ExcelListener.java
@@ -2,6 +2,7 @@ package cn.chenc.framework.excel.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
+import org.apache.poi.ss.formula.functions.T;
import java.util.ArrayList;
import java.util.List;
@@ -15,14 +16,31 @@ import java.util.List;
public class ExcelListener extends AnalysisEventListener {
//可以通过实例获取该值
private List