From 55f2cdcc58e36210f0c6be9c93488bf37d1c8f5e Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期四, 20 三月 2025 09:34:16 +0800
Subject: [PATCH] 高级安全防护
---
src/main/resources/application.properties | 13 ++++++++++---
src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java | 3 +++
src/main/java/com/jsh/erp/controller/ConfigSecurityController.java | 12 ++++++++----
src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java | 3 ++-
src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java | 24 +++++++++++++++++++++++-
5 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java b/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java
index c0252e1..f50d4e5 100644
--- a/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java
+++ b/src/main/java/com/jsh/erp/controller/ConfigSecurityController.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
import com.jsh.erp.datasource.entities.SysDict;
import com.jsh.erp.dto.ConfigSecurityCreateOrUpdate;
import com.jsh.erp.dto.ConfigSecurityQuery;
@@ -83,10 +84,13 @@
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
- List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery);
- Long total = configSecurityService.findListCount(configSecurityQuery);
- map.put("total", total);
- map.put("rows", dataList);
+// List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery);
+// Long total = configSecurityService.findListCount(configSecurityQuery);
+// map.put("total", total);
+// map.put("rows", dataList);
+ PageInfo<ConfigSecurity> pageInfo =configSecurityService.findPageInfo(configSecurityQuery);
+ map.put("total",pageInfo.getTotal());
+ map.put("rows",pageInfo.getList());
res.code = 200;
res.data = map;
} catch(Exception e){
diff --git a/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java b/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java
index 1057621..84e6e64 100644
--- a/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java
+++ b/src/main/java/com/jsh/erp/dto/ConfigSecurityCreateOrUpdate.java
@@ -7,6 +7,7 @@
import javax.validation.constraints.Max;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
@Data
@NoArgsConstructor
@@ -16,7 +17,7 @@
private Long id;
@NotEmpty(message = "关键字不能为空")
- @Max(value = 50, message = "关键字长度不能超过50")
+ @Size(max = 50, message = "关键字长度不能超过50")
private String keyword;
@NotEmpty(message = "类型不能为空")
diff --git a/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java b/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java
index 2070ed0..cecc4d4 100644
--- a/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java
+++ b/src/main/java/com/jsh/erp/service/configSecurity/ConfigSecurityService.java
@@ -1,5 +1,6 @@
package com.jsh.erp.service.configSecurity;
+import com.github.pagehelper.PageInfo;
import com.jsh.erp.datasource.entities.ConfigSecurity;
import com.jsh.erp.dto.ConfigSecurityQuery;
@@ -21,4 +22,6 @@
int deleteBatch(String ids);
int batchSetStatus(Integer status, String ids) throws Exception;
+
+ PageInfo<ConfigSecurity> findPageInfo(ConfigSecurityQuery configSecurityQuery);
}
diff --git a/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java b/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java
index 45d1a62..7497e33 100644
--- a/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java
+++ b/src/main/java/com/jsh/erp/service/configSecurity/impl/ConfigSecurityServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.ConfigSecurity;
import com.jsh.erp.datasource.entities.ConfigSecurityExample;
@@ -53,7 +54,7 @@
@Override
public List<ConfigSecurity> findList(ConfigSecurityQuery configSecurityQuery) {
// 设置分页参数
- PageHelper.startPage(configSecurityQuery.getCurrentPage()-1, configSecurityQuery.getPageSize());
+
ConfigSecurityExample example = new ConfigSecurityExample();
ConfigSecurityExample.Criteria criteria = example.createCriteria();
@@ -67,6 +68,7 @@
example.setOrderByClause(" create_time desc ");
+ PageHelper.startPage(configSecurityQuery.getCurrentPage(), configSecurityQuery.getPageSize());
return configSecurityMapper.selectByExample(example);
}
@@ -155,5 +157,25 @@
return result;
}
+ @Override
+ public PageInfo<ConfigSecurity> findPageInfo(ConfigSecurityQuery configSecurityQuery) {
+ ConfigSecurityExample example = new ConfigSecurityExample();
+ ConfigSecurityExample.Criteria criteria = example.createCriteria();
+ criteria.andDeleteFlagEqualTo(false);
+ if (StringUtils.isNotEmpty(configSecurityQuery.getKeyword())) {
+ criteria.andKeywordLike("%" + configSecurityQuery.getKeyword() + "%");
+ }
+ if (StringUtils.isNotEmpty(configSecurityQuery.getType())) {
+ criteria.andTypeEqualTo(configSecurityQuery.getType());
+ }
+
+ example.setOrderByClause(" create_time desc ");
+
+ PageHelper.startPage(configSecurityQuery.getCurrentPage(), configSecurityQuery.getPageSize());
+ List<ConfigSecurity> list = configSecurityMapper.selectByExample(example);
+ return new PageInfo<>(list);
+
+ }
+
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index eb77fa7..56e209c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -10,11 +10,13 @@
spring.datasource.password=CloudRoam
#mybatis-plus配置
mybatis-plus.mapper-locations=classpath:./mapper_xml/*.xml
+
+
# Redis
#spring.redis.host=192.168.1.235
-spring.redis.host=localhost
+spring.redis.host=192.168.1.235
spring.redis.port=6379
-#spring.redis.password=123456
+spring.redis.password=123456
#租户对应的角色id
manage.roleId=10
#租户允许创建的用户数
@@ -40,4 +42,9 @@
volc.sms.secret-key= your-volc-secret-key # ???SecretKey
volc.sms.region= cn-north-1 # ??????????
volc.sms.sign-name= ????? # ????
-volc.sms.template-id= SMS_1234567890 # ????ID
\ No newline at end of file
+volc.sms.template-id= SMS_1234567890 # ????ID
+
+pagehelper.helper-dialect=mysql
+pagehelper.reasonable=true
+pagehelper.support-methods-arguments=true
+pagehelper.params=count=countSql
\ No newline at end of file
--
Gitblit v1.9.3