This commit is contained in:
xbx 2024-03-26 17:31:09 +08:00
parent 699c4382f2
commit bc8165a8d9
15 changed files with 495 additions and 526 deletions

View File

@ -0,0 +1,172 @@
package org.jeecg.modules.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.common.system.query.QueryGenerator;
import org.jeecg.modules.entity.RmsLocation;
import org.jeecg.modules.model.TreeModel;
import org.jeecg.modules.service.IRmsLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
/**
* @Description: 存放地表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
@Api(tags = "存放地表")
@RestController
@RequestMapping("/CET/cetLocation")
@Slf4j
public class RmsLocationController extends JeecgController<RmsLocation, IRmsLocationService> {
@Autowired
private IRmsLocationService rmsLocationService;
/**
* 分页列表查询
*
* @param rmsLocation
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "存放地表-分页列表查询")
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<RmsLocation>> queryPageList(RmsLocation rmsLocation,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<RmsLocation> queryWrapper = QueryGenerator.initQueryWrapper(rmsLocation, req.getParameterMap());
Page<RmsLocation> page = new Page<RmsLocation>(pageNo, pageSize);
IPage<RmsLocation> pageList = rmsLocationService.page(page, queryWrapper);
//return Result.OK(rmsLocationService.getsLocationData(page, queryWrapper));
return Result.OK(pageList);
}
//获取树结构
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/getTree")
public Result<ArrayList<TreeModel>> getTreeList() {
return Result.OK(rmsLocationService.getTreeList());
}
//获取级联样式
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/getCascader")
public Result<ArrayList<TreeModel>> getCascaderList(@RequestParam(name = "type", defaultValue = "0") Integer type) {
return Result.OK(rmsLocationService.getCascaderList(type));
}
/**
* 添加
*
* @param rmsLocation
* @return
*/
@AutoLog(value = "存放地表-添加")
@ApiOperation(value = "存放地表-添加", notes = "存放地表-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody RmsLocation rmsLocation) {
rmsLocationService.save(rmsLocation);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param rmsLocation
* @return
*/
@AutoLog(value = "存放地表-编辑")
@ApiOperation(value = "存放地表-编辑", notes = "存放地表-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody RmsLocation rmsLocation) {
rmsLocationService.updateById(rmsLocation);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "存放地表-通过id删除")
@ApiOperation(value = "存放地表-通过id删除", notes = "存放地表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
rmsLocationService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "存放地表-批量删除")
@ApiOperation(value = "存放地表-批量删除", notes = "存放地表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.rmsLocationService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "存放地表-通过id查询")
@ApiOperation(value = "存放地表-通过id查询", notes = "存放地表-通过id查询")
@GetMapping(value = "/queryById")
public Result<RmsLocation> queryById(@RequestParam(name = "id", required = true) String id) {
RmsLocation rmsLocation = rmsLocationService.getById(id);
if (rmsLocation == null) {
return Result.error("未找到对应数据");
}
return Result.OK(rmsLocation);
}
/**
* 导出excel
*
* @param request
* @param rmsLocation
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, RmsLocation rmsLocation) {
return super.exportXls(request, rmsLocation, RmsLocation.class, "存放地表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, RmsLocation.class);
}
}

View File

@ -0,0 +1,89 @@
package org.jeecg.modules.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 存放地表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
@Data
@TableName("cet_location")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "rms_location对象", description = "存放地表")
public class RmsLocation implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**
* 所属部门
*/
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
/**
* 存放地名称
*/
@Excel(name = "存放地名称", width = 15)
@ApiModelProperty(value = "存放地名称")
private String locationName;
/**
* 排序号
*/
@Excel(name = "排序号", width = 15)
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
/**
* 父节点id
*/
@Excel(name = "父节点id", width = 15)
@ApiModelProperty(value = "父节点id")
private String parentLocationId;
@Excel(name = "考场人数", width = 15)
@ApiModelProperty(value = "考场人数")
private Integer personNumber;
}

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.RmsLocation;
/**
* @Description: 存放地表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
public interface RmsLocationMapper extends BaseMapper<RmsLocation> {
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.test.mapper.TestMapper"> <mapper namespace="rms.mapper.RmsLocationMapper">
</mapper> </mapper>

View File

@ -0,0 +1,23 @@
package org.jeecg.modules.model;
import lombok.Data;
import java.util.ArrayList;
/**
* 树结构模型
* 包含以下属性
* 1. 树key
* 2. 树title
* 3. 树children
*/
@Data
public class TreeModel {
private String key;
private String value;
private String title;
private String label;
private Integer sortNumber;
private Integer personNumber;
private ArrayList<TreeModel> children;
}

View File

@ -0,0 +1,31 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.entity.RmsLocation;
import org.jeecg.modules.model.TreeModel;
import java.util.ArrayList;
/**
* @Description: 存放地表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
public interface IRmsLocationService extends IService<RmsLocation> {
//获取表格数据
ArrayList<RmsLocation> getsLocationData(Page<RmsLocation> page, QueryWrapper<RmsLocation> queryWrapper);
//获取全部的树结构
ArrayList<TreeModel> getTreeList();
//获取某个节点的子节点ids包括自身
ArrayList<String> getChildrenIds(String id);
//获取级联样式
ArrayList<TreeModel> getCascaderList(Integer type);
}

View File

@ -0,0 +1,164 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.entity.RmsLocation;
import org.jeecg.modules.mapper.RmsLocationMapper;
import org.jeecg.modules.model.TreeModel;
import org.jeecg.modules.service.IRmsLocationService;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @Description: 存放地表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
@Service
public class RmsLocationServiceImpl extends ServiceImpl<RmsLocationMapper, RmsLocation> implements IRmsLocationService {
//获取分页的树数据排序规则为父级在上子集依据sortNumber排序
@Override
public ArrayList<RmsLocation> getsLocationData(Page<RmsLocation> page, QueryWrapper<RmsLocation> queryWrapper) {
//此处查询器查询出来的已经是只有父节点和一层子节点的数据了
//查询全部数据然后先写入父节点再写入子节点依据sortNumber排序最后再依据原本的分页规则进行分页
//获取全部的树结构
Page<RmsLocation> newPage = new Page<>(1, 100000);
IPage<RmsLocation> pageList = page(newPage, queryWrapper);
//如果list长于2即有多个子节点的情况下进行排序否则直接返回
if (pageList.getRecords().size() > 2) {
ArrayList<RmsLocation> treeModels = (ArrayList<RmsLocation>) pageList.getRecords();
return treeModels;
}
//如果长于2遍历全部父节点出现最多的即为总父节点
HashMap<String, Integer> parentMap = new HashMap<>();
for (RmsLocation location : pageList.getRecords()) {
if (location.getParentLocationId() != null && !location.getParentLocationId().isEmpty()) {
if (parentMap.containsKey(location.getParentLocationId())) {
parentMap.put(location.getParentLocationId(), parentMap.get(location.getParentLocationId()) + 1);
} else {
parentMap.put(location.getParentLocationId(), 1);
}
}
}
//
return null;
}
//获取完整的树结构
public ArrayList<TreeModel> getTreeList() {
//依据排序号对list进行排序
ArrayList<TreeModel> treeModels = getTreeModels();
sortTree(treeModels);
return treeModels;
}
//递归对树结构进行排序
private void sortTree(ArrayList<TreeModel> treeModels) {
treeModels.sort((o1, o2) -> {
if (o1.getSortNumber() == null) {
return -1;
}
if (o2.getSortNumber() == null) {
return 1;
}
return o1.getSortNumber() - o2.getSortNumber();
});
for (TreeModel treeModel : treeModels) {
sortTree(treeModel.getChildren());
}
}
//获取级联样式只搜索前两层
public ArrayList<TreeModel> getCascaderList(Integer type) {
List<RmsLocation> list = getBaseMapper().selectList(null);
ArrayList<TreeModel> treeModels = getTreeModels(list);
ArrayList<TreeModel> cascaderList = new ArrayList<>();
for (TreeModel treeModel : treeModels) {
cascaderList.add(treeModel);
//如果存在子集的话
//如果type=1则不进行该操作
if (type == 0 && treeModel.getChildren().size() > 0) {
for (TreeModel child : treeModel.getChildren()) {
child.setChildren(null);
}
}
}
return cascaderList;
}
//获取某个节点的子节点ids包括自身
public ArrayList<String> getChildrenIds(String id) {
ArrayList<String> childrenIds = new ArrayList<>();
childrenIds.add(id);
ArrayList<TreeModel> treeModels = getTreeModels();
for (TreeModel treeModel : treeModels) {
if (treeModel.getKey().equals(id)) {
getChildrenIds(treeModel, childrenIds);
break;
}
}
return childrenIds;
}
private void getChildrenIds(TreeModel treeModel, ArrayList<String> childrenIds) {
for (TreeModel child : treeModel.getChildren()) {
childrenIds.add(child.getKey());
getChildrenIds(child, childrenIds);
}
}
//查询树结构
@NotNull
private ArrayList<TreeModel> getTreeModels() {
List<RmsLocation> list = getBaseMapper().selectList(null);
return getTreeModels(list);
}
@NotNull
private static ArrayList<TreeModel> getTreeModels(List<RmsLocation> list) {
// 2. RmsLocation 转换为 TreeModel
HashMap<String, TreeModel> treeModelMap = new HashMap<>();
for (RmsLocation location : list) {
TreeModel treeModel = new TreeModel();
treeModel.setKey(location.getId());
treeModel.setValue(location.getId());
treeModel.setTitle(location.getLocationName());
treeModel.setLabel(location.getLocationName());
treeModel.setChildren(new ArrayList<>());
treeModel.setSortNumber(location.getSortNumber());
treeModel.setPersonNumber(location.getPersonNumber());
treeModelMap.put(location.getId(), treeModel);
}
// 3. 构建树结构
ArrayList<TreeModel> tree = new ArrayList<>();
for (RmsLocation location : list) {
TreeModel current = treeModelMap.get(location.getId());
if (location.getParentLocationId() == null || location.getParentLocationId().isEmpty()) {
// 如果没有父节点则是树的根节点
tree.add(current);
} else {
// 如果有父节点找到父节点并将当前节点添加为其子节点
TreeModel parent = treeModelMap.get(location.getParentLocationId());
if (parent != null) {
parent.getChildren().add(current);
}
}
}
return tree;
}
}

View File

@ -1,156 +0,0 @@
package org.jeecg.test.controller;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.test.entity.Test;
import org.jeecg.test.service.ITestService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: 测试
* @Author: jeecg-boot
* @Date: 2024-03-01
* @Version: V1.0
*/
@Api(tags="测试")
@RestController
@RequestMapping("/test/test")
@Slf4j
public class TestController extends JeecgController<Test, ITestService> {
@Autowired
private ITestService testService;
/**
* 分页列表查询
*
* @param test
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "测试-分页列表查询")
@ApiOperation(value="测试-分页列表查询", notes="测试-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<Test>> queryPageList(Test test,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<Test> queryWrapper = QueryGenerator.initQueryWrapper(test, req.getParameterMap());
Page<Test> page = new Page<Test>(pageNo, pageSize);
IPage<Test> pageList = testService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param test
* @return
*/
@AutoLog(value = "测试-添加")
@ApiOperation(value="测试-添加", notes="测试-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody Test test) {
testService.save(test);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param test
* @return
*/
@AutoLog(value = "测试-编辑")
@ApiOperation(value="测试-编辑", notes="测试-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody Test test) {
testService.updateById(test);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "测试-通过id删除")
@ApiOperation(value="测试-通过id删除", notes="测试-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
testService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "测试-批量删除")
@ApiOperation(value="测试-批量删除", notes="测试-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.testService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "测试-通过id查询")
@ApiOperation(value="测试-通过id查询", notes="测试-通过id查询")
@GetMapping(value = "/queryById")
public Result<Test> queryById(@RequestParam(name="id",required=true) String id) {
Test test = testService.getById(id);
if(test==null) {
return Result.error("未找到对应数据");
}
return Result.OK(test);
}
/**
* 导出excel
*
* @param request
* @param test
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Test test) {
return super.exportXls(request, test, Test.class, "测试");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Test.class);
}
}

View File

@ -1,78 +0,0 @@
package org.jeecg.test.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 测试
* @Author: jeecg-boot
* @Date: 2024-03-01
* @Version: V1.0
*/
@Data
@TableName("test")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="test对象", description="测试")
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
/**学号*/
@Excel(name = "学号", width = 15)
@ApiModelProperty(value = "学号")
private java.lang.String studentId;
/**姓名*/
@Excel(name = "姓名", width = 15)
@ApiModelProperty(value = "姓名")
private java.lang.String studentName;
/**数学*/
@Excel(name = "数学", width = 15)
@ApiModelProperty(value = "数学")
private java.lang.String achievement1;
/**英语*/
@Excel(name = "英语", width = 15)
@ApiModelProperty(value = "英语")
private java.lang.String achievement2;
/**政治*/
@Excel(name = "政治", width = 15)
@ApiModelProperty(value = "政治")
private java.lang.String achievement3;
}

View File

@ -1,14 +0,0 @@
package org.jeecg.test.mapper;
import org.jeecg.test.entity.Test;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 测试
* @Author: jeecg-boot
* @Date: 2024-03-01
* @Version: V1.0
*/
public interface TestMapper extends BaseMapper<Test> {
}

View File

@ -1,14 +0,0 @@
package org.jeecg.test.service;
import org.jeecg.test.entity.Test;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 测试
* @Author: jeecg-boot
* @Date: 2024-03-01
* @Version: V1.0
*/
public interface ITestService extends IService<Test> {
}

View File

@ -1,19 +0,0 @@
package org.jeecg.test.service.impl;
import org.jeecg.test.entity.Test;
import org.jeecg.test.mapper.TestMapper;
import org.jeecg.test.service.ITestService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 测试
* @Author: jeecg-boot
* @Date: 2024-03-01
* @Version: V1.0
*/
@Service
public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements ITestService {
}

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.JeecgSystemApplication;
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 = JeecgSystemApplication.class)
public class SendMessageGenerate {
@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,65 +0,0 @@
package org.jeecg.modules.system.test;
import org.jeecg.JeecgSystemApplication;
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 = JeecgSystemApplication.class)
public class SampleGenerate {
@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,39 +0,0 @@
package org.jeecg.smallTools;
import org.junit.Test;
/**
* 测试sql分割替换等操作
*
* @author: scott
* @date: 2023年09月05日 16:13
*/
public class generateSqlHandle {
/**
* 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);
}
}