!6 同步develop分支

* sync -- 同步develop分支
This commit is contained in:
KonBAI
2022-01-18 13:16:15 +00:00
parent a649962696
commit 5676316380
338 changed files with 10957 additions and 9551 deletions

View File

@@ -1,5 +1,6 @@
package com.ruoyi.generator.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil;
import com.ruoyi.common.annotation.Log;
@@ -16,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -45,7 +45,7 @@ public class GenController extends BaseController {
* 查询代码生成列表
*/
@ApiOperation("查询代码生成列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@SaCheckPermission("tool:gen:list")
@GetMapping("/list")
public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
return genTableService.selectPageGenTableList(genTable, pageQuery);
@@ -55,7 +55,7 @@ public class GenController extends BaseController {
* 修改代码生成业务
*/
@ApiOperation("修改代码生成业务")
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
@SaCheckPermission("tool:gen:query")
@GetMapping(value = "/{talbleId}")
public R<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
GenTable table = genTableService.selectGenTableById(talbleId);
@@ -72,7 +72,7 @@ public class GenController extends BaseController {
* 查询数据库列表
*/
@ApiOperation("查询数据库列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@SaCheckPermission("tool:gen:list")
@GetMapping("/db/list")
public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
return genTableService.selectPageDbTableList(genTable, pageQuery);
@@ -82,7 +82,7 @@ public class GenController extends BaseController {
* 查询数据表字段列表
*/
@ApiOperation("查询数据表字段列表")
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@SaCheckPermission("tool:gen:list")
@GetMapping(value = "/column/{talbleId}")
public TableDataInfo<GenTableColumn> columnList(Long tableId) {
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
@@ -96,7 +96,7 @@ public class GenController extends BaseController {
* 导入表结构(保存)
*/
@ApiOperation("导入表结构(保存)")
@PreAuthorize("@ss.hasPermi('tool:gen:import')")
@SaCheckPermission("tool:gen:import")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
public R<Void> importTableSave(String tables) {
@@ -111,7 +111,7 @@ public class GenController extends BaseController {
* 修改保存代码生成业务
*/
@ApiOperation("修改保存代码生成业务")
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@SaCheckPermission("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping
public R<Void> editSave(@Validated @RequestBody GenTable genTable) {
@@ -124,7 +124,7 @@ public class GenController extends BaseController {
* 删除代码生成
*/
@ApiOperation("删除代码生成")
@PreAuthorize("@ss.hasPermi('tool:gen:remove')")
@SaCheckPermission("tool:gen:remove")
@Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}")
public R<Void> remove(@PathVariable Long[] tableIds) {
@@ -136,7 +136,7 @@ public class GenController extends BaseController {
* 预览代码
*/
@ApiOperation("预览代码")
@PreAuthorize("@ss.hasPermi('tool:gen:preview')")
@SaCheckPermission("tool:gen:preview")
@GetMapping("/preview/{tableId}")
public R<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
Map<String, String> dataMap = genTableService.previewCode(tableId);
@@ -147,7 +147,7 @@ public class GenController extends BaseController {
* 生成代码(下载方式)
*/
@ApiOperation("生成代码(下载方式)")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@SaCheckPermission("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/download/{tableName}")
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
@@ -159,7 +159,7 @@ public class GenController extends BaseController {
* 生成代码(自定义路径)
*/
@ApiOperation("生成代码(自定义路径)")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@SaCheckPermission("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public R<Void> genCode(@PathVariable("tableName") String tableName) {
@@ -171,7 +171,7 @@ public class GenController extends BaseController {
* 同步数据库
*/
@ApiOperation("同步数据库")
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@SaCheckPermission("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}")
public R<Void> synchDb(@PathVariable("tableName") String tableName) {
@@ -183,7 +183,7 @@ public class GenController extends BaseController {
* 批量生成代码
*/
@ApiOperation("批量生成代码")
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@SaCheckPermission("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {

View File

@@ -1,7 +1,7 @@
package com.ruoyi.generator.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.generator.domain.GenTableColumn;
import java.util.List;
@@ -12,7 +12,7 @@ import java.util.List;
* @author Lion Li
*/
@InterceptorIgnore(dataPermission = "true")
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> {
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumnMapper, GenTableColumn, GenTableColumn> {
/**
* 根据表名称查询列信息
*

View File

@@ -2,7 +2,7 @@ package com.ruoyi.generator.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.generator.domain.GenTable;
import org.apache.ibatis.annotations.Param;
@@ -14,7 +14,7 @@ import java.util.List;
* @author Lion Li
*/
@InterceptorIgnore(dataPermission = "true")
public interface GenTableMapper extends BaseMapperPlus<GenTable> {
public interface GenTableMapper extends BaseMapperPlus<GenTableMapper, GenTable, GenTable> {
Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);

View File

@@ -1,9 +1,9 @@
package com.ruoyi.generator.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
@@ -14,8 +14,11 @@ import java.util.List;
*
* @author Lion Li
*/
@RequiredArgsConstructor
@Service
public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMapper, GenTableColumn, GenTableColumn> implements IGenTableColumnService {
public class GenTableColumnServiceImpl implements IGenTableColumnService {
private final GenTableColumnMapper baseMapper;
/**
* 查询业务字段列表
@@ -25,7 +28,7 @@ public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMap
*/
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
return list(new LambdaQueryWrapper<GenTableColumn>()
return baseMapper.selectList(new LambdaQueryWrapper<GenTableColumn>()
.eq(GenTableColumn::getTableId, tableId)
.orderByAsc(GenTableColumn::getSort));
}

View File

@@ -8,12 +8,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
@@ -22,12 +19,11 @@ import com.ruoyi.generator.mapper.GenTableMapper;
import com.ruoyi.generator.util.GenUtils;
import com.ruoyi.generator.util.VelocityInitializer;
import com.ruoyi.generator.util.VelocityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -47,11 +43,12 @@ import java.util.zip.ZipOutputStream;
* @author Lion Li
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTable, GenTable> implements IGenTableService {
public class GenTableServiceImpl implements IGenTableService {
@Autowired
private GenTableColumnMapper genTableColumnMapper;
private final GenTableMapper baseMapper;
private final GenTableColumnMapper genTableColumnMapper;
/**
* 查询业务信息
@@ -150,7 +147,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
@Transactional(rollbackFor = Exception.class)
public void deleteGenTableByIds(Long[] tableIds) {
List<Long> ids = Arrays.asList(tableIds);
removeByIds(ids);
baseMapper.deleteBatchIds(ids);
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids));
}
@@ -162,7 +159,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
@Override
@Transactional(rollbackFor = Exception.class)
public void importGenTable(List<GenTable> tableList) {
String operName = SecurityUtils.getUsername();
String operName = LoginUtils.getUsername();
try {
for (GenTable table : tableList) {
String tableName = table.getTableName();
@@ -177,7 +174,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
saveColumns.add(column);
}
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
genTableColumnMapper.insertBatch(saveColumns);
}
}
}
@@ -228,7 +225,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip);
IOUtils.closeQuietly(zip);
IoUtil.close(zip);
return outputStream.toByteArray();
}
@@ -294,7 +291,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
}
});
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertAll(saveColumns);
genTableColumnMapper.insertBatch(saveColumns);
}
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
@@ -317,7 +314,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
for (String tableName : tableNames) {
generatorCode(tableName, zip);
}
IOUtils.closeQuietly(zip);
IoUtil.close(zip);
return outputStream.toByteArray();
}

View File

@@ -1,6 +1,5 @@
package com.ruoyi.generator.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.generator.domain.GenTableColumn;
import java.util.List;
@@ -10,7 +9,7 @@ import java.util.List;
*
* @author Lion Li
*/
public interface IGenTableColumnService extends IService<GenTableColumn> {
public interface IGenTableColumnService {
/**
* 查询业务字段列表
*

View File

@@ -1,6 +1,5 @@
package com.ruoyi.generator.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.generator.domain.GenTable;
@@ -13,7 +12,7 @@ import java.util.Map;
*
* @author Lion Li
*/
public interface IGenTableService extends IService<GenTable> {
public interface IGenTableService {
TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);