3.2.0-beta,重构很大:升级springboot2.6.6、spring-cloud-alibaba 2021.1、mybatisplus3.5.1、代码规范部分重构

This commit is contained in:
zhangdaiscott
2022-04-18 09:37:28 +08:00
parent 948e1668b6
commit 9dcff93372
487 changed files with 9754 additions and 2928 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>jeecg-boot-parent</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>3.1.0</version>
<version>3.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -27,6 +27,10 @@
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-job</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

View File

@ -1,14 +1,35 @@
//package org.jeecg;
//
//import org.jeecg.common.base.BaseMap;
//import org.jeecg.common.constant.GlobalConstants;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.openfeign.EnableFeignClients;
//import org.springframework.data.redis.core.RedisTemplate;
//
//@SpringBootApplication
//@EnableFeignClients
//public class JeecgDemoCloudApplication {
//public class JeecgDemoCloudApplication implements CommandLineRunner {
// @Autowired
// private RedisTemplate<String, Object> redisTemplate;
//
// public static void main(String[] args) {
// SpringApplication.run(JeecgDemoCloudApplication.class, args);
// }
//
// /**
// * 启动的时候触发下gateway网关刷新
// *
// * 解决: 先启动gateway后启动服务Swagger接口文档访问不通的问题
// * @param args
// */
// @Override
// public void run(String... args) {
// BaseMap params = new BaseMap();
// params.put(GlobalConstants.HANDLER_NAME, GlobalConstants.LODER_ROUDER_HANDLER);
// //刷新网关
// redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);
// }
//}

View File

@ -1,48 +0,0 @@
//package org.jeecg.modules.demo.cloud.controller;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.api.vo.Result;
//import org.jeecg.common.system.api.ISysBaseAPI;
//import org.jeecg.common.system.vo.DictModel;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// *
// */
//@Slf4j
//@Api(tags = "Cloud示例")
//@RestController
//@RequestMapping("/test")
//public class JcloudDemoController {
//
//
// @Resource
// private ISysBaseAPI sysBaseAPI;
//
// /**
// * 测试
// *
// * @return
// */
// @GetMapping("/remote")
// @ApiOperation(value = "测试feign", notes = "测试feign")
// public Result remoteDict() {
//// try{
//// //睡5秒网关Hystrix3秒超时会触发熔断降级操作
//// Thread.sleep(5000);
//// }catch (Exception e){
//// e.printStackTrace();
//// }
// List<DictModel> list = sysBaseAPI.queryAllDict();
// return Result.OK(list);
// }
//
//
//}

View File

@ -0,0 +1,68 @@
//package org.jeecg.modules.demo.cloud.controller;
//
//import com.alibaba.csp.sentinel.annotation.SentinelResource;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.api.vo.Result;
//import org.jeecg.common.system.api.ISysBaseAPI;
//import org.jeecg.common.system.vo.DictModel;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// *
// */
//@Slf4j
//@Api(tags = "【微服务】单元测试")
//@RestController
//@RequestMapping("/test")
//public class JcloudDemoFeignController {
// @Resource
// private ISysBaseAPI sysBaseApi;
//// @Autowired
//// private ErpHelloApi erpHelloApi;
//
// /**
// * 测试
// *
// * @return
// */
// @GetMapping("/callSystem")
// //@SentinelResource(value = "remoteDict",fallback = "getDefaultHandler")
// @ApiOperation(value = "通过feign调用system服务", notes = "测试jeecg-demo服务是否通过fegin调用system服务接口")
// public Result getRemoteDict() {
// List<DictModel> list = sysBaseApi.queryAllDict();
// return Result.OK(list);
// }
//
//
//// /**
//// * 测试调用 erp 微服务接口
//// * 【如何测试通过archetype生成微服务模块快速集成测试】
//// * http://doc.jeecg.com/2194069
//// * @return
//// */
//// @GetMapping("/callErp")
//// @ApiOperation(value = "测试feign erp", notes = "测试feign erp")
//// public Result callErp() {
//// log.info("call erp 服务");
//// String res = erpHelloApi.callHello();
//// return Result.OK(res);
//// }
//
// /**
// * 熔断,默认回调函数
// *
// * @return
// */
// public Result<Object> getDefaultHandler() {
// log.info("测试JcloudDemoController-remoteDict 熔断降级");
// return Result.error("测试JcloudDemoController-remoteDict 熔断降级");
// }
//
//}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.demo.cloud.provider;
package org.jeecg.modules.demo.cloud.controller;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.cloud.service.JcloudDemoService;
import org.springframework.web.bind.annotation.GetMapping;
@ -10,18 +11,23 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* feign服务端接口
* 服务端提供方feign接口
* 提供给system-start调用测试看feign是否畅通
* @author: jeecg-boot
*/
@Slf4j
@RestController
@RequestMapping("/test")
public class JcloudDemoProvider {
public class JcloudDemoProviderController {
@Resource
private JcloudDemoService jcloudDemoService;
@GetMapping("/getMessage")
public Result<String> getMessage(@RequestParam String name) {
return jcloudDemoService.getMessage(name);
public String getMessage(@RequestParam String name) {
String msg = jcloudDemoService.getMessage(name);
log.info(" 微服务被调用:{} ",msg);
return msg;
}
}

View File

@ -2,6 +2,16 @@ package org.jeecg.modules.demo.cloud.service;
import org.jeecg.common.api.vo.Result;
/**
* @Description: JcloudDemoService接口
* @author: jeecg-boot
*/
public interface JcloudDemoService {
Result<String> getMessage(String name);
/**
* 获取信息(测试)
* @param name 姓名
* @return "Hello" + name
*/
String getMessage(String name);
}

View File

@ -4,10 +4,15 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.cloud.service.JcloudDemoService;
import org.springframework.stereotype.Service;
/**
* @Description: JcloudDemoServiceImpl实现类
* @author: jeecg-boot
*/
@Service
public class JcloudDemoServiceImpl implements JcloudDemoService {
@Override
public Result<String> getMessage(String name) {
return Result.OK("Hello" + name);
public String getMessage(String name) {
String resMsg = "Hello我是jeecg-demo服务节点收到你的消息"+ name +"";
return resMsg;
}
}

View File

@ -0,0 +1,74 @@
//
//package org.jeecg.modules.demo.cloud.xxljob;
//
//import com.xxl.job.core.biz.model.ReturnT;
//import com.xxl.job.core.handler.annotation.XxlJob;
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.config.mqtoken.UserTokenContext;
//import org.jeecg.common.constant.CommonConstant;
//import org.jeecg.common.system.api.ISysBaseAPI;
//import org.jeecg.common.system.util.JwtUtil;
//import org.jeecg.common.util.RedisUtil;
//import org.jeecg.common.util.SpringContextUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//
///**
// * xxl-job定时任务测试
// */
//@Slf4j
//@Component
//public class TestJobHandler {
// @Autowired
// ISysBaseAPI sysBaseApi;
//
// /**
// * 简单任务
// *
// * 测试无token调用feign接口
// *
// * @param params
// * @return
// */
//
// @XxlJob(value = "testJob")
// public ReturnT<String> demoJobHandler(String params) {
// //1.生成临时令牌Token到线程中
// UserTokenContext.setToken(getTemporaryToken());
//
// log.info("我是 jeecg-demo 服务里的定时任务 testJob , 我执行了...............................");
// log.info("我调用 jeecg-system 服务的字典接口:{}",sysBaseApi.queryAllDict());
// //。。。此处可以写多个feign接口调用
//
// //2.使用完删除临时令牌Token
// UserTokenContext.remove();
// return ReturnT.SUCCESS;
// }
//
// public void init() {
// log.info("init");
// }
//
// public void destroy() {
// log.info("destory");
// }
//
// /**
// * 获取临时令牌
// *
// * 模拟登陆接口,获取模拟 Token
// * @return
// */
// public static String getTemporaryToken() {
// RedisUtil redisUtil = SpringContextUtils.getBean(RedisUtil.class);
// // 模拟登录生成Token
// String token = JwtUtil.sign("??", "??");
// // 设置Token缓存有效时间为 5 分钟
// redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
// redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 5 * 60 * 1000);
// return token;
// }
//
//}
//

View File

@ -17,6 +17,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description: MockController
* @author: jeecg-boot
*/
@RestController
@RequestMapping("/mock/api")
@Slf4j
@ -72,7 +76,7 @@ public class MockController {
}
@GetMapping(value = "/permission/no-pager")
public String permission_no_page() {
public String permissionNoPage() {
return readJson("classpath:org/jeecg/modules/demo/mock/json/permission_no_page.json");
}
@ -129,7 +133,7 @@ public class MockController {
if(fs[i].getTotalSpace()==0) {
continue;
}
Map<String,Object> map = new HashMap<>();
Map<String,Object> map = new HashMap<>(5);
map.put("name", fsv.getSystemDisplayName(fs[i]));
map.put("max", fs[i].getTotalSpace());
map.put("rest", fs[i].getFreeSpace());
@ -177,13 +181,19 @@ public class MockController {
//-------------------------------------------------------------------------------------------
//author:lvdandan-----date20190315---for:添加数据日志json----
/**
* 数据日志
*/
public String sysDataLogJson() {
return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
}
//author:lvdandan-----date20190315---for:添加数据日志json----
//--update-begin--author:wangshuai-----date20201023---for:返回用户信息json数据----
@GetMapping(value = "/getUserInfo")
/**
* 用户信息
*/
@GetMapping(value = "/getUserInfo")
public String getUserInfo(){
return readJson("classpath:org/jeecg/modules/demo/mock/json/userinfo.json");
}

View File

@ -10,12 +10,12 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.VXESocketConst;
import org.jeecg.common.constant.VxeSocketConst;
import org.jeecg.common.system.query.MatchTypeEnum;
import org.jeecg.common.system.query.QueryCondition;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.demo.mock.vxe.entity.MockEntity;
import org.jeecg.modules.demo.mock.vxe.websocket.VXESocket;
import org.jeecg.modules.demo.mock.vxe.websocket.VxeSocket;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@ -24,6 +24,10 @@ import java.io.InputStream;
import java.net.URLDecoder;
import java.util.*;
/**
* @Description: VxeMockController
* @author: jeecg-boot
*/
@RestController
@RequestMapping("/mock/vxe")
@Slf4j
@ -59,8 +63,9 @@ public class VxeMockController {
* @param tug_status
* @return
*/
@Deprecated
@GetMapping("/change2")
public Result mockChange2(@RequestParam("id") String id, @RequestParam("tug_status") String tug_status) {
public Result mockChange2(@RequestParam("id") String id,@RequestParam("tug_status") String tugStatus) {
/* id 为 行的idrowId只要获取到rowId那么只需要调用 VXESocket.sendMessageToAll() 即可 */
// 封装行数据
@ -68,8 +73,8 @@ public class VxeMockController {
// 这个字段就是要更改的行数据ID
rowData.put("id", id);
// 这个字段就是要更改的列的key和具体的值
JSONObject tugStatus = JSON.parseObject(tug_status);
rowData.put("tug_status", tugStatus);
JSONObject status = JSON.parseObject(tugStatus);
rowData.put("tug_status", status);
// 模拟更改数据
this.mockChange(rowData);
@ -108,9 +113,9 @@ public class VxeMockController {
socketData.put("args", new Object[]{rowData, ""});
// 封装消息字符串,这里的
// type 必须是 VXESocketConst.TYPE_UVT
String message = VXESocket.packageMessage(VXESocketConst.TYPE_UVT, socketData);
String message = VxeSocket.packageMessage(VxeSocketConst.TYPE_UVT, socketData);
// 调用 sendMessageToAll 发送给所有在线的用户
VXESocket.sendMessageToAll(message);
VxeSocket.sendMessageToAll(message);
}
/**
@ -129,9 +134,9 @@ public class VxeMockController {
socketData.put("args", new Object[]{status});
// 封装消息字符串,这里的 type 必须是 VXESocketConst.TYPE_UVT
String message = VXESocket.packageMessage(VXESocketConst.TYPE_CSD, socketData);
String message = VxeSocket.packageMessage(VxeSocketConst.TYPE_CSD, socketData);
// 调用 sendMessageToAll 发送给所有在线的用户
VXESocket.sendMessageToAll(message);
VxeSocket.sendMessageToAll(message);
return Result.ok();
}
@ -260,7 +265,8 @@ public class VxeMockController {
// 模拟JSON数据路径
String path = "classpath:org/jeecg/modules/demo/mock/vxe/json/ddjh.json";
if ("8".equals(status)) {
String statusValue = "8";
if (statusValue.equals(status)) {
path = "classpath:org/jeecg/modules/demo/mock/vxe/json/ddjh_s8.json";
}
// 读取JSON数据
@ -273,7 +279,7 @@ public class VxeMockController {
// 逐行查询子表数据,用于计算拖轮状态
List<JSONObject> records = page.getRecords();
for (JSONObject record : records) {
Map<String, Integer> tugStatusMap = new HashMap<>();
Map<String, Integer> tugStatusMap = new HashMap<>(5);
String id = record.getString("id");
// 查询出主表的拖轮
String tugMain = record.getString("tug");
@ -340,12 +346,12 @@ public class VxeMockController {
*/
private IPage<JSONObject> queryDataPage(JSONArray dataList, String parentId, Integer pageNo, Integer pageSize) {
// 根据父级id查询子级
JSONArray dataDB = dataList;
JSONArray dataDb = dataList;
if (StringUtils.isNotBlank(parentId)) {
JSONArray results = new JSONArray();
List<String> parentIds = Arrays.asList(parentId.split(","));
this.queryByParentId(dataDB, parentIds, results);
dataDB = results;
this.queryByParentId(dataDb, parentIds, results);
dataDb = results;
}
// 模拟分页实际中应用SQL自带的分页
List<JSONObject> records = new ArrayList<>();
@ -353,23 +359,23 @@ public class VxeMockController {
long beginIndex, endIndex;
// 如果任意一个参数为null则不分页
if (pageNo == null || pageSize == null) {
page = new Page<>(0, dataDB.size());
page = new Page<>(0, dataDb.size());
beginIndex = 0;
endIndex = dataDB.size();
endIndex = dataDb.size();
} else {
page = new Page<>(pageNo, pageSize);
beginIndex = page.offset();
endIndex = page.offset() + page.getSize();
}
for (long i = beginIndex; (i < endIndex && i < dataDB.size()); i++) {
JSONObject data = dataDB.getJSONObject((int) i);
for (long i = beginIndex; (i < endIndex && i < dataDb.size()); i++) {
JSONObject data = dataDb.getJSONObject((int) i);
data = JSON.parseObject(data.toJSONString());
// 不返回 children
data.remove("children");
records.add(data);
}
page.setRecords(records);
page.setTotal(dataDB.size());
page.setTotal(dataDb.size());
return page;
}

View File

@ -4,15 +4,22 @@ import lombok.Data;
/**
* 模拟实体
* @author: jeecg-boot
*/
@Data
public class MockEntity {
// id
/**
* id
*/
private String id;
// 父级ID
/**
* 父级ID
*/
private String parentId;
// 状态
/**
* 状态
*/
private String status;
/* -- 省略其他字段 -- */

View File

@ -3,7 +3,7 @@ package org.jeecg.modules.demo.mock.vxe.websocket;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.VXESocketConst;
import org.jeecg.common.constant.VxeSocketConst;
import org.springframework.stereotype.Component;
import javax.websocket.OnClose;
@ -18,11 +18,12 @@ import java.util.Map;
/**
* vxe WebSocket用于实现实时无痕刷新的功能
* @author: jeecg-boot
*/
@Slf4j
@Component
@ServerEndpoint("/vxeSocket/{userId}/{pageId}")
public class VXESocket {
public class VxeSocket {
/**
* 当前 session
@ -46,18 +47,18 @@ public class VXESocket {
* 因为一个用户可能打开多个页面,多个页面就会有多个连接;
* key是userIdvalue是Map对象子Map的key是pageIdvalue是VXESocket对象
*/
private static Map<String, Map<String, VXESocket>> userPool = new HashMap<>();
private static Map<String, Map<String, VxeSocket>> userPool = new HashMap<>();
/**
* 连接池包含所有WebSocket连接
* key是socketIdvalue是VXESocket对象
*/
private static Map<String, VXESocket> socketPool = new HashMap<>();
private static Map<String, VxeSocket> socketPool = new HashMap<>();
/**
* 获取某个用户所有的页面
*/
public static Map<String, VXESocket> getUserPool(String userId) {
return userPool.computeIfAbsent(userId, k -> new HashMap<>());
public static Map<String, VxeSocket> getUserPool(String userId) {
return userPool.computeIfAbsent(userId, k -> new HashMap<>(5));
}
/**
@ -80,8 +81,8 @@ public class VXESocket {
*/
public static String packageMessage(String type, Object data) {
JSONObject message = new JSONObject();
message.put(VXESocketConst.TYPE, type);
message.put(VXESocketConst.DATA, data);
message.put(VxeSocketConst.TYPE, type);
message.put(VxeSocketConst.DATA, data);
return message.toJSONString();
}
@ -92,9 +93,9 @@ public class VXESocket {
* @param message 消息内容
*/
public static void sendMessageTo(String userId, String message) {
Collection<VXESocket> values = getUserPool(userId).values();
Collection<VxeSocket> values = getUserPool(userId).values();
if (values.size() > 0) {
for (VXESocket socketItem : values) {
for (VxeSocket socketItem : values) {
socketItem.sendMessage(message);
}
} else {
@ -109,7 +110,7 @@ public class VXESocket {
* @param message 消息内容
*/
public static void sendMessageTo(String userId, String pageId, String message) {
VXESocket socketItem = getUserPool(userId).get(pageId);
VxeSocket socketItem = getUserPool(userId).get(pageId);
if (socketItem != null) {
socketItem.sendMessage(message);
} else {
@ -125,7 +126,7 @@ public class VXESocket {
*/
public static void sendMessageTo(String[] userIds, String message) {
for (String userId : userIds) {
VXESocket.sendMessageTo(userId, message);
VxeSocket.sendMessageTo(userId, message);
}
}
@ -135,7 +136,7 @@ public class VXESocket {
* @param message 消息内容
*/
public static void sendMessageToAll(String message) {
for (VXESocket socketItem : socketPool.values()) {
for (VxeSocket socketItem : socketPool.values()) {
socketItem.sendMessage(message);
}
}
@ -186,14 +187,14 @@ public class VXESocket {
log.warn("【vxeSocket】收到不合法的消息:" + message);
return;
}
String type = json.getString(VXESocketConst.TYPE);
String type = json.getString(VxeSocketConst.TYPE);
switch (type) {
// 心跳检测
case VXESocketConst.TYPE_HB:
this.sendMessage(VXESocket.packageMessage(type, true));
case VxeSocketConst.TYPE_HB:
this.sendMessage(VxeSocket.packageMessage(type, true));
break;
// 更新form数据
case VXESocketConst.TYPE_UVT:
case VxeSocketConst.TYPE_UVT:
this.handleUpdateForm(json);
break;
default:
@ -209,8 +210,8 @@ public class VXESocket {
*/
private void handleUpdateForm(JSONObject json) {
// 将事件转发给所有人
JSONObject data = json.getJSONObject(VXESocketConst.DATA);
VXESocket.sendMessageToAll(VXESocket.packageMessage(VXESocketConst.TYPE_UVT, data));
JSONObject data = json.getJSONObject(VxeSocketConst.DATA);
VxeSocket.sendMessageToAll(VxeSocket.packageMessage(VxeSocketConst.TYPE_UVT, data));
}
}

View File

@ -59,7 +59,7 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
@ApiOperation(value = "获取Demo数据列表", notes = "获取所有Demo数据列表")
@GetMapping(value = "/list")
@PermissionData(pageComponent = "jeecg/JeecgDemoList")
public Result<IPage<JeecgDemo>> list(JeecgDemo jeecgDemo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
public Result<?> list(JeecgDemo jeecgDemo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<JeecgDemo> queryWrapper = QueryGenerator.initQueryWrapper(jeecgDemo, req.getParameterMap());
queryWrapper.orderByDesc("create_time");
@ -136,7 +136,7 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
*/
@GetMapping(value = "/queryById")
@ApiOperation(value = "通过ID查询DEMO", notes = "通过ID查询DEMO")
public Result<JeecgDemo> queryById(@ApiParam(name = "id", value = "示例id", required = true) @RequestParam(name = "id", required = true) String id) {
public Result<?> queryById(@ApiParam(name = "id", value = "示例id", required = true) @RequestParam(name = "id", required = true) String id) {
JeecgDemo jeecgDemo = jeecgDemoService.getById(id);
return Result.OK(jeecgDemo);
}
@ -239,6 +239,9 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
// ==========================================动态表单 JSON接收测试===========================================
/**
* online新增数据
*/
@PostMapping(value = "/testOnlineAdd")
public Result<?> testOnlineAdd(@RequestBody JSONObject json) {
log.info(json.toJSONString());

View File

@ -224,7 +224,8 @@ public class JeecgOrderMainController extends JeecgController<JeecgOrderMain, IJ
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(2);

View File

@ -216,7 +216,8 @@ public class JoaDemoController {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);

View File

@ -71,10 +71,12 @@ public class JeecgDemo extends JeecgEntity implements Serializable {
/** 个人简介 */
@ApiModelProperty(value = "个人简介")
private java.lang.String content;
@ApiModelProperty(value = "租户ID")
private java.lang.Integer tenantId;
/** 部门编码 */
@Excel(name="部门编码",width=25)
@ApiModelProperty(value = "部门编码")
private java.lang.String sysOrgCode;
@ApiModelProperty(value = "租户ID")
private java.lang.Integer tenantId;
}

View File

@ -17,6 +17,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
*/
public interface JeecgDemoMapper extends BaseMapper<JeecgDemo> {
/**
* 根据姓名查询demo列表数据
* @param name 姓名
* @return demo集合
*/
public List<JeecgDemo> getDemoByName(@Param("name") String name);
/**

View File

@ -23,7 +23,12 @@ public interface JeecgOrderCustomerMapper extends BaseMapper<JeecgOrderCustomer>
*/
@Delete("DELETE FROM JEECG_ORDER_CUSTOMER WHERE ORDER_ID = #{mainId}")
public boolean deleteCustomersByMainId(String mainId);
/**
* 通过主表订单外键查询客户
* @param mainId 订单id
* @return 订单客户集合
*/
@Select("SELECT * FROM JEECG_ORDER_CUSTOMER WHERE ORDER_ID = #{mainId}")
public List<JeecgOrderCustomer> selectCustomersByMainId(String mainId);
}

View File

@ -22,8 +22,12 @@ public interface JeecgOrderTicketMapper extends BaseMapper<JeecgOrderTicket> {
*/
@Delete("DELETE FROM JEECG_ORDER_TICKET WHERE ORDER_ID = #{mainId}")
public boolean deleteTicketsByMainId(String mainId);
/**
* 通过主表订单外键查询订单机票
* @param mainId 订单id
* @return 返回订单机票集合
*/
@Select("SELECT * FROM JEECG_ORDER_TICKET WHERE ORDER_ID = #{mainId}")
public List<JeecgOrderTicket> selectTicketsByMainId(String mainId);
}

View File

@ -12,9 +12,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
* @Version: V1.0
*/
public interface IJeecgDemoService extends JeecgService<JeecgDemo> {
/**
* 测试事务
*/
public void testTran();
/**
* 通过id过去demo数据先读缓存在读数据库
* @param id 数据库id
* @return demo对象
*/
public JeecgDemo getByIdCacheable(String id);
/**

View File

@ -13,6 +13,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @Version: V1.0
*/
public interface IJeecgOrderCustomerService extends IService<JeecgOrderCustomer> {
/**
* 根据订单id获取订单客户数据
* @param mainId 订单id
* @return 订单顾客集合
*/
public List<JeecgOrderCustomer> selectCustomersByMainId(String mainId);
}

View File

@ -20,27 +20,37 @@ public interface IJeecgOrderMainService extends IService<JeecgOrderMain> {
/**
* 添加一对多
*
* @param jeecgOrderMain 订单实体类
* @param jeecgOrderCustomerList 订单客户集合
* @param jeecgOrderTicketList 订单机票集合
*/
public void saveMain(JeecgOrderMain jeecgOrderMain,List<JeecgOrderCustomer> jeecgOrderCustomerList,List<JeecgOrderTicket> jeecgOrderTicketList) ;
/**
* 修改一对多
*
* @param jeecgOrderMain 订单实体类
* @param jeecgOrderCustomerList 订单客户集合
* @param jeecgOrderTicketList 订单机票集合
*/
public void updateMain(JeecgOrderMain jeecgOrderMain,List<JeecgOrderCustomer> jeecgOrderCustomerList,List<JeecgOrderTicket> jeecgOrderTicketList);
/**
* 删除一对多
* @param jformOrderMain
* @param id 订单id
*/
public void delMain (String id);
/**
* 批量删除一对多
* @param jformOrderMain
* @param idList 订单id集合
*/
public void delBatchMain (Collection<? extends Serializable> idList);
/**
* 修改一对多
* @param jeecgOrderMain 订单实体类
* @param jeecgOrderCustomerList 订单客户集合
* @param jeecgOrderTicketList 订单机票集合
*/
public void updateCopyMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList);
}

View File

@ -13,6 +13,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @Version: V1.0
*/
public interface IJeecgOrderTicketService extends IService<JeecgOrderTicket> {
/**
* 通过订单id查询订单机票
* @param mainId 订单id
* @return 订单机票集合
*/
public List<JeecgOrderTicket> selectTicketsByMainId(String mainId);
}

View File

@ -36,7 +36,7 @@ public class JeecgDemoServiceImpl extends ServiceImpl<JeecgDemoMapper, JeecgDemo
* 加上注解:@Transactional声明的方法就是一个独立的事务有异常DB操作全部回滚
*/
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void testTran() {
JeecgDemo pp = new JeecgDemo();
pp.setAge(1111);
@ -47,8 +47,8 @@ public class JeecgDemoServiceImpl extends ServiceImpl<JeecgDemoMapper, JeecgDemo
pp2.setAge(2222);
pp2.setName("测试事务 小白兔 2");
jeecgDemoMapper.insert(pp2);
Integer.parseInt("hello");//自定义异常
//自定义异常
Integer.parseInt("hello");
JeecgDemo pp3 = new JeecgDemo();
pp3.setAge(3333);

View File

@ -35,7 +35,7 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
private JeecgOrderTicketMapper jeecgOrderTicketMapper;
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void saveMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList) {
jeecgOrderMainMapper.insert(jeecgOrderMain);
if (jeecgOrderCustomerList != null) {
@ -53,7 +53,7 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void updateMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList) {
jeecgOrderMainMapper.updateById(jeecgOrderMain);
@ -83,7 +83,7 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
* @param jeecgOrderTicketList
*/
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void updateCopyMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList) {
jeecgOrderMainMapper.updateById(jeecgOrderMain);
@ -142,7 +142,7 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
}
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void delMain(String id) {
jeecgOrderMainMapper.deleteById(id);
jeecgOrderTicketMapper.deleteTicketsByMainId(id);
@ -150,7 +150,7 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
for(Serializable id:idList) {
jeecgOrderMainMapper.deleteById(id);

View File

@ -9,6 +9,10 @@ import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import lombok.Data;
/**
* @Description: 一对多示例
* @author: jeecg-boot
*/
@Data
public class JeecgOrderMainPage {

View File

@ -1,40 +0,0 @@
//
//package org.jeecg.modules.demo.xxljob;
//
//import com.xxl.job.core.biz.model.ReturnT;
//import com.xxl.job.core.handler.annotation.XxlJob;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//
///**
// * xxl-job定时任务测试
// */
//@Component
//@Slf4j
//public class TestJobHandler {
//
//
// /**
// * 简单任务
// *
// * @param params
// * @return
// */
//
// @XxlJob(value = "testJob")
// public ReturnT<String> demoJobHandler(String params) {
// log.info("我是demo服务里的定时任务testJob,我执行了...............................");
// return ReturnT.SUCCESS;
// }
//
// public void init() {
// log.info("init");
// }
//
// public void destroy() {
// log.info("destory");
// }
//
//}
//

View File

@ -13,8 +13,8 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.MatchTypeEnum;
import org.jeecg.common.system.query.QueryCondition;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.constant.VXESocketConst;
import org.jeecg.modules.demo.mock.vxe.websocket.VXESocket;
import org.jeecg.common.constant.VxeSocketConst;
import org.jeecg.modules.demo.mock.vxe.websocket.VxeSocket;
import org.jeecg.modules.dlglong.entity.MockEntity;
import org.springframework.web.bind.annotation.*;
@ -24,6 +24,10 @@ import java.io.InputStream;
import java.net.URLDecoder;
import java.util.*;
/**
* @Description: DlMockController
* @author: jeecg-boot
*/
@Slf4j
@RestController
@RequestMapping("/mock/dlglong")
@ -56,11 +60,11 @@ public class DlMockController {
* 模拟更改拖轮状态
*
* @param id
* @param tug_status
* @param tugStatus
* @return
*/
@GetMapping("/change2")
public Result mockChange2(@RequestParam("id") String id, @RequestParam("tug_status") String tug_status) {
public Result mockChange2(@RequestParam("id") String id, @RequestParam("tug_status") String tugStatus) {
/* id 为 行的idrowId只要获取到rowId那么只需要调用 VXESocket.sendMessageToAll() 即可 */
// 封装行数据
@ -68,8 +72,8 @@ public class DlMockController {
// 这个字段就是要更改的行数据ID
rowData.put("id", id);
// 这个字段就是要更改的列的key和具体的值
JSONObject tugStatus = JSON.parseObject(tug_status);
rowData.put("tug_status", tugStatus);
JSONObject status = JSON.parseObject(tugStatus);
rowData.put("tug_status", status);
// 模拟更改数据
this.mockChange(rowData);
@ -107,9 +111,9 @@ public class DlMockController {
// 这里的 args 必须得是一个数组下标0是行数据下标1是caseId一般不用传
socketData.put("args", new Object[]{rowData, ""});
// 封装消息字符串,这里的 type 必须是 VXESocketConst.TYPE_UVT
String message = VXESocket.packageMessage(VXESocketConst.TYPE_UVT, socketData);
String message = VxeSocket.packageMessage(VxeSocketConst.TYPE_UVT, socketData);
// 调用 sendMessageToAll 发送给所有在线的用户
VXESocket.sendMessageToAll(message);
VxeSocket.sendMessageToAll(message);
}
/**
@ -128,9 +132,9 @@ public class DlMockController {
socketData.put("args", new Object[]{status});
// 封装消息字符串,这里的 type 必须是 VXESocketConst.TYPE_UVT
String message = VXESocket.packageMessage(VXESocketConst.TYPE_CSD, socketData);
String message = VxeSocket.packageMessage(VxeSocketConst.TYPE_CSD, socketData);
// 调用 sendMessageToAll 发送给所有在线的用户
VXESocket.sendMessageToAll(message);
VxeSocket.sendMessageToAll(message);
return Result.ok();
}
@ -259,7 +263,8 @@ public class DlMockController {
// 模拟JSON数据路径
String path = "classpath:org/jeecg/modules/dlglong/json/ddjh.json";
if ("8".equals(status)) {
String statusValue = "8";
if (statusValue.equals(status)) {
path = "classpath:org/jeecg/modules/dlglong/json/ddjh_s8.json";
}
// 读取JSON数据
@ -272,7 +277,7 @@ public class DlMockController {
// 逐行查询子表数据,用于计算拖轮状态
List<JSONObject> records = page.getRecords();
for (JSONObject record : records) {
Map<String, Integer> tugStatusMap = new HashMap<>();
Map<String, Integer> tugStatusMap = new HashMap<>(5);
String id = record.getString("id");
// 查询出主表的拖轮
String tugMain = record.getString("tug");
@ -339,12 +344,12 @@ public class DlMockController {
*/
private IPage<JSONObject> queryDataPage(JSONArray dataList, String parentId, Integer pageNo, Integer pageSize) {
// 根据父级id查询子级
JSONArray dataDB = dataList;
JSONArray dataDb = dataList;
if (StringUtils.isNotBlank(parentId)) {
JSONArray results = new JSONArray();
List<String> parentIds = Arrays.asList(parentId.split(","));
this.queryByParentId(dataDB, parentIds, results);
dataDB = results;
this.queryByParentId(dataDb, parentIds, results);
dataDb = results;
}
// 模拟分页实际中应用SQL自带的分页
List<JSONObject> records = new ArrayList<>();
@ -352,23 +357,23 @@ public class DlMockController {
long beginIndex, endIndex;
// 如果任意一个参数为null则不分页
if (pageNo == null || pageSize == null) {
page = new Page<>(0, dataDB.size());
page = new Page<>(0, dataDb.size());
beginIndex = 0;
endIndex = dataDB.size();
endIndex = dataDb.size();
} else {
page = new Page<>(pageNo, pageSize);
beginIndex = page.offset();
endIndex = page.offset() + page.getSize();
}
for (long i = beginIndex; (i < endIndex && i < dataDB.size()); i++) {
JSONObject data = dataDB.getJSONObject((int) i);
for (long i = beginIndex; (i < endIndex && i < dataDb.size()); i++) {
JSONObject data = dataDb.getJSONObject((int) i);
data = JSON.parseObject(data.toJSONString());
// 不返回 children
data.remove("children");
records.add(data);
}
page.setRecords(records);
page.setTotal(dataDB.size());
page.setTotal(dataDb.size());
return page;
}

View File

@ -4,15 +4,22 @@ import lombok.Data;
/**
* 模拟实体
* @author: jeecg-boot
*/
@Data
public class MockEntity {
// id
/**
* id
*/
private String id;
// 父级ID
/**
* 父级ID
*/
private String parentId;
// 状态
/**
* 状态
*/
private String status;
/* -- 省略其他字段 -- */