package com.mdd.generator.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.mdd.common.core.PageResult;
import com.mdd.common.entity.system.SystemAuthMenu;
import com.mdd.common.exception.OperateException;
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
import com.mdd.common.util.StringUtils;
import com.mdd.common.util.TimeUtils;
import com.mdd.generator.constant.GenConstants;
import com.mdd.generator.entity.GenTable;
import com.mdd.generator.entity.GenTableColumn;
import com.mdd.generator.mapper.GenTableColumnMapper;
import com.mdd.generator.mapper.GenTableMapper;
import com.mdd.generator.service.IGenerateService;
import com.mdd.generator.util.GenUtil;
import com.mdd.generator.util.VelocityUtil;
import com.mdd.generator.validate.GenParam;
import com.mdd.generator.validate.PageParam;
import com.mdd.generator.vo.DbColumnVo;
import com.mdd.generator.vo.DbTableVo;
import com.mdd.generator.vo.GenColumnVo;
import com.mdd.generator.vo.GenTableVo;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 代码生成器服务实现类
*/
@Service
public class GenerateServiceImpl implements IGenerateService {
private static final Logger log = LoggerFactory.getLogger(GenerateServiceImpl.class);
@Resource
GenTableMapper genTableMapper;
@Resource
GenTableColumnMapper genTableColumnMapper;
@Resource
SystemAuthMenuMapper systemAuthMenuMapper;
/**
* 库列表
*
* @author fzr
* @param pageParam 分页参数
* @param params 搜索参数
* @return PageResult<Map<String, String>>
*/
@Override
public PageResult<DbTableVo> db(PageParam pageParam, Map<String, String> params) {
Integer page = pageParam.getPageNo();
Integer limit = pageParam.getPageSize();
PageHelper.startPage(page, limit);
List<DbTableVo> tables = genTableMapper.selectDbTableList(params);
for (DbTableVo vo : tables) {
if (vo.getUpdateTime() == null) {
vo.setUpdateTime("");
}
}
return PageResult.pageHelper(tables);
}
/**
* 库列表
*
* @author fzr
* @param params 搜索参数
* @return PageResult<Map<String, String>>
*/
@Override
public List<DbTableVo> dbAll(Map<String, String> params) {
List<DbTableVo> tables = genTableMapper.selectDbTableAllList(params);
for (DbTableVo vo : tables) {
if (vo.getUpdateTime() == null) {
vo.setUpdateTime("");
}
}
return tables;
}
/**
* 根据表名查字段
*
* @param tableName 表名
* @return List<DbColumnVo>
*/
@Override
public List<DbColumnVo> dbColumn(String tableName) {
List<GenTableColumn> columns = genTableMapper.selectDbTableColumnsByName(tableName);
List<DbColumnVo> list = new LinkedList<>();
for (GenTableColumn col : columns) {
DbColumnVo vo = new DbColumnVo();
vo.setColumnName(col.getColumnName());
vo.setColumnType(col.getColumnType());
vo.setColumnComment(col.getColumnComment());
list.add(vo);
}
return list;
}
/**
* 生成列表
*
* @param pageParam 分页参数
* @param params 搜索参数
* @return PageResult<Map<String, Object>>
*/
@Override
public PageResult<GenTableVo> list(PageParam pageParam, Map<String, String> params) {
Integer page = pageParam.getPageNo();
Integer limit = pageParam.getPageSize();
QueryWrapper<GenTable> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("id");
queryWrapper.select("id,gen_type,table_name,table_comment,create_time,update_time");
genTableMapper.setSearch(queryWrapper, params, new String[]{
"like:tableName@table_name:str",
"like:tableComment@table_comment:str",
"datetime:startTime-endTime@create_time:str"
});
IPage<GenTable> iPage = genTableMapper.selectPage(new Page<>(page, limit), queryWrapper);
List<GenTableVo> list = new LinkedList<>();
for (GenTable item : iPage.getRecords()) {
GenTableVo vo = new GenTableVo();
BeanUtils.copyProperties(item, vo);
vo.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
list.add(vo);
}
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
}
/**
* 生成详情
*
* @author fzr
* @return Object
*/
@Override
public Map<String, Object> detail(Integer id) {
Map<String, Object> maps = new LinkedHashMap<>();
GenTable genTable = genTableMapper.selectById(id);
Assert.notNull(genTable, "查询的数据不存在");
// 基本信息
Map<String, Object> base = new LinkedHashMap<>();
base.put("id", genTable.getId());
base.put("tableName", genTable.getTableName());
base.put("tableComment", genTable.getTableComment());
base.put("entityName", genTable.getEntityName());
base.put("authorName", genTable.getAuthorName());
base.put("remarks", genTable.getRemarks());
base.put("createTime", TimeUtils.timestampToDate(genTable.getCreateTime()));
base.put("updateTime", TimeUtils.timestampToDate(genTable.getUpdateTime()));
maps.put("base", base);
// 生成信息
Map<String, Object> gen = new LinkedHashMap<>();
gen.put("genTpl", genTable.getGenTpl());
gen.put("genType", genTable.getGenType());
gen.put("genPath", genTable.getGenPath());
gen.put("moduleName", genTable.getModuleName());
gen.put("functionName", genTable.getFunctionName());
gen.put("treePrimary", genTable.getTreePrimary());
gen.put("treeParent", genTable.getTreeParent());
gen.put("treeName", genTable.getTreeName());
gen.put("subTableName", genTable.getSubTableName());
gen.put("subTableFk", genTable.getSubTableFk());
gen.put("subTableFr", genTable.getSubTableFr());
gen.put("menuStatus", genTable.getMenuStatus());
gen.put("menuPid", genTable.getMenuPid());
gen.put("menuName", genTable.getMenuName());
maps.put("gen", gen);
// 字段信息
QueryWrapper<GenTableColumn> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("table_id", id);
queryWrapper.orderByAsc("sort");
List<GenColumnVo> columns = new LinkedList<>();
for (GenTableColumn item : genTableColumnMapper.selectList(queryWrapper)) {
GenColumnVo vo = new GenColumnVo();
BeanUtils.copyProperties(item, vo);
vo.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
columns.add(vo);
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
likeadmin是一套基于Vue3的免费任意商用管理后台框架,它包含1805个文件,其中488个Java文件、327个JavaScript文件、314个Vue文件、228个SVG文件、162个TypeScript文件、96个PNG文件、78个CSS文件、22个JSON文件和18个SCSS文件。该框架专为快速开发业务项目而设计,支持管理后台、微信小程序、手机H5和PC端,集成了常见业务场景,可帮助你高效打造项目产品。它使用JDK8、Springboot2.5、TypeScript、Vue3、vite2和Element Plus1.2(ElementUI)技术栈,提供Springboot管理后台、前后端分离管理后台、Vue.js管理后台和Element UI管理后台等解决方案。
资源推荐
资源详情
资源评论
收起资源包目录
基于Vue3的likeadmin免费任意商用管理后台设计源码 (1806个子文件)
.eslintrc.cjs 1KB
.eslintrc.cjs 1KB
mysqld.cnf 1KB
entry.5522eb0f.css 337KB
element-plus.ac0f3cb6.css 212KB
iconfont.css 79KB
index.4df2ba90.css 59KB
u-icon.81bcc25e.css 47KB
vue3-video-play.c9f7fe01.css 27KB
index.bb66d4f7.css 25KB
@wangeditor.4f35b623.css 15KB
uni.830f39b2.css 15KB
z-paging.7a94f2f9.css 8KB
u-button.48af928a.css 4KB
error-404.18ced855.css 4KB
pay.58f44799.css 3KB
dark.css 2KB
var.css 2KB
u-form-item.e55e5c90.css 2KB
error-500.e60962de.css 2KB
var.css 2KB
index.6d650969.css 2KB
recharge.f77e36a4.css 2KB
default.c7bb6831.css 2KB
u-popup.3b64afbe.css 2KB
tabbar.0ded8ef7.css 1KB
user_data.fbd6c979.css 1KB
picker.4f0f5330.css 1KB
highlight.5f5db245.css 1KB
news.cf577e19.css 1KB
u-checkbox.c93b1db2.css 1KB
nprogress.a2a0c377.css 997B
oa-phone.8b9170e2.css 931B
login.4d41b1b0.css 893B
u-avatar.dfe1b6cb.css 890B
user_wallet.65835499.css 852B
u-avatar-cropper.91a54bb1.css 849B
u-search.35cfd0ff.css 769B
u-badge.e5ec9c3e.css 711B
index.58ba4db9.css 645B
user_set.3bc68286.css 627B
info.afbb61a1.css 619B
picker.05436930.css 573B
tabbar.5c487d41.css 427B
index.be29c95e.css 409B
collection.c4157529.css 404B
news-card.9d2e9b2e.css 403B
news_detail.3a6411e3.css 401B
index.2ace3fcf.css 397B
u-image.a7813cd9.css 388B
index.9bce7fe7.css 330B
search.c7afcc50.css 325B
login.c4e413a4.css 296B
index.0d25a475.css 284B
preview-pc.a17d7b25.css 254B
error.be93caf8.css 240B
menu.a050bec6.css 231B
security.31c65502.css 230B
decoration-img.49159595.css 192B
preview.6e931073.css 190B
content.efb8af20.css 188B
content.9f244b19.css 188B
content.75595e09.css 175B
user.bfaffbd1.css 148B
content.c9a2d497.css 141B
index.ffcb57f7.css 136B
content.8f3b2cf8.css 126B
pc.21b28473.css 124B
index.9d59564a.css 124B
u-parse.93f983af.css 115B
payment_result.4b7a68e2.css 115B
as_us.a2f8b82c.css 91B
u-verification-code.e967c1e9.css 74B
tailwind.css 72B
cache.b08e0053.css 60B
tailwind.css 58B
index.a318de61.css 52B
forget_pwd.4dcdda84.css 44B
register.4507cc80.css 44B
change_password.a7a587c2.css 44B
bind_mobile.d6fec8d5.css 44B
var.css 0B
.env.example 223B
.env.development.example 61B
.env.production.example 60B
.env.production.example 36B
.env.development.example 36B
.env.production.example 29B
.env.development.example 28B
.gitignore 393B
.gitignore 386B
.gitignore 319B
.gitignore 179B
.gitignore 97B
.gitignore 10B
index.html 5KB
404.html 2KB
200.html 2KB
index.html 2KB
index.html 1KB
共 1806 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
沐知全栈开发
- 粉丝: 5017
- 资源: 4984
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- .archivetemp解压密码.url
- AI运营网站系统+支持GTP4 支持Midjourney绘画+文档分析+多模态模型支持+识图模型
- CNC转换器(信诚)CNC转换器(信诚)
- CNC转换器(信诚)CNC转换器(信诚)
- FaceFusionSharp OnnxRuntime版 视频换脸.rar
- 上市公司澄清公告数据集.xlsx
- 基于Matlab实现的基于车辆运动学,实现低速度下的MPC轨迹跟踪(高分项目)
- 安卓Android社团管理App+源代码+文档说明+数据库(高分项目).zip
- 基于安卓Android的社团管理App+sql数据库(高分毕设项目).zip
- 通用性I2C接口的应用之驱动SHT20(N32G45XVL-STB)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功