!15 修改test

Merge pull request !15 from new_new_new/feature/20260506-branch
This commit is contained in:
new_new_new
2026-05-06 00:57:12 +00:00
committed by Gitee
38 changed files with 1039 additions and 719 deletions
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatter;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -0,0 +1,168 @@
package org.jeecg.modules.bg.xispeak.controller.feedback;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
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.common.util.oConvertUtils;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import org.jeecg.modules.bg.xispeak.service.IBgXiSpeakFeedbackService;
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.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Tag(name="习总书记重要讲话反馈表")
@RestController
@RequestMapping("/bg/xispeak/bgXiSpeak")
@Slf4j
public class BgXiSpeakFeedbackController extends JeecgController<BgXiSpeakFeedback, IBgXiSpeakFeedbackService> {
@Autowired
private IBgXiSpeakFeedbackService bgXiSpeakFeedbackService;
/**
* 分页列表查询
*
* @param bgXiSpeakFeedback
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@Operation(summary="习总书记重要讲话反馈表-分页列表查询")
@GetMapping(value = "/listBgXiSpeakFeedbackByMainId")
public Result<IPage<BgXiSpeakFeedback>> queryPageList(BgXiSpeakFeedback bgXiSpeakFeedback,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<BgXiSpeakFeedback> queryWrapper = QueryGenerator.initQueryWrapper(bgXiSpeakFeedback, req.getParameterMap());
Page<BgXiSpeakFeedback> page = new Page<BgXiSpeakFeedback>(pageNo, pageSize);
IPage<BgXiSpeakFeedback> pageList = bgXiSpeakFeedbackService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param bgXiSpeakFeedback
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-添加")
@Operation(summary="习总书记重要讲话反馈表-添加")
@PostMapping(value = "/addBgXiSpeakFeedback")
public Result<String> add(@RequestBody BgXiSpeakFeedback bgXiSpeakFeedback) {
bgXiSpeakFeedbackService.save(bgXiSpeakFeedback);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param bgXiSpeakFeedback
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-编辑")
@Operation(summary="习总书记重要讲话反馈表-编辑")
@PostMapping(value = "/editBgXiSpeakFeedback")
public Result<String> edit(@RequestBody BgXiSpeakFeedback bgXiSpeakFeedback) {
bgXiSpeakFeedbackService.updateById(bgXiSpeakFeedback);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-通过id删除")
@Operation(summary="习总书记重要讲话反馈表-通过id删除")
@DeleteMapping(value = "/deleteBgXiSpeakFeedback")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
bgXiSpeakFeedbackService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "习总书记重要讲话反馈表-批量删除")
@Operation(summary="习总书记重要讲话反馈表-批量删除")
@DeleteMapping(value = "/deleteBatchBgXiSpeakFeedback")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.bgXiSpeakFeedbackService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@Operation(summary="习总书记重要讲话反馈表-通过id查询")
@GetMapping(value = "/queryBgXiSpeakFeedbackById")
public Result<BgXiSpeakFeedback> queryById(@RequestParam(name="id",required=true) String id) {
BgXiSpeakFeedback bgXiSpeakFeedback = bgXiSpeakFeedbackService.getById(id);
if(bgXiSpeakFeedback==null) {
return Result.error("未找到对应数据");
}
return Result.OK(bgXiSpeakFeedback);
}
/**
* 导出excel
*
* @param request
* @param bgXiSpeakFeedback
*/
@RequestMapping(value = "/exportBgXiSpeakFeedback")
public ModelAndView exportXls(HttpServletRequest request, BgXiSpeakFeedback bgXiSpeakFeedback) {
return super.exportXls(request, bgXiSpeakFeedback, BgXiSpeakFeedback.class, "习总书记重要讲话反馈表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importBgXiSpeakFeedback", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
return super.importExcel(request, response, BgXiSpeakFeedback.class);
}
}
@@ -157,4 +157,12 @@ public class BgXiSpeak implements Serializable {
@Excel(name = "督办次数", width = 15)
@Schema(description = "督办次数")
private java.lang.Integer supervisionCount;
/**dw领导userId字段*/
@Excel(name = "领导userId字段", width = 15)
@Schema(description = "领导userId字段")
private java.lang.String sdwLeaderList;
/**dw领导userId字段*/
@Excel(name = "是否需要sdw审批", width = 15)
@Schema(description = "是否需要sdw审批")
private java.lang.Integer needSdwApproval;
}
@@ -0,0 +1,84 @@
package org.jeecg.modules.bg.xispeak.entity;
import java.io.Serializable;
import java.util.Date;
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 io.swagger.v3.oas.annotations.media.Schema;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Data
@TableName("bg_xi_speak_feedback")
@Schema(description="习总书记重要讲话反馈表")
public class BgXiSpeakFeedback implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private java.lang.String id;
/**创建人*/
@Schema(description = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private java.util.Date createTime;
/**更新人*/
@Schema(description = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private java.lang.String sysOrgCode;
/**反馈部门id*/
@Excel(name = "反馈部门id", width = 15)
@Schema(description = "反馈部门id")
private java.lang.String responDeptid;
/**反馈部门名称*/
@Excel(name = "反馈部门名称", width = 15)
@Schema(description = "反馈部门名称")
private java.lang.String responDeptname;
/**反馈人id*/
@Excel(name = "反馈人id", width = 15)
@Schema(description = "反馈人id")
private java.lang.String responPersonid;
/**反馈人姓名*/
@Excel(name = "反馈人姓名", width = 15)
@Schema(description = "反馈人姓名")
private java.lang.String responPersonname;
/**反馈时间*/
@Excel(name = "反馈时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "反馈时间")
private java.util.Date responTime;
/**落实情况*/
@Excel(name = "落实情况", width = 15)
@Schema(description = "落实情况")
private java.lang.String implStatus;
/**完成状态*/
@Excel(name = "完成状态", width = 15)
@Schema(description = "完成状态")
private java.lang.String completionStatus;
/**外键*/
@Excel(name = "外键", width = 15)
@Schema(description = "外键")
private java.lang.String mainId;
}
@@ -0,0 +1,16 @@
package org.jeecg.modules.bg.xispeak.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Mapper
public interface BgXiSpeakFeedbackMapper extends BaseMapper<BgXiSpeakFeedback> {
}
@@ -0,0 +1,14 @@
package org.jeecg.modules.bg.xispeak.service;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
public interface IBgXiSpeakFeedbackService extends IService<BgXiSpeakFeedback> {
}
@@ -0,0 +1,19 @@
package org.jeecg.modules.bg.xispeak.service.impl;
import org.jeecg.modules.bg.xispeak.entity.BgXiSpeakFeedback;
import org.jeecg.modules.bg.xispeak.mapper.BgXiSpeakFeedbackMapper;
import org.jeecg.modules.bg.xispeak.service.IBgXiSpeakFeedbackService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 习总书记重要讲话反馈表
* @Author: jeecg-boot
* @Date: 2026-04-28
* @Version: V1.0
*/
@Service
public class BgXiSpeakFeedbackServiceImpl extends ServiceImpl<BgXiSpeakFeedbackMapper, BgXiSpeakFeedback> implements IBgXiSpeakFeedbackService {
}
@@ -7,7 +7,6 @@ import org.jeecg.modules.demo.bgpartymatter.entity.BgPartymatterFeedback;
import org.jeecg.modules.demo.bgpartymatter.mapper.BgPartymatterFeedbackMapper;
import org.jeecg.modules.demo.bgpartymatter.mapper.BgPartymatterMapper;
import org.jeecg.modules.demo.bgpartymatter.service.IBgPartymatterService;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -1,270 +0,0 @@
package org.jeecg.modules.test.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.vo.TestMainTablePage;
import org.jeecg.modules.test.service.ITestMainTableService;
import org.jeecg.modules.test.service.ITestSonTableService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
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 com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Tag(name="test")
@RestController
@RequestMapping("/test/testMainTable")
@Slf4j
public class TestMainTableController {
@Autowired
private ITestMainTableService testMainTableService;
@Autowired
private ITestSonTableService testSonTableService;
/**
* 分页列表查询
*
* @param testMainTable
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "test-分页列表查询")
@Operation(summary="test-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<TestMainTable>> queryPageList(TestMainTable testMainTable,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TestMainTable> queryWrapper = QueryGenerator.initQueryWrapper(testMainTable, req.getParameterMap());
Page<TestMainTable> page = new Page<TestMainTable>(pageNo, pageSize);
IPage<TestMainTable> pageList = testMainTableService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param testMainTablePage
* @return
*/
@AutoLog(value = "test-添加")
@Operation(summary="test-添加")
@RequiresPermissions("test:test_main_table:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody TestMainTablePage testMainTablePage) {
TestMainTable testMainTable = new TestMainTable();
BeanUtils.copyProperties(testMainTablePage, testMainTable);
testMainTableService.saveMain(testMainTable, testMainTablePage.getTestSonTableList());
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param testMainTablePage
* @return
*/
@AutoLog(value = "test-编辑")
@Operation(summary="test-编辑")
@RequiresPermissions("test:test_main_table:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody TestMainTablePage testMainTablePage) {
TestMainTable testMainTable = new TestMainTable();
BeanUtils.copyProperties(testMainTablePage, testMainTable);
TestMainTable testMainTableEntity = testMainTableService.getById(testMainTable.getId());
if(testMainTableEntity==null) {
return Result.error("未找到对应数据");
}
testMainTableService.updateMain(testMainTable, testMainTablePage.getTestSonTableList());
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "test-通过id删除")
@Operation(summary="test-通过id删除")
@RequiresPermissions("test:test_main_table:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
testMainTableService.delMain(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "test-批量删除")
@Operation(summary="test-批量删除")
@RequiresPermissions("test:test_main_table:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.testMainTableService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "test-通过id查询")
@Operation(summary="test-通过id查询")
@GetMapping(value = "/queryById")
public Result<TestMainTable> queryById(@RequestParam(name="id",required=true) String id) {
TestMainTable testMainTable = testMainTableService.getById(id);
if(testMainTable==null) {
return Result.error("未找到对应数据");
}
return Result.OK(testMainTable);
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "test通过主表ID查询")
@Operation(summary="test主表ID查询")
@GetMapping(value = "/queryTestSonTableByMainId")
public Result<List<TestSonTable>> queryTestSonTableListByMainId(@RequestParam(name="id",required=true) String id) {
List<TestSonTable> testSonTableList = testSonTableService.selectByMainId(id);
return Result.OK(testSonTableList);
}
/**
* 导出excel
*
* @param request
* @param testMainTable
*/
@RequiresPermissions("test:test_main_table:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, TestMainTable testMainTable) {
// Step.1 组装查询条件查询数据
QueryWrapper<TestMainTable> queryWrapper = QueryGenerator.initQueryWrapper(testMainTable, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//配置选中数据查询条件
String selections = request.getParameter("selections");
if(oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList);
}
//Step.2 获取导出数据
List<TestMainTable> testMainTableList = testMainTableService.list(queryWrapper);
// Step.3 组装pageList
List<TestMainTablePage> pageList = new ArrayList<TestMainTablePage>();
for (TestMainTable main : testMainTableList) {
TestMainTablePage vo = new TestMainTablePage();
BeanUtils.copyProperties(main, vo);
List<TestSonTable> testSonTableList = testSonTableService.selectByMainId(main.getId());
vo.setTestSonTableList(testSonTableList);
pageList.add(vo);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "test列表");
mv.addObject(NormalExcelConstants.CLASS, TestMainTablePage.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("test数据", "导出人:"+sysUser.getRealname(), "test"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("test:test_main_table:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<TestMainTablePage> list = ExcelImportUtil.importExcel(file.getInputStream(), TestMainTablePage.class, params);
for (TestMainTablePage page : list) {
TestMainTable po = new TestMainTable();
BeanUtils.copyProperties(page, po);
testMainTableService.saveMain(po, page.getTestSonTableList());
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.OK("文件导入失败!");
}
}
@@ -1,65 +0,0 @@
package org.jeecg.modules.test.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
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 org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
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.v3.oas.annotations.media.Schema;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Schema(description="test")
@Data
@TableName("test_main_table")
public class TestMainTable implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**a字段*/
@Excel(name = "a字段", width = 15)
@Schema(description = "a字段")
private String fieldA;
/**b字段*/
@Excel(name = "b字段", width = 15)
@Schema(description = "b字段")
private String fieldB;
@TableLogic(value = "0", delval = "1")
private int delFlag = 0;
}
@@ -1,62 +0,0 @@
package org.jeecg.modules.test.entity;
import java.io.Serializable;
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 org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.util.Date;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.UnsupportedEncodingException;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Schema(description="test")
@Data
@TableName("test_son_table")
public class TestSonTable implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**字段c*/
@Excel(name = "字段c", width = 15)
@Schema(description = "字段c")
private String fieldC;
/**主表id*/
@Schema(description = "主表id")
private String mainTableId;
@TableLogic(value = "0", delval = "1")
private int delFlag = 0;
}
@@ -1,17 +0,0 @@
package org.jeecg.modules.test.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.test.entity.TestMainTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface TestMainTableMapper extends BaseMapper<TestMainTable> {
}
@@ -1,31 +0,0 @@
package org.jeecg.modules.test.mapper;
import java.util.List;
import org.jeecg.modules.test.entity.TestSonTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface TestSonTableMapper extends BaseMapper<TestSonTable> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<TestSonTable>
*/
public List<TestSonTable> selectByMainId(@Param("mainId") String mainId);
}
@@ -1,5 +0,0 @@
<?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">
<mapper namespace="org.jeecg.modules.test.mapper.TestMainTableMapper">
</mapper>
@@ -1,16 +0,0 @@
<?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">
<mapper namespace="org.jeecg.modules.test.mapper.TestSonTableMapper">
<delete id="deleteByMainId" parameterType="java.lang.String">
DELETE
FROM test_son_table
WHERE
main_table_id = #{mainId} </delete>
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.test.entity.TestSonTable">
SELECT *
FROM test_son_table
WHERE
main_table_id = #{mainId} </select>
</mapper>
@@ -1,48 +0,0 @@
package org.jeecg.modules.test.service;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface ITestMainTableService extends IService<TestMainTable> {
/**
* 添加一对多
*
* @param testMainTable
* @param testSonTableList
*/
public void saveMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList) ;
/**
* 修改一对多
*
* @param testMainTable
* @param testSonTableList
*/
public void updateMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList);
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);
}
@@ -1,22 +0,0 @@
package org.jeecg.modules.test.service;
import org.jeecg.modules.test.entity.TestSonTable;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
public interface ITestSonTableService extends IService<TestSonTable> {
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<TestSonTable>
*/
public List<TestSonTable> selectByMainId(String mainId);
}
@@ -1,83 +0,0 @@
package org.jeecg.modules.test.service.impl;
import org.jeecg.common.aspect.annotation.CascadeDelete;
import org.jeecg.common.aspect.annotation.SonTable;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.jeecg.modules.test.mapper.TestMainTableMapper;
import org.jeecg.modules.test.service.ITestMainTableService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Service
public class TestMainTableServiceImpl extends ServiceImpl<TestMainTableMapper, TestMainTable> implements ITestMainTableService {
@Autowired
private TestMainTableMapper testMainTableMapper;
@Autowired
private TestSonTableMapper testSonTableMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(TestMainTable testMainTable, List<TestSonTable> testSonTableList) {
testMainTableMapper.insert(testMainTable);
if(testSonTableList!=null && testSonTableList.size()>0) {
for(TestSonTable entity:testSonTableList) {
//外键设置
entity.setMainTableId(testMainTable.getId());
testSonTableMapper.insert(entity);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(TestMainTable testMainTable,List<TestSonTable> testSonTableList) {
testMainTableMapper.updateById(testMainTable);
//1.先删除子表数据
testSonTableMapper.deleteByMainId(testMainTable.getId());
//2.子表数据重新插入
if(testSonTableList!=null && testSonTableList.size()>0) {
for(TestSonTable entity:testSonTableList) {
//外键设置
entity.setMainTableId(testMainTable.getId());
testSonTableMapper.insert(entity);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@CascadeDelete(sons = {
// 配置子表1:Mapper类 + 子表中关联主表的字段名
@SonTable(mapper = TestSonTableMapper.class, joinColumn = "main_table_id"),
})
public void delMain(String id) {
testMainTableMapper.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
for(Serializable id:idList) {
testSonTableMapper.deleteByMainId(id.toString());
testMainTableMapper.deleteById(id);
}
}
}
@@ -1,27 +0,0 @@
package org.jeecg.modules.test.service.impl;
import org.jeecg.modules.test.entity.TestSonTable;
import org.jeecg.modules.test.mapper.TestSonTableMapper;
import org.jeecg.modules.test.service.ITestSonTableService;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Service
public class TestSonTableServiceImpl extends ServiceImpl<TestSonTableMapper, TestSonTable> implements ITestSonTableService {
@Autowired
private TestSonTableMapper testSonTableMapper;
@Override
public List<TestSonTable> selectByMainId(String mainId) {
return testSonTableMapper.selectByMainId(mainId);
}
}
@@ -1,64 +0,0 @@
package org.jeecg.modules.test.vo;
import java.util.List;
import org.jeecg.modules.test.entity.TestMainTable;
import org.jeecg.modules.test.entity.TestSonTable;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* @Description: test
* @Author: jeecg-boot
* @Date: 2026-04-03
* @Version: V1.0
*/
@Data
@Schema(description="test")
public class TestMainTablePage {
/**主键*/
@Schema(description = "主键")
private String id;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private String sysOrgCode;
/**a字段*/
@Excel(name = "a字段", width = 15)
@Schema(description = "a字段")
private String fieldA;
/**b字段*/
@Excel(name = "b字段", width = 15)
@Schema(description = "b字段")
private String fieldB;
@ExcelCollection(name="test")
@Schema(description = "test")
private List<TestSonTable> testSonTableList;
}