好使版本

This commit is contained in:
1378012178@qq.com 2025-03-11 15:32:19 +08:00
parent d2f00ea4e7
commit 7ad0dc8a7f
22 changed files with 76 additions and 799 deletions

View File

@ -1,52 +0,0 @@
version: '2'
services:
jeecg-boot-mysql:
build:
context: ./db
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: '%'
TZ: Asia/Shanghai
restart: always
container_name: jeecg-boot-mysql
image: jeecg-boot-mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
--default-authentication-plugin=caching_sha2_password
ports:
- 3306:3306
networks:
- jeecg-boot
jeecg-boot-redis:
image: registry.cn-hangzhou.aliyuncs.com/jeecgdocker/redis:5.0
ports:
- 6379:6379
restart: always
hostname: jeecg-boot-redis
container_name: jeecg-boot-redis
networks:
- jeecg-boot
jeecg-boot-system:
build:
context: ./jeecg-module-system/jeecg-system-start
restart: on-failure
depends_on:
- jeecg-boot-mysql
- jeecg-boot-redis
container_name: jeecg-boot-system
image: jeecg-boot-system
hostname: jeecg-boot-system
ports:
- 8080:8080
networks:
- jeecg-boot
networks:
jeecg-boot:
name: jeecg_boot

View File

@ -2,7 +2,7 @@
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">
<parent>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-parent</artifactId>
<version>2.0.0</version>
</parent>

View File

@ -109,7 +109,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
filterChainDefinitionMap.put("/testDictType/abc", "anon");//TODO 待删除
//update-begin--Author:scott Date:20221116 for排除静态资源后缀
filterChainDefinitionMap.put("/", "anon");

View File

@ -0,0 +1,22 @@
<?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">
<parent>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-parent</artifactId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nursing-unit-config</artifactId>
<dependencies>
<dependency>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-base-core</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,25 @@
package org.jeecg.modules.demo.cloud.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*/
@RestController
@RequestMapping("/testDictType")
public class DictTypeController {
/**
* 测试
*
* @return
*/
@GetMapping("/abc")
public void abc() {
System.out.println(12313);
}
}

View File

@ -13,8 +13,9 @@
<dependencies>
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-base-core</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nu-system-api</artifactId>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nursing-unit-system</artifactId>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -18,7 +18,7 @@
<dependencies>
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-base-core</artifactId>
</dependency>
</dependencies>

View File

@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nursing-unit-system</artifactId>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -12,7 +12,7 @@
<dependencies>
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nu-system-local-api</artifactId>
<version>${nursingunit.version}</version>
</dependency>
@ -30,6 +30,7 @@
<groupId>org.jeecgframework</groupId>
<artifactId>weixin4j</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nursing-unit-system</artifactId>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -14,16 +14,23 @@
<dependencies>
<!-- SYSTEM 系统管理模块 -->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nu-system-biz</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!-- DEMO 示例模块 -->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-demo</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!-- config 示例模块 -->
<dependency>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-config</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!-- flyway 数据库自动升级 -->
<dependency>

View File

@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
@ -18,7 +19,7 @@ import java.util.Map;
* 单体启动类
*/
@Slf4j
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.nu","org.jeecg"})
public class NUSystemApplication extends SpringBootServletInitializer {
@Override

View File

@ -300,6 +300,7 @@ logging:
level:
org.flywaydb: debug
org.jeecg.modules.system.mapper: info
#swagger
knife4j:
#开启增强配置

View File

@ -1,47 +0,0 @@
//package org.jeecg;
//
//import com.alibaba.fastjson.JSONObject;
//import org.jeecg.common.util.RestUtil;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//
///**
// * @Description: TODO
// * @author: scott
// * @date: 2022年05月10日 14:02
// */
//public class TestMain {
// public static void main(String[] args) {
// // 请求地址
// String url = "https://api.boot.jeecg.com/sys/user/list";
// // 请求 Header 用于传递Token
// HttpHeaders headers = getHeaders();
// // 请求方式是 GET 代表获取数据
// HttpMethod method = HttpMethod.GET;
//
// System.out.println("请求地址:" + url);
// System.out.println("请求方式:" + method);
//
// // 利用 RestUtil 请求该url
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
// if (result != null && result.getBody() != null) {
// System.out.println("返回结果:" + result.getBody().toJSONString());
// } else {
// System.out.println("查询失败");
// }
// }
// private static HttpHeaders getHeaders() {
// String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.50h-g6INOZRVnznExiawFb1U6PPjcVVA4POeYRA5a5Q";
// System.out.println("请求Token" + token);
//
// HttpHeaders headers = new HttpHeaders();
// String mediaType = MediaType.APPLICATION_JSON_VALUE;
// headers.setContentType(MediaType.parseMediaType(mediaType));
// headers.set("Accept", mediaType);
// headers.set("X-Access-Token", token);
// return headers;
// }
//
//}

View File

@ -1,139 +0,0 @@
package org.jeecg.modules.message.test;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;
import org.jeecg.NUSystemApplication;
import org.jeecg.common.api.dto.message.BusMessageDTO;
import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.enums.DySmsEnum;
import org.jeecg.common.constant.enums.EmailTemplateEnum;
import org.jeecg.common.constant.enums.MessageTypeEnum;
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.util.DySmsHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
import java.util.Map;
/**
* @Description: 消息推送测试
* @Author: lsq
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = NUSystemApplication.class)
public class SendMessageTest {
@Autowired
ISysBaseAPI sysBaseAPI;
/**
* 发送系统消息
*/
@Test
public void sendSysAnnouncement() {
//发送人
String fromUser = "admin";
//接收人
String toUser = "jeecg";
//标题
String title = "系统消息";
//内容
String msgContent = "TEST:今日份日程计划已送达!";
//发送系统消息
sysBaseAPI.sendSysAnnouncement(new MessageDTO(fromUser, toUser, title, msgContent));
//消息类型
String msgCategory = CommonConstant.MSG_CATEGORY_1;
//业务类型
String busType = SysAnnmentTypeEnum.EMAIL.getType();
//业务ID
String busId = "11111";
//发送带业务参数的系统消息
BusMessageDTO busMessageDTO = new BusMessageDTO(fromUser, toUser, title, msgContent, msgCategory, busType,busId);
sysBaseAPI.sendBusAnnouncement(busMessageDTO);
}
/**
* 发送模版消息
*/
@Test
public void sendTemplateAnnouncement() {
//发送人
String fromUser = "admin";
//接收人
String toUser = "jeecg";
//标题
String title = "通知公告";
//模版编码
String templateCode = "412358";
//模版参数
Map templateParam = new HashMap<>();
templateParam.put("realname","JEECG用户");
sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser,toUser,title,templateParam,templateCode));
//业务类型
String busType = SysAnnmentTypeEnum.EMAIL.getType();
//业务ID
String busId = "11111";
//发送带业务参数的模版消息
BusTemplateMessageDTO busMessageDTO = new BusTemplateMessageDTO(fromUser, toUser, title, templateParam ,templateCode, busType,busId);
sysBaseAPI.sendBusTemplateAnnouncement(busMessageDTO);
//新发送模版消息
MessageDTO messageDTO = new MessageDTO();
messageDTO.setType(MessageTypeEnum.XT.getType());
messageDTO.setToAll(false);
messageDTO.setToUser(toUser);
messageDTO.setTitle("【流程错误】");
messageDTO.setFromUser("admin");
HashMap data = new HashMap<>();
data.put(CommonConstant.NOTICE_MSG_BUS_TYPE, "msg_node");
messageDTO.setData(data);
messageDTO.setContent("TEST:流程执行失败!任务节点未找到");
sysBaseAPI.sendTemplateMessage(messageDTO);
}
/**
* 发送邮件
*/
@Test
public void sendEmailMsg() {
String title = "【日程提醒】您的日程任务即将开始";
String content = "TEST:尊敬的王先生您购买的演唱会将于本周日1008分在国家大剧院如期举行届时请携带好您的门票和身份证到场";
String email = "250678106@qq.com";
sysBaseAPI.sendEmailMsg(email,title,content);
}
/**
* 发送html模版邮件
*/
@Test
public void sendTemplateEmailMsg() {
String title = "收到一个催办";
String email = "250678106@qq.com";
JSONObject params = new JSONObject();
params.put("bpm_name","高级设置");
params.put("bpm_task","审批人");
params.put("datetime","2023-10-07 18:00:49");
params.put("url","http://boot3.jeecg.com/message/template");
params.put("remark","快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点");
sysBaseAPI.sendHtmlTemplateEmail(email,title, EmailTemplateEnum.BPM_CUIBAN_EMAIL,params);
}
/**
* 发送短信
*/
@Test
public void sendSms() throws ClientException {
//手机号
String mobile = "159***";
//消息模版
DySmsEnum templateCode = DySmsEnum.LOGIN_TEMPLATE_CODE;
//模版所需参数
JSONObject obj = new JSONObject();
obj.put("code", "4XDP");
DySmsHelper.sendSms(mobile, obj, templateCode);
}
}

View File

@ -1,86 +0,0 @@
package org.jeecg.modules.system.test;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.NUSystemApplication;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.RestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 系统用户单元测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = NUSystemApplication.class)
public class InsertDemoTest {
/**
* 测试地址实际使用时替换成你自己的地址
*/
private final String BASE_URL = "http://localhost:8080/jeecg-boot//test/jeecgDemo/";
//测试用户名和密码
private final String USERNAME = "admin";
private final String PASSWORD = "123456";
@Autowired
private RedisUtil redisUtil;
/**
* 测试用例新增
*/
@Test
public void testAdd() {
// 请求地址
String url = BASE_URL + "add" ;
// 请求 Header 用于传递Token
HttpHeaders headers = this.getHeaders();
// 请求方式是 POST 代表提交新增数据
HttpMethod method = HttpMethod.POST;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
for (int i = 0; i < 100; i++) {
String name = "李哈哈" + i;
JSONObject params = new JSONObject();
params.put("name", name);
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
}
private String getToken() {
String token = JwtUtil.sign(USERNAME, PASSWORD);
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 60);
return token;
}
private HttpHeaders getHeaders() {
String token = this.getToken();
System.out.println("请求Token" + token);
HttpHeaders headers = new HttpHeaders();
String mediaType = MediaType.APPLICATION_JSON_VALUE;
headers.setContentType(MediaType.parseMediaType(mediaType));
headers.set("Accept", mediaType);
headers.set("X-Access-Token", token);
return headers;
}
}

View File

@ -1,65 +0,0 @@
package org.jeecg.modules.system.test;
import org.jeecg.NUSystemApplication;
import org.jeecg.modules.demo.mock.MockController;
import org.jeecg.modules.demo.test.entity.JeecgDemo;
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
import org.jeecg.modules.system.service.ISysDataLogService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = NUSystemApplication.class)
public class SampleTest {
@Resource
private JeecgDemoMapper jeecgDemoMapper;
@Resource
private IJeecgDemoService jeecgDemoService;
@Resource
private ISysDataLogService sysDataLogService;
@Resource
private MockController mock;
@Test
public void testSelect() {
System.out.println(("----- selectAll method test ------"));
List<JeecgDemo> userList = jeecgDemoMapper.selectList(null);
Assert.assertEquals(5, userList.size());
userList.forEach(System.out::println);
}
@Test
public void testXmlSql() {
System.out.println(("----- selectAll method test ------"));
List<JeecgDemo> userList = jeecgDemoMapper.getDemoByName("Sandy12");
userList.forEach(System.out::println);
}
/**
* 测试事务
*/
@Test
public void testTran() {
jeecgDemoService.testTran();
}
/**
* 测试数据日志添加
*/
@Test
public void testDataLogSave() {
System.out.println(("----- datalog test ------"));
String tableName = "jeecg_demo";
String dataId = "4028ef81550c1a7901550c1cd6e70001";
String dataContent = mock.sysDataLogJson();
sysDataLogService.addDataLog(tableName, dataId, dataContent);
}
}

View File

@ -1,89 +0,0 @@
package org.jeecg.modules.system.test;
import org.jeecg.NUSystemApplication;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.config.JeecgBaseConfig;
import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @Description: 系统表白名单测试
* @Author: sunjianlei
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = NUSystemApplication.class)
public class SysTableWhiteCheckTest {
@Autowired
IDictTableWhiteListHandler whiteListHandler;
@Autowired
ISysBaseAPI sysBaseAPI;
@Autowired
JeecgBaseConfig jeecgBaseConfig;
@Before
public void before() {
String lowCodeMode = this.jeecgBaseConfig.getFirewall().getLowCodeMode();
System.out.println("当前 LowCode 模式为: " + lowCodeMode);
// 清空缓存防止影响测试
whiteListHandler.clear();
}
@Test
public void testSql() {
System.out.println("=== 开始测试 SQL 方式 ===");
String[] sqlArr = new String[]{
"select username from sys_user",
"select username, CONCAT(realname, SEX) from SYS_USER",
"select username, CONCAT(realname, sex) from sys_user",
};
for (String sql : sqlArr) {
System.out.println("- 测试Sql: " + sql);
try {
sysBaseAPI.dictTableWhiteListCheckBySql(sql);
System.out.println("-- 测试通过");
} catch (Exception e) {
System.out.println("-- 测试未通过: " + e.getMessage());
}
}
System.out.println("=== 结束测试 SQL 方式 ===");
}
@Test
public void testDict() {
System.out.println("=== 开始测试 DICT 方式 ===");
String table = "sys_user";
String code = "username";
String text = "realname";
this.testDict(table, code, text);
table = "sys_user";
code = "username";
text = "CONCAT(realname, sex)";
this.testDict(table, code, text);
table = "SYS_USER";
code = "username";
text = "CONCAT(realname, SEX)";
this.testDict(table, code, text);
System.out.println("=== 结束测试 DICT 方式 ===");
}
private void testDict(String table, String code, String text) {
try {
sysBaseAPI.dictTableWhiteListCheckByDict(table, code, text);
System.out.println("- 测试通过");
} catch (Exception e) {
System.out.println("- 测试未通过: " + e.getMessage());
}
}
}

View File

@ -1,177 +0,0 @@
package org.jeecg.modules.system.test;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.NUSystemApplication;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.RestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 系统用户单元测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = NUSystemApplication.class)
public class SysUserTest {
/**
* 测试地址实际使用时替换成你自己的地址
*/
private final String BASE_URL = "http://localhost:8080/jeecg-boot/sys/user/";
//测试用户名和密码
private final String USERNAME = "admin";
private final String PASSWORD = "123456";
@Autowired
private RedisUtil redisUtil;
/**
* 测试用例查询记录
*/
@Test
public void testQuery() {
// 请求地址
String url = BASE_URL + "list";
// 请求 Header 用于传递Token
HttpHeaders headers = this.getHeaders();
// 请求方式是 GET 代表获取数据
HttpMethod method = HttpMethod.GET;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
// 利用 RestUtil 请求该url
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
/**
* 测试用例新增
*/
@Test
public void testAdd() {
// 请求地址
String url = BASE_URL + "add" ;
// 请求 Header 用于传递Token
HttpHeaders headers = this.getHeaders();
// 请求方式是 POST 代表提交新增数据
HttpMethod method = HttpMethod.POST;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
JSONObject params = new JSONObject();
params.put("username", "wangwuTest");
params.put("password", "123456");
params.put("confirmpassword","123456");
params.put("realname", "单元测试");
params.put("activitiSync", "1");
params.put("userIdentity","1");
params.put("workNo","0025");
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
/**
* 测试用例修改
*/
@Test
public void testEdit() {
// 数据Id
String dataId = "1331795062924374018";
// 请求地址
String url = BASE_URL + "edit";
// 请求 Header 用于传递Token
HttpHeaders headers = this.getHeaders();
// 请求方式是 PUT 代表提交修改数据
HttpMethod method = HttpMethod.PUT;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
JSONObject params = new JSONObject();
params.put("username", "wangwuTest");
params.put("realname", "单元测试1111");
params.put("activitiSync", "1");
params.put("userIdentity","1");
params.put("workNo","0025");
params.put("id",dataId);
System.out.println("请求参数:" + params.toJSONString());
// 利用 RestUtil 请求该url
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
/**
* 测试用例删除
*/
@Test
public void testDelete() {
// 数据Id
String dataId = "1331795062924374018";
// 请求地址
String url = BASE_URL + "delete" + "?id=" + dataId;
// 请求 Header 用于传递Token
HttpHeaders headers = this.getHeaders();
// 请求方式是 DELETE 代表删除数据
HttpMethod method = HttpMethod.DELETE;
System.out.println("请求地址:" + url);
System.out.println("请求方式:" + method);
// 利用 RestUtil 请求该url
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
if (result != null && result.getBody() != null) {
System.out.println("返回结果:" + result.getBody().toJSONString());
} else {
System.out.println("查询失败");
}
}
private String getToken() {
String token = JwtUtil.sign(USERNAME, PASSWORD);
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 60);
return token;
}
private HttpHeaders getHeaders() {
String token = this.getToken();
System.out.println("请求Token" + token);
HttpHeaders headers = new HttpHeaders();
String mediaType = MediaType.APPLICATION_JSON_VALUE;
headers.setContentType(MediaType.parseMediaType(mediaType));
headers.set("Accept", mediaType);
headers.set("X-Access-Token", token);
return headers;
}
}

View File

@ -1,39 +0,0 @@
package org.jeecg.smallTools;
import org.junit.Test;
/**
* 测试sql分割替换等操作
*
* @author: scott
* @date: 2023年09月05日 16:13
*/
public class TestSqlHandle {
/**
* Where 分割测试
*/
@Test
public void testSqlSplitWhere() {
String tableFilterSql = " select * from data.sys_user Where name='12312' and age>100";
String[] arr = tableFilterSql.split(" (?i)where ");
for (String sql : arr) {
System.out.println("sql片段" + sql);
}
}
/**
* Where 替换
*/
@Test
public void testSqlWhereReplace() {
String input = " Where name='12312' and age>100";
String pattern = "(?i)where "; // (?i) 表示不区分大小写
String replacedString = input.replaceAll(pattern, "");
System.out.println("替换前的字符串:" + input);
System.out.println("替换后的字符串:" + replacedString);
}
}

View File

@ -1,76 +0,0 @@
package org.jeecg.smallTools;
import com.alibaba.fastjson.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Base64;
/**
* 字符串处理测试
*
* @author: scott
* @date: 2023年03月30日 15:27
*/
public class TestStr {
/**
* 测试参数格式化的问题数字值有问题
*/
@Test
public void testParameterFormat() {
String url = "/pages/lowApp/process/taskDetail?tenantId={0}&procInsId={1}&taskId={2}&taskDefKey={3}";
String cc = MessageFormat.format(url, "6364", "111", "22", "333");
System.out.println("参数是字符串:" + cc);
String cc2 = MessageFormat.format(url, 6364, 111, 22, 333);
System.out.println("参数是数字(出问题):" + cc2);
}
@Test
public void testStringSplitError() {
String conditionValue = "qweqwe";
String[] conditionValueArray = conditionValue.split(",");
System.out.println("length = "+ conditionValueArray.length);
Arrays.stream(conditionValueArray).forEach(System.out::println);
}
@Test
public void testJSONArrayJoin() {
JSONArray valArray = new JSONArray();
valArray.add("123");
valArray.add("qwe");
System.out.println("值: " + StringUtils.join(valArray, ","));
}
@Test
public void testSql() {
String sql = "select * from sys_user where sex = ${sex}";
sql = sql.replaceAll("'?\\$\\{sex}'?","1");
System.out.println(sql);
}
@Test
public void base64(){
String encodedString = "5L+d5a2Y5aSx6LSl77yM5YWN6LS554mI5pyA5aSa5Yib5bu6ezB95p2h6L+e5o6l77yM6K+35Y2H57qn5ZWG5Lia54mI77yB";
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
String decodedString = new String(decodedBytes);
String tipMsg = MessageFormat.format(decodedString, 10);
System.out.println(tipMsg);
}
/**
* 正则测试字符串只保存中文和数字和字母
*/
@Test
public void testSpecialChar() {
String str = "Hello, World! 你好这是一段特殊符号的测试This is a test string with special characters: @#$%^&*";
// 使用正则表达式替换特殊字符
String replacedStr = str.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5]", "");
System.out.println("Replaced String: " + replacedStr);
}
}

View File

@ -3,7 +3,7 @@
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">
<parent>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-parent</artifactId>
<version>2.0.0</version>
</parent>

21
pom.xml
View File

@ -1,6 +1,6 @@
<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>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-parent</artifactId>
<version>2.0.0</version>
<packaging>pom</packaging>
@ -70,6 +70,7 @@
<modules>
<module>nursing-unit-base-core</module>
<module>nursing-unit-demo</module>
<module>nursing-unit-config</module>
<module>nursing-unit-system</module>
</modules>
@ -165,7 +166,7 @@
<!-- system 模块-->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nu-system-biz</artifactId>
<version>${nursingunit.version}</version>
</dependency>
@ -178,29 +179,17 @@
</dependency>
<!-- jeecg core -->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-base-core</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!-- system 单体 api -->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nu-local-api</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!-- system 微服务 api -->
<dependency>
<groupId>org.nursingunit.boot</groupId>
<artifactId>nu-cloud-api</artifactId>
<version>${nursingunit.version}</version>
</dependency>
<!--微服务启动依赖-->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!--xxl-job定时任务-->
<dependency>
<groupId>org.jeecgframework.boot</groupId>