mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
JeecgBoot 3.3.0 版本发布,基于代码生成器的企业级低代码平台
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -17,6 +18,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.UUIDGenerator;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -325,4 +327,133 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
||||
return "hello world!";
|
||||
}
|
||||
|
||||
// =====Vue3 Native 原生页面示例===============================================================================================
|
||||
@GetMapping(value = "/oneNative/list")
|
||||
public Result oneNativeList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){
|
||||
Object oneNative = redisUtil.get("one-native");
|
||||
JSONArray data = new JSONArray();
|
||||
if(null != oneNative){
|
||||
JSONObject nativeObject = (JSONObject) oneNative;
|
||||
data = nativeObject.getJSONArray("data");
|
||||
}
|
||||
IPage<JSONObject> objectPage = queryDataPage(data, pageNo, pageSize);
|
||||
return Result.OK(objectPage);
|
||||
}
|
||||
|
||||
@PostMapping("/oneNative/add")
|
||||
public Result<String> oneNativeAdd(@RequestBody JSONObject jsonObject){
|
||||
Object oneNative = redisUtil.get("one-native");
|
||||
JSONObject nativeObject = new JSONObject();
|
||||
JSONArray data = new JSONArray();
|
||||
if(null != oneNative){
|
||||
nativeObject = (JSONObject) oneNative;
|
||||
data = nativeObject.getJSONArray("data");
|
||||
}
|
||||
jsonObject.put("id", UUIDGenerator.generate());
|
||||
data.add(jsonObject);
|
||||
nativeObject.put("data",data);
|
||||
redisUtil.set("one-native",nativeObject);
|
||||
return Result.OK("添加成功");
|
||||
}
|
||||
|
||||
@PutMapping("/oneNative/edit")
|
||||
public Result<String> oneNativeEdit(@RequestBody JSONObject jsonObject){
|
||||
JSONObject oneNative = (JSONObject)redisUtil.get("one-native");
|
||||
JSONArray data = oneNative.getJSONArray("data");
|
||||
data = getNativeById(data,jsonObject);
|
||||
oneNative.put("data", data);
|
||||
redisUtil.set("one-native", oneNative);
|
||||
return Result.OK("修改成功");
|
||||
}
|
||||
|
||||
@DeleteMapping("/oneNative/delete")
|
||||
public Result<String> oneNativeDelete(@RequestParam(name = "ids") String ids){
|
||||
Object oneNative = redisUtil.get("one-native");
|
||||
if(null != oneNative){
|
||||
JSONObject nativeObject = (JSONObject) oneNative;
|
||||
JSONArray data = nativeObject.getJSONArray("data");
|
||||
data = deleteNativeById(data,ids);
|
||||
nativeObject.put("data",data);
|
||||
redisUtil.set("one-native",nativeObject);
|
||||
}
|
||||
return Result.OK("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取redis对应id的数据
|
||||
* @param data
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getNativeById(JSONArray data,JSONObject jsonObject){
|
||||
String dbId = "id";
|
||||
String id = jsonObject.getString(dbId);
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if(id.equals(data.getJSONObject(i).getString(dbId))){
|
||||
data.set(i,jsonObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除redis中包含的id数据
|
||||
* @param data
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public JSONArray deleteNativeById(JSONArray data,String ids){
|
||||
String dbId = "id";
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
//如果id包含直接清除data中的数据
|
||||
if(ids.contains(data.getJSONObject(i).getString(dbId))){
|
||||
data.fluentRemove(i);
|
||||
}
|
||||
//判断data的长度是否还剩1位
|
||||
if(data.size() == 1 && ids.contains(data.getJSONObject(0).getString(dbId))){
|
||||
data.fluentRemove(0);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟查询数据,可以根据父ID查询,可以分页
|
||||
*
|
||||
* @param dataList 数据列表
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页大小
|
||||
* @return
|
||||
*/
|
||||
private IPage<JSONObject> queryDataPage(JSONArray dataList, Integer pageNo, Integer pageSize) {
|
||||
// 根据父级id查询子级
|
||||
JSONArray dataDb = dataList;
|
||||
// 模拟分页(实际中应用SQL自带的分页)
|
||||
List<JSONObject> records = new ArrayList<>();
|
||||
IPage<JSONObject> page;
|
||||
long beginIndex, endIndex;
|
||||
// 如果任意一个参数为null,则不分页
|
||||
if (pageNo == null || pageSize == null) {
|
||||
page = new Page<>(0, dataDb.size());
|
||||
beginIndex = 0;
|
||||
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);
|
||||
data = JSON.parseObject(data.toJSONString());
|
||||
// 不返回 children
|
||||
data.remove("children");
|
||||
records.add(data);
|
||||
}
|
||||
page.setRecords(records);
|
||||
page.setTotal(dataDb.size());
|
||||
return page;
|
||||
}
|
||||
// =====Vue3 Native 原生页面示例===============================================================================================
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
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.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDynamicDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 动态数据源测试
|
||||
* @Author: zyf
|
||||
* @Date:2020-04-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "动态数据源测试")
|
||||
@RestController
|
||||
@RequestMapping("/test/dynamic")
|
||||
public class JeecgDynamicDataController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
|
||||
@Autowired
|
||||
private IJeecgDynamicDataService jeecgDynamicDataService;
|
||||
|
||||
|
||||
/**
|
||||
* 动态切换数据源
|
||||
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/test1")
|
||||
@AutoLog(value = "动态切换数据源")
|
||||
@ApiOperation(value = "动态切换数据源", notes = "动态切换数据源")
|
||||
public Result<List<JeecgDemo>> selectSpelByKey(@RequestParam(required = false) String dsName) {
|
||||
List<JeecgDemo> list = jeecgDynamicDataService.selectSpelByKey(dsName);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -47,4 +47,6 @@ public class JeecgOrderMain implements Serializable {
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
private String bpmStatus;
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package org.jeecg.modules.demo.test.service;
|
||||
|
||||
import org.jeecg.common.system.base.service.JeecgService;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 动态数据源测试
|
||||
* @Author: zyf
|
||||
* @Date:2020-04-21
|
||||
*/
|
||||
public interface IJeecgDynamicDataService extends JeecgService<JeecgDemo> {
|
||||
|
||||
/**
|
||||
* 测试从header获取数据源
|
||||
* @return
|
||||
*/
|
||||
public List<JeecgDemo> selectSpelByHeader();
|
||||
|
||||
/**
|
||||
* 使用spel从参数获取
|
||||
* @param dsName
|
||||
* @return
|
||||
*/
|
||||
public List<JeecgDemo> selectSpelByKey(String dsName);
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package org.jeecg.modules.demo.test.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDynamicDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 动态数据源测试
|
||||
* @Author: zyf
|
||||
* @Date:2020-04-21
|
||||
*/
|
||||
@Service
|
||||
public class JeecgDynamicDataServiceImpl extends ServiceImpl<JeecgDemoMapper, JeecgDemo> implements IJeecgDynamicDataService {
|
||||
|
||||
@Override
|
||||
public List<JeecgDemo> selectSpelByHeader() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JeecgDemo> selectSpelByKey(String dsName) {
|
||||
return list();
|
||||
}
|
||||
}
|
||||
@ -44,5 +44,7 @@ public class JeecgOrderMainPage {
|
||||
private List<JeecgOrderCustomer> jeecgOrderCustomerList;
|
||||
@ExcelCollection(name="机票")
|
||||
private List<JeecgOrderTicket> jeecgOrderTicketList;
|
||||
|
||||
private String bpmStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
//
|
||||
//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.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定时任务测试
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//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;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
Reference in New Issue
Block a user