1.初始化版本,2.引入thirdpart模块,引入canteen模块,初始化菜品分类,spu
This commit is contained in:
commit
aff77150d6
1595 files changed
+168833
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen;
|
||||
|
||||
import com.bsd.pjcloud.common.datasource.annotation.EnableDynamicDataSource;
|
||||
import com.bsd.pjcloud.common.feign.annotation.EnablePjcloudFeignClients;
|
||||
import com.bsd.pjcloud.common.security.annotation.EnablePjcloudResourceServer;
|
||||
import com.bsd.pjcloud.common.swagger.annotation.EnableOpenApi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/07/29 代码生成模块
|
||||
*/
|
||||
@EnableDynamicDataSource
|
||||
@EnablePjcloudFeignClients
|
||||
@EnableOpenApi("gen")
|
||||
@EnableDiscoveryClient
|
||||
@EnablePjcloudResourceServer
|
||||
@SpringBootApplication
|
||||
public class PjcloudCodeGenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PjcloudCodeGenApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.bsd.pjcloud.codegen.config;
|
||||
|
||||
import cn.smallbun.screw.core.constant.DefaultConstants;
|
||||
import lombok.Data;
|
||||
import org.anyline.util.ConfigTable;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 代码生成默认配置类
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2024/7/15
|
||||
*/
|
||||
@Data
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConfigurationProperties(prefix = PjcloudCodeGenDefaultProperties.PREFIX)
|
||||
public class PjcloudCodeGenDefaultProperties implements InitializingBean {
|
||||
|
||||
public static final String PREFIX = "codegen";
|
||||
|
||||
/**
|
||||
* 是否开启在线更新
|
||||
*/
|
||||
private boolean autoCheckVersion = true;
|
||||
|
||||
/**
|
||||
* 模板项目地址
|
||||
*/
|
||||
private String onlineUrl = DefaultConstants.CGTM_URL;
|
||||
|
||||
/**
|
||||
* 生成代码的包名
|
||||
*/
|
||||
private String packageName = "com.bsd.pjcloud";
|
||||
|
||||
/**
|
||||
* 生成代码的版本
|
||||
*/
|
||||
private String version = "1.0.0";
|
||||
|
||||
/**
|
||||
* 生成代码的模块名
|
||||
*/
|
||||
private String moduleName = "admin";
|
||||
|
||||
/**
|
||||
* 生成代码的后端路径
|
||||
*/
|
||||
private String backendPath = "pjcloud";
|
||||
|
||||
/**
|
||||
* 生成代码的前端路径
|
||||
*/
|
||||
private String frontendPath = "pjcloud-ui";
|
||||
|
||||
/**
|
||||
* 生成代码的作者
|
||||
*/
|
||||
private String author = "pjcloud";
|
||||
|
||||
/**
|
||||
* 生成代码的邮箱
|
||||
*/
|
||||
private String email = "sw@pjcloud.vip";
|
||||
|
||||
/**
|
||||
* 表单布局(一列、两列)
|
||||
*/
|
||||
private Integer formLayout = 2;
|
||||
|
||||
/**
|
||||
* 下载方式 (0 文件下载、1写入目录)
|
||||
*/
|
||||
private String generatorType = "0";
|
||||
|
||||
/**
|
||||
* 是否同步路由
|
||||
*/
|
||||
private String syncRoute = "0";
|
||||
|
||||
/**
|
||||
* <a href="http://doc.anyline.org/aa/3c_14011">集成mybatis动态数据源</a>
|
||||
*
|
||||
* @throws Exception 例外
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
ConfigTable.KEEP_ADAPTER = 0;
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenCreateTable;
|
||||
import com.bsd.pjcloud.codegen.service.GenCreateTableService;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GenCreateTableVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/create-table")
|
||||
@Tag(description = "create-table", name = "自动创建表管理管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenCreateTableController {
|
||||
|
||||
private final GenCreateTableService createTableService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param createTable 自动创建表管理
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPage(Page page, @ModelAttribute GenCreateTable createTable,
|
||||
@RequestParam(required = false) String[] queryTime) {
|
||||
QueryWrapper<GenCreateTable> query = Wrappers.query(createTable);
|
||||
return R.ok(createTableService.page(page, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询自动创建表管理
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(createTableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增自动创建表管理
|
||||
* @param createTableVO 自动创建表管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增自动创建表管理", description = "新增自动创建表管理")
|
||||
@PostMapping
|
||||
@HasPermission("codegen_table_add")
|
||||
public R save(@RequestBody GenCreateTableVO createTableVO) {
|
||||
// 切换目标数据源
|
||||
DynamicDataSourceContextHolder.push(createTableVO.getDsName());
|
||||
createTableService.createTable(createTableVO);
|
||||
GenCreateTable createTable = new GenCreateTable();
|
||||
BeanUtil.copyProperties(createTableVO, createTable);
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
return R.ok(createTableService.saveOrUpdate(createTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改自动创建表管理
|
||||
* @param createTable 自动创建表管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改自动创建表管理", description = "修改自动创建表管理")
|
||||
@PutMapping
|
||||
@HasPermission("codegen_table_add")
|
||||
public R updateById(@RequestBody GenCreateTable createTable) {
|
||||
return R.ok(createTableService.updateById(createTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除自动创建表管理
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除自动创建表管理", description = "通过id删除自动创建表管理")
|
||||
@DeleteMapping("/{id}")
|
||||
@HasPermission("codegen_table_add")
|
||||
public R removeById(@PathVariable Long id) {
|
||||
return R.ok(createTableService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户所有自动创建表管理
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
return R.ok(createTableService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ids删除
|
||||
* @param ids ids
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过ids删除", description = "通过ids删除")
|
||||
@DeleteMapping
|
||||
@HasPermission("codegen_table_add")
|
||||
public R removeById(@RequestBody List<Long> ids) {
|
||||
return R.ok(createTableService.removeByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.smallbun.screw.boot.config.Screw;
|
||||
import cn.smallbun.screw.boot.properties.ScrewProperties;
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenDatasourceConf;
|
||||
import com.bsd.pjcloud.codegen.service.GenDatasourceConfService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.core.util.SpringContextHolder;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.common.xss.core.XssCleanIgnore;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 数据源管理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-03-31 16:00:20
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/dsconf")
|
||||
public class GenDsConfController {
|
||||
|
||||
private final GenDatasourceConfService datasourceConfService;
|
||||
|
||||
private final Screw screw;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param datasourceConf 数据源表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getSysDatasourceConfPage(Page page, GenDatasourceConf datasourceConf) {
|
||||
return R.ok(datasourceConfService.page(page,
|
||||
Wrappers.<GenDatasourceConf>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName,
|
||||
datasourceConf.getDsName())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据源
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Inner(value = false)
|
||||
public R list() {
|
||||
return R.ok(datasourceConfService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询数据源表
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(datasourceConfService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据源表
|
||||
* @param datasourceConf 数据源表
|
||||
* @return R
|
||||
*/
|
||||
@PostMapping
|
||||
@XssCleanIgnore
|
||||
public R save(@RequestBody GenDatasourceConf datasourceConf) {
|
||||
return R.ok(datasourceConfService.saveDsByEnc(datasourceConf));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据源表
|
||||
* @param conf 数据源表
|
||||
* @return R
|
||||
*/
|
||||
@PutMapping
|
||||
@XssCleanIgnore
|
||||
public R updateById(@RequestBody GenDatasourceConf conf) {
|
||||
return R.ok(datasourceConfService.updateDsByEnc(conf));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除数据源表
|
||||
* @param ids id
|
||||
* @return R
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(datasourceConfService.removeByDsId(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源对应的文档
|
||||
* @param dsName 数据源名称
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/doc")
|
||||
public void generatorDoc(String dsName, HttpServletResponse response) {
|
||||
// 设置指定的数据源
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
DataSource dataSource = dynamicRoutingDataSource.determineDataSource();
|
||||
|
||||
// 设置指定的目标表
|
||||
ScrewProperties screwProperties = SpringContextHolder.getBean(ScrewProperties.class);
|
||||
|
||||
// 生成
|
||||
byte[] data = screw.documentGeneration(dsName, dataSource, screwProperties).toByteArray();
|
||||
response.reset();
|
||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
|
||||
response.setContentType("application/octet-stream");
|
||||
IoUtil.write(response.getOutputStream(), Boolean.FALSE, data);
|
||||
}
|
||||
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFieldType;
|
||||
import com.bsd.pjcloud.codegen.service.GenFieldTypeService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/fieldtype")
|
||||
@Tag(description = "fieldtype", name = "列属性管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenFieldTypeController {
|
||||
|
||||
private final GenFieldTypeService fieldTypeService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param fieldType 列属性
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getFieldTypePage(Page page, GenFieldType fieldType) {
|
||||
return R.ok(fieldTypeService.page(page,
|
||||
Wrappers.<GenFieldType>lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(fieldType.getColumnType()), GenFieldType::getColumnType,
|
||||
fieldType.getColumnType())));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询列表", description = "查询列表")
|
||||
@GetMapping("/list")
|
||||
public R list(GenFieldType fieldType) {
|
||||
return R.ok(fieldTypeService.list(Wrappers.query(fieldType)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询列属性
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/details/{id}")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(fieldTypeService.getById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public R getDetails(GenFieldType query) {
|
||||
return R.ok(fieldTypeService.getOne(Wrappers.query(query), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增列属性
|
||||
* @param fieldType 列属性
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增列属性", description = "新增列属性")
|
||||
@SysLog("新增列属性")
|
||||
@PostMapping
|
||||
public R save(@RequestBody GenFieldType fieldType) {
|
||||
return R.ok(fieldTypeService.save(fieldType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列属性
|
||||
* @param fieldType 列属性
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改列属性", description = "修改列属性")
|
||||
@SysLog("修改列属性")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody GenFieldType fieldType) {
|
||||
return R.ok(fieldTypeService.updateById(fieldType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除列属性
|
||||
* @param ids id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除列属性", description = "通过id删除列属性")
|
||||
@SysLog("通过id删除列属性")
|
||||
@DeleteMapping
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(fieldTypeService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param fieldType 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<GenFieldType> export(GenFieldType fieldType) {
|
||||
return fieldTypeService.list(Wrappers.query(fieldType));
|
||||
}
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFormConf;
|
||||
import com.bsd.pjcloud.codegen.service.GenFormConfService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 表单管理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-08-12 15:55:35
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/form")
|
||||
@Tag(description = "form", name = "表单管理")
|
||||
public class GenFormConfController {
|
||||
|
||||
private final GenFormConfService genRecordService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param formConf 生成记录
|
||||
* @return
|
||||
*/
|
||||
@Operation(description = "分页查询", summary = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getGenFormConfPage(Page page, GenFormConf formConf) {
|
||||
return R.ok(genRecordService.page(page, Wrappers.query(formConf)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询生成记录
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(description = "通过id查询", summary = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(genRecordService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增生成记录
|
||||
* @param formConf 生成记录
|
||||
* @return R
|
||||
*/
|
||||
@Operation(description = "新增生成记录", summary = "新增生成记录")
|
||||
@PostMapping
|
||||
public R save(@RequestBody GenFormConf formConf) {
|
||||
genRecordService.save(formConf);
|
||||
return R.ok(formConf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改生成记录
|
||||
* @param formConf 生成记录
|
||||
* @return R
|
||||
*/
|
||||
@Operation(description = "修改生成记录", summary = "修改生成记录")
|
||||
@SysLog("修改生成记录")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody GenFormConf formConf) {
|
||||
return R.ok(genRecordService.updateById(formConf));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除生成记录
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(description = "通过id删除生成记录", summary = "通过id删除生成记录")
|
||||
@SysLog("通过id删除生成记录")
|
||||
@DeleteMapping("/{id}")
|
||||
public R removeById(@PathVariable Long id) {
|
||||
return R.ok(genRecordService.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.service.GenGroupService;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GroupVO;
|
||||
import com.bsd.pjcloud.codegen.util.vo.TemplateGroupDTO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板分组
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 20:01:53
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/group")
|
||||
@Tag(description = "group", name = "模板分组管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenGroupController {
|
||||
|
||||
private final GenGroupService genGroupService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param genGroup 模板分组
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@HasPermission("codegen_group_view")
|
||||
public R getgenGroupPage(Page page, GenGroupEntity genGroup) {
|
||||
LambdaQueryWrapper<GenGroupEntity> wrapper = Wrappers.<GenGroupEntity>lambdaQuery()
|
||||
.like(genGroup.getId() != null, GenGroupEntity::getId, genGroup.getId())
|
||||
.like(StrUtil.isNotEmpty(genGroup.getGroupName()), GenGroupEntity::getGroupName, genGroup.getGroupName());
|
||||
return R.ok(genGroupService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询模板分组
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@HasPermission("codegen_group_view")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(genGroupService.getGroupVoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模板分组
|
||||
*
|
||||
* @param genTemplateGroup 模板分组
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增模板分组", description = "新增模板分组")
|
||||
@SysLog("新增模板分组")
|
||||
@PostMapping
|
||||
@HasPermission("codegen_group_add")
|
||||
public R save(@RequestBody TemplateGroupDTO genTemplateGroup) {
|
||||
genGroupService.saveGenGroup(genTemplateGroup);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模板分组
|
||||
*
|
||||
* @param groupVo 模板分组
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改模板分组", description = "修改模板分组")
|
||||
@SysLog("修改模板分组")
|
||||
@PutMapping
|
||||
@HasPermission("codegen_group_edit")
|
||||
public R updateById(@RequestBody GroupVO groupVo) {
|
||||
genGroupService.updateGroupAndTemplateById(groupVo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除模板分组
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除模板分组", description = "通过id删除模板分组")
|
||||
@SysLog("通过id删除模板分组")
|
||||
@DeleteMapping
|
||||
@HasPermission("codegen_group_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
genGroupService.delGroupAndTemplate(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param genGroup 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@HasPermission("codegen_group_export")
|
||||
public List<GenGroupEntity> export(GenGroupEntity genGroup) {
|
||||
return genGroupService.list(Wrappers.query(genGroup));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 响应信息主体
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "查询列表", description = "查询列表")
|
||||
public R list() {
|
||||
List<GenGroupEntity> list = genGroupService.list(Wrappers.<GenGroupEntity>lambdaQuery()
|
||||
.orderByDesc(GenGroupEntity::getCreateTime));
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTable;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
import com.bsd.pjcloud.codegen.service.GenTableColumnService;
|
||||
import com.bsd.pjcloud.codegen.service.GenTableService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:34:55
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/table")
|
||||
@Tag(description = "table", name = "列属性管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenTableController {
|
||||
|
||||
private final GenTableColumnService tableColumnService;
|
||||
|
||||
private final GenTableService tableService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param table 列属性
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getTablePage(Page page, GenTable table) {
|
||||
return R.ok(tableService.queryTablePage(page, table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询表信息(代码生成设置 + 表 + 字段设置)
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getTable(@PathVariable("id") Long id) {
|
||||
return R.ok(tableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源所有表
|
||||
* @param dsName 数据源
|
||||
*/
|
||||
@GetMapping("/list/{dsName}")
|
||||
public R listTable(@PathVariable("dsName") String dsName) {
|
||||
return R.ok(tableService.queryTableList(dsName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/{dsName}/{tableName}")
|
||||
public R<GenTable> getTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) {
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/column/{dsName}/{tableName}")
|
||||
public R getColumn(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableColumn(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/ddl/{dsName}/{tableName}")
|
||||
public R getDdl(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableDdl(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步表信息
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/sync/{dsName}/{tableName}")
|
||||
public R<GenTable> syncTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) {
|
||||
// 表配置删除
|
||||
tableService.remove(
|
||||
Wrappers.<GenTable>lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName));
|
||||
// 字段配置删除
|
||||
tableColumnService.remove(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName));
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列属性
|
||||
* @param table 列属性
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改列属性", description = "修改列属性")
|
||||
@SysLog("修改列属性")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody GenTable table) {
|
||||
return R.ok(tableService.updateById(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改表字段数据
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @param tableFieldList 字段列表
|
||||
*/
|
||||
@PutMapping("/field/{dsName}/{tableName}")
|
||||
public R<String> updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName,
|
||||
@RequestBody List<GenTableColumnEntity> tableFieldList) {
|
||||
tableColumnService.updateTableField(dsName, tableName, tableFieldList);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param table 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<GenTable> export(GenTable table) {
|
||||
return tableService.list(Wrappers.query(table));
|
||||
}
|
||||
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import com.bsd.pjcloud.codegen.service.GenTemplateService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import com.bsd.pjcloud.common.xss.core.XssCleanIgnore;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 17:15:44
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/template")
|
||||
@Tag(description = "template", name = "模板管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenTemplateController {
|
||||
|
||||
private final GenTemplateService genTemplateService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param genTemplate 模板
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@HasPermission("codegen_template_view")
|
||||
public R getGenTemplatePage(Page page, GenTemplateEntity genTemplate) {
|
||||
LambdaQueryWrapper<GenTemplateEntity> wrapper = Wrappers.<GenTemplateEntity>lambdaQuery()
|
||||
.like(genTemplate.getId() != null, GenTemplateEntity::getId, genTemplate.getId())
|
||||
.like(StrUtil.isNotEmpty(genTemplate.getTemplateName()), GenTemplateEntity::getTemplateName,
|
||||
genTemplate.getTemplateName());
|
||||
return R.ok(genTemplateService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部模板
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "查询全部", description = "查询全部")
|
||||
@GetMapping("/list")
|
||||
@HasPermission("codegen_template_view")
|
||||
public R list() {
|
||||
return R.ok(genTemplateService.list(Wrappers.<GenTemplateEntity>lambdaQuery()
|
||||
.orderByDesc(GenTemplateEntity::getCreateTime)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询模板
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@HasPermission("codegen_template_view")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(genTemplateService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模板
|
||||
*
|
||||
* @param genTemplate 模板
|
||||
* @return R
|
||||
*/
|
||||
@XssCleanIgnore
|
||||
@Operation(summary = "新增模板", description = "新增模板")
|
||||
@SysLog("新增模板")
|
||||
@PostMapping
|
||||
@HasPermission("codegen_template_add")
|
||||
public R save(@RequestBody GenTemplateEntity genTemplate) {
|
||||
return R.ok(genTemplateService.save(genTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模板
|
||||
*
|
||||
* @param genTemplate 模板
|
||||
* @return R
|
||||
*/
|
||||
@XssCleanIgnore
|
||||
@Operation(summary = "修改模板", description = "修改模板")
|
||||
@SysLog("修改模板")
|
||||
@PutMapping
|
||||
@HasPermission("codegen_template_edit")
|
||||
public R updateById(@RequestBody GenTemplateEntity genTemplate) {
|
||||
return R.ok(genTemplateService.updateById(genTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除模板
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除模板", description = "通过id删除模板")
|
||||
@SysLog("通过id删除模板")
|
||||
@DeleteMapping
|
||||
@HasPermission("codegen_template_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(genTemplateService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param genTemplate 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@HasPermission("codegen_template_export")
|
||||
public List<GenTemplateEntity> export(GenTemplateEntity genTemplate) {
|
||||
return genTemplateService.list(Wrappers.query(genTemplate));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在线更新模板
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "在线更新模板", description = "在线更新模板")
|
||||
@GetMapping("/online")
|
||||
@HasPermission("codegen_template_view")
|
||||
public R online() {
|
||||
return genTemplateService.onlineUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查版本
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Operation(summary = "在线检查模板", description = "在线检查模板")
|
||||
@GetMapping("/checkVersion")
|
||||
@HasPermission("codegen_template_view")
|
||||
public R checkVersion() {
|
||||
return genTemplateService.checkVersion();
|
||||
}
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.service.GenTemplateGroupService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板分组关联表
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-22 09:25:15
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/templateGroup")
|
||||
@Tag(description = "templateGroup", name = "模板分组关联表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenTemplateGroupController {
|
||||
|
||||
private final GenTemplateGroupService genTemplateGroupService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param genTemplateGroup 模板分组关联表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@HasPermission("codegen_templateGroup_view")
|
||||
public R getgenTemplateGroupPage(Page page, GenTemplateGroupEntity genTemplateGroup) {
|
||||
LambdaQueryWrapper<GenTemplateGroupEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(genTemplateGroupService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询模板分组关联表
|
||||
* @param groupId id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{groupId}")
|
||||
@HasPermission("codegen_templateGroup_view")
|
||||
public R getById(@PathVariable("groupId") Long groupId) {
|
||||
return R.ok(genTemplateGroupService.getById(groupId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模板分组关联表
|
||||
* @param genTemplateGroup 模板分组关联表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增模板分组关联表", description = "新增模板分组关联表")
|
||||
@SysLog("新增模板分组关联表")
|
||||
@PostMapping
|
||||
@HasPermission("codegen_templateGroup_add")
|
||||
public R save(@RequestBody GenTemplateGroupEntity genTemplateGroup) {
|
||||
return R.ok(genTemplateGroupService.save(genTemplateGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模板分组关联表
|
||||
* @param genTemplateGroup 模板分组关联表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改模板分组关联表", description = "修改模板分组关联表")
|
||||
@SysLog("修改模板分组关联表")
|
||||
@PutMapping
|
||||
@HasPermission("codegen_templateGroup_edit")
|
||||
public R updateById(@RequestBody GenTemplateGroupEntity genTemplateGroup) {
|
||||
return R.ok(genTemplateGroupService.updateById(genTemplateGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除模板分组关联表
|
||||
* @param ids groupId列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除模板分组关联表", description = "通过id删除模板分组关联表")
|
||||
@SysLog("通过id删除模板分组关联表")
|
||||
@DeleteMapping
|
||||
@HasPermission("codegen_templateGroup_del")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(genTemplateGroupService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param genTemplateGroup 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@HasPermission("codegen_templateGroup_export")
|
||||
public List<GenTemplateGroupEntity> export(GenTemplateGroupEntity genTemplateGroup) {
|
||||
return genTemplateGroupService.list(Wrappers.query(genTemplateGroup));
|
||||
}
|
||||
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.controller;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.bsd.pjcloud.codegen.service.GeneratorService;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 代码生成器
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2018-07-30
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/generator")
|
||||
public class GeneratorController {
|
||||
|
||||
private final GeneratorService generatorService;
|
||||
|
||||
/**
|
||||
* ZIP 下载生成代码
|
||||
* @param tableIds 数据表ID
|
||||
* @param response 流输出对象
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/download")
|
||||
@Idempotent(key = "#tableIds", expireTime = 10, info = "正在生成代码,请勿重复操作")
|
||||
public void download(String tableIds, HttpServletResponse response) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||
|
||||
// 生成代码
|
||||
for (String tableId : tableIds.split(StrUtil.COMMA)) {
|
||||
generatorService.downloadCode(Long.parseLong(tableId), zip);
|
||||
}
|
||||
|
||||
IoUtil.close(zip);
|
||||
|
||||
// zip压缩包数据
|
||||
byte[] data = outputStream.toByteArray();
|
||||
|
||||
response.reset();
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s.zip", tableIds));
|
||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
IoUtil.write(response.getOutputStream(), false, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标目录生成代码
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/code")
|
||||
@Idempotent(key = "#tableIds", expireTime = 10, info = "正在生成代码,请勿重复操作")
|
||||
public R<String> code(String tableIds) throws Exception {
|
||||
// 生成代码
|
||||
for (String tableId : tableIds.split(StrUtil.COMMA)) {
|
||||
generatorService.generatorCode(Long.valueOf(tableId));
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览代码
|
||||
* @param tableId 表ID
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/preview")
|
||||
public List<Map<String, String>> preview(Long tableId) {
|
||||
return generatorService.preview(tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单设计器初始化数据
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return json string
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/vform")
|
||||
public String vform(String dsName, String tableName) {
|
||||
return generatorService.vform(dsName, tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单设计器初始化数据
|
||||
* @param formId 表单ID
|
||||
* @return json string
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/vform/sfc")
|
||||
public void vformSfc(Long formId, HttpServletResponse response) {
|
||||
String result = generatorService.vformSfc(formId);
|
||||
|
||||
byte[] data = result.getBytes(StandardCharsets.UTF_8);
|
||||
response.reset();
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=form.vue");
|
||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(data.length));
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
IoUtil.write(response.getOutputStream(), false, data);
|
||||
}
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/07/29 列属性: https://blog.csdn.net/lkforce/article/details/79557482
|
||||
*/
|
||||
@Data
|
||||
public class ColumnEntity {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* JAVA 数据类型
|
||||
*/
|
||||
private String javaType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 驼峰属性
|
||||
*/
|
||||
private String caseAttrName;
|
||||
|
||||
/**
|
||||
* 普通属性
|
||||
*/
|
||||
private String lowerAttrName;
|
||||
|
||||
/**
|
||||
* 属性类型
|
||||
*/
|
||||
private String attrType;
|
||||
|
||||
/**
|
||||
* 其他信息
|
||||
*/
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*/
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 是否可以为空
|
||||
*/
|
||||
private Boolean nullable;
|
||||
|
||||
/**
|
||||
* 是否隐藏
|
||||
*/
|
||||
private Boolean hidden;
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/8/2 生成配置
|
||||
*/
|
||||
@Data
|
||||
public class GenConfig {
|
||||
|
||||
/**
|
||||
* 数据源name
|
||||
*/
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 包名
|
||||
*/
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author;
|
||||
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 表前缀
|
||||
*/
|
||||
private String tablePrefix;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表备注
|
||||
*/
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 代码风格 0 - avue 1 - element 2 - uview
|
||||
*/
|
||||
private String style;
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("gen_create_table")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "自动创建表管理")
|
||||
public class GenCreateTable extends Model<GenCreateTable> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@Schema(description = "数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@Schema(description = "表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表注释
|
||||
*/
|
||||
@Schema(description = "表注释")
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 字段信息
|
||||
*/
|
||||
@Schema(description = "字段信息")
|
||||
private String columnInfo;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-正常,1-删除)
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据源表
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-03-31 16:00:20
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("gen_datasource_conf")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GenDatasourceConf extends Model<GenDatasourceConf> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
private String dsType;
|
||||
|
||||
/**
|
||||
* 配置类型 (0 主机形式 | 1 url形式)
|
||||
*/
|
||||
private Integer confType;
|
||||
|
||||
/**
|
||||
* 主机地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* jdbc-url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 实例
|
||||
*/
|
||||
private String instance;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0-正常,1-删除
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_field_type")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "列属性")
|
||||
public class GenFieldType extends Model<GenFieldType> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*/
|
||||
@Schema(description = "字段类型")
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 属性类型
|
||||
*/
|
||||
@Schema(description = "属性类型")
|
||||
private String attrType;
|
||||
|
||||
/**
|
||||
* 属性包名
|
||||
*/
|
||||
@Schema(description = "属性包名")
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-正常,1-删除)
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 生成记录
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-08-12 15:55:35
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("gen_form_conf")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "生成记录")
|
||||
public class GenFormConf extends Model<GenFormConf> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@Schema(description = "数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@Schema(description = "表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表单信息
|
||||
*/
|
||||
@Schema(description = "表单信息")
|
||||
private String formInfo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 0-正常,1-删除
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 所属租户
|
||||
*/
|
||||
@Schema(description = "所属租户", hidden = true)
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 模板分组
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 20:01:53
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("gen_group")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "模板分组")
|
||||
public class GenGroupEntity extends Model<GenGroupEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
@Schema(description = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 分组描述
|
||||
*/
|
||||
@Schema(description = "分组描述")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String groupDesc;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-正常,1-删除)
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:34:55
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_table")
|
||||
@FieldNameConstants
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "列属性")
|
||||
public class GenTable extends Model<GenTable> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@Schema(description = "数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@Schema(description = "数据源类型")
|
||||
private String dbType;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@Schema(description = "表名")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 类名
|
||||
*/
|
||||
@Schema(description = "类名")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@Schema(description = "说明")
|
||||
private String tableComment;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 项目包名
|
||||
*/
|
||||
@Schema(description = "项目包名")
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 项目版本号
|
||||
*/
|
||||
@Schema(description = "项目版本号")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 生成方式 0:zip压缩包 1:自定义目录
|
||||
*/
|
||||
@Schema(description = "生成方式 0:zip压缩包 1:自定义目录")
|
||||
private String generatorType;
|
||||
|
||||
/**
|
||||
* 后端生成路径
|
||||
*/
|
||||
@Schema(description = "后端生成路径")
|
||||
private String backendPath;
|
||||
|
||||
/**
|
||||
* 前端生成路径
|
||||
*/
|
||||
@Schema(description = "前端生成路径")
|
||||
private String frontendPath;
|
||||
|
||||
/**
|
||||
* 模块名
|
||||
*/
|
||||
@Schema(description = "模块名")
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 功能名
|
||||
*/
|
||||
@Schema(description = "功能名")
|
||||
private String functionName;
|
||||
|
||||
/**
|
||||
* 表单布局 1:一列 2:两列
|
||||
*/
|
||||
@Schema(description = "表单布局 1:一列 2:两列")
|
||||
private Integer formLayout;
|
||||
|
||||
/**
|
||||
* 所属菜单ID
|
||||
*/
|
||||
@Schema(description = "所属菜单ID")
|
||||
private Long syncMenuId;
|
||||
|
||||
/**
|
||||
* 是否同步路由
|
||||
*/
|
||||
@Schema
|
||||
private String syncRoute;
|
||||
|
||||
/**
|
||||
* 基类ID
|
||||
*/
|
||||
@Schema(description = "基类ID")
|
||||
private Long baseclassId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 代码生成风格
|
||||
*/
|
||||
private Long style;
|
||||
|
||||
/**
|
||||
* 子表名称
|
||||
*/
|
||||
private String childTableName;
|
||||
|
||||
/**
|
||||
* 主表关联键
|
||||
*/
|
||||
private String mainField;
|
||||
|
||||
/**
|
||||
* 子表关联键
|
||||
*/
|
||||
private String childField;
|
||||
|
||||
/**
|
||||
* 字段列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<GenTableColumnEntity> fieldList;
|
||||
|
||||
/**
|
||||
* 子表字段列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<GenTableColumnEntity> childFieldList;
|
||||
|
||||
/**
|
||||
* 代码风格(模版分组信息)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<GenGroupEntity> groupList;
|
||||
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2023-02-06
|
||||
*
|
||||
* 记录表字段的配置信息
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_table_column")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GenTableColumnEntity extends Model<GenDatasourceConf> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名
|
||||
*/
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 字段类型
|
||||
*/
|
||||
private String fieldType;
|
||||
|
||||
/**
|
||||
* 字段说明
|
||||
*/
|
||||
private String fieldComment;
|
||||
|
||||
/**
|
||||
* 属性名
|
||||
*/
|
||||
private String attrName;
|
||||
|
||||
/**
|
||||
* 属性类型
|
||||
*/
|
||||
private String attrType;
|
||||
|
||||
/**
|
||||
* 属性包名
|
||||
*/
|
||||
private String packageName;
|
||||
|
||||
/**
|
||||
* 自动填充
|
||||
*/
|
||||
private String autoFill;
|
||||
|
||||
/**
|
||||
* 主键 0:否 1:是
|
||||
*/
|
||||
private String primaryPk;
|
||||
|
||||
/**
|
||||
* 基类字段 0:否 1:是
|
||||
*/
|
||||
private String baseField;
|
||||
|
||||
/**
|
||||
* 表单项 0:否 1:是
|
||||
*/
|
||||
private String formItem;
|
||||
|
||||
/**
|
||||
* 表单必填 0:否 1:是
|
||||
*/
|
||||
private String formRequired;
|
||||
|
||||
/**
|
||||
* 表单类型
|
||||
*/
|
||||
private String formType;
|
||||
|
||||
/**
|
||||
* 表单效验
|
||||
*/
|
||||
private String formValidator;
|
||||
|
||||
/**
|
||||
* 列表项 0:否 1:是
|
||||
*/
|
||||
private String gridItem;
|
||||
|
||||
/**
|
||||
* 列表排序 0:否 1:是
|
||||
*/
|
||||
private String gridSort;
|
||||
|
||||
/**
|
||||
* 查询项 0:否 1:是
|
||||
*/
|
||||
private String queryItem;
|
||||
|
||||
/**
|
||||
* 查询方式
|
||||
*/
|
||||
private String queryType;
|
||||
|
||||
/**
|
||||
* 查询表单类型
|
||||
*/
|
||||
private String queryFormType;
|
||||
|
||||
/**
|
||||
* 字段字典类型
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String fieldDict;
|
||||
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 17:15:44
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("gen_template")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "模板")
|
||||
public class GenTemplateEntity extends Model<GenTemplateEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
@Schema(description = "模板名称")
|
||||
private String templateName;
|
||||
|
||||
/**
|
||||
* 模板路径
|
||||
*/
|
||||
@Schema(description = "模板路径")
|
||||
private String generatorPath;
|
||||
|
||||
/**
|
||||
* 模板描述
|
||||
*/
|
||||
@Schema(description = "模板描述")
|
||||
private String templateDesc;
|
||||
|
||||
/**
|
||||
* 模板代码
|
||||
*/
|
||||
@Schema(description = "模板代码")
|
||||
private String templateCode;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标识(0-正常,1-删除)
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 模板分组关联表
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-22 09:25:15
|
||||
*/
|
||||
@Data
|
||||
@TableName("gen_template_group")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "模板分组关联表")
|
||||
public class GenTemplateGroupEntity extends Model<GenTemplateGroupEntity> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 分组id
|
||||
*/
|
||||
@Schema(description = "分组id")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 模板id
|
||||
*/
|
||||
@Schema(description = "模板id")
|
||||
private Long templateId;
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/07/29 表属性: https://blog.csdn.net/lkforce/article/details/79557482
|
||||
*/
|
||||
@Data
|
||||
public class TableEntity {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private ColumnEntity pk;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private List<ColumnEntity> columns;
|
||||
|
||||
/**
|
||||
* 驼峰类型
|
||||
*/
|
||||
private String caseClassName;
|
||||
|
||||
/**
|
||||
* 普通类型
|
||||
*/
|
||||
private String lowerClassName;
|
||||
|
||||
/**
|
||||
* 数据库类型 (用于根据数据库个性化)
|
||||
*/
|
||||
private String dbType;
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenCreateTable;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenCreateTableMapper extends PjcloudBaseMapper<GenCreateTable> {
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenDatasourceConf;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 数据源表
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-03-31 16:00:20
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenDatasourceConfMapper extends PjcloudBaseMapper<GenDatasourceConf> {
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态查询
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022-07-09
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenDynamicMapper {
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<LinkedHashMap<String, Object>> dynamicQuerySql(@Param("value") String sq);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenFieldType;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenFieldTypeMapper extends PjcloudBaseMapper<GenFieldType> {
|
||||
|
||||
/**
|
||||
* 根据tableId,获取包列表
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return 返回包列表
|
||||
*/
|
||||
Set<String> getPackageByTableId(@Param("dsName") String dsName, @Param("tableName") String tableName);
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenFormConf;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 生成记录
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-08-12 15:55:35
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenFormConfMapper extends PjcloudBaseMapper<GenFormConf> {
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GroupVO;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 模板分组
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 20:01:53
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenGroupMapper extends PjcloudBaseMapper<GenGroupEntity> {
|
||||
|
||||
GroupVO getGroupVoById(@Param("id") Long id);
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenTableColumnMapper extends PjcloudBaseMapper<GenTableColumnEntity> {
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenTable;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:34:55
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenTableMapper extends PjcloudBaseMapper<GenTable> {
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 模板分组关联表
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-22 09:25:15
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenTemplateGroupMapper extends BaseMapper<GenTemplateGroupEntity> {
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.mapper;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 17:15:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface GenTemplateMapper extends PjcloudBaseMapper<GenTemplateEntity> {
|
||||
|
||||
/**
|
||||
* 根据groupId查询 模板
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
List<GenTemplateEntity> listTemplateById(Long groupId);
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenCreateTable;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GenCreateTableVO;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
public interface GenCreateTableService extends IService<GenCreateTable> {
|
||||
|
||||
/**
|
||||
* 自动创建表
|
||||
* @param createTableVO 表信息
|
||||
*/
|
||||
Boolean createTable(GenCreateTableVO createTableVO);
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenDatasourceConf;
|
||||
|
||||
/**
|
||||
* 数据源表
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-03-31 16:00:20
|
||||
*/
|
||||
public interface GenDatasourceConfService extends IService<GenDatasourceConf> {
|
||||
|
||||
/**
|
||||
* 保存数据源并且加密
|
||||
* @param genDatasourceConf
|
||||
* @return
|
||||
*/
|
||||
Boolean saveDsByEnc(GenDatasourceConf genDatasourceConf);
|
||||
|
||||
/**
|
||||
* 更新数据源
|
||||
* @param genDatasourceConf
|
||||
* @return
|
||||
*/
|
||||
Boolean updateDsByEnc(GenDatasourceConf genDatasourceConf);
|
||||
|
||||
/**
|
||||
* 更新动态数据的数据源列表
|
||||
* @param datasourceConf
|
||||
* @return
|
||||
*/
|
||||
void addDynamicDataSource(GenDatasourceConf datasourceConf);
|
||||
|
||||
/**
|
||||
* 校验数据源配置是否有效
|
||||
* @param datasourceConf 数据源信息
|
||||
* @return 有效/无效
|
||||
*/
|
||||
Boolean checkDataSource(GenDatasourceConf datasourceConf);
|
||||
|
||||
/**
|
||||
* 通过数据源名称删除
|
||||
* @param dsIds 数据源ID
|
||||
* @return
|
||||
*/
|
||||
Boolean removeByDsId(Long[] dsIds);
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFieldType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
public interface GenFieldTypeService extends IService<GenFieldType> {
|
||||
|
||||
/**
|
||||
* 根据tableId,获取包列表
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return 返回包列表
|
||||
*/
|
||||
Set<String> getPackageByTableId(String dsName, String tableName);
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFormConf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 表单管理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-08-12 15:55:35
|
||||
*/
|
||||
public interface GenFormConfService extends IService<GenFormConf> {
|
||||
|
||||
/**
|
||||
* 解析 form json
|
||||
* @param formInfo json
|
||||
* @return 字段
|
||||
*/
|
||||
Map<String, List<JSONObject>> parse(String formInfo);
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GroupVO;
|
||||
import com.bsd.pjcloud.codegen.util.vo.TemplateGroupDTO;
|
||||
|
||||
/**
|
||||
* 模板分组
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 20:01:53
|
||||
*/
|
||||
public interface GenGroupService extends IService<GenGroupEntity> {
|
||||
|
||||
void saveGenGroup(TemplateGroupDTO genTemplateGroup);
|
||||
|
||||
/**
|
||||
* 删除分组极其关系
|
||||
* @param ids
|
||||
*/
|
||||
void delGroupAndTemplate(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询group数据
|
||||
* @param id
|
||||
*/
|
||||
GroupVO getGroupVoById(Long id);
|
||||
|
||||
/**
|
||||
* 更新group数据
|
||||
* @param GroupVo
|
||||
*/
|
||||
void updateGroupAndTemplateById(GroupVO GroupVo);
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
public interface GenTableColumnService extends IService<GenTableColumnEntity> {
|
||||
|
||||
void initFieldList(List<GenTableColumnEntity> tableFieldList);
|
||||
|
||||
void updateTableField(String dsName, String tableName, List<GenTableColumnEntity> tableFieldList);
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTable;
|
||||
import org.anyline.metadata.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:34:55
|
||||
*/
|
||||
public interface GenTableService extends IService<GenTable> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询对应数据源的表
|
||||
*
|
||||
* @param page 分页信息
|
||||
* @param table 查询条件
|
||||
* @return 表
|
||||
*/
|
||||
IPage queryTablePage(Page<Table> page, GenTable table);
|
||||
|
||||
/**
|
||||
* 查询表信息(列),然后插入到中间表中
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名
|
||||
* @return GenTable
|
||||
*/
|
||||
GenTable queryOrBuildTable(String dsName, String tableName);
|
||||
|
||||
/**
|
||||
* 查询表ddl 语句
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return ddl 语句
|
||||
* @throws Exception
|
||||
*/
|
||||
String queryTableDdl(String dsName, String tableName) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询数据源里面的全部表
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @return table
|
||||
*/
|
||||
List<String> queryTableList(String dsName);
|
||||
|
||||
/**
|
||||
* 查询表的全部字段
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @return column
|
||||
*/
|
||||
List<String> queryTableColumn(String dsName, String tableName);
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
|
||||
/**
|
||||
* 模板分组关联表
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-22 09:25:15
|
||||
*/
|
||||
public interface GenTemplateGroupService extends IService<GenTemplateGroupEntity> {
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 17:15:44
|
||||
*/
|
||||
public interface GenTemplateService extends IService<GenTemplateEntity> {
|
||||
|
||||
/**
|
||||
* 检查版本
|
||||
* @return {@link R }
|
||||
*/
|
||||
R checkVersion();
|
||||
|
||||
|
||||
/**
|
||||
* 在线更新
|
||||
*
|
||||
* @return {@link R }
|
||||
*/
|
||||
R onlineUpdate();
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/7/29
|
||||
*/
|
||||
public interface GeneratorService {
|
||||
|
||||
/**
|
||||
* 生成代码zip写出
|
||||
*
|
||||
* @param tableId 表
|
||||
* @param zip 输出流
|
||||
*/
|
||||
void downloadCode(Long tableId, ZipOutputStream zip);
|
||||
|
||||
/**
|
||||
* 预览代码
|
||||
*
|
||||
* @param tableId 表
|
||||
* @return [{模板名称:渲染结果}]
|
||||
*/
|
||||
List<Map<String, String>> preview(Long tableId);
|
||||
|
||||
/**
|
||||
* 目标目录写入渲染结果
|
||||
*
|
||||
* @param tableId 表
|
||||
*/
|
||||
void generatorCode(Long tableId);
|
||||
|
||||
/**
|
||||
* 获取表单设计器需要的 JSON
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return json string
|
||||
*/
|
||||
String vform(String dsName, String tableName);
|
||||
|
||||
/**
|
||||
* 获取表单设计器需要的 JSON
|
||||
*
|
||||
* @param formId 数据源名称
|
||||
* @return json string
|
||||
*/
|
||||
String vformSfc(Long formId);
|
||||
|
||||
/**
|
||||
* 同步路由和菜单
|
||||
*
|
||||
* @param tableId 表ID
|
||||
*/
|
||||
void syncRouteAndMenu(Long tableId);
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenCreateTable;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenCreateTableMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenCreateTableService;
|
||||
import com.bsd.pjcloud.codegen.util.table.CreateTableHandler;
|
||||
import com.bsd.pjcloud.codegen.util.table.model.TableInfo;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GenCreateTableVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.anyline.metadata.Column;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CreateTableServiceImpl extends ServiceImpl<GenCreateTableMapper, GenCreateTable>
|
||||
implements GenCreateTableService {
|
||||
|
||||
private final CreateTableHandler createTableHandler;
|
||||
|
||||
@Override
|
||||
public Boolean createTable(GenCreateTableVO createTableVO) {
|
||||
String columnsInfo = createTableVO.getColumnsInfo();
|
||||
TableInfo tableInfo = new TableInfo();
|
||||
tableInfo.setName(createTableVO.getTableName());
|
||||
LinkedHashMap<String, Column> columns = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, JSONObject> linkedHashMap = JSONUtil.toBean(columnsInfo, LinkedHashMap.class);
|
||||
linkedHashMap.forEach((key, val) -> {
|
||||
columns.put(key, JSONUtil.toBean(val, Column.class));
|
||||
});
|
||||
tableInfo.setColumns(columns);
|
||||
tableInfo.setComment(createTableVO.getComments());
|
||||
return createTableHandler.createTable(tableInfo);
|
||||
}
|
||||
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.dynamic.datasource.creator.DataSourceCreator;
|
||||
import com.baomidou.dynamic.datasource.creator.DataSourceProperty;
|
||||
import com.baomidou.dynamic.datasource.creator.druid.DruidConfig;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenDatasourceConf;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenDatasourceConfMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenDatasourceConfService;
|
||||
import com.bsd.pjcloud.common.core.util.SpringContextHolder;
|
||||
import com.bsd.pjcloud.common.datasource.util.DsConfTypeEnum;
|
||||
import com.bsd.pjcloud.common.datasource.util.DsJdbcUrlEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jasypt.encryption.StringEncryptor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 数据源表
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-03-31 16:00:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfMapper, GenDatasourceConf>
|
||||
implements GenDatasourceConfService {
|
||||
|
||||
private final StringEncryptor stringEncryptor;
|
||||
|
||||
private final DataSourceCreator druidDataSourceCreator;
|
||||
|
||||
/**
|
||||
* 保存数据源并且加密
|
||||
* @param conf
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveDsByEnc(GenDatasourceConf conf) {
|
||||
// 校验配置合法性
|
||||
if (!checkDataSource(conf)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
// 添加动态数据源
|
||||
addDynamicDataSource(conf);
|
||||
|
||||
// 更新数据库配置
|
||||
conf.setPassword(stringEncryptor.encrypt(conf.getPassword()));
|
||||
this.baseMapper.insert(conf);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据源
|
||||
* @param conf 数据源信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateDsByEnc(GenDatasourceConf conf) {
|
||||
if (!checkDataSource(conf)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
// 先移除
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
|
||||
dynamicRoutingDataSource.removeDataSource(baseMapper.selectById(conf.getId()).getName());
|
||||
|
||||
// 再添加
|
||||
addDynamicDataSource(conf);
|
||||
|
||||
// 更新数据库配置
|
||||
if (StrUtil.isNotBlank(conf.getPassword())) {
|
||||
conf.setPassword(stringEncryptor.encrypt(conf.getPassword()));
|
||||
}
|
||||
this.baseMapper.updateById(conf);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过数据源名称删除
|
||||
* @param dsIds 数据源ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean removeByDsId(Long[] dsIds) {
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
|
||||
this.baseMapper.selectBatchIds(CollUtil.toList(dsIds))
|
||||
.forEach(ds -> dynamicRoutingDataSource.removeDataSource(ds.getName()));
|
||||
this.baseMapper.deleteBatchIds(CollUtil.toList(dsIds));
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加动态数据源
|
||||
* @param conf 数据源信息
|
||||
*/
|
||||
@Override
|
||||
public void addDynamicDataSource(GenDatasourceConf conf) {
|
||||
DataSourceProperty dataSourceProperty = new DataSourceProperty();
|
||||
dataSourceProperty.setPoolName(conf.getName());
|
||||
dataSourceProperty.setUrl(conf.getUrl());
|
||||
dataSourceProperty.setUsername(conf.getUsername());
|
||||
dataSourceProperty.setPassword(conf.getPassword());
|
||||
|
||||
// 增加 ValidationQuery 参数
|
||||
DruidConfig druidConfig = new DruidConfig();
|
||||
DsJdbcUrlEnum urlEnum = DsJdbcUrlEnum.get(conf.getDsType());
|
||||
druidConfig.setValidationQuery(urlEnum.getValidationQuery());
|
||||
dataSourceProperty.setDruid(druidConfig);
|
||||
DataSource dataSource = druidDataSourceCreator.createDataSource(dataSourceProperty);
|
||||
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
|
||||
dynamicRoutingDataSource.addDataSource(dataSourceProperty.getPoolName(), dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数据源配置是否有效
|
||||
* @param conf 数据源信息
|
||||
* @return 有效/无效
|
||||
*/
|
||||
@Override
|
||||
public Boolean checkDataSource(GenDatasourceConf conf) {
|
||||
String url;
|
||||
// JDBC 配置形式
|
||||
if (DsConfTypeEnum.JDBC.getType().equals(conf.getConfType())) {
|
||||
url = conf.getUrl();
|
||||
}
|
||||
else if (DsJdbcUrlEnum.MSSQL.getDbName().equals(conf.getDsType())) {
|
||||
// 主机形式 sql server 特殊处理
|
||||
DsJdbcUrlEnum urlEnum = DsJdbcUrlEnum.get(conf.getDsType());
|
||||
url = String.format(urlEnum.getUrl(), conf.getHost(), conf.getPort(), conf.getDsName());
|
||||
}
|
||||
else {
|
||||
DsJdbcUrlEnum urlEnum = DsJdbcUrlEnum.get(conf.getDsType());
|
||||
url = String.format(urlEnum.getUrl(), conf.getHost(), conf.getPort(), conf.getDsName());
|
||||
}
|
||||
|
||||
conf.setUrl(url);
|
||||
|
||||
try (Connection connection = DriverManager.getConnection(url, conf.getUsername(), conf.getPassword())) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
log.error("数据源配置 {} , 获取链接失败", conf.getName(), e);
|
||||
throw new RuntimeException("数据库配置错误,链接失败");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFieldType;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenFieldTypeMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenFieldTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:16:01
|
||||
*/
|
||||
@Service
|
||||
public class GenFieldTypeServiceImpl extends ServiceImpl<GenFieldTypeMapper, GenFieldType>
|
||||
implements GenFieldTypeService {
|
||||
|
||||
/**
|
||||
* 根据tableId,获取包列表
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return 返回包列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getPackageByTableId(String dsName, String tableName) {
|
||||
Set<String> importList = baseMapper.getPackageByTableId(dsName, tableName);
|
||||
return importList.stream().filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFormConf;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenFormConfMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenFormConfService;
|
||||
import com.bsd.pjcloud.codegen.util.VFormConfigConsts;
|
||||
import com.bsd.pjcloud.codegen.util.VFormTypeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 表单管理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2019-08-12 15:55:35
|
||||
*/
|
||||
@Service
|
||||
public class GenFormConfServiceImpl extends ServiceImpl<GenFormConfMapper, GenFormConf> implements GenFormConfService {
|
||||
|
||||
/**
|
||||
* 表单解析方法
|
||||
* @param formInfo json
|
||||
* @return 字段列表
|
||||
*/
|
||||
@Override
|
||||
public Map<String, List<JSONObject>> parse(String formInfo) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(formInfo);
|
||||
Map<String, List<JSONObject>> resultMap = new LinkedHashMap<>();
|
||||
parseForm(jsonObject, resultMap);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 form config
|
||||
* @param json 表单配置
|
||||
* @param resultMap 返回结果
|
||||
*/
|
||||
private void parseForm(JSONObject json, Map<String, List<JSONObject>> resultMap) {
|
||||
JSONArray widgetList = json.getJSONArray(VFormConfigConsts.widgetList);
|
||||
String groupKey = json.getStr(VFormConfigConsts.groupKey, RandomUtil.randomString(5));
|
||||
widgetList.stream().map(o -> (JSONObject) o).forEach(jsonObject -> {
|
||||
String type = jsonObject.getStr(VFormConfigConsts.type);
|
||||
if (VFormTypeEnum.GRID.getType().equals(type)) {
|
||||
parseGrid(jsonObject, resultMap);
|
||||
}
|
||||
else if (VFormTypeEnum.GRID_COL.getType().equals(type)) {
|
||||
parseForm(jsonObject, resultMap);
|
||||
}
|
||||
else {
|
||||
int span = Optional.ofNullable(json.getJSONObject(VFormConfigConsts.options))
|
||||
.map(options -> options.getInt(VFormConfigConsts.span, 24))
|
||||
.orElse(24);
|
||||
|
||||
jsonObject.set(VFormConfigConsts.span, span);
|
||||
|
||||
List<JSONObject> jsonObjects = resultMap.computeIfAbsent(groupKey, k -> new ArrayList<>());
|
||||
jsonObjects.add(jsonObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 grid 容器
|
||||
* @param jsonObject 入参
|
||||
* @param resultMap 结果
|
||||
*/
|
||||
private void parseGrid(JSONObject jsonObject, Map<String, List<JSONObject>> resultMap) {
|
||||
JSONArray cols = jsonObject.getJSONArray(VFormConfigConsts.cols);
|
||||
String key = jsonObject.getStr(VFormConfigConsts.key);
|
||||
cols.stream().map(o -> (JSONObject) o).forEach(col -> {
|
||||
String colType = col.getStr(VFormConfigConsts.type);
|
||||
if (VFormTypeEnum.GRID_COL.getType().equals(colType)) {
|
||||
col.set(VFormConfigConsts.groupKey, key);
|
||||
parseForm(col, resultMap);
|
||||
}
|
||||
|
||||
if (VFormTypeEnum.GRID.getType().equals(colType)) {
|
||||
parseGrid(col, resultMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenGroupMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenGroupService;
|
||||
import com.bsd.pjcloud.codegen.service.GenTemplateGroupService;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GroupVO;
|
||||
import com.bsd.pjcloud.codegen.util.vo.TemplateGroupDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板分组
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 20:01:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class GenGroupServiceImpl extends ServiceImpl<GenGroupMapper, GenGroupEntity> implements GenGroupService {
|
||||
|
||||
private final GenTemplateGroupService genTemplateGroupService;
|
||||
|
||||
/**
|
||||
* 新增模板分组
|
||||
* @param genTemplateGroup
|
||||
*/
|
||||
@Override
|
||||
public void saveGenGroup(TemplateGroupDTO genTemplateGroup) {
|
||||
// 1.保存group
|
||||
GenGroupEntity groupEntity = new GenGroupEntity();
|
||||
BeanUtil.copyProperties(genTemplateGroup, groupEntity);
|
||||
baseMapper.insert(groupEntity);
|
||||
// 2.保存关系
|
||||
List<GenTemplateGroupEntity> goals = new LinkedList<>();
|
||||
for (Long TemplateId : genTemplateGroup.getTemplateId()) {
|
||||
GenTemplateGroupEntity templateGroup = new GenTemplateGroupEntity();
|
||||
templateGroup.setTemplateId(TemplateId).setGroupId(groupEntity.getId());
|
||||
goals.add(templateGroup);
|
||||
}
|
||||
genTemplateGroupService.saveBatch(goals);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照ids删除
|
||||
* @param ids groupIds
|
||||
*/
|
||||
@Override
|
||||
public void delGroupAndTemplate(Long[] ids) {
|
||||
// 删除分组
|
||||
this.removeBatchByIds(CollUtil.toList(ids));
|
||||
// 删除关系
|
||||
genTemplateGroupService
|
||||
.remove(Wrappers.<GenTemplateGroupEntity>lambdaQuery().in(GenTemplateGroupEntity::getGroupId, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照id查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GroupVO getGroupVoById(Long id) {
|
||||
return baseMapper.getGroupVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id更新
|
||||
* @param groupVo
|
||||
*/
|
||||
@Override
|
||||
public void updateGroupAndTemplateById(GroupVO groupVo) {
|
||||
// 1.更新自身
|
||||
GenGroupEntity groupEntity = new GenGroupEntity();
|
||||
BeanUtil.copyProperties(groupVo, groupEntity);
|
||||
this.updateById(groupEntity);
|
||||
// 2.更新模板
|
||||
// 2.1根据id删除之前的模板
|
||||
genTemplateGroupService.remove(
|
||||
Wrappers.<GenTemplateGroupEntity>lambdaQuery().eq(GenTemplateGroupEntity::getGroupId, groupVo.getId()));
|
||||
// 2.2根据ids创建新的模板分组赋值
|
||||
List<GenTemplateGroupEntity> goals = new LinkedList<>();
|
||||
for (Long templateId : groupVo.getTemplateId()) {
|
||||
goals.add(new GenTemplateGroupEntity().setGroupId(groupVo.getId()).setTemplateId(templateId));
|
||||
}
|
||||
genTemplateGroupService.saveBatch(goals);
|
||||
}
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.text.NamingCase;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFieldType;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenFieldTypeMapper;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenTableColumnMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenTableColumnService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 表字段信息管理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2020/5/18
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenTableColumnServiceImpl extends ServiceImpl<GenTableColumnMapper, GenTableColumnEntity>
|
||||
implements GenTableColumnService {
|
||||
|
||||
private final GenFieldTypeMapper fieldTypeMapper;
|
||||
|
||||
/**
|
||||
* 初始化表单字段列表,主要是将数据库表中的字段转化为表单需要的字段数据格式,并为审计字段排序
|
||||
* @param tableFieldList 表单字段列表
|
||||
*/
|
||||
public void initFieldList(List<GenTableColumnEntity> tableFieldList) {
|
||||
// 字段类型、属性类型映射
|
||||
List<GenFieldType> list = fieldTypeMapper.selectList(Wrappers.emptyWrapper());
|
||||
Map<String, GenFieldType> fieldTypeMap = new LinkedHashMap<>(list.size());
|
||||
list.forEach(
|
||||
fieldTypeMapping -> fieldTypeMap.put(fieldTypeMapping.getColumnType().toLowerCase(), fieldTypeMapping));
|
||||
|
||||
// 索引计数器
|
||||
AtomicInteger index = new AtomicInteger(0);
|
||||
tableFieldList.forEach(field -> {
|
||||
// 将字段名转化为驼峰格式
|
||||
field.setAttrName(NamingCase.toCamelCase(field.getFieldName()));
|
||||
|
||||
// 获取字段对应的类型
|
||||
GenFieldType fieldTypeMapping = fieldTypeMap.getOrDefault(field.getFieldType().toLowerCase(), null);
|
||||
if (fieldTypeMapping == null) {
|
||||
// 没找到对应的类型,则为Object类型
|
||||
field.setAttrType("Object");
|
||||
}
|
||||
else {
|
||||
field.setAttrType(fieldTypeMapping.getAttrType());
|
||||
field.setPackageName(fieldTypeMapping.getPackageName());
|
||||
}
|
||||
|
||||
// 设置查询类型和表单查询类型都为“=”
|
||||
field.setQueryType("=");
|
||||
field.setQueryFormType("text");
|
||||
|
||||
// 设置表单类型为文本框类型
|
||||
field.setFormType("text");
|
||||
|
||||
// 保证审计字段最后显示
|
||||
field.setSort(Objects.isNull(field.getSort()) ? index.getAndIncrement() : field.getSort());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定数据源和表名的表单字段信息
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名
|
||||
* @param tableFieldList 表单字段列表
|
||||
*/
|
||||
@Override
|
||||
|
||||
public void updateTableField(String dsName, String tableName, List<GenTableColumnEntity> tableFieldList) {
|
||||
AtomicInteger sort = new AtomicInteger();
|
||||
this.updateBatchById(tableFieldList.stream()
|
||||
.peek(field -> field.setSort(sort.getAndIncrement()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
+277
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.NamingCase;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.config.PjcloudCodeGenDefaultProperties;
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTable;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenTableMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenGroupService;
|
||||
import com.bsd.pjcloud.codegen.service.GenTableColumnService;
|
||||
import com.bsd.pjcloud.codegen.service.GenTableService;
|
||||
import com.bsd.pjcloud.codegen.util.AutoFillEnum;
|
||||
import com.bsd.pjcloud.codegen.util.BoolFillEnum;
|
||||
import com.bsd.pjcloud.codegen.util.CommonColumnFiledEnum;
|
||||
import com.bsd.pjcloud.codegen.util.GenKit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.anyline.metadata.Column;
|
||||
import org.anyline.metadata.Database;
|
||||
import org.anyline.metadata.Table;
|
||||
import org.anyline.proxy.CacheProxy;
|
||||
import org.anyline.proxy.ServiceProxy;
|
||||
import org.anyline.service.AnylineService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 列属性
|
||||
*
|
||||
* @author pjcloud code generator
|
||||
* @date 2023-02-06 20:34:55
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements GenTableService {
|
||||
|
||||
private final PjcloudCodeGenDefaultProperties defaultProperties;
|
||||
|
||||
private final GenTableColumnService columnService;
|
||||
|
||||
private final GenGroupService genGroupService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询表ddl 语句
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return ddl 语句
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String queryTableDdl(String dsName, String tableName) throws Exception {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
Table table = ServiceProxy.metadata().table(tableName); // 获取表结构
|
||||
table.execute(false);// 不执行SQL
|
||||
ServiceProxy.ddl().create(table);
|
||||
return table.getDdl();// 返回创建表的DDL
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表的全部字段
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @return column
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryTableColumn(String dsName, String tableName) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
CacheProxy.clear();
|
||||
return ServiceProxy.metadata().columns(tableName).values().stream().map(Column::getName).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询对应数据源的表
|
||||
*
|
||||
* @param page 分页信息
|
||||
* @param table 查询条件
|
||||
* @return 表
|
||||
*/
|
||||
@Override
|
||||
public IPage queryTablePage(Page<Table> page, GenTable table) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(table.getDsName());
|
||||
CacheProxy.clear();
|
||||
List<Table> tableList = ServiceProxy.metadata().tables()
|
||||
.values().stream().filter(t -> {
|
||||
if (StrUtil.isBlank(table.getTableName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 通过表名和表注释进行模糊查询
|
||||
return StrUtil.containsIgnoreCase(t.getName(false), table.getTableName())
|
||||
|| StrUtil.containsIgnoreCase(t.getComment(), table.getTableName());
|
||||
})
|
||||
// 根据 createTime 、updateTime 倒序排序
|
||||
.sorted((o1, o2) -> {
|
||||
long time1 = (o1.getUpdateTime() != null ? o1.getUpdateTime().getTime() :
|
||||
(o1.getCreateTime() != null ? o1.getCreateTime().getTime() : 0));
|
||||
long time2 = (o2.getUpdateTime() != null ? o2.getUpdateTime().getTime() :
|
||||
(o2.getCreateTime() != null ? o2.getCreateTime().getTime() : 0));
|
||||
return NumberUtil.compare(time2, time1);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 根据 page 进行分页
|
||||
List<Table> records = CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), tableList);
|
||||
page.setTotal(tableList.size());
|
||||
page.setRecords(records);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源里面的全部表
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @return table
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryTableList(String dsName) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
CacheProxy.clear();
|
||||
return ServiceProxy.metadata().tables().values().stream().map(Table::getName).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表信息(列),然后插入到中间表中
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名
|
||||
* @return GenTable
|
||||
*/
|
||||
@Override
|
||||
public GenTable queryOrBuildTable(String dsName, String tableName) {
|
||||
GenTable genTable = baseMapper.selectOne(
|
||||
Wrappers.<GenTable>lambdaQuery().eq(GenTable::getTableName, tableName).eq(GenTable::getDsName, dsName));
|
||||
// 如果 genTable 为空, 执行导入
|
||||
if (Objects.isNull(genTable)) {
|
||||
genTable = this.tableImport(dsName, tableName);
|
||||
}
|
||||
|
||||
List<GenTableColumnEntity> fieldList = columnService.list(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName)
|
||||
.orderByAsc(GenTableColumnEntity::getSort));
|
||||
genTable.setFieldList(fieldList);
|
||||
|
||||
// 查询模板分组信息
|
||||
List<GenGroupEntity> groupEntities = genGroupService.list();
|
||||
genTable.setGroupList(groupEntities);
|
||||
return genTable;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
protected GenTable tableImport(String dsName, String tableName) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
|
||||
// 查询表是否存在
|
||||
GenTable table = new GenTable();
|
||||
// 从数据库获取表信息
|
||||
CacheProxy.clear();
|
||||
AnylineService service = ServiceProxy.service();
|
||||
Table tableMetadata = service.metadata().table(tableName);
|
||||
Database database = service.metadata().database();
|
||||
// 获取默认表配置信息 ()
|
||||
|
||||
table.setPackageName(defaultProperties.getPackageName());
|
||||
table.setVersion(defaultProperties.getVersion());
|
||||
table.setBackendPath(defaultProperties.getBackendPath());
|
||||
table.setFrontendPath(defaultProperties.getFrontendPath());
|
||||
table.setAuthor(defaultProperties.getAuthor());
|
||||
table.setEmail(defaultProperties.getEmail());
|
||||
table.setTableName(tableName);
|
||||
table.setDsName(dsName);
|
||||
table.setTableComment(tableMetadata.getComment());
|
||||
|
||||
table.setDbType(database.getDatabase().title());
|
||||
table.setFormLayout(defaultProperties.getFormLayout());
|
||||
table.setSyncRoute(defaultProperties.getSyncRoute());
|
||||
table.setGeneratorType(defaultProperties.getGeneratorType());
|
||||
table.setClassName(NamingCase.toPascalCase(tableName));
|
||||
// 模块名称默认为 admin
|
||||
table.setModuleName(defaultProperties.getModuleName());
|
||||
table.setFunctionName(GenKit.getFunctionName(tableName));
|
||||
table.setCreateTime(LocalDateTime.now());
|
||||
|
||||
// 使用默认数据源
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
this.save(table);
|
||||
|
||||
// 获取原生字段数据
|
||||
List<GenTableColumnEntity> tableFieldList = getGenTableColumnEntities(dsName, tableName, tableMetadata);
|
||||
|
||||
// 初始化字段数据
|
||||
columnService.initFieldList(tableFieldList);
|
||||
// 保存列数据
|
||||
columnService.saveOrUpdateBatch(tableFieldList);
|
||||
|
||||
table.setFieldList(tableFieldList);
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段信息
|
||||
*
|
||||
* @param dsName 数据源信息
|
||||
* @param tableName 表名称
|
||||
* @param tableMetadata 表的元数据
|
||||
* @return list
|
||||
*/
|
||||
private static @NotNull List<GenTableColumnEntity> getGenTableColumnEntities(String dsName, String tableName,
|
||||
Table tableMetadata) {
|
||||
List<GenTableColumnEntity> tableFieldList = new ArrayList<>();
|
||||
LinkedHashMap<String, Column> columns = tableMetadata.getColumns();
|
||||
columns.forEach((columnName, column) -> {
|
||||
GenTableColumnEntity genTableColumnEntity = new GenTableColumnEntity();
|
||||
genTableColumnEntity.setTableName(tableName);
|
||||
genTableColumnEntity.setDsName(dsName);
|
||||
genTableColumnEntity.setFieldName(column.getName());
|
||||
genTableColumnEntity.setFieldComment(column.getComment());
|
||||
genTableColumnEntity.setFieldType(column.getTypeName());
|
||||
genTableColumnEntity.setPrimaryPk(
|
||||
column.isPrimaryKey() == 1 ? BoolFillEnum.TRUE.getValue() : BoolFillEnum.FALSE.getValue());
|
||||
genTableColumnEntity.setAutoFill(AutoFillEnum.DEFAULT.name());
|
||||
genTableColumnEntity.setFormItem(BoolFillEnum.TRUE.getValue());
|
||||
genTableColumnEntity.setGridItem(BoolFillEnum.TRUE.getValue());
|
||||
|
||||
// 审计字段处理
|
||||
if (EnumUtil.contains(CommonColumnFiledEnum.class, column.getName())) {
|
||||
CommonColumnFiledEnum commonColumnFiledEnum = CommonColumnFiledEnum.valueOf(column.getName());
|
||||
genTableColumnEntity.setFormItem(commonColumnFiledEnum.getFormItem());
|
||||
genTableColumnEntity.setGridItem(commonColumnFiledEnum.getGridItem());
|
||||
genTableColumnEntity.setAutoFill(commonColumnFiledEnum.getAutoFill());
|
||||
genTableColumnEntity.setSort(commonColumnFiledEnum.getSort());
|
||||
}
|
||||
tableFieldList.add(genTableColumnEntity);
|
||||
});
|
||||
return tableFieldList;
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenTemplateGroupMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenTemplateGroupService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 模板分组关联表
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-22 09:25:15
|
||||
*/
|
||||
@Service
|
||||
public class GenTemplateGroupServiceImpl extends ServiceImpl<GenTemplateGroupMapper, GenTemplateGroupEntity>
|
||||
implements GenTemplateGroupService {
|
||||
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.smallbun.screw.core.constant.DefaultConstants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.codegen.config.PjcloudCodeGenDefaultProperties;
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenGroupMapper;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenTemplateGroupMapper;
|
||||
import com.bsd.pjcloud.codegen.mapper.GenTemplateMapper;
|
||||
import com.bsd.pjcloud.codegen.service.GenTemplateService;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GenTemplateFileVO;
|
||||
import com.bsd.pjcloud.common.core.exception.CheckedException;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*
|
||||
* @author PIG
|
||||
* @date 2023-02-21 11:08:43
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenTemplateServiceImpl extends ServiceImpl<GenTemplateMapper, GenTemplateEntity>
|
||||
implements GenTemplateService {
|
||||
|
||||
private final PjcloudCodeGenDefaultProperties defaultProperties;
|
||||
|
||||
private final GenTemplateGroupMapper genTemplateGroupMapper;
|
||||
|
||||
private final GenGroupMapper genGroupMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 在线更新
|
||||
*
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R onlineUpdate() {
|
||||
// 获取 config.json 和 version 文件
|
||||
Map<String, Object> configAndVersion = getConfigAndVersion();
|
||||
JSONObject configJsonObj = (JSONObject) configAndVersion.get("configJsonObj");
|
||||
String versionFile = (String) configAndVersion.get("versionFile");
|
||||
|
||||
// 查询出全部的模板组名称
|
||||
Set<String> cgtmConfigGroupNames = configJsonObj.keySet();
|
||||
|
||||
// 根据模板组名称+version 查询是否存在,不存在则新增,存在跳过
|
||||
for (String cgtmConfigGroupName : cgtmConfigGroupNames) {
|
||||
boolean exists = genGroupMapper.exists(Wrappers.<GenGroupEntity>lambdaQuery()
|
||||
.eq(GenGroupEntity::getGroupName, cgtmConfigGroupName + versionFile));
|
||||
|
||||
if (exists) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 插入新的模板组(名称 + VERSION), 再解析 config.json group 里面的所有模板
|
||||
insertTemplateFiles(versionFile, configJsonObj, cgtmConfigGroupName);
|
||||
}
|
||||
return R.ok("更新成功,版本号:" + versionFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查版本
|
||||
*
|
||||
* @return {@link R }
|
||||
*/
|
||||
public R checkVersion() {
|
||||
// 关闭在线更新提示
|
||||
if (!defaultProperties.isAutoCheckVersion()) {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
// 获取 config.json 和 version 文件
|
||||
Map<String, Object> configAndVersion = getConfigAndVersion();
|
||||
JSONObject configJsonObj = (JSONObject) configAndVersion.get("configJsonObj");
|
||||
String versionFile = (String) configAndVersion.get("versionFile");
|
||||
|
||||
// 查询出全部的模板组名称
|
||||
boolean exists = false;
|
||||
Set<String> cgtmConfigGroupNames = configJsonObj.keySet();
|
||||
for (String cgtmConfigGroupName : cgtmConfigGroupNames) {
|
||||
exists = genGroupMapper.exists(Wrappers.<GenGroupEntity>lambdaQuery()
|
||||
.eq(GenGroupEntity::getGroupName, cgtmConfigGroupName + versionFile));
|
||||
}
|
||||
|
||||
return R.ok(exists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置和版本
|
||||
*
|
||||
* @return {@link Map }<{@link String }, {@link Object }>
|
||||
*/
|
||||
private Map<String, Object> getConfigAndVersion() {
|
||||
// 获取 config.json 和 version 文件
|
||||
String configFile = getCGTMFile("config.json");
|
||||
String versionFile = getCGTMFile("VERSION");
|
||||
|
||||
// 解析 config.json
|
||||
JSONObject configJsonObj = JSONUtil.parseObj(configFile);
|
||||
|
||||
// 将 configJsonObj 和 versionFile 放入 Map 中
|
||||
Map<String, Object> configAndVersion = new HashMap<>();
|
||||
configAndVersion.put("configJsonObj", configJsonObj);
|
||||
configAndVersion.put("versionFile", versionFile);
|
||||
|
||||
return configAndVersion;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 插入模板文件
|
||||
*
|
||||
* @param version 版本
|
||||
* @param configJsonObj config.json
|
||||
* @param groupName 组名称
|
||||
*/
|
||||
private void insertTemplateFiles(String version, JSONObject configJsonObj, String groupName) {
|
||||
// 创建新的 group
|
||||
GenGroupEntity genGroupEntity = new GenGroupEntity();
|
||||
genGroupEntity.setGroupName(groupName + version);
|
||||
genGroupMapper.insert(genGroupEntity);
|
||||
|
||||
// 解析json配置文件
|
||||
List<GenTemplateFileVO> templateFileVOList = configJsonObj.getBeanList(groupName, GenTemplateFileVO.class);
|
||||
for (GenTemplateFileVO genTemplateFileVO : templateFileVOList) {
|
||||
// 1. 获取模板文件
|
||||
String templateFile = getCGTMFile(genTemplateFileVO.getTemplateFile());
|
||||
|
||||
// 2. 插入模板文件
|
||||
GenTemplateEntity genTemplateEntity = new GenTemplateEntity();
|
||||
genTemplateEntity.setTemplateName(genTemplateFileVO.getTemplateName() + version);
|
||||
genTemplateEntity.setTemplateDesc(genTemplateFileVO.getTemplateName() + version);
|
||||
genTemplateEntity.setTemplateCode(templateFile);
|
||||
genTemplateEntity.setGeneratorPath(genTemplateFileVO.getGeneratorPath());
|
||||
baseMapper.insert(genTemplateEntity);
|
||||
|
||||
// 3. 插入模板组关联
|
||||
GenTemplateGroupEntity genTemplateGroupEntity = new GenTemplateGroupEntity();
|
||||
genTemplateGroupEntity.setTemplateId(genTemplateEntity.getId());
|
||||
genTemplateGroupEntity.setGroupId(genGroupEntity.getId());
|
||||
genTemplateGroupMapper.insert(genTemplateGroupEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 cgtmfile
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return {@link String }
|
||||
*/
|
||||
private String getCGTMFile(String fileName) {
|
||||
HttpResponse response = HttpRequest.get(String.format("%s/CGTM/raw/master/%s", DefaultConstants.CGTM_URL, fileName))
|
||||
.execute();
|
||||
|
||||
if (response.getStatus() == HttpStatus.HTTP_OK || StrUtil.isNotBlank(response.body())) {
|
||||
return response.body();
|
||||
} else {
|
||||
log.warn("在线更新模板失败:{} ,Http Code:{}", fileName, response.getStatus());
|
||||
throw new CheckedException("在线更新模板失败,任务终止!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+506
@@ -0,0 +1,506 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.NamingCase;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysMenu;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysRouteConf;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteMenuService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteRouteConfService;
|
||||
import com.bsd.pjcloud.codegen.config.PjcloudCodeGenDefaultProperties;
|
||||
import com.bsd.pjcloud.codegen.entity.GenFormConf;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTable;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTableColumnEntity;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import com.bsd.pjcloud.codegen.service.*;
|
||||
import com.bsd.pjcloud.codegen.util.DataModelConstants;
|
||||
import com.bsd.pjcloud.codegen.util.GeneratorStyleEnum;
|
||||
import com.bsd.pjcloud.codegen.util.VelocityKit;
|
||||
import com.bsd.pjcloud.codegen.util.vo.GroupVO;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MenuTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.exception.CheckedException;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.core.util.RetOps;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringBootVersion;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018-07-30
|
||||
* <p>
|
||||
* 代码生成器
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
private final PjcloudCodeGenDefaultProperties defaultProperties;
|
||||
|
||||
private final GenTableColumnService columnService;
|
||||
|
||||
private final GenFormConfService formConfService;
|
||||
|
||||
private final GenFieldTypeService fieldTypeService;
|
||||
|
||||
private final GenTableService tableService;
|
||||
|
||||
private final GenGroupService genGroupService;
|
||||
|
||||
private final GenTemplateService genTemplateService;
|
||||
|
||||
private final RemoteMenuService menuService;
|
||||
|
||||
private final RemoteRouteConfService routeService;
|
||||
|
||||
/**
|
||||
* 生成代码zip写出
|
||||
*
|
||||
* @param tableId 表
|
||||
* @param zip 输出流
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void downloadCode(Long tableId, ZipOutputStream zip) {
|
||||
// 数据模型
|
||||
Map<String, Object> dataModel = getDataModel(tableId);
|
||||
|
||||
Long style = (Long) dataModel.get(GenTable.Fields.style);
|
||||
|
||||
GroupVO groupVo = genGroupService.getGroupVoById(style);
|
||||
List<GenTemplateEntity> templateList = groupVo.getTemplateList();
|
||||
|
||||
String frontendPath = defaultProperties.getFrontendPath();
|
||||
String backendPath = defaultProperties.getBackendPath();
|
||||
|
||||
// 同步数据
|
||||
this.syncRouteAndMenu(tableId);
|
||||
|
||||
for (GenTemplateEntity template : templateList) {
|
||||
String templateCode = template.getTemplateCode();
|
||||
String generatorPath = template.getGeneratorPath();
|
||||
|
||||
dataModel.put(GenTable.Fields.frontendPath, frontendPath);
|
||||
dataModel.put(GenTable.Fields.backendPath, backendPath);
|
||||
String content = VelocityKit.renderStr(templateCode, dataModel);
|
||||
String path = VelocityKit.renderStr(generatorPath, dataModel);
|
||||
|
||||
// 添加到zip
|
||||
zip.putNextEntry(new ZipEntry(path));
|
||||
IoUtil.writeUtf8(zip, false, content);
|
||||
zip.flush();
|
||||
zip.closeEntry();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 表达式优化的预览代码方法
|
||||
*
|
||||
* @param tableId 表
|
||||
* @return [{模板名称:渲染结果}]
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public List<Map<String, String>> preview(Long tableId) {
|
||||
// 数据模型
|
||||
Map<String, Object> dataModel = getDataModel(tableId);
|
||||
|
||||
Long style = (Long) dataModel.get(GenTable.Fields.style);
|
||||
|
||||
// 获取模板列表,Lambda 表达式简化代码
|
||||
List<GenTemplateEntity> templateList = genGroupService.getGroupVoById(style).getTemplateList();
|
||||
|
||||
String frontendPath = defaultProperties.getFrontendPath();
|
||||
String backendPath = defaultProperties.getBackendPath();
|
||||
|
||||
// 如果是同步菜单的模式则不生成SQL
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
Long syncMenuId = MapUtil.getLong(dataModel, GenTable.Fields.syncMenuId);
|
||||
for (GenTemplateEntity template : templateList) {
|
||||
// 跳过菜单文件生成
|
||||
if (Objects.nonNull(syncMenuId) && template.getGeneratorPath().contains("menu.sql")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String templateCode = template.getTemplateCode();
|
||||
String generatorPath = template.getGeneratorPath();
|
||||
|
||||
// 预览模式下, 使用相对路径展示
|
||||
dataModel.put(GenTable.Fields.frontendPath, frontendPath);
|
||||
dataModel.put(GenTable.Fields.backendPath, backendPath);
|
||||
String content = VelocityKit.renderStr(templateCode, dataModel);
|
||||
String path = VelocityKit.renderStr(generatorPath, dataModel);
|
||||
|
||||
// 使用 map 简化代码
|
||||
result.add(new HashMap<>(4) {
|
||||
{
|
||||
put("code", content);
|
||||
put("codePath", path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标目录写入渲染结果方法
|
||||
*
|
||||
* @param tableId 表
|
||||
*/
|
||||
@Override
|
||||
public void generatorCode(Long tableId) {
|
||||
// 数据模型
|
||||
Map<String, Object> dataModel = getDataModel(tableId);
|
||||
Long style = (Long) dataModel.get(GenTable.Fields.style);
|
||||
|
||||
// 获取模板列表,Lambda 表达式简化代码
|
||||
List<GenTemplateEntity> templateList = genGroupService.getGroupVoById(style).getTemplateList();
|
||||
Long syncMenuId = MapUtil.getLong(dataModel, GenTable.Fields.syncMenuId);
|
||||
this.syncRouteAndMenu(tableId);
|
||||
for (GenTemplateEntity template : templateList) {
|
||||
// 跳过菜单文件生成
|
||||
if (Objects.nonNull(syncMenuId) && template.getGeneratorPath().contains("menu.sql")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String templateCode = template.getTemplateCode();
|
||||
String generatorPath = template.getGeneratorPath();
|
||||
String content = VelocityKit.renderStr(templateCode, dataModel);
|
||||
String path = VelocityKit.renderStr(generatorPath, dataModel);
|
||||
FileUtil.writeUtf8String(content, path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单设计器需要的 JSON 方法
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @return JSON 字符串
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String vform(String dsName, String tableName) {
|
||||
// 查询表的元数据
|
||||
GenTable genTable = tableService.queryOrBuildTable(dsName, tableName);
|
||||
|
||||
// 获取数据模型
|
||||
Map<String, Object> dataModel = getDataModel(genTable.getId());
|
||||
|
||||
// 获取模板信息,Lambda 表达式简化代码
|
||||
GenTemplateEntity genTemplateEntity = genTemplateService.getOneOpt(Wrappers.<GenTemplateEntity>lambdaQuery()
|
||||
.likeRight(GenTemplateEntity::getTemplateName, GeneratorStyleEnum.VFORM_JSON.getDesc())
|
||||
.orderByDesc(GenTemplateEntity::getCreateTime), false
|
||||
)
|
||||
.orElseThrow(() -> new CheckedException("模板不存在"));
|
||||
// 渲染模板并返回结果
|
||||
return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sfc vue
|
||||
*
|
||||
* @param id 表单配置 ID
|
||||
* @return JSON 字符串
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String vformSfc(Long id) {
|
||||
// 获取表单配置信息
|
||||
GenFormConf formConf = formConfService.getById(id);
|
||||
|
||||
// 查询表的元数据
|
||||
GenTable genTable = tableService.queryOrBuildTable(formConf.getDsName(), formConf.getTableName());
|
||||
|
||||
// 获取数据模型
|
||||
Map<String, Object> dataModel = getDataModel(genTable.getId());
|
||||
|
||||
// 解析组件列表
|
||||
Map<String, List<JSONObject>> resultMap = formConfService.parse(formConf.getFormInfo());
|
||||
|
||||
// 遍历 widgetList
|
||||
dataModel.put("resultMap", resultMap);
|
||||
|
||||
// 获取模板信息 查询模板中最新的 vform.json 文件
|
||||
GenTemplateEntity genTemplateEntity = genTemplateService.getOneOpt(Wrappers.<GenTemplateEntity>lambdaQuery()
|
||||
.likeRight(GenTemplateEntity::getTemplateName, GeneratorStyleEnum.VFORM_VUE.getDesc())
|
||||
.orderByDesc(GenTemplateEntity::getCreateTime), false
|
||||
)
|
||||
.orElseThrow(() -> new CheckedException("模板不存在"));
|
||||
|
||||
// 渲染模板并返回结果
|
||||
return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步路由和菜单
|
||||
*
|
||||
* @param tableId 表ID
|
||||
*/
|
||||
@Override
|
||||
public void syncRouteAndMenu(Long tableId) {
|
||||
GenTable table = tableService.getById(tableId);
|
||||
syncMenu(table);
|
||||
syncRoute(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步菜单,同步按钮
|
||||
*
|
||||
* @param table 表配置
|
||||
*/
|
||||
private void syncMenu(GenTable table) {
|
||||
if (Objects.isNull(table.getSyncMenuId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
String menuName = String.format("%s管理", table.getTableComment());
|
||||
SysMenu query = new SysMenu();
|
||||
query.setName(menuName);
|
||||
query.setMenuType(MenuTypeEnum.LEFT_MENU.getType());
|
||||
|
||||
List<SysMenu> existingMenus = RetOps.of(menuService.getMenuDetails(query)).getData().orElse(Collections.emptyList());
|
||||
|
||||
if (!CollUtil.isEmpty(existingMenus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysMenu sysMenu = createMenu(table, menuName);
|
||||
R<SysMenu> sysMenuR = menuService.saveMenu(sysMenu);
|
||||
|
||||
if (sysMenuR.getData() != null) {
|
||||
createButtons(table, sysMenuR.getData().getMenuId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建菜单
|
||||
*
|
||||
* @param table 表配置
|
||||
* @param menuName 菜单名称
|
||||
* @return {@link SysMenu }
|
||||
*/
|
||||
private SysMenu createMenu(GenTable table, String menuName) {
|
||||
SysMenu sysMenu = new SysMenu();
|
||||
sysMenu.setParentId(table.getSyncMenuId());
|
||||
sysMenu.setName(menuName);
|
||||
sysMenu.setMenuType(MenuTypeEnum.LEFT_MENU.getType());
|
||||
sysMenu.setPath(String.format("/%s/%s/index", table.getModuleName(), table.getFunctionName()));
|
||||
return sysMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建按钮
|
||||
*
|
||||
* @param table 表配置
|
||||
* @param parentId 父 ID
|
||||
*/
|
||||
private void createButtons(GenTable table, Long parentId) {
|
||||
String[] buttonNames = {"查看", "新增", "编辑", "删除", "导入导出"};
|
||||
String[] permissions = {"view", "add", "edit", "del", "export"};
|
||||
|
||||
for (int i = 0; i < buttonNames.length; i++) {
|
||||
SysMenu button = new SysMenu();
|
||||
button.setParentId(parentId);
|
||||
button.setMenuType(MenuTypeEnum.BUTTON.getType());
|
||||
button.setName(buttonNames[i]);
|
||||
button.setPermission(String.format("%s_%s_%s", table.getModuleName(), table.getFunctionName(), permissions[i]));
|
||||
menuService.saveMenu(button);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步路由
|
||||
*
|
||||
* @param table 表配置
|
||||
*/
|
||||
private void syncRoute(GenTable table) {
|
||||
if (!YesNoEnum.YES.getCode().equals(table.getSyncRoute())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<SysRouteConf> existingRoutes = RetOps.of(routeService.getRouteDetails()).getData().orElse(Collections.emptyList());
|
||||
boolean exist = existingRoutes.stream()
|
||||
.anyMatch(routeConf -> routeConf.getRouteId().equals(table.getModuleName()));
|
||||
|
||||
if (exist) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysRouteConf sysRouteConf = createRoute(table);
|
||||
routeService.saveSysRouteConf(sysRouteConf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建路由
|
||||
*
|
||||
* @param table 表配置
|
||||
* @return {@link SysRouteConf }
|
||||
*/
|
||||
private SysRouteConf createRoute(GenTable table) {
|
||||
SysRouteConf sysRouteConf = new SysRouteConf();
|
||||
sysRouteConf.setRouteId(table.getModuleName());
|
||||
sysRouteConf.setRouteName(table.getModuleName());
|
||||
sysRouteConf.setPredicates(String.format("[{\"args\": {\"_genkey_0\": \"/%s/**\"}, \"name\": \"Path\"}]", table.getModuleName()));
|
||||
sysRouteConf.setFilters("[]");
|
||||
sysRouteConf.setUri(String.format("lb://%s-biz", table.getModuleName()));
|
||||
return sysRouteConf;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 Lambda 表达式优化的获取数据模型方法
|
||||
*
|
||||
* @param tableId 表格 ID
|
||||
* @return 数据模型 Map 对象
|
||||
*/
|
||||
private Map<String, Object> getDataModel(Long tableId) {
|
||||
// 获取表格信息
|
||||
GenTable table = tableService.getById(tableId);
|
||||
// 获取字段列表
|
||||
List<GenTableColumnEntity> fieldList = columnService.lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getTableName())
|
||||
.orderByAsc(GenTableColumnEntity::getSort)
|
||||
.list();
|
||||
|
||||
table.setFieldList(fieldList);
|
||||
|
||||
// 创建数据模型对象
|
||||
Map<String, Object> dataModel = new HashMap<>();
|
||||
|
||||
// 填充数据模型
|
||||
dataModel.put(DataModelConstants.IS_SPRING_BOOT_3, isSpringBoot3());
|
||||
dataModel.put(DataModelConstants.SYNC_MENU_ID, Objects.nonNull(table.getSyncMenuId()));
|
||||
dataModel.put(DataModelConstants.DB_TYPE, table.getDbType());
|
||||
dataModel.put(DataModelConstants.PACKAGE, table.getPackageName());
|
||||
dataModel.put(DataModelConstants.PACKAGE_PATH, table.getPackageName().replace(".", "/"));
|
||||
dataModel.put(DataModelConstants.VERSION, table.getVersion());
|
||||
dataModel.put(DataModelConstants.MODULE_NAME, table.getModuleName());
|
||||
dataModel.put(DataModelConstants.MODULE_NAME_UPPER_FIRST, StrUtil.upperFirst(table.getModuleName()));
|
||||
dataModel.put(DataModelConstants.FUNCTION_NAME, table.getFunctionName());
|
||||
dataModel.put(DataModelConstants.FUNCTION_NAME_UPPER_FIRST, StrUtil.upperFirst(table.getFunctionName()));
|
||||
dataModel.put(DataModelConstants.FORM_LAYOUT, table.getFormLayout());
|
||||
dataModel.put(DataModelConstants.STYLE, table.getStyle());
|
||||
dataModel.put(DataModelConstants.AUTHOR, table.getAuthor());
|
||||
dataModel.put(DataModelConstants.DATETIME, DateUtil.now());
|
||||
dataModel.put(DataModelConstants.DATE, DateUtil.today());
|
||||
setFieldTypeList(dataModel, table);
|
||||
|
||||
// 获取导入的包列表
|
||||
Set<String> importList = fieldTypeService.getPackageByTableId(table.getDsName(), table.getTableName());
|
||||
dataModel.put(DataModelConstants.IMPORT_LIST, importList);
|
||||
dataModel.put(DataModelConstants.TABLE_NAME, table.getTableName());
|
||||
dataModel.put(DataModelConstants.TABLE_COMMENT, table.getTableComment());
|
||||
dataModel.put(DataModelConstants.CLASS_NAME, StrUtil.lowerFirst(table.getClassName()));
|
||||
dataModel.put(DataModelConstants.CLASS_NAME_UPPER_FIRST, table.getClassName());
|
||||
dataModel.put(DataModelConstants.FIELD_LIST, table.getFieldList());
|
||||
|
||||
dataModel.put(DataModelConstants.BACKEND_PATH, table.getBackendPath());
|
||||
dataModel.put(DataModelConstants.FRONTEND_PATH, table.getFrontendPath());
|
||||
|
||||
// 设置子表
|
||||
String childTableName = table.getChildTableName();
|
||||
if (StrUtil.isNotBlank(childTableName)) {
|
||||
List<GenTableColumnEntity> childFieldList = columnService.lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, table.getDsName())
|
||||
.eq(GenTableColumnEntity::getTableName, table.getChildTableName())
|
||||
.list();
|
||||
dataModel.put(DataModelConstants.CHILD_FIELD_LIST, childFieldList);
|
||||
dataModel.put(DataModelConstants.CHILD_TABLE_NAME, childTableName);
|
||||
dataModel.put(DataModelConstants.MAIN_FIELD, NamingCase.toCamelCase(table.getMainField()));
|
||||
dataModel.put(DataModelConstants.CHILD_FIELD, NamingCase.toCamelCase(table.getChildField()));
|
||||
dataModel.put(DataModelConstants.CHILD_CLASS_NAME_UPPER_FIRST, NamingCase.toPascalCase(childTableName));
|
||||
dataModel.put(DataModelConstants.CHILD_CLASS_NAME, StrUtil.lowerFirst(NamingCase.toPascalCase(childTableName)));
|
||||
// 设置是否是多租户模式 (判断字段列表中是否包含 tenant_id 字段)
|
||||
childFieldList.stream().filter(genTableColumnEntity -> genTableColumnEntity.getFieldName().equals("tenant_id"))
|
||||
.findFirst().ifPresent(columnEntity -> dataModel.put(DataModelConstants.IS_CHILD_TENANT, true));
|
||||
}
|
||||
|
||||
// 设置是否是多租户模式 (判断字段列表中是否包含 tenant_id 字段)
|
||||
table.getFieldList().stream().filter(genTableColumnEntity -> genTableColumnEntity.getFieldName().equals("tenant_id"))
|
||||
.findFirst().ifPresent(columnEntity -> dataModel.put(DataModelConstants.IS_TENANT, true));
|
||||
|
||||
return dataModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前是否是 SpringBoot3 版本
|
||||
*
|
||||
* @return true/fasle
|
||||
*/
|
||||
private boolean isSpringBoot3() {
|
||||
return StrUtil.startWith(SpringBootVersion.getVersion(), "3");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将表字段按照类型分组并存储到数据模型中
|
||||
*
|
||||
* @param dataModel 存储数据的 Map 对象
|
||||
* @param table 表信息对象
|
||||
*/
|
||||
private void setFieldTypeList(Map<String, Object> dataModel, GenTable table) {
|
||||
// 按字段类型分组,使用 Map 存储不同类型的字段列表
|
||||
Map<Boolean, List<GenTableColumnEntity>> typeMap = table.getFieldList()
|
||||
.stream()
|
||||
.collect(Collectors.partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk())));
|
||||
|
||||
// 从分组后的 Map 中获取不同类型的字段列表
|
||||
List<GenTableColumnEntity> primaryList = typeMap.get(true);
|
||||
List<GenTableColumnEntity> formList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getFormItem()))
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> gridList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getGridItem()))
|
||||
.collect(Collectors.toList());
|
||||
List<GenTableColumnEntity> queryList = typeMap.get(false)
|
||||
.stream()
|
||||
.filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getQueryItem()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(primaryList)) {
|
||||
dataModel.put("pk", primaryList.get(0));
|
||||
}
|
||||
dataModel.put("primaryList", primaryList);
|
||||
dataModel.put("formList", formList);
|
||||
dataModel.put("gridList", gridList);
|
||||
dataModel.put("queryList", queryList);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
/**
|
||||
* 字段自动填充 枚举
|
||||
*
|
||||
* @author 阿沐 babamu@126.com
|
||||
*/
|
||||
public enum AutoFillEnum {
|
||||
|
||||
DEFAULT, INSERT, UPDATE, INSERT_UPDATE, CREATE;
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* boolean 类型枚举
|
||||
*
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum BoolFillEnum {
|
||||
|
||||
/**
|
||||
* true
|
||||
*/
|
||||
TRUE("1"),
|
||||
/**
|
||||
* false
|
||||
*/
|
||||
FALSE("0");
|
||||
|
||||
private final String value;
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2023/3/12
|
||||
* <p>
|
||||
* 通用字段的填充策略和显示策略
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CommonColumnFiledEnum {
|
||||
|
||||
/**
|
||||
* create_by 字段
|
||||
*/
|
||||
create_by("0", "0", AutoFillEnum.INSERT.name(), 100),
|
||||
|
||||
/**
|
||||
* create_time 字段
|
||||
*/
|
||||
create_time("0", "0", AutoFillEnum.INSERT.name(), 101),
|
||||
/**
|
||||
* update_by 字段
|
||||
*/
|
||||
update_by("0", "0", AutoFillEnum.INSERT_UPDATE.name(), 102),
|
||||
/**
|
||||
* update_time 字段
|
||||
*/
|
||||
update_time("0", "0", AutoFillEnum.INSERT_UPDATE.name(), 103),
|
||||
/**
|
||||
* del_flag 字段
|
||||
*/
|
||||
del_flag("0", "0", AutoFillEnum.DEFAULT.name(), 104),
|
||||
/**
|
||||
* tenant_id 字段
|
||||
*/
|
||||
tenant_id("0", "0", AutoFillEnum.DEFAULT.name(), 105);
|
||||
|
||||
/**
|
||||
* 表单是否默认显示 1/0
|
||||
*/
|
||||
private String formItem;
|
||||
|
||||
/**
|
||||
* 表格是否默认显示 1/0
|
||||
*/
|
||||
private String gridItem;
|
||||
|
||||
/**
|
||||
* 自动填充策略
|
||||
*/
|
||||
private String autoFill;
|
||||
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
/**
|
||||
* 代码生成模板中能使用的变量名称
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2024/7/16
|
||||
*/
|
||||
public class DataModelConstants {
|
||||
// 基本信息
|
||||
public static final String IS_SPRING_BOOT_3 = "isSpringBoot3";
|
||||
public static final String SYNC_MENU_ID = "syncMenuId";
|
||||
public static final String DB_TYPE = "dbType";
|
||||
public static final String PACKAGE = "package";
|
||||
public static final String PACKAGE_PATH = "packagePath";
|
||||
public static final String VERSION = "version";
|
||||
|
||||
// 模块和功能名称
|
||||
public static final String MODULE_NAME = "moduleName";
|
||||
public static final String MODULE_NAME_UPPER_FIRST = "ModuleName";
|
||||
public static final String FUNCTION_NAME = "functionName";
|
||||
public static final String FUNCTION_NAME_UPPER_FIRST = "FunctionName";
|
||||
|
||||
// 布局和样式
|
||||
public static final String FORM_LAYOUT = "formLayout";
|
||||
public static final String STYLE = "style";
|
||||
|
||||
// 作者和时间
|
||||
public static final String AUTHOR = "author";
|
||||
public static final String DATETIME = "datetime";
|
||||
public static final String DATE = "date";
|
||||
|
||||
// 导入列表
|
||||
public static final String IMPORT_LIST = "importList";
|
||||
|
||||
// 表信息
|
||||
public static final String TABLE_NAME = "tableName";
|
||||
public static final String TABLE_COMMENT = "tableComment";
|
||||
public static final String CLASS_NAME = "className";
|
||||
public static final String CLASS_NAME_UPPER_FIRST = "ClassName";
|
||||
public static final String FIELD_LIST = "fieldList";
|
||||
|
||||
// 路径
|
||||
public static final String BACKEND_PATH = "backendPath";
|
||||
public static final String FRONTEND_PATH = "frontendPath";
|
||||
|
||||
// 子表信息
|
||||
public static final String CHILD_FIELD_LIST = "childFieldList";
|
||||
public static final String CHILD_TABLE_NAME = "childTableName";
|
||||
public static final String MAIN_FIELD = "mainField";
|
||||
public static final String CHILD_FIELD = "childField";
|
||||
public static final String CHILD_CLASS_NAME_UPPER_FIRST = "ChildClassName";
|
||||
public static final String CHILD_CLASS_NAME = "childClassName";
|
||||
public static final String IS_CHILD_TENANT = "isChildTenant";
|
||||
|
||||
// 租户信息
|
||||
public static final String IS_TENANT = "isTenant";
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2023/2/7
|
||||
*/
|
||||
public class DictTool {
|
||||
|
||||
/**
|
||||
* 将字段列表转换为带有双引号的逗号分隔的字符串
|
||||
* @return 带有双引号的逗号分隔的字符串
|
||||
*/
|
||||
public static String quotation(List<String> fields) {
|
||||
|
||||
return CollUtil.join(new HashSet<>(fields), StrUtil.COMMA, s -> String.format("'%s'", s));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字段列表转换为逗号分隔的字符串
|
||||
* @return 逗号分隔的字符串
|
||||
*/
|
||||
public static String format(List<String> fields) {
|
||||
return CollUtil.join(new HashSet<>(fields), StrUtil.COMMA);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* 代码生成工具类
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/2/16
|
||||
*/
|
||||
@UtilityClass
|
||||
public class GenKit {
|
||||
|
||||
/**
|
||||
* 获取功能名 sys_a_b sysAb
|
||||
* @param tableName 表名
|
||||
* @return 功能名
|
||||
*/
|
||||
public String getFunctionName(String tableName) {
|
||||
return StrUtil.toCamelCase(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块名称
|
||||
* @param packageName 包名
|
||||
* @return 功能名
|
||||
*/
|
||||
public String getModuleName(String packageName) {
|
||||
return StrUtil.subAfter(packageName, ".", true);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 代码生成主题
|
||||
*
|
||||
* @author 冷冷
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum GeneratorStyleEnum {
|
||||
|
||||
VFORM_JSON(1L, "vform.json"),
|
||||
|
||||
VFORM_VUE(2L, "vform.vue");
|
||||
|
||||
/**
|
||||
* 对应模板ID
|
||||
*/
|
||||
private Long templateId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import cn.hutool.core.text.NamingCase;
|
||||
|
||||
/**
|
||||
* 命名规则处理,针对驼峰,下划线等处理
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/1/31
|
||||
*/
|
||||
public class NamingCaseTool {
|
||||
|
||||
/**
|
||||
* 传入字段获取的get方法
|
||||
* @param in 字段名称
|
||||
* @return
|
||||
*/
|
||||
public static String getProperty(String in) {
|
||||
return String.format("get%s", NamingCase.toPascalCase(in));
|
||||
}
|
||||
|
||||
public static String setProperty(String in) {
|
||||
return String.format("set%s", NamingCase.toPascalCase(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母大写
|
||||
* @param in 字段
|
||||
* @return 首字母大写
|
||||
*/
|
||||
public static String pascalCase(String in) {
|
||||
return String.format(NamingCase.toPascalCase(in));
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
/**
|
||||
* vform 的通用变量
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/6/5
|
||||
*/
|
||||
public interface VFormConfigConsts {
|
||||
|
||||
String widgetList = "widgetList";
|
||||
|
||||
String groupKey = "groupKey";
|
||||
|
||||
String type = "type";
|
||||
|
||||
String options = "options";
|
||||
|
||||
String span = "span";
|
||||
|
||||
String cols = "cols";
|
||||
|
||||
String key = "key";
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* vfrom 字段类型
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/6/5
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum VFormTypeEnum {
|
||||
|
||||
GRID("grid"),
|
||||
|
||||
GRID_COL("grid-col");
|
||||
|
||||
private final String type;
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.bsd.pjcloud.codegen.util;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.apache.velocity.tools.generic.DateTool;
|
||||
import org.apache.velocity.tools.generic.MathTool;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 模板引擎工具类
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/2/7
|
||||
*/
|
||||
@Service
|
||||
public class VelocityKit {
|
||||
|
||||
/**
|
||||
* Velocity 模板渲染方法
|
||||
* @param template 模板
|
||||
* @param map 数据模型
|
||||
* @return 渲染结果
|
||||
*/
|
||||
public static String render(String template, Map<String, Object> map) {
|
||||
// 设置velocity资源加载器
|
||||
Properties prop = new Properties();
|
||||
prop.put("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||
Velocity.init(prop);
|
||||
|
||||
VelocityContext context = new VelocityContext(map);
|
||||
// 函数库,使用 Lambda 表达式简化代码
|
||||
Optional.of(new MathTool()).ifPresent(mt -> context.put("math", mt));
|
||||
Optional.of(new DateTool()).ifPresent(dt -> context.put("dateTool", dt));
|
||||
Optional.of(new DictTool()).ifPresent(dt -> context.put("dict", dt));
|
||||
Optional.of(new NamingCaseTool()).ifPresent(nct -> context.put("str", nct));
|
||||
|
||||
// 渲染模板,使用 Lambda 表达式简化代码
|
||||
StringWriter sw = new StringWriter();
|
||||
Optional.ofNullable(Velocity.getTemplate(template, CharsetUtil.UTF_8)).ifPresent(tpl -> tpl.merge(context, sw));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染文本
|
||||
* @param str
|
||||
* @param dataModel 数据
|
||||
* @return
|
||||
*/
|
||||
public static String renderStr(String str, Map<String, Object> dataModel) {
|
||||
// 设置velocity资源加载器
|
||||
Velocity.init();
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
VelocityContext context = new VelocityContext(dataModel);
|
||||
// 函数库
|
||||
context.put("math", new MathTool());
|
||||
context.put("dateTool", new DateTool());
|
||||
context.put("dict", new DictTool());
|
||||
context.put("str", new NamingCaseTool());
|
||||
Velocity.evaluate(context, stringWriter, "renderStr", str);
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.bsd.pjcloud.codegen.util.table;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import com.bsd.pjcloud.codegen.util.table.enums.TableModelEnum;
|
||||
import com.bsd.pjcloud.codegen.util.table.model.TableInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.anyline.metadata.Table;
|
||||
import org.anyline.proxy.ServiceProxy;
|
||||
import org.anyline.service.AnylineService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 创建表核心逻辑类
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-18 21:56:11
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CreateTableHandler {
|
||||
|
||||
/**
|
||||
* 运行表单主键ID
|
||||
*/
|
||||
private final static String RUN_FORM_COLUMN_NAME = "run_form_id";
|
||||
|
||||
/**
|
||||
* 自动创建表
|
||||
* @param tableInfo 表信息
|
||||
*/
|
||||
public Boolean createTable(TableInfo tableInfo) {
|
||||
if (tableInfo.getColumns() == null || tableInfo.getColumns().isEmpty()) {
|
||||
throw new RuntimeException("自动创建表[" + tableInfo.getName() + "]中至少需要一个字段");
|
||||
}
|
||||
if (!TableModelEnum.CREATE.name().toLowerCase().equals(tableInfo.getModel())) {
|
||||
throw new RuntimeException("自动创建表[" + tableInfo.getModel() + "]模式的处理未找到,请检查");
|
||||
}
|
||||
try {
|
||||
AnylineService service = ServiceProxy.service();
|
||||
// 如果已存在,删除重键
|
||||
Table table = service.metadata().table(tableInfo.getName(), false);
|
||||
if (null != table)
|
||||
service.ddl().drop(table);
|
||||
// 执行建表SQL
|
||||
service.ddl().create(tableInfo);
|
||||
log.info("自动创建表处理完成!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("自动创建表异常", e);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.bsd.pjcloud.codegen.util.table.enums;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 表生成模式
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-18 21:56:11
|
||||
*/
|
||||
public enum TableModelEnum {
|
||||
|
||||
/**
|
||||
* 创建模式: 将删除所有已存在的表,重新创建,会清除所有数据
|
||||
*/
|
||||
CREATE,
|
||||
/**
|
||||
* 更新模式: 保留已存在的表以及字段,不针对字段或其结构进行修改,不影响数据
|
||||
*/
|
||||
UPDATE,
|
||||
/**
|
||||
* 默认模式: 不做任何操作
|
||||
*/
|
||||
NONE;
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.bsd.pjcloud.codegen.util.table.model;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import com.bsd.pjcloud.codegen.util.table.enums.TableModelEnum;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.anyline.metadata.Table;
|
||||
|
||||
/**
|
||||
* 表信息
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-18 21:56:11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TableInfo extends Table<TableInfo> {
|
||||
|
||||
/**
|
||||
* 建表模式
|
||||
*/
|
||||
private String model = TableModelEnum.CREATE.name().toLowerCase();
|
||||
|
||||
/**
|
||||
* 表CRUD模式
|
||||
*/
|
||||
private String crudModel;
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.bsd.pjcloud.codegen.util.vo;
|
||||
/*
|
||||
* Copyright (c) 2018-2025, luolin All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: luolin (766488893@qq.com)
|
||||
*/
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 自动创建表管理
|
||||
*
|
||||
* @author luolin
|
||||
* @date 2022-09-23 21:56:11
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "自动创建表管理")
|
||||
public class GenCreateTableVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@NotBlank(message = "表名称不能为空")
|
||||
@Schema(description = "表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表注释
|
||||
*/
|
||||
@NotBlank(message = "表注释不能为空")
|
||||
@Schema(description = "表注释")
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@NotBlank(message = "数据源名称不能为空")
|
||||
@Schema(description = "数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 主键策略
|
||||
*/
|
||||
@NotBlank(message = "主键策略不能为空")
|
||||
@Schema(description = "主键策略")
|
||||
private String pkPolicy;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private Long createUser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 表字段信息
|
||||
*/
|
||||
@Schema(description = "表字段信息")
|
||||
private String columnsInfo;
|
||||
|
||||
/**
|
||||
* 字段信息
|
||||
*/
|
||||
@Schema(description = "字段信息")
|
||||
private String columnInfo;
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.bsd.pjcloud.codegen.util.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2024/7/13
|
||||
* <p>
|
||||
* CGTM 文件路径
|
||||
* <p>
|
||||
* {
|
||||
* "templateName": "Controller",
|
||||
* "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java",
|
||||
* "templateDesc": "后台Controller",
|
||||
* "templateFile": "temps/Controller"
|
||||
* },
|
||||
*/
|
||||
@Data
|
||||
public class GenTemplateFileVO {
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String generatorPath;
|
||||
/**
|
||||
* 模板 desc
|
||||
*/
|
||||
private String templateDesc;
|
||||
/**
|
||||
* 模板文件
|
||||
*/
|
||||
private String templateFile;
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.bsd.pjcloud.codegen.util.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.bsd.pjcloud.codegen.entity.GenTemplateEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GroupVO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
@Schema(description = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 分组描述
|
||||
*/
|
||||
@Schema(description = "分组描述")
|
||||
private String groupDesc;
|
||||
|
||||
/**
|
||||
* 模板ids
|
||||
*/
|
||||
@Schema(description = "拥有的模板列表")
|
||||
private Long[] templateId;
|
||||
|
||||
/**
|
||||
* 模板列表
|
||||
*/
|
||||
@Schema(description = "拥有的模板列表")
|
||||
private List<GenTemplateEntity> templateList;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.bsd.pjcloud.codegen.util.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2022/5/2
|
||||
*/
|
||||
@Data
|
||||
public class SqlDto {
|
||||
|
||||
/**
|
||||
* 数据源ID
|
||||
*/
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* sql脚本
|
||||
*/
|
||||
private String sql;
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.codegen.util.vo;
|
||||
|
||||
import com.bsd.pjcloud.codegen.entity.GenGroupEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "模板传输对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TemplateGroupDTO extends GenGroupEntity {
|
||||
|
||||
/**
|
||||
* 模板id集合
|
||||
*/
|
||||
@Schema(description = "模板id集合")
|
||||
private List<Long> templateId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
server:
|
||||
port: 5003
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
cloud:
|
||||
nacos:
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
discovery:
|
||||
server-addr: ${NACOS_HOST:pjcloud-register}:${NACOS_PORT:8848}
|
||||
config:
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application-@profiles.active@.yml
|
||||
- optional:nacos:${spring.application.name}-@profiles.active@.yml
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: pjcloud
|
||||
-->
|
||||
|
||||
<!--
|
||||
小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
|
||||
<properties>
|
||||
<log-path>/Users/pjcloud</log-path>
|
||||
</properties>
|
||||
1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
|
||||
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
|
||||
-->
|
||||
<configuration debug="false" scan="false">
|
||||
<property name="log.path" value="logs/${project.artifactId}"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<logger name="org.activiti.engine.impl.db" level="DEBUG">
|
||||
<appender-ref ref="debug"/>
|
||||
</logger>
|
||||
|
||||
<!--nacos 心跳 INFO 屏蔽-->
|
||||
<logger name="com.alibaba.nacos" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="debug">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~
|
||||
~ Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: pjcloud
|
||||
~
|
||||
-->
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.codegen.mapper.GenFieldTypeMapper">
|
||||
|
||||
<resultMap id="fieldTypeMap" type="com.bsd.pjcloud.codegen.entity.GenFieldType">
|
||||
<id property="id" column="id"/>
|
||||
<result property="columnType" column="column_type"/>
|
||||
<result property="attrType" column="attr_type"/>
|
||||
<result property="packageName" column="package_name"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getPackageByTableId" resultType="String">
|
||||
select t1.package_name
|
||||
from gen_field_type t1,
|
||||
gen_table_column t2
|
||||
where t1.attr_type = t2.attr_type
|
||||
and t2.ds_name = #{dsName} and t2.table_name = #{tableName}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: pjcloud
|
||||
-->
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.codegen.mapper.GenFormConfMapper">
|
||||
|
||||
<resultMap id="genRecordMap" type="com.bsd.pjcloud.codegen.entity.GenFormConf">
|
||||
<id property="id" column="id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="formInfo" column="form_info"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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="com.bsd.pjcloud.codegen.mapper.GenGroupMapper">
|
||||
|
||||
<resultMap id="genGroupMap" type="com.bsd.pjcloud.codegen.util.vo.GroupVO">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="groupName" column="group_name"/>
|
||||
<result property="groupDesc" column="group_desc"/>
|
||||
<collection property="templateList" ofType="com.bsd.pjcloud.codegen.entity.GenTemplateEntity"
|
||||
select="com.bsd.pjcloud.codegen.mapper.GenTemplateMapper.listTemplateById" column="group_id">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getGroupVoById" resultMap="genGroupMap">
|
||||
SELECT
|
||||
g.id as group_id ,
|
||||
g.group_name ,
|
||||
g.group_desc
|
||||
FROM
|
||||
gen_group g
|
||||
WHERE g.id = #{id}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~
|
||||
~ Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: pjcloud
|
||||
~
|
||||
-->
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.codegen.mapper.GenTableMapper">
|
||||
|
||||
<resultMap id="tableMap" type="com.bsd.pjcloud.codegen.entity.GenTable">
|
||||
<id property="id" column="id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="className" column="class_name"/>
|
||||
<result property="tableComment" column="table_comment"/>
|
||||
<result property="author" column="author"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="packageName" column="package_name"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="generatorType" column="generator_type"/>
|
||||
<result property="backendPath" column="backend_path"/>
|
||||
<result property="frontendPath" column="frontend_path"/>
|
||||
<result property="moduleName" column="module_name"/>
|
||||
<result property="functionName" column="function_name"/>
|
||||
<result property="formLayout" column="form_layout"/>
|
||||
<result property="datasourceId" column="datasource_id"/>
|
||||
<result property="baseclassId" column="baseclass_id"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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="com.bsd.pjcloud.codegen.mapper.GenTemplateGroupMapper">
|
||||
|
||||
<resultMap id="genTemplateGroupMap" type="com.bsd.pjcloud.codegen.entity.GenTemplateGroupEntity">
|
||||
<id property="groupId" column="group_id"/>
|
||||
<id property="templateId" column="template_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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="com.bsd.pjcloud.codegen.mapper.GenTemplateMapper">
|
||||
|
||||
<resultMap id="genTemplateMap" type="com.bsd.pjcloud.codegen.entity.GenTemplateEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="templateName" column="template_name"/>
|
||||
<result property="generatorPath" column="generator_path"/>
|
||||
<result property="templateDesc" column="template_desc"/>
|
||||
<result property="templateCode" column="template_code"/>
|
||||
</resultMap>
|
||||
<select id="listTemplateById" resultType="com.bsd.pjcloud.codegen.entity.GenTemplateEntity">
|
||||
SELECT
|
||||
t.id as id,t.template_name,t.generator_path,t.template_desc,t.template_code
|
||||
FROM gen_template t ,
|
||||
gen_template_group tg
|
||||
WHERE t.id = tg.template_id
|
||||
AND t.del_flag = '0'
|
||||
and tg.group_id = #{groupId}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user