fase()规范化

dev-2
王熙朝 2024-05-10 14:43:05 +08:00
parent a9aa680abe
commit 91ceda487b
222 changed files with 5596 additions and 5053 deletions

View File

@ -21,5 +21,5 @@ public class ServiceNameConstants {
*/ */
public static final String FILE_SERVICE = "muyu-file"; public static final String FILE_SERVICE = "muyu-file";
public static final String TEST_MUYU = "muyu-test"; public static final String EDITION_MUYU = "muyu-edition";
} }

View File

@ -13,7 +13,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomSwagger2 @EnableCustomSwagger2
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class MuYuFileApplication { public class MuYuFileApplication {
public static void main (String[] args) { public static void main(String[] args) {
SpringApplication.run(MuYuFileApplication.class, args); SpringApplication.run(MuYuFileApplication.class, args);
} }
} }

View File

@ -33,40 +33,40 @@ public class MinioConfig {
*/ */
private String bucketName; private String bucketName;
public String getUrl () { public String getUrl() {
return url; return url;
} }
public void setUrl (String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
public String getAccessKey () { public String getAccessKey() {
return accessKey; return accessKey;
} }
public void setAccessKey (String accessKey) { public void setAccessKey(String accessKey) {
this.accessKey = accessKey; this.accessKey = accessKey;
} }
public String getSecretKey () { public String getSecretKey() {
return secretKey; return secretKey;
} }
public void setSecretKey (String secretKey) { public void setSecretKey(String secretKey) {
this.secretKey = secretKey; this.secretKey = secretKey;
} }
public String getBucketName () { public String getBucketName() {
return bucketName; return bucketName;
} }
public void setBucketName (String bucketName) { public void setBucketName(String bucketName) {
this.bucketName = bucketName; this.bucketName = bucketName;
} }
@Bean @Bean
public MinioClient getMinioClient () { public MinioClient getMinioClient() {
return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build(); return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
} }
} }

View File

@ -27,7 +27,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
private String localFilePath; private String localFilePath;
@Override @Override
public void addResourceHandlers (ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
/** 本地文件上传路径 */ /** 本地文件上传路径 */
registry.addResourceHandler(localFilePrefix + "/**") registry.addResourceHandler(localFilePrefix + "/**")
.addResourceLocations("file:" + localFilePath + File.separator); .addResourceLocations("file:" + localFilePath + File.separator);
@ -37,7 +37,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
* *
*/ */
@Override @Override
public void addCorsMappings (CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
// 设置允许跨域的路由 // 设置允许跨域的路由
registry.addMapping(localFilePrefix + "/**") registry.addMapping(localFilePrefix + "/**")
// 设置允许跨域请求的域名 // 设置允许跨域请求的域名

View File

@ -2,8 +2,8 @@ package com.muyu.file.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.file.FileUtils; import com.muyu.common.core.utils.file.FileUtils;
import com.muyu.file.service.ISysFileService;
import com.muyu.common.system.domain.SysFile; import com.muyu.common.system.domain.SysFile;
import com.muyu.file.service.ISysFileService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,7 +27,7 @@ public class SysFileController {
* *
*/ */
@PostMapping("upload") @PostMapping("upload")
public Result<SysFile> upload (MultipartFile file) { public Result<SysFile> upload(MultipartFile file) {
try { try {
// 上传并返回访问地址 // 上传并返回访问地址
String url = sysFileService.uploadFile(file); String url = sysFileService.uploadFile(file);

View File

@ -31,13 +31,11 @@ public class FastDfsSysFileServiceImpl implements ISysFileService {
* FastDfs * FastDfs
* *
* @param file * @param file
*
* @return 访 * @return 访
*
* @throws Exception * @throws Exception
*/ */
@Override @Override
public String uploadFile (MultipartFile file) throws Exception { public String uploadFile(MultipartFile file) throws Exception {
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(), StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
FileTypeUtils.getExtension(file), null); FileTypeUtils.getExtension(file), null);

View File

@ -12,10 +12,8 @@ public interface ISysFileService {
* *
* *
* @param file * @param file
*
* @return 访 * @return 访
*
* @throws Exception * @throws Exception
*/ */
public String uploadFile (MultipartFile file) throws Exception; public String uploadFile(MultipartFile file) throws Exception;
} }

View File

@ -36,13 +36,11 @@ public class LocalSysFileServiceImpl implements ISysFileService {
* *
* *
* @param file * @param file
*
* @return 访 * @return 访
*
* @throws Exception * @throws Exception
*/ */
@Override @Override
public String uploadFile (MultipartFile file) throws Exception { public String uploadFile(MultipartFile file) throws Exception {
String name = FileUploadUtils.upload(localFilePath, file); String name = FileUploadUtils.upload(localFilePath, file);
String url = domain + localFilePrefix + name; String url = domain + localFilePrefix + name;
return url; return url;

View File

@ -28,13 +28,11 @@ public class MinioSysFileServiceImpl implements ISysFileService {
* Minio * Minio
* *
* @param file * @param file
*
* @return 访 * @return 访
*
* @throws Exception * @throws Exception
*/ */
@Override @Override
public String uploadFile (MultipartFile file) throws Exception { public String uploadFile(MultipartFile file) throws Exception {
String fileName = FileUploadUtils.extractFilename(file); String fileName = FileUploadUtils.extractFilename(file);
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
PutObjectArgs args = PutObjectArgs.builder() PutObjectArgs args = PutObjectArgs.builder()

View File

@ -38,12 +38,10 @@ public class FileUploadUtils {
* *
* @param baseDir * @param baseDir
* @param file * @param file
*
* @return * @return
*
* @throws IOException * @throws IOException
*/ */
public static final String upload (String baseDir, MultipartFile file) throws IOException { public static final String upload(String baseDir, MultipartFile file) throws IOException {
try { try {
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
} catch (FileException fe) { } catch (FileException fe) {
@ -59,15 +57,13 @@ public class FileUploadUtils {
* @param baseDir * @param baseDir
* @param file * @param file
* @param allowedExtension * @param allowedExtension
*
* @return * @return
*
* @throws FileSizeLimitExceededException * @throws FileSizeLimitExceededException
* @throws FileNameLengthLimitExceededException * @throws FileNameLengthLimitExceededException
* @throws IOException * @throws IOException
* @throws InvalidExtensionException * @throws InvalidExtensionException
*/ */
public static final String upload (String baseDir, MultipartFile file, String[] allowedExtension) public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException { InvalidExtensionException {
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
@ -87,12 +83,12 @@ public class FileUploadUtils {
/** /**
* *
*/ */
public static final String extractFilename (MultipartFile file) { public static final String extractFilename(MultipartFile file) {
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file)); FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
} }
private static final File getAbsoluteFile (String uploadDir, String fileName) throws IOException { private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
File desc = new File(uploadDir + File.separator + fileName); File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists()) { if (!desc.exists()) {
@ -103,7 +99,7 @@ public class FileUploadUtils {
return desc.isAbsolute() ? desc : desc.getAbsoluteFile(); return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
} }
private static final String getPathFileName (String fileName) throws IOException { private static final String getPathFileName(String fileName) throws IOException {
String pathFileName = "/" + fileName; String pathFileName = "/" + fileName;
return pathFileName; return pathFileName;
} }
@ -112,11 +108,10 @@ public class FileUploadUtils {
* *
* *
* @param file * @param file
*
* @throws FileSizeLimitExceededException * @throws FileSizeLimitExceededException
* @throws InvalidExtensionException * @throws InvalidExtensionException
*/ */
public static final void assertAllowed (MultipartFile file, String[] allowedExtension) public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException { throws FileSizeLimitExceededException, InvalidExtensionException {
long size = file.getSize(); long size = file.getSize();
if (size > DEFAULT_MAX_SIZE) { if (size > DEFAULT_MAX_SIZE) {
@ -149,10 +144,9 @@ public class FileUploadUtils {
* *
* @param extension * @param extension
* @param allowedExtension * @param allowedExtension
*
* @return true/false * @return true/false
*/ */
public static final boolean isAllowedExtension (String extension, String[] allowedExtension) { public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
for (String str : allowedExtension) { for (String str : allowedExtension) {
if (str.equalsIgnoreCase(extension)) { if (str.equalsIgnoreCase(extension)) {
return true; return true;

View File

@ -17,7 +17,7 @@
<dependencies> <dependencies>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>

View File

@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableMyFeignClients @EnableMyFeignClients
@SpringBootApplication @SpringBootApplication
public class MuYuGenApplication { public class MuYuGenApplication {
public static void main (String[] args) { public static void main(String[] args) {
SpringApplication.run(MuYuGenApplication.class, args); SpringApplication.run(MuYuGenApplication.class, args);
} }
} }

View File

@ -31,35 +31,35 @@ public class GenConfig {
*/ */
public static String tablePrefix; public static String tablePrefix;
public static String getAuthor () { public static String getAuthor() {
return author; return author;
} }
public void setAuthor (String author) { public void setAuthor(String author) {
GenConfig.author = author; GenConfig.author = author;
} }
public static String getPackageName () { public static String getPackageName() {
return packageName; return packageName;
} }
public void setPackageName (String packageName) { public void setPackageName(String packageName) {
GenConfig.packageName = packageName; GenConfig.packageName = packageName;
} }
public static boolean getAutoRemovePre () { public static boolean getAutoRemovePre() {
return autoRemovePre; return autoRemovePre;
} }
public void setAutoRemovePre (boolean autoRemovePre) { public void setAutoRemovePre(boolean autoRemovePre) {
GenConfig.autoRemovePre = autoRemovePre; GenConfig.autoRemovePre = autoRemovePre;
} }
public static String getTablePrefix () { public static String getTablePrefix() {
return tablePrefix; return tablePrefix;
} }
public void setTablePrefix (String tablePrefix) { public void setTablePrefix(String tablePrefix) {
GenConfig.tablePrefix = tablePrefix; GenConfig.tablePrefix = tablePrefix;
} }
} }

View File

@ -1,8 +1,8 @@
package com.muyu.gen.controller; package com.muyu.gen.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.text.Convert; import com.muyu.common.core.text.Convert;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log; import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
@ -41,7 +41,7 @@ public class GenController extends BaseController {
*/ */
@RequiresPermissions("tool:gen:list") @RequiresPermissions("tool:gen:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<GenTable>> genList (GenTable genTable) { public Result<TableDataInfo<GenTable>> genList(GenTable genTable) {
startPage(); startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable); List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list); return getDataTable(list);
@ -52,7 +52,7 @@ public class GenController extends BaseController {
*/ */
@RequiresPermissions("tool:gen:query") @RequiresPermissions("tool:gen:query")
@GetMapping(value = "/{tableId}") @GetMapping(value = "/{tableId}")
public Result getInfo (@PathVariable Long tableId) { public Result getInfo(@PathVariable Long tableId) {
GenTable table = genTableService.selectGenTableById(tableId); GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll(); List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId); List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
@ -68,7 +68,7 @@ public class GenController extends BaseController {
*/ */
@RequiresPermissions("tool:gen:list") @RequiresPermissions("tool:gen:list")
@GetMapping("/db/list") @GetMapping("/db/list")
public Result<TableDataInfo<GenTable>> dataList (GenTable genTable) { public Result<TableDataInfo<GenTable>> dataList(GenTable genTable) {
startPage(); startPage();
List<GenTable> list = genTableService.selectDbTableList(genTable); List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list); return getDataTable(list);
@ -78,7 +78,7 @@ public class GenController extends BaseController {
* *
*/ */
@GetMapping(value = "/column/{tableId}") @GetMapping(value = "/column/{tableId}")
public Result<TableDataInfo<GenTableColumn>> columnList (Long tableId) { public Result<TableDataInfo<GenTableColumn>> columnList(Long tableId) {
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId); List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
return Result.success( return Result.success(
TableDataInfo.<GenTableColumn>builder() TableDataInfo.<GenTableColumn>builder()
@ -94,7 +94,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:import") @RequiresPermissions("tool:gen:import")
@Log(title = "代码生成", businessType = BusinessType.IMPORT) @Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable") @PostMapping("/importTable")
public Result importTableSave (String tables) { public Result importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables); String[] tableNames = Convert.toStrArray(tables);
// 查询表信息 // 查询表信息
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
@ -108,7 +108,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:edit") @RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE) @Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result editSave (@Validated @RequestBody GenTable genTable) { public Result editSave(@Validated @RequestBody GenTable genTable) {
genTableService.validateEdit(genTable); genTableService.validateEdit(genTable);
genTableService.updateGenTable(genTable); genTableService.updateGenTable(genTable);
return success(); return success();
@ -120,7 +120,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:remove") @RequiresPermissions("tool:gen:remove")
@Log(title = "代码生成", businessType = BusinessType.DELETE) @Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}") @DeleteMapping("/{tableIds}")
public Result remove (@PathVariable Long[] tableIds) { public Result remove(@PathVariable Long[] tableIds) {
genTableService.deleteGenTableByIds(tableIds); genTableService.deleteGenTableByIds(tableIds);
return success(); return success();
} }
@ -130,7 +130,7 @@ public class GenController extends BaseController {
*/ */
@RequiresPermissions("tool:gen:preview") @RequiresPermissions("tool:gen:preview")
@GetMapping("/preview/{tableId}") @GetMapping("/preview/{tableId}")
public Result preview (@PathVariable("tableId") Long tableId) throws IOException { public Result preview(@PathVariable("tableId") Long tableId) throws IOException {
Map<String, String> dataMap = genTableService.previewCode(tableId); Map<String, String> dataMap = genTableService.previewCode(tableId);
return success(dataMap); return success(dataMap);
} }
@ -141,7 +141,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code") @RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE) @Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/download/{tableName}") @GetMapping("/download/{tableName}")
public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
byte[] data = genTableService.downloadCode(tableName); byte[] data = genTableService.downloadCode(tableName);
genCode(response, data); genCode(response, data);
} }
@ -152,7 +152,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code") @RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE) @Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}") @GetMapping("/genCode/{tableName}")
public Result genCode (@PathVariable("tableName") String tableName) { public Result genCode(@PathVariable("tableName") String tableName) {
genTableService.generatorCode(tableName); genTableService.generatorCode(tableName);
return success(); return success();
} }
@ -163,7 +163,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:edit") @RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE) @Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}") @GetMapping("/synchDb/{tableName}")
public Result synchDb (@PathVariable("tableName") String tableName) { public Result synchDb(@PathVariable("tableName") String tableName) {
genTableService.synchDb(tableName); genTableService.synchDb(tableName);
return success(); return success();
} }
@ -174,7 +174,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code") @RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE) @Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode") @GetMapping("/batchGenCode")
public void batchGenCode (HttpServletResponse response, String tables) throws IOException { public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
String[] tableNames = Convert.toStrArray(tables); String[] tableNames = Convert.toStrArray(tables);
byte[] data = genTableService.downloadCode(tableNames); byte[] data = genTableService.downloadCode(tableNames);
genCode(response, data); genCode(response, data);
@ -183,7 +183,7 @@ public class GenController extends BaseController {
/** /**
* zip * zip
*/ */
private void genCode (HttpServletResponse response, byte[] data) throws IOException { private void genCode(HttpServletResponse response, byte[] data) throws IOException {
response.reset(); response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\""); response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\"");
response.addHeader("Content-Length", String.valueOf(data.length)); response.addHeader("Content-Length", String.valueOf(data.length));

View File

@ -15,8 +15,6 @@ import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
/** /**
* gen_table * gen_table
* *
@ -154,19 +152,19 @@ public class GenTable extends BaseEntity {
*/ */
private String parentMenuName; private String parentMenuName;
public static boolean isSub (String tplCategory) { public static boolean isSub(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
} }
public static boolean isTree (String tplCategory) { public static boolean isTree(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
} }
public static boolean isCrud (String tplCategory) { public static boolean isCrud(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
} }
public static boolean isSuperColumn (String tplCategory, String javaField) { public static boolean isSuperColumn(String tplCategory, String javaField) {
if (isTree(tplCategory)) { if (isTree(tplCategory)) {
return StringUtils.equalsAnyIgnoreCase(javaField, return StringUtils.equalsAnyIgnoreCase(javaField,
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
@ -174,203 +172,203 @@ public class GenTable extends BaseEntity {
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
} }
public Long getTableId () { public Long getTableId() {
return tableId; return tableId;
} }
public void setTableId (Long tableId) { public void setTableId(Long tableId) {
this.tableId = tableId; this.tableId = tableId;
} }
public String getTableName () { public String getTableName() {
return tableName; return tableName;
} }
public void setTableName (String tableName) { public void setTableName(String tableName) {
this.tableName = tableName; this.tableName = tableName;
} }
public String getTableComment () { public String getTableComment() {
return tableComment; return tableComment;
} }
public void setTableComment (String tableComment) { public void setTableComment(String tableComment) {
this.tableComment = tableComment; this.tableComment = tableComment;
} }
public String getSubTableName () { public String getSubTableName() {
return subTableName; return subTableName;
} }
public void setSubTableName (String subTableName) { public void setSubTableName(String subTableName) {
this.subTableName = subTableName; this.subTableName = subTableName;
} }
public String getSubTableFkName () { public String getSubTableFkName() {
return subTableFkName; return subTableFkName;
} }
public void setSubTableFkName (String subTableFkName) { public void setSubTableFkName(String subTableFkName) {
this.subTableFkName = subTableFkName; this.subTableFkName = subTableFkName;
} }
public String getClassName () { public String getClassName() {
return className; return className;
} }
public void setClassName (String className) { public void setClassName(String className) {
this.className = className; this.className = className;
} }
public String getTplCategory () { public String getTplCategory() {
return tplCategory; return tplCategory;
} }
public void setTplCategory (String tplCategory) { public void setTplCategory(String tplCategory) {
this.tplCategory = tplCategory; this.tplCategory = tplCategory;
} }
public String getPackageName () { public String getPackageName() {
return packageName; return packageName;
} }
public void setPackageName (String packageName) { public void setPackageName(String packageName) {
this.packageName = packageName; this.packageName = packageName;
} }
public String getModuleName () { public String getModuleName() {
return moduleName; return moduleName;
} }
public void setModuleName (String moduleName) { public void setModuleName(String moduleName) {
this.moduleName = moduleName; this.moduleName = moduleName;
} }
public String getBusinessName () { public String getBusinessName() {
return businessName; return businessName;
} }
public void setBusinessName (String businessName) { public void setBusinessName(String businessName) {
this.businessName = businessName; this.businessName = businessName;
} }
public String getFunctionName () { public String getFunctionName() {
return functionName; return functionName;
} }
public void setFunctionName (String functionName) { public void setFunctionName(String functionName) {
this.functionName = functionName; this.functionName = functionName;
} }
public String getFunctionAuthor () { public String getFunctionAuthor() {
return functionAuthor; return functionAuthor;
} }
public void setFunctionAuthor (String functionAuthor) { public void setFunctionAuthor(String functionAuthor) {
this.functionAuthor = functionAuthor; this.functionAuthor = functionAuthor;
} }
public String getGenType () { public String getGenType() {
return genType; return genType;
} }
public void setGenType (String genType) { public void setGenType(String genType) {
this.genType = genType; this.genType = genType;
} }
public String getGenPath () { public String getGenPath() {
return genPath; return genPath;
} }
public void setGenPath (String genPath) { public void setGenPath(String genPath) {
this.genPath = genPath; this.genPath = genPath;
} }
public GenTableColumn getPkColumn () { public GenTableColumn getPkColumn() {
return pkColumn; return pkColumn;
} }
public void setPkColumn (GenTableColumn pkColumn) { public void setPkColumn(GenTableColumn pkColumn) {
this.pkColumn = pkColumn; this.pkColumn = pkColumn;
} }
public GenTable getSubTable () { public GenTable getSubTable() {
return subTable; return subTable;
} }
public void setSubTable (GenTable subTable) { public void setSubTable(GenTable subTable) {
this.subTable = subTable; this.subTable = subTable;
} }
public List<GenTableColumn> getColumns () { public List<GenTableColumn> getColumns() {
return columns; return columns;
} }
public void setColumns (List<GenTableColumn> columns) { public void setColumns(List<GenTableColumn> columns) {
this.columns = columns; this.columns = columns;
} }
public String getOptions () { public String getOptions() {
return options; return options;
} }
public void setOptions (String options) { public void setOptions(String options) {
this.options = options; this.options = options;
} }
public String getTreeCode () { public String getTreeCode() {
return treeCode; return treeCode;
} }
public void setTreeCode (String treeCode) { public void setTreeCode(String treeCode) {
this.treeCode = treeCode; this.treeCode = treeCode;
} }
public String getTreeParentCode () { public String getTreeParentCode() {
return treeParentCode; return treeParentCode;
} }
public void setTreeParentCode (String treeParentCode) { public void setTreeParentCode(String treeParentCode) {
this.treeParentCode = treeParentCode; this.treeParentCode = treeParentCode;
} }
public String getTreeName () { public String getTreeName() {
return treeName; return treeName;
} }
public void setTreeName (String treeName) { public void setTreeName(String treeName) {
this.treeName = treeName; this.treeName = treeName;
} }
public String getParentMenuId () { public String getParentMenuId() {
return parentMenuId; return parentMenuId;
} }
public void setParentMenuId (String parentMenuId) { public void setParentMenuId(String parentMenuId) {
this.parentMenuId = parentMenuId; this.parentMenuId = parentMenuId;
} }
public String getParentMenuName () { public String getParentMenuName() {
return parentMenuName; return parentMenuName;
} }
public void setParentMenuName (String parentMenuName) { public void setParentMenuName(String parentMenuName) {
this.parentMenuName = parentMenuName; this.parentMenuName = parentMenuName;
} }
public boolean isSub () { public boolean isSub() {
return isSub(this.tplCategory); return isSub(this.tplCategory);
} }
public boolean isTree () { public boolean isTree() {
return isTree(this.tplCategory); return isTree(this.tplCategory);
} }
public boolean isCrud () { public boolean isCrud() {
return isCrud(this.tplCategory); return isCrud(this.tplCategory);
} }
public boolean isSuperColumn (String javaField) { public boolean isSuperColumn(String javaField) {
return isSuperColumn(this.tplCategory, javaField); return isSuperColumn(this.tplCategory, javaField);
} }
} }

View File

@ -114,7 +114,7 @@ public class GenTableColumn extends BaseEntity {
*/ */
private Integer sort; private Integer sort;
public static boolean isSuperColumn (String javaField) { public static boolean isSuperColumn(String javaField) {
return StringUtils.equalsAnyIgnoreCase(javaField, return StringUtils.equalsAnyIgnoreCase(javaField,
// BaseEntity // BaseEntity
"createBy", "createTime", "updateBy", "updateTime", "remark", "createBy", "createTime", "updateBy", "updateTime", "remark",
@ -122,224 +122,224 @@ public class GenTableColumn extends BaseEntity {
"parentName", "parentId", "orderNum", "ancestors"); "parentName", "parentId", "orderNum", "ancestors");
} }
public static boolean isUsableColumn (String javaField) { public static boolean isUsableColumn(String javaField) {
// isSuperColumn()中的名单用于避免生成多余Domain属性若某些属性在生成页面时需要用到不能忽略则放在此处白名单 // isSuperColumn()中的名单用于避免生成多余Domain属性若某些属性在生成页面时需要用到不能忽略则放在此处白名单
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
} }
public Long getColumnId () { public Long getColumnId() {
return columnId; return columnId;
} }
public void setColumnId (Long columnId) { public void setColumnId(Long columnId) {
this.columnId = columnId; this.columnId = columnId;
} }
public Long getTableId () { public Long getTableId() {
return tableId; return tableId;
} }
public void setTableId (Long tableId) { public void setTableId(Long tableId) {
this.tableId = tableId; this.tableId = tableId;
} }
public String getColumnName () { public String getColumnName() {
return columnName; return columnName;
} }
public void setColumnName (String columnName) { public void setColumnName(String columnName) {
this.columnName = columnName; this.columnName = columnName;
} }
public String getColumnComment () { public String getColumnComment() {
return columnComment; return columnComment;
} }
public void setColumnComment (String columnComment) { public void setColumnComment(String columnComment) {
this.columnComment = columnComment; this.columnComment = columnComment;
} }
public String getColumnType () { public String getColumnType() {
return columnType; return columnType;
} }
public void setColumnType (String columnType) { public void setColumnType(String columnType) {
this.columnType = columnType; this.columnType = columnType;
} }
public String getJavaType () { public String getJavaType() {
return javaType; return javaType;
} }
public void setJavaType (String javaType) { public void setJavaType(String javaType) {
this.javaType = javaType; this.javaType = javaType;
} }
public String getJavaField () { public String getJavaField() {
return javaField; return javaField;
} }
public void setJavaField (String javaField) { public void setJavaField(String javaField) {
this.javaField = javaField; this.javaField = javaField;
} }
public String getCapJavaField () { public String getCapJavaField() {
return StringUtils.capitalize(javaField); return StringUtils.capitalize(javaField);
} }
public String getIsPk () { public String getIsPk() {
return isPk; return isPk;
} }
public void setIsPk (String isPk) { public void setIsPk(String isPk) {
this.isPk = isPk; this.isPk = isPk;
} }
public boolean isPk () { public boolean isPk() {
return isPk(this.isPk); return isPk(this.isPk);
} }
public boolean isPk (String isPk) { public boolean isPk(String isPk) {
return isPk != null && StringUtils.equals("1", isPk); return isPk != null && StringUtils.equals("1", isPk);
} }
public String getIsIncrement () { public String getIsIncrement() {
return isIncrement; return isIncrement;
} }
public void setIsIncrement (String isIncrement) { public void setIsIncrement(String isIncrement) {
this.isIncrement = isIncrement; this.isIncrement = isIncrement;
} }
public boolean isIncrement () { public boolean isIncrement() {
return isIncrement(this.isIncrement); return isIncrement(this.isIncrement);
} }
public boolean isIncrement (String isIncrement) { public boolean isIncrement(String isIncrement) {
return isIncrement != null && StringUtils.equals("1", isIncrement); return isIncrement != null && StringUtils.equals("1", isIncrement);
} }
public String getIsRequired () { public String getIsRequired() {
return isRequired; return isRequired;
} }
public void setIsRequired (String isRequired) { public void setIsRequired(String isRequired) {
this.isRequired = isRequired; this.isRequired = isRequired;
} }
public boolean isRequired () { public boolean isRequired() {
return isRequired(this.isRequired); return isRequired(this.isRequired);
} }
public boolean isRequired (String isRequired) { public boolean isRequired(String isRequired) {
return isRequired != null && StringUtils.equals("1", isRequired); return isRequired != null && StringUtils.equals("1", isRequired);
} }
public String getIsInsert () { public String getIsInsert() {
return isInsert; return isInsert;
} }
public void setIsInsert (String isInsert) { public void setIsInsert(String isInsert) {
this.isInsert = isInsert; this.isInsert = isInsert;
} }
public boolean isInsert () { public boolean isInsert() {
return isInsert(this.isInsert); return isInsert(this.isInsert);
} }
public boolean isInsert (String isInsert) { public boolean isInsert(String isInsert) {
return isInsert != null && StringUtils.equals("1", isInsert); return isInsert != null && StringUtils.equals("1", isInsert);
} }
public String getIsEdit () { public String getIsEdit() {
return isEdit; return isEdit;
} }
public void setIsEdit (String isEdit) { public void setIsEdit(String isEdit) {
this.isEdit = isEdit; this.isEdit = isEdit;
} }
public boolean isEdit () { public boolean isEdit() {
return isInsert(this.isEdit); return isInsert(this.isEdit);
} }
public boolean isEdit (String isEdit) { public boolean isEdit(String isEdit) {
return isEdit != null && StringUtils.equals("1", isEdit); return isEdit != null && StringUtils.equals("1", isEdit);
} }
public String getIsList () { public String getIsList() {
return isList; return isList;
} }
public void setIsList (String isList) { public void setIsList(String isList) {
this.isList = isList; this.isList = isList;
} }
public boolean isList () { public boolean isList() {
return isList(this.isList); return isList(this.isList);
} }
public boolean isList (String isList) { public boolean isList(String isList) {
return isList != null && StringUtils.equals("1", isList); return isList != null && StringUtils.equals("1", isList);
} }
public String getIsQuery () { public String getIsQuery() {
return isQuery; return isQuery;
} }
public void setIsQuery (String isQuery) { public void setIsQuery(String isQuery) {
this.isQuery = isQuery; this.isQuery = isQuery;
} }
public boolean isQuery () { public boolean isQuery() {
return isQuery(this.isQuery); return isQuery(this.isQuery);
} }
public boolean isQuery (String isQuery) { public boolean isQuery(String isQuery) {
return isQuery != null && StringUtils.equals("1", isQuery); return isQuery != null && StringUtils.equals("1", isQuery);
} }
public String getQueryType () { public String getQueryType() {
return queryType; return queryType;
} }
public void setQueryType (String queryType) { public void setQueryType(String queryType) {
this.queryType = queryType; this.queryType = queryType;
} }
public String getHtmlType () { public String getHtmlType() {
return htmlType; return htmlType;
} }
public void setHtmlType (String htmlType) { public void setHtmlType(String htmlType) {
this.htmlType = htmlType; this.htmlType = htmlType;
} }
public String getDictType () { public String getDictType() {
return dictType; return dictType;
} }
public void setDictType (String dictType) { public void setDictType(String dictType) {
this.dictType = dictType; this.dictType = dictType;
} }
public Integer getSort () { public Integer getSort() {
return sort; return sort;
} }
public void setSort (Integer sort) { public void setSort(Integer sort) {
this.sort = sort; this.sort = sort;
} }
public boolean isSuperColumn () { public boolean isSuperColumn() {
return isSuperColumn(this.javaField); return isSuperColumn(this.javaField);
} }
public boolean isUsableColumn () { public boolean isUsableColumn() {
return isUsableColumn(javaField); return isUsableColumn(javaField);
} }
public String readConverterExp () { public String readConverterExp() {
String remarks = StringUtils.substringBetween(this.columnComment, "", ""); String remarks = StringUtils.substringBetween(this.columnComment, "", "");
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (StringUtils.isNotEmpty(remarks)) { if (StringUtils.isNotEmpty(remarks)) {

View File

@ -15,53 +15,47 @@ public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> {
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
List<GenTableColumn> selectDbTableColumnsByName (String tableName); List<GenTableColumn> selectDbTableColumnsByName(String tableName);
/** /**
* *
* *
* @param tableId * @param tableId
*
* @return * @return
*/ */
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId); List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/** /**
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
int insertGenTableColumn (GenTableColumn genTableColumn); int insertGenTableColumn(GenTableColumn genTableColumn);
/** /**
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
int updateGenTableColumn (GenTableColumn genTableColumn); int updateGenTableColumn(GenTableColumn genTableColumn);
/** /**
* *
* *
* @param genTableColumns * @param genTableColumns
*
* @return * @return
*/ */
int deleteGenTableColumns (List<GenTableColumn> genTableColumns); int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
/** /**
* *
* *
* @param ids ID * @param ids ID
*
* @return * @return
*/ */
int deleteGenTableColumnByIds (Long[] ids); int deleteGenTableColumnByIds(Long[] ids);
} }

View File

@ -15,78 +15,70 @@ public interface GenTableMapper extends BaseMapper<GenTable> {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
List<GenTable> selectGenTableList (GenTable genTable); List<GenTable> selectGenTableList(GenTable genTable);
/** /**
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
List<GenTable> selectDbTableList (GenTable genTable); List<GenTable> selectDbTableList(GenTable genTable);
/** /**
* *
* *
* @param tableNames * @param tableNames
*
* @return * @return
*/ */
List<GenTable> selectDbTableListByNames (String[] tableNames); List<GenTable> selectDbTableListByNames(String[] tableNames);
/** /**
* *
* *
* @return * @return
*/ */
List<GenTable> selectGenTableAll (); List<GenTable> selectGenTableAll();
/** /**
* ID * ID
* *
* @param id ID * @param id ID
*
* @return * @return
*/ */
GenTable selectGenTableById (Long id); GenTable selectGenTableById(Long id);
/** /**
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
GenTable selectGenTableByName (String tableName); GenTable selectGenTableByName(String tableName);
/** /**
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
int insertGenTable (GenTable genTable); int insertGenTable(GenTable genTable);
/** /**
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
int updateGenTable (GenTable genTable); int updateGenTable(GenTable genTable);
/** /**
* *
* *
* @param ids ID * @param ids ID
*
* @return * @return
*/ */
int deleteGenTableByIds (Long[] ids); int deleteGenTableByIds(Long[] ids);
} }

View File

@ -22,11 +22,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
* *
* *
* @param tableId * @param tableId
*
* @return * @return
*/ */
@Override @Override
public List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId) { public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
} }
@ -34,11 +33,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
@Override @Override
public int insertGenTableColumn (GenTableColumn genTableColumn) { public int insertGenTableColumn(GenTableColumn genTableColumn) {
return genTableColumnMapper.insertGenTableColumn(genTableColumn); return genTableColumnMapper.insertGenTableColumn(genTableColumn);
} }
@ -46,11 +44,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
@Override @Override
public int updateGenTableColumn (GenTableColumn genTableColumn) { public int updateGenTableColumn(GenTableColumn genTableColumn) {
return genTableColumnMapper.updateGenTableColumn(genTableColumn); return genTableColumnMapper.updateGenTableColumn(genTableColumn);
} }
@ -58,11 +55,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
* *
* *
* @param ids ID * @param ids ID
*
* @return * @return
*/ */
@Override @Override
public int deleteGenTableColumnByIds (String ids) { public int deleteGenTableColumnByIds(String ids) {
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
} }
} }

View File

@ -58,10 +58,9 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* @param table * @param table
* @param template * @param template
*
* @return * @return
*/ */
public static String getGenPath (GenTable table, String template) { public static String getGenPath(GenTable table, String template) {
String genPath = table.getGenPath(); String genPath = table.getGenPath();
if (StringUtils.equals(genPath, "/")) { if (StringUtils.equals(genPath, "/")) {
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
@ -73,11 +72,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param id ID * @param id ID
*
* @return * @return
*/ */
@Override @Override
public GenTable selectGenTableById (Long id) { public GenTable selectGenTableById(Long id) {
GenTable genTable = genTableMapper.selectGenTableById(id); GenTable genTable = genTableMapper.selectGenTableById(id);
setTableFromOptions(genTable); setTableFromOptions(genTable);
return genTable; return genTable;
@ -87,11 +85,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
@Override @Override
public List<GenTable> selectGenTableList (GenTable genTable) { public List<GenTable> selectGenTableList(GenTable genTable) {
return genTableMapper.selectGenTableList(genTable); return genTableMapper.selectGenTableList(genTable);
} }
@ -99,11 +96,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
@Override @Override
public List<GenTable> selectDbTableList (GenTable genTable) { public List<GenTable> selectDbTableList(GenTable genTable) {
return genTableMapper.selectDbTableList(genTable); return genTableMapper.selectDbTableList(genTable);
} }
@ -111,11 +107,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param tableNames * @param tableNames
*
* @return * @return
*/ */
@Override @Override
public List<GenTable> selectDbTableListByNames (String[] tableNames) { public List<GenTable> selectDbTableListByNames(String[] tableNames) {
return genTableMapper.selectDbTableListByNames(tableNames); return genTableMapper.selectDbTableListByNames(tableNames);
} }
@ -125,7 +120,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @return * @return
*/ */
@Override @Override
public List<GenTable> selectGenTableAll () { public List<GenTable> selectGenTableAll() {
return genTableMapper.selectGenTableAll(); return genTableMapper.selectGenTableAll();
} }
@ -133,12 +128,11 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateGenTable (GenTable genTable) { public void updateGenTable(GenTable genTable) {
String options = JSON.toJSONString(genTable.getParams()); String options = JSON.toJSONString(genTable.getParams());
genTable.setOptions(options); genTable.setOptions(options);
int row = genTableMapper.updateGenTable(genTable); int row = genTableMapper.updateGenTable(genTable);
@ -153,12 +147,11 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param tableIds ID * @param tableIds ID
*
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteGenTableByIds (Long[] tableIds) { public void deleteGenTableByIds(Long[] tableIds) {
genTableMapper.deleteGenTableByIds(tableIds); genTableMapper.deleteGenTableByIds(tableIds);
genTableColumnMapper.deleteGenTableColumnByIds(tableIds); genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
} }
@ -170,7 +163,7 @@ public class GenTableServiceImpl implements IGenTableService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void importGenTable (List<GenTable> tableList) { public void importGenTable(List<GenTable> tableList) {
String operName = SecurityUtils.getUsername(); String operName = SecurityUtils.getUsername();
try { try {
for (GenTable table : tableList) { for (GenTable table : tableList) {
@ -195,11 +188,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param tableId * @param tableId
*
* @return * @return
*/ */
@Override @Override
public Map<String, String> previewCode (Long tableId) { public Map<String, String> previewCode(Long tableId) {
Map<String, String> dataMap = new LinkedHashMap<>(); Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId); GenTable table = genTableMapper.selectGenTableById(tableId);
@ -227,11 +219,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
@Override @Override
public byte[] downloadCode (String tableName) { public byte[] downloadCode(String tableName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip); generatorCode(tableName, zip);
@ -245,7 +236,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @param tableName * @param tableName
*/ */
@Override @Override
public void generatorCode (String tableName) { public void generatorCode(String tableName) {
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息 // 设置主子表信息
@ -282,7 +273,7 @@ public class GenTableServiceImpl implements IGenTableService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void synchDb (String tableName) { public void synchDb(String tableName) {
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> tableColumns = table.getColumns(); List<GenTableColumn> tableColumns = table.getColumns();
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
@ -326,11 +317,10 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* *
* @param tableNames * @param tableNames
*
* @return * @return
*/ */
@Override @Override
public byte[] downloadCode (String[] tableNames) { public byte[] downloadCode(String[] tableNames) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableName : tableNames) { for (String tableName : tableNames) {
@ -343,7 +333,7 @@ public class GenTableServiceImpl implements IGenTableService {
/** /**
* *
*/ */
private void generatorCode (String tableName, ZipOutputStream zip) { private void generatorCode(String tableName, ZipOutputStream zip) {
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息 // 设置主子表信息
@ -381,7 +371,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @param genTable * @param genTable
*/ */
@Override @Override
public void validateEdit (GenTable genTable) { public void validateEdit(GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
String options = JSON.toJSONString(genTable.getParams()); String options = JSON.toJSONString(genTable.getParams());
JSONObject paramsObj = JSON.parseObject(options); JSONObject paramsObj = JSON.parseObject(options);
@ -406,7 +396,7 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* @param table * @param table
*/ */
public void setPkColumn (GenTable table) { public void setPkColumn(GenTable table) {
for (GenTableColumn column : table.getColumns()) { for (GenTableColumn column : table.getColumns()) {
if (column.isPk()) { if (column.isPk()) {
table.setPkColumn(column); table.setPkColumn(column);
@ -434,7 +424,7 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* @param table * @param table
*/ */
public void setSubTable (GenTable table) { public void setSubTable(GenTable table) {
String subTableName = table.getSubTableName(); String subTableName = table.getSubTableName();
if (StringUtils.isNotEmpty(subTableName)) { if (StringUtils.isNotEmpty(subTableName)) {
table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
@ -446,7 +436,7 @@ public class GenTableServiceImpl implements IGenTableService {
* *
* @param genTable * @param genTable
*/ */
public void setTableFromOptions (GenTable genTable) { public void setTableFromOptions(GenTable genTable) {
JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj)) { if (StringUtils.isNotNull(paramsObj)) {
String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeCode = paramsObj.getString(GenConstants.TREE_CODE);

View File

@ -14,35 +14,31 @@ public interface IGenTableColumnService {
* *
* *
* @param tableId * @param tableId
*
* @return * @return
*/ */
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId); List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/** /**
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
int insertGenTableColumn (GenTableColumn genTableColumn); int insertGenTableColumn(GenTableColumn genTableColumn);
/** /**
* *
* *
* @param genTableColumn * @param genTableColumn
*
* @return * @return
*/ */
int updateGenTableColumn (GenTableColumn genTableColumn); int updateGenTableColumn(GenTableColumn genTableColumn);
/** /**
* *
* *
* @param ids ID * @param ids ID
*
* @return * @return
*/ */
int deleteGenTableColumnByIds (String ids); int deleteGenTableColumnByIds(String ids);
} }

View File

@ -15,117 +15,107 @@ public interface IGenTableService {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
List<GenTable> selectGenTableList (GenTable genTable); List<GenTable> selectGenTableList(GenTable genTable);
/** /**
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
List<GenTable> selectDbTableList (GenTable genTable); List<GenTable> selectDbTableList(GenTable genTable);
/** /**
* *
* *
* @param tableNames * @param tableNames
*
* @return * @return
*/ */
List<GenTable> selectDbTableListByNames (String[] tableNames); List<GenTable> selectDbTableListByNames(String[] tableNames);
/** /**
* *
* *
* @return * @return
*/ */
List<GenTable> selectGenTableAll (); List<GenTable> selectGenTableAll();
/** /**
* *
* *
* @param id ID * @param id ID
*
* @return * @return
*/ */
GenTable selectGenTableById (Long id); GenTable selectGenTableById(Long id);
/** /**
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
void updateGenTable (GenTable genTable); void updateGenTable(GenTable genTable);
/** /**
* *
* *
* @param tableIds ID * @param tableIds ID
*
* @return * @return
*/ */
void deleteGenTableByIds (Long[] tableIds); void deleteGenTableByIds(Long[] tableIds);
/** /**
* *
* *
* @param tableList * @param tableList
*/ */
void importGenTable (List<GenTable> tableList); void importGenTable(List<GenTable> tableList);
/** /**
* *
* *
* @param tableId * @param tableId
*
* @return * @return
*/ */
Map<String, String> previewCode (Long tableId); Map<String, String> previewCode(Long tableId);
/** /**
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
byte[] downloadCode (String tableName); byte[] downloadCode(String tableName);
/** /**
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
void generatorCode (String tableName); void generatorCode(String tableName);
/** /**
* *
* *
* @param tableName * @param tableName
*/ */
void synchDb (String tableName); void synchDb(String tableName);
/** /**
* *
* *
* @param tableNames * @param tableNames
*
* @return * @return
*/ */
byte[] downloadCode (String[] tableNames); byte[] downloadCode(String[] tableNames);
/** /**
* *
* *
* @param genTable * @param genTable
*/ */
void validateEdit (GenTable genTable); void validateEdit(GenTable genTable);
} }

View File

@ -18,7 +18,7 @@ public class GenUtils {
/** /**
* *
*/ */
public static void initTable (GenTable genTable, String operName) { public static void initTable(GenTable genTable, String operName) {
genTable.setClassName(convertClassName(genTable.getTableName())); genTable.setClassName(convertClassName(genTable.getTableName()));
genTable.setPackageName(GenConfig.getPackageName()); genTable.setPackageName(GenConfig.getPackageName());
genTable.setModuleName(getModuleName(GenConfig.getPackageName())); genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
@ -31,7 +31,7 @@ public class GenUtils {
/** /**
* *
*/ */
public static void initColumnField (GenTableColumn column, GenTable table) { public static void initColumnField(GenTableColumn column, GenTable table) {
String dataType = getDbType(column.getColumnType()); String dataType = getDbType(column.getColumnType());
String columnName = column.getColumnName(); String columnName = column.getColumnName();
column.setTableId(table.getTableId()); column.setTableId(table.getTableId());
@ -116,10 +116,9 @@ public class GenUtils {
* *
* @param arr * @param arr
* @param targetValue * @param targetValue
*
* @return * @return
*/ */
public static boolean arraysContains (String[] arr, String targetValue) { public static boolean arraysContains(String[] arr, String targetValue) {
return Arrays.asList(arr).contains(targetValue); return Arrays.asList(arr).contains(targetValue);
} }
@ -127,10 +126,9 @@ public class GenUtils {
* *
* *
* @param packageName * @param packageName
*
* @return * @return
*/ */
public static String getModuleName (String packageName) { public static String getModuleName(String packageName) {
int lastIndex = packageName.lastIndexOf("."); int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length(); int nameLength = packageName.length();
return StringUtils.substring(packageName, lastIndex + 1, nameLength); return StringUtils.substring(packageName, lastIndex + 1, nameLength);
@ -140,10 +138,9 @@ public class GenUtils {
* *
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
public static String getBusinessName (String tableName) { public static String getBusinessName(String tableName) {
int lastIndex = tableName.lastIndexOf("_"); int lastIndex = tableName.lastIndexOf("_");
int nameLength = tableName.length(); int nameLength = tableName.length();
return StringUtils.substring(tableName, lastIndex + 1, nameLength); return StringUtils.substring(tableName, lastIndex + 1, nameLength);
@ -153,10 +150,9 @@ public class GenUtils {
* Java * Java
* *
* @param tableName * @param tableName
*
* @return * @return
*/ */
public static String convertClassName (String tableName) { public static String convertClassName(String tableName) {
boolean autoRemovePre = GenConfig.getAutoRemovePre(); boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix(); String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
@ -171,10 +167,9 @@ public class GenUtils {
* *
* @param replacementm * @param replacementm
* @param searchList * @param searchList
*
* @return * @return
*/ */
public static String replaceFirst (String replacementm, String[] searchList) { public static String replaceFirst(String replacementm, String[] searchList) {
String text = replacementm; String text = replacementm;
for (String searchString : searchList) { for (String searchString : searchList) {
if (replacementm.startsWith(searchString)) { if (replacementm.startsWith(searchString)) {
@ -189,10 +184,9 @@ public class GenUtils {
* *
* *
* @param text * @param text
*
* @return * @return
*/ */
public static String replaceText (String text) { public static String replaceText(String text) {
return RegExUtils.replaceAll(text, "(?:表|若依)", ""); return RegExUtils.replaceAll(text, "(?:表|若依)", "");
} }
@ -200,10 +194,9 @@ public class GenUtils {
* *
* *
* @param columnType * @param columnType
*
* @return * @return
*/ */
public static String getDbType (String columnType) { public static String getDbType(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) { if (StringUtils.indexOf(columnType, "(") > 0) {
return StringUtils.substringBefore(columnType, "("); return StringUtils.substringBefore(columnType, "(");
} else { } else {
@ -215,10 +208,9 @@ public class GenUtils {
* *
* *
* @param columnType * @param columnType
*
* @return * @return
*/ */
public static Integer getColumnLength (String columnType) { public static Integer getColumnLength(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) { if (StringUtils.indexOf(columnType, "(") > 0) {
String length = StringUtils.substringBetween(columnType, "(", ")"); String length = StringUtils.substringBetween(columnType, "(", ")");
return Integer.valueOf(length); return Integer.valueOf(length);

View File

@ -14,7 +14,7 @@ public class VelocityInitializer {
/** /**
* vm * vm
*/ */
public static void initVelocity () { public static void initVelocity() {
Properties p = new Properties(); Properties p = new Properties();
try { try {
// 加载classpath目录下的vm文件 // 加载classpath目录下的vm文件

View File

@ -40,7 +40,7 @@ public class VelocityUtils {
* *
* @return * @return
*/ */
public static VelocityContext prepareContext (GenTable genTable) { public static VelocityContext prepareContext(GenTable genTable) {
String moduleName = genTable.getModuleName(); String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName(); String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName(); String packageName = genTable.getPackageName();
@ -76,14 +76,14 @@ public class VelocityUtils {
return velocityContext; return velocityContext;
} }
public static void setMenuVelocityContext (VelocityContext context, GenTable genTable) { public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options); JSONObject paramsObj = JSON.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj); String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId); context.put("parentMenuId", parentMenuId);
} }
public static void setTreeVelocityContext (VelocityContext context, GenTable genTable) { public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options); JSONObject paramsObj = JSON.parseObject(options);
String treeCode = getTreecode(paramsObj); String treeCode = getTreecode(paramsObj);
@ -102,7 +102,7 @@ public class VelocityUtils {
} }
} }
public static void setSubVelocityContext (VelocityContext context, GenTable genTable) { public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
GenTable subTable = genTable.getSubTable(); GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName(); String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName(); String subTableFkName = genTable.getSubTableFkName();
@ -124,7 +124,7 @@ public class VelocityUtils {
* *
* @return * @return
*/ */
public static List<String> getTemplateList (String tplCategory) { public static List<String> getTemplateList(String tplCategory) {
List<String> templates = new ArrayList<String>(); List<String> templates = new ArrayList<String>();
templates.add("vm/java/domain.java.vm"); templates.add("vm/java/domain.java.vm");
templates.add("vm/java/mapper.java.vm"); templates.add("vm/java/mapper.java.vm");
@ -148,7 +148,7 @@ public class VelocityUtils {
/** /**
* *
*/ */
public static String getFileName (String template, GenTable genTable) { public static String getFileName(String template, GenTable genTable) {
// 文件名称 // 文件名称
String fileName = ""; String fileName = "";
// 包路径 // 包路径
@ -195,10 +195,9 @@ public class VelocityUtils {
* *
* *
* @param packageName * @param packageName
*
* @return * @return
*/ */
public static String getPackagePrefix (String packageName) { public static String getPackagePrefix(String packageName) {
int lastIndex = packageName.lastIndexOf("."); int lastIndex = packageName.lastIndexOf(".");
return StringUtils.substring(packageName, 0, lastIndex); return StringUtils.substring(packageName, 0, lastIndex);
} }
@ -207,10 +206,9 @@ public class VelocityUtils {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
public static HashSet<String> getImportList (GenTable genTable) { public static HashSet<String> getImportList(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns(); List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable(); GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>(); HashSet<String> importList = new HashSet<String>();
@ -232,10 +230,9 @@ public class VelocityUtils {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
public static String getDicts (GenTable genTable) { public static String getDicts(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns(); List<GenTableColumn> columns = genTable.getColumns();
Set<String> dicts = new HashSet<String>(); Set<String> dicts = new HashSet<String>();
addDicts(dicts, columns); addDicts(dicts, columns);
@ -252,7 +249,7 @@ public class VelocityUtils {
* @param dicts * @param dicts
* @param columns * @param columns
*/ */
public static void addDicts (Set<String> dicts, List<GenTableColumn> columns) { public static void addDicts(Set<String> dicts, List<GenTableColumn> columns) {
for (GenTableColumn column : columns) { for (GenTableColumn column : columns) {
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
column.getHtmlType(), column.getHtmlType(),
@ -267,10 +264,9 @@ public class VelocityUtils {
* *
* @param moduleName * @param moduleName
* @param businessName * @param businessName
*
* @return * @return
*/ */
public static String getPermissionPrefix (String moduleName, String businessName) { public static String getPermissionPrefix(String moduleName, String businessName) {
return StringUtils.format("{}:{}", moduleName, businessName); return StringUtils.format("{}:{}", moduleName, businessName);
} }
@ -278,10 +274,9 @@ public class VelocityUtils {
* ID * ID
* *
* @param paramsObj * @param paramsObj
*
* @return ID * @return ID
*/ */
public static String getParentMenuId (JSONObject paramsObj) { public static String getParentMenuId(JSONObject paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
&& StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID))) { && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID))) {
return paramsObj.getString(GenConstants.PARENT_MENU_ID); return paramsObj.getString(GenConstants.PARENT_MENU_ID);
@ -293,10 +288,9 @@ public class VelocityUtils {
* *
* *
* @param paramsObj * @param paramsObj
*
* @return * @return
*/ */
public static String getTreecode (JSONObject paramsObj) { public static String getTreecode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_CODE)) { if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
} }
@ -307,10 +301,9 @@ public class VelocityUtils {
* *
* *
* @param paramsObj * @param paramsObj
*
* @return * @return
*/ */
public static String getTreeParentCode (JSONObject paramsObj) { public static String getTreeParentCode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) { if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
} }
@ -321,10 +314,9 @@ public class VelocityUtils {
* *
* *
* @param paramsObj * @param paramsObj
*
* @return * @return
*/ */
public static String getTreeName (JSONObject paramsObj) { public static String getTreeName(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_NAME)) { if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
} }
@ -335,10 +327,9 @@ public class VelocityUtils {
* *
* *
* @param genTable * @param genTable
*
* @return * @return
*/ */
public static int getExpandColumn (GenTable genTable) { public static int getExpandColumn(GenTable genTable) {
String options = genTable.getOptions(); String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options); JSONObject paramsObj = JSON.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME); String treeName = paramsObj.getString(GenConstants.TREE_NAME);

View File

@ -1,31 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false"> <configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-gen" /> <property name="log.path" value="logs/muyu-gen"/>
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 --> <!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
</appender> </appender>
<!-- 系统日志输出 --> <!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file> <file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 --> <!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory> <maxHistory>60</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 --> <!-- 过滤的级别 -->
<level>INFO</level> <level>INFO</level>
<!-- 匹配时的操作:接收(记录) --> <!-- 匹配时的操作:接收(记录) -->
@ -33,16 +33,16 @@
<!-- 不匹配时的操作:拒绝(不记录) --> <!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch> <onMismatch>DENY</onMismatch>
</filter> </filter>
</appender> </appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file> <file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 --> <!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory> <maxHistory>60</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
@ -50,25 +50,25 @@
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 --> <!-- 过滤的级别 -->
<level>ERROR</level> <level>ERROR</level>
<!-- 匹配时的操作:接收(记录) --> <!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch> <onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) --> <!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch> <onMismatch>DENY</onMismatch>
</filter> </filter>
</appender> </appender>
<!-- 系统模块日志级别控制 --> <!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info" /> <logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 --> <!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" /> <logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info"> <root level="info">
<appender-ref ref="file_info" /> <appender-ref ref="console"/>
<appender-ref ref="file_error" /> </root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root> </root>
</configuration> </configuration>

View File

@ -55,7 +55,8 @@
from gen_table_column from gen_table_column
</sql> </sql>
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn" resultMap="GenTableColumnResult"> <select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn"
resultMap="GenTableColumnResult">
<include refid="selectGenTableColumnVo"/> <include refid="selectGenTableColumnVo"/>
where table_id = #{tableId} where table_id = #{tableId}
order by sort order by sort
@ -64,10 +65,10 @@
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name, select column_name,
(case when (is_nullable = 'stream' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when (is_nullable = 'stream' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required,
(case when column_key = 'PRI' then '1' else '0' end) as is_pk, (case when column_key = 'PRI' then '1' else '0' end) as is_pk,
ordinal_position as sort, ordinal_position as sort,
column_comment, column_comment,
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
column_type column_type
from information_schema.columns from information_schema.columns
where table_schema = (select database()) where table_schema = (select database())
@ -75,7 +76,8 @@
order by ordinal_position order by ordinal_position
</select> </select>
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> <insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true"
keyProperty="columnId">
insert into gen_table_column ( insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if> <if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if> <if test="columnName != null and columnName != ''">column_name,</if>

View File

@ -249,7 +249,8 @@
order by c.sort order by c.sort
</select> </select>
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId"> <insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true"
keyProperty="tableId">
insert into gen_table ( insert into gen_table (
<if test="tableName != null">table_name,</if> <if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if> <if test="tableComment != null and tableComment != ''">table_comment,</if>

View File

@ -3,6 +3,7 @@ package ${packageName}.controller;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -33,30 +34,27 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/${businessName}") @RequestMapping("/${businessName}")
public class ${ClassName}Controller extends BaseController public class ${ClassName}Controller extends BaseController {
{
@Autowired @Autowired
private I${ClassName}Service ${className}Service; private I${ClassName}Service ${className}Service;
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
*/ */
@RequiresPermissions("${permissionPrefix}:list") @RequiresPermissions("${permissionPrefix}:list")
@GetMapping("/list") @GetMapping("/list")
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
public Result<TableDataInfo> list(${ClassName} ${className}) public Result<TableDataInfo> list(${ClassName} ${className}) {
{
startPage(); startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list); return getDataTable(list);
} }
#elseif($table.tree) #elseif($table.tree)
public Result list(${ClassName} ${className}) public Result list(${ClassName} ${className}) {
{ List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return success(list);
return success(list); }
} #end
#end
/** /**
* 导出${functionName}列表 * 导出${functionName}列表
@ -64,10 +62,9 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:export") @RequiresPermissions("${permissionPrefix}:export")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT) @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className}) public void export(HttpServletResponse response, ${ClassName} ${className}) {
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
util.exportExcel(response, list, "${functionName}数据"); util.exportExcel(response, list, "${functionName}数据");
} }
@ -76,8 +73,7 @@ public class ${ClassName}Controller extends BaseController
*/ */
@RequiresPermissions("${permissionPrefix}:query") @RequiresPermissions("${permissionPrefix}:query")
@GetMapping(value = "/{${pkColumn.javaField}}") @GetMapping(value = "/{${pkColumn.javaField}}")
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
{
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
} }
@ -87,8 +83,7 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:add") @RequiresPermissions("${permissionPrefix}:add")
@Log(title = "${functionName}", businessType = BusinessType.INSERT) @Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result add(@RequestBody ${ClassName} ${className}) public Result add(@RequestBody ${ClassName} ${className}) {
{
return toAjax(${className}Service.insert${ClassName}(${className})); return toAjax(${className}Service.insert${ClassName}(${className}));
} }
@ -98,8 +93,7 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:edit") @RequiresPermissions("${permissionPrefix}:edit")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE) @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result edit(@RequestBody ${ClassName} ${className}) public Result edit(@RequestBody ${ClassName} ${className}) {
{
return toAjax(${className}Service.update${ClassName}(${className})); return toAjax(${className}Service.update${ClassName}(${className}));
} }
@ -108,9 +102,8 @@ public class ${ClassName}Controller extends BaseController
*/ */
@RequiresPermissions("${permissionPrefix}:remove") @RequiresPermissions("${permissionPrefix}:remove")
@Log(title = "${functionName}", businessType = BusinessType.DELETE) @Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}") @DeleteMapping("/{${pkColumn.javaField}s}")
public Result remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) public Result remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
{
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
} }
} }

View File

@ -19,87 +19,87 @@ import com.muyu.common.core.web.domain.TreeEntity;
* @date ${datetime} * @date ${datetime}
*/ */
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
#set($Entity="BaseEntity") #set($Entity="BaseEntity")
#elseif($table.tree) #elseif($table.tree)
#set($Entity="TreeEntity") #set($Entity="TreeEntity")
#end #end
public class ${ClassName} extends ${Entity} public class ${ClassName} extends ${Entity}
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID=1L;
#foreach ($column in $columns) #foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField)) #if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */ /** $column.columnComment */
#if($column.list) #if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date') #elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else #else
@Excel(name = "${comment}") @Excel(name = "${comment}")
#end #end
#end #end
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end #end
#end #end
#if($table.sub) #if($table.sub)
/** $table.subTable.functionName信息 */ /** $table.subTable.functionName信息 */
private List<${subClassName}> ${subclassName}List; private List<${subClassName}> ${subclassName}List;
#end #end
#foreach ($column in $columns) #foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField)) #if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField) #set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end #end
public void set${AttrName}($column.javaType $column.javaField) public void set${AttrName}($column.javaType $column.javaField)
{ {
this.$column.javaField = $column.javaField; this.$column.javaField = $column.javaField;
} }
public $column.javaType get${AttrName}() public $column.javaType get${AttrName}()
{ {
return $column.javaField; return $column.javaField;
} }
#end #end
#end #end
#if($table.sub) #if($table.sub)
public List<${subClassName}> get${subClassName}List() public List<${subClassName}> get${subClassName}List()
{ {
return ${subclassName}List; return ${subclassName}List;
} }
public void set${subClassName}List(List<${subClassName}> ${subclassName}List) public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
{ {
this.${subclassName}List = ${subclassName}List; this.${subclassName}List= ${subclassName}List;
} }
#end #end
@Override @Override
public String toString() { public String toString(){
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField) #set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end #end
.append("${column.javaField}", get${AttrName}()) .append("${column.javaField}",get${AttrName}())
#end #end
#if($table.sub) #if($table.sub)
.append("${subclassName}List", get${subClassName}List()) .append("${subclassName}List",get${subClassName}List())
#end #end
.toString(); .toString();
} }
} }

View File

@ -1,6 +1,7 @@
package ${packageName}.mapper; package ${packageName}.mapper;
import java.util.List; import java.util.List;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
#if($table.sub) #if($table.sub)
import ${packageName}.domain.${subClassName}; import ${packageName}.domain.${subClassName};
@ -8,15 +9,14 @@ import ${packageName}.domain.${subClassName};
/** /**
* ${functionName}Mapper接口 * ${functionName}Mapper接口
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper public interface ${ClassName}Mapper {
{
/** /**
* 查询${functionName} * 查询${functionName}
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName} * @return ${functionName}
*/ */
@ -24,7 +24,7 @@ public interface ${ClassName}Mapper
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return ${functionName}集合 * @return ${functionName}集合
*/ */
@ -32,7 +32,7 @@ public interface ${ClassName}Mapper
/** /**
* 新增${functionName} * 新增${functionName}
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
@ -40,7 +40,7 @@ public interface ${ClassName}Mapper
/** /**
* 修改${functionName} * 修改${functionName}
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
@ -48,7 +48,7 @@ public interface ${ClassName}Mapper
/** /**
* 删除${functionName} * 删除${functionName}
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return 结果 * @return 结果
*/ */
@ -56,36 +56,36 @@ public interface ${ClassName}Mapper
/** /**
* 批量删除${functionName} * 批量删除${functionName}
* *
* @param ${pkColumn.javaField}s 需要删除的数据主键集合 * @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
#if($table.sub) #if($table.sub)
/** /**
* 批量删除${subTable.functionName} * 批量删除${subTable.functionName}
* *
* @param ${pkColumn.javaField}s 需要删除的数据主键集合 * @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 批量新增${subTable.functionName}
*
* @param ${subclassName}List ${subTable.functionName}列表
* @return 结果
*/
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
/** /**
* 通过${functionName}主键删除${subTable.functionName}信息 * 批量新增${subTable.functionName}
* *
* @param ${pkColumn.javaField} ${functionName}ID * @param ${subclassName}List ${subTable.functionName}列表
* @return 结果 * @return 结果
*/ */
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
#end
/**
* 通过${functionName}主键删除${subTable.functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
#end
} }

View File

@ -1,19 +1,19 @@
package ${packageName}.service; package ${packageName}.service;
import java.util.List; import java.util.List;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
/** /**
* ${functionName}Service接口 * ${functionName}Service接口
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
public interface I${ClassName}Service public interface I${ClassName}Service {
{
/** /**
* 查询${functionName} * 查询${functionName}
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName} * @return ${functionName}
*/ */
@ -21,7 +21,7 @@ public interface I${ClassName}Service
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return ${functionName}集合 * @return ${functionName}集合
*/ */
@ -29,7 +29,7 @@ public interface I${ClassName}Service
/** /**
* 新增${functionName} * 新增${functionName}
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
@ -37,7 +37,7 @@ public interface I${ClassName}Service
/** /**
* 修改${functionName} * 修改${functionName}
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
@ -45,7 +45,7 @@ public interface I${ClassName}Service
/** /**
* 批量删除${functionName} * 批量删除${functionName}
* *
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果 * @return 结果
*/ */
@ -53,7 +53,7 @@ public interface I${ClassName}Service
/** /**
* 删除${functionName}信息 * 删除${functionName}信息
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return 结果 * @return 结果
*/ */

View File

@ -1,20 +1,21 @@
package ${packageName}.service.impl; package ${packageName}.service.impl;
import java.util.List; import java.util.List;
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime') #if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.DateUtils;
#break #break
#end #end
#end #end
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
#if($table.sub) #if($table.sub)
import java.util.ArrayList; import java.util.ArrayList;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional; import com.muyu.common.core.utils.StringUtils;
import ${packageName}.domain.${subClassName}; import org.springframework.transaction.annotation.Transactional;
#end import ${packageName}.domain.${subClassName};
#end
import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
@ -26,8 +27,7 @@ import ${packageName}.service.I${ClassName}Service;
* @date ${datetime} * @date ${datetime}
*/ */
@Service @Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service public class ${ClassName}ServiceImpl implements I${ClassName}Service {
{
@Autowired @Autowired
private ${ClassName}Mapper ${className}Mapper; private ${ClassName}Mapper ${className}Mapper;
@ -38,8 +38,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @return ${functionName} * @return ${functionName}
*/ */
@Override @Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
{
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
} }
@ -50,8 +49,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @return ${functionName} * @return ${functionName}
*/ */
@Override @Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) {
{
return ${className}Mapper.select${ClassName}List(${className}); return ${className}Mapper.select${ClassName}List(${className});
} }
@ -61,24 +59,23 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
#if($table.sub) #if($table.sub)
@Transactional @Transactional
#end #end
@Override @Override
public int insert${ClassName}(${ClassName} ${className}) public int insert${ClassName}(${ClassName} ${className}) {
{ #foreach ($column in $columns)
#foreach ($column in $columns) #if($column.javaField == 'createTime')
#if($column.javaField == 'createTime') ${className}.setCreateTime(DateUtils.getNowDate());
${className}.setCreateTime(DateUtils.getNowDate()); #end
#end #end
#end #if($table.sub)
#if($table.sub) int rows = ${className}Mapper.insert${ClassName}(${className});
int rows = ${className}Mapper.insert${ClassName}(${className}); insert${subClassName}(${className});
insert${subClassName}(${className}); return rows;
return rows; #else
#else return ${className}Mapper.insert${ClassName}(${className});
return ${className}Mapper.insert${ClassName}(${className}); #end
#end
} }
/** /**
@ -87,21 +84,21 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
#if($table.sub) #if($table.sub)
@Transactional @Transactional
#end #end
@Override @Override
public int update${ClassName}(${ClassName} ${className}) public int update${ClassName}(${ClassName} ${className}) {
{ #foreach ($column in $columns)
#foreach ($column in $columns) #if($column.javaField == 'updateTime')
#if($column.javaField == 'updateTime') ${className}.setUpdateTime(DateUtils.getNowDate());
${className}.setUpdateTime(DateUtils.getNowDate()); #end
#end #end
#end #if($table.sub)
#if($table.sub) ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}())
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); ;
insert${subClassName}(${className}); insert${subClassName}(${className});
#end #end
return ${className}Mapper.update${ClassName}(${className}); return ${className}Mapper.update${ClassName}(${className});
} }
@ -111,15 +108,14 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键 * @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果 * @return 结果
*/ */
#if($table.sub) #if($table.sub)
@Transactional @Transactional
#end #end
@Override @Override
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
{ #if($table.sub)
#if($table.sub) ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); #end
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
} }
@ -129,41 +125,37 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return 结果 * @return 结果
*/ */
#if($table.sub) #if($table.sub)
@Transactional @Transactional
#end #end
@Override @Override
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
{ #if($table.sub)
#if($table.sub) ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); #end
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
} }
#if($table.sub) #if($table.sub)
/** /**
* 新增${subTable.functionName}信息 * 新增${subTable.functionName}信息
* *
* @param ${className} ${functionName}对象 * @param ${className} ${functionName}对象
*/ */
public void insert${subClassName}(${ClassName} ${className}) public void insert${subClassName}(${ClassName} ${className}) {
{ List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); if (StringUtils.isNotNull(${subclassName}List)) {
if (StringUtils.isNotNull(${subclassName}List)) List<${subClassName}> list = new ArrayList<${subClassName}>();
{ for (${subClassName} ${subclassName} :${subclassName}List)
List<${subClassName}> list = new ArrayList<${subClassName}>(); {
for (${subClassName} ${subclassName} : ${subclassName}List) ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
{ list.add(${subclassName});
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); }
list.add(${subclassName}); if (list.size() > 0) {
} ${className}Mapper.batch${subClassName}(list);
if (list.size() > 0) }
{
${className}Mapper.batch${subClassName}(list);
} }
} }
} #end
#end
} }

View File

@ -1,8 +1,8 @@
package ${packageName}.domain; package ${packageName}.domain;
#foreach ($import in $subImportList) #foreach ($import in $subImportList)
import ${import}; import ${import};
#end #end
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
@ -20,62 +20,62 @@ import com.muyu.common.core.web.domain.BaseEntity;
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class ${subClassName} extends BaseEntity public class ${subClassName} extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID=1L;
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField)) #if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */ /** $column.columnComment */
#if($column.list) #if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date') #elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else #else
@Excel(name = "${comment}") @Excel(name = "${comment}")
#end #end
#end #end
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end #end
#end #end
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField)) #if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField) #set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end #end
public void set${AttrName}($column.javaType $column.javaField) public void set${AttrName}($column.javaType $column.javaField)
{ {
this.$column.javaField = $column.javaField; this.$column.javaField = $column.javaField;
} }
public $column.javaType get${AttrName}() public $column.javaType get${AttrName}()
{ {
return $column.javaField; return $column.javaField;
} }
#end #end
#end #end
@Override @Override
public String toString() { public String toString(){
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField) #set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end #end
.append("${column.javaField}", get${AttrName}()) .append("${column.javaField}",get${AttrName}())
#end #end
.toString(); .toString();
} }
} }

View File

@ -2,43 +2,43 @@ import request from '@/utils/request'
// 查询${functionName}列表 // 查询${functionName}列表
export function list${BusinessName}(query) { export function list${BusinessName}(query) {
return request({ return request({
url: '/${moduleName}/${businessName}/list', url: '/${moduleName}/${businessName}/list',
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 查询${functionName}详细 // 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) { export function get${BusinessName}(${pkColumn.javaField}) {
return request({ return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'get' method: 'get'
}) })
} }
// 新增${functionName} // 新增${functionName}
export function add${BusinessName}(data) { export function add${BusinessName}(data) {
return request({ return request({
url: '/${moduleName}/${businessName}', url: '/${moduleName}/${businessName}',
method: 'post', method: 'post',
data: data data: data
}) })
} }
// 修改${functionName} // 修改${functionName}
export function update${BusinessName}(data) { export function update${BusinessName}(data) {
return request({ return request({
url: '/${moduleName}/${businessName}', url: '/${moduleName}/${businessName}',
method: 'put', method: 'put',
data: data data: data
}) })
} }
// 删除${functionName} // 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) { export function del${BusinessName}(${pkColumn.javaField}) {
return request({ return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete' method: 'delete'
}) })
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($column.htmlType == "input") #if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-input <el-input
v-model="queryParams.${column.javaField}" v-model="queryParams.${column.javaField}"
placeholder="请输入${comment}" placeholder="请输入${comment}"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value=""/>
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-date-picker clearable <el-date-picker clearable
v-model="queryParams.${column.javaField}" v-model="queryParams.${column.javaField}"
type="date" type="date"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
placeholder="选择${comment}"> placeholder="选择${comment}">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
<el-form-item label="${comment}" style="width: 308px"> <el-form-item label="${comment}" style="width: 308px">
<el-date-picker <el-date-picker
v-model="daterange${AttrName}" v-model="daterange${AttrName}"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
type="daterange" type="daterange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
#end #end
#end #end
#end #end
<el-form-item> <el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button>
@ -69,76 +69,85 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
plain plain
icon="Plus" icon="Plus"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['${moduleName}:${businessName}:add']" v-hasPermi="['${moduleName}:${businessName}:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="info" type="info"
plain plain
icon="Sort" icon="Sort"
@click="toggleExpandAll" @click="toggleExpandAll"
>展开/折叠</el-button> >展开/折叠
</el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table <el-table
v-if="refreshTable" v-if="refreshTable"
v-loading="loading" v-loading="loading"
:data="${businessName}List" :data="${businessName}List"
row-key="${treeCode}" row-key="${treeCode}"
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
#foreach($column in $columns) #foreach($column in $columns)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($column.pk) #if($column.pk)
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template #default="scope"> <template #default="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload") #elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<template #default="scope"> <template #default="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}"> <el-table-column label="${comment}" align="center" prop="${javaField}">
<template #default="scope"> <template #default="scope">
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> <dict-tag :options="${column.dictType}"
#else :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> #else
#end <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
</template> #end
</el-table-column> </template>
#elseif($column.list && "" != $javaField) </el-table-column>
#if(${foreach.index} == 1) #elseif($column.list && "" != $javaField)
<el-table-column label="${comment}" prop="${javaField}" /> #if(${foreach.index} == 1)
#else <el-table-column label="${comment}" prop="${javaField}"/>
<el-table-column label="${comment}" align="center" prop="${javaField}" /> #else
#end <el-table-column label="${comment}" align="center" prop="${javaField}"/>
#end #end
#end #end
#end
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button> v-hasPermi="['${moduleName}:${businessName}:edit']">修改
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button> </el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:add']">新增
</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:remove']">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -146,119 +155,120 @@
<!-- 添加或修改${functionName}对话框 --> <!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body> <el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#if($column.insert && !$column.pk) #if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn)) #if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode) #if("" != $treeParentCode && $column.javaField == $treeParentCode)
<el-form-item label="${comment}" prop="${treeParentCode}"> <el-form-item label="${comment}" prop="${treeParentCode}">
<el-tree-select <el-tree-select
v-model="form.${treeParentCode}" v-model="form.${treeParentCode}"
:data="${businessName}Options" :data="${businessName}Options"
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" :props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
value-key="${treeCode}" value-key="${treeCode}"
placeholder="请选择${comment}" placeholder="请选择${comment}"
check-strictly check-strictly
/> />
</el-form-item> </el-form-item>
#elseif($column.htmlType == "input") #elseif($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" /> <el-input v-model="form.${field}" placeholder="请输入${comment}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "imageUpload") #elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<image-upload v-model="form.${field}"/> <image-upload v-model="form.${field}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "fileUpload") #elseif($column.htmlType == "fileUpload")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<file-upload v-model="form.${field}"/> <file-upload v-model="form.${field}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "editor") #elseif($column.htmlType == "editor")
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<editor v-model="form.${field}" :min-height="192"/> <editor v-model="form.${field}" :min-height="192"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType) #elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"> <el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
#if($column.javaType == "Integer" || $column.javaType == "Long") #if($column.javaType == "Integer" || $column.javaType == "Long")
:value="parseInt(dict.value)" :value="parseInt(dict.value)"
#else #else
:value="dict.value" :value="dict.value"
#end #end
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "select" && $dictType) #elseif($column.htmlType == "select" && $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"> <el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value=""/>
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "checkbox" && "" != $dictType) #elseif($column.htmlType == "checkbox" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}"> <el-checkbox-group v-model="form.${field}">
<el-checkbox <el-checkbox
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
:label="dict.value"> :label="dict.value">
{{dict.label}} {{dict.label}}
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "checkbox" && $dictType) #elseif($column.htmlType == "checkbox" && $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}"> <el-checkbox-group v-model="form.${field}">
<el-checkbox>请选择字典生成</el-checkbox> <el-checkbox>请选择字典生成</el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType) #elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-radio-group v-model="form.${field}"> <el-radio-group v-model="form.${field}">
<el-radio <el-radio
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
#if($column.javaType == "Integer" || $column.javaType == "Long") #if($column.javaType == "Integer" || $column.javaType == "Long")
:label="parseInt(dict.value)" :label="parseInt(dict.value)"
#else #else
:label="dict.value" :label="dict.value"
#end #end
>{{dict.label}}</el-radio> >{{dict.label}}
</el-radio-group> </el-radio>
</el-form-item> </el-radio-group>
#elseif($column.htmlType == "radio" && $dictType) </el-form-item>
<el-form-item label="${comment}" prop="${field}"> #elseif($column.htmlType == "radio" && $dictType)
<el-radio-group v-model="form.${field}"> <el-form-item label="${comment}" prop="${field}">
<el-radio label="1">请选择字典生成</el-radio> <el-radio-group v-model="form.${field}">
</el-radio-group> <el-radio label="1">请选择字典生成</el-radio>
</el-form-item> </el-radio-group>
#elseif($column.htmlType == "datetime") </el-form-item>
<el-form-item label="${comment}" prop="${field}"> #elseif($column.htmlType == "datetime")
<el-date-picker clearable <el-form-item label="${comment}" prop="${field}">
v-model="form.${field}" <el-date-picker clearable
type="date" v-model="form.${field}"
value-format="YYYY-MM-DD" type="date"
placeholder="选择${comment}"> value-format="YYYY-MM-DD"
</el-date-picker> placeholder="选择${comment}">
</el-form-item> </el-date-picker>
#elseif($column.htmlType == "textarea") </el-form-item>
<el-form-item label="${comment}" prop="${field}"> #elseif($column.htmlType == "textarea")
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" /> <el-form-item label="${comment}" prop="${field}">
</el-form-item> <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容"/>
#end </el-form-item>
#end #end
#end #end
#end #end
#end
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -271,204 +281,262 @@
</template> </template>
<script setup name="${BusinessName}"> <script setup name="${BusinessName}">
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; import {get${BusinessName}, list${BusinessName}} from "@/api/";
const { proxy } = getCurrentInstance(); const {proxy} = getCurrentInstance();
#if(${dicts} != '') #if(${dicts} != '')
#set($dictsNoSymbol=$dicts.replace("'", "")) #set($dictsNoSymbol=$dicts.replace("'", ""))
const { ${dictsNoSymbol} } = proxy.useDict(${dicts}); const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
#end #end
const ${businessName}List = ref([]); const ${businessName}List = ref([]);
const ${businessName}Options = ref([]); const ${businessName}Options = ref([]);
const open = ref(false); const open = ref(false);
const loading = ref(true); const loading = ref(true);
const showSearch = ref(true); const showSearch = ref(true);
const title = ref(""); const title = ref("");
const isExpandAll = ref(true); const isExpandAll = ref(true);
const refreshTable = ref(true); const refreshTable = ref(true);
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const daterange${AttrName} = ref([]); const daterange${AttrName} = ref([]);
#end #end
#end #end
const data = reactive({ const data = reactive({
form: {}, form: {},
queryParams: { queryParams: {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.query) #if($column.query)
$column.javaField: null#if($foreach.count != $columns.size()),#end $column.javaField: null#if($foreach.count != $columns.size()),#end
#end #end
#end #end
}, },
rules: { rules: {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.required) #if($column.required)
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
$column.javaField: [ $column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } {
]#if($foreach.count != $columns.size()),#end required: true, message: "$comment不能为空", trigger: #if($column.htmlType ==
#end "select" || $column.htmlType == "radio")"change"#else"blur"#end }
#end ]#if($foreach.count != $columns.size()),#end
} #end
}); #end
const { queryParams, form, rules } = toRefs(data);
/** 查询${functionName}列表 */
function getList() {
loading.value = true;
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
queryParams.value.params = {};
#break
#end
#end
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
}
#end
#end
list${BusinessName}(queryParams.value).then(response => {
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
loading.value = false;
});
}
/** 查询${functionName}下拉树结构 */
function getTreeselect() {
list${BusinessName}().then(response => {
${businessName}Options.value = [];
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
${businessName}Options.value.push(data);
});
}
// 取消按钮
function cancel() {
open.value = false;
reset();
}
// 表单重置
function reset() {
form.value = {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
};
proxy.resetForm("${businessName}Ref");
}
/** 搜索按钮操作 */
function handleQuery() {
getList();
}
/** 重置按钮操作 */
function resetQuery() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
daterange${AttrName}.value = [];
#end
#end
proxy.resetForm("queryRef");
handleQuery();
}
/** 新增按钮操作 */
function handleAdd(row) {
reset();
getTreeselect();
if (row != null && row.${treeCode}) {
form.value.${treeParentCode} = row.${treeCode};
} else {
form.value.${treeParentCode} = 0;
}
open.value = true;
title.value = "添加${functionName}";
}
/** 展开/折叠操作 */
function toggleExpandAll() {
refreshTable.value = false;
isExpandAll.value = !isExpandAll.value;
nextTick(() => {
refreshTable.value = true;
});
}
/** 修改按钮操作 */
async function handleUpdate(row) {
reset();
await getTreeselect();
if (row != null) {
form.value.${treeParentCode} = row.${treeCode};
}
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
form.value = response.data;
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(",");
#end
#end
open.value = true;
title.value = "修改${functionName}";
});
}
/** 提交按钮 */
function submitForm() {
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
if (valid) {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.join(",");
#end
#end
if (form.value.${pkColumn.javaField} != null) {
update${BusinessName}(form.value).then(response => {
proxy.#[[$modal]]#.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
add${BusinessName}(form.value).then(response => {
proxy.#[[$modal]]#.msgSuccess("新增成功");
open.value = false;
getList();
});
}
} }
}); });
}
/** 删除按钮操作 */ const {queryParams, form, rules} = toRefs(data);
function handleDelete(row) {
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() { /** 查询${functionName}列表 */
return del${BusinessName}(row.${pkColumn.javaField}); function getList() {
}).then(() => { loading.value = true;
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
queryParams.value.params = {};
#break
#end
#end
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
}
#end
#end
list${BusinessName}(queryParams.value).then(response => {
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
loading.value = false;
});
}
/** 查询${functionName}下拉树结构 */
function getTreeselect() {
list${BusinessName}().then(response => {
${businessName}Options.value = [];
const data = {${treeCode}: 0, ${treeName}: '顶级节点', children: []};
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
${businessName}Options.value.push(data);
});
}
// 取消按钮
function cancel() {
open.value = false;
reset();
}
// 表单重置
function reset() {
form.value = {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
};
proxy.resetForm("${businessName}Ref");
}
/** 搜索按钮操作 */
function handleQuery() {
getList(); getList();
proxy.#[[$modal]]#.msgSuccess("删除成功"); }
}).catch(() => {});
}
getList(); /** 重置按钮操作 */
function resetQuery() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
daterange${AttrName}.value = [];
#end
#end
proxy.resetForm("queryRef");
handleQuery();
}
/** 新增按钮操作 */
function handleAdd(row) {
reset();
getTreeselect();
if (row != null && row.${treeCode}) {
form.value.${treeParentCode} = row.${treeCode};
} else {
form.value.${treeParentCode} = 0;
}
open.value = true;
title.value = "添加${functionName}";
}
/** 展开/折叠操作 */
function toggleExpandAll() {
refreshTable.value = false;
isExpandAll.value = !isExpandAll.value;
nextTick(() => {
refreshTable.value = true;
});
}
/** 修改按钮操作 */
async function handleUpdate(row) {
reset();
await getTreeselect();
if (row != null) {
form.value.${treeParentCode} = row.${treeCode};
}
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
form.value = response.data;
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(",");
#end
#end
open.value = true;
title.value = "修改${functionName}";
});
}
/** 提交按钮 */
function submitForm() {
proxy.
#
[[$]]
#refs["${businessName}Ref"].validate(valid => {
if (valid) {
#foreach($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.$
{
column.javaField
}
.
join(",");
#end
#end
if (form.value.${
pkColumn.javaField
}
!=
null
)
{
update$
{
BusinessName
}
(form.value).then(response => {
proxy.
#
[[$modal]]
#.
msgSuccess("修改成功");
open.value = false;
getList();
});
}
else
{
add$
{
BusinessName
}
(form.value).then(response => {
proxy.
#
[[$modal]]
#.
msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
proxy.
#
[[$modal]]
#.
confirm('是否确认删除${functionName}编号为"' + row.$
{
pkColumn.javaField
}
+'"的数据项?'
).
then(function () {
return del$
{
BusinessName
}
(row.$
{
pkColumn.javaField
}
)
;
}).then(() => {
getList();
proxy.
#
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
}
getList();
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +1,168 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper"> <mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result"> <resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns) #foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" /> <result property="${column.javaField}" column="${column.columnName}"/>
#end #end
</resultMap> </resultMap>
#if($table.sub) #if($table.sub)
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result"> <resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" /> <collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}"
</resultMap> javaType="java.util.List" resultMap="${subClassName}Result"/>
</resultMap>
<resultMap type="${subClassName}" id="${subClassName}Result"> <resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" /> <result property="${column.javaField}" column="sub_${column.columnName}"/>
#end #end
</resultMap> </resultMap>
#end #end
<sql id="select${ClassName}Vo"> <sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName} select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end
from ${tableName}
</sql> </sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result"> <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/> <include refid="select${ClassName}Vo"/>
<where> <where>
#foreach($column in $columns) #foreach($column in $columns)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($javaType=$column.javaType) #set($javaType=$column.javaType)
#set($columnName=$column.columnName) #set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query) #if($column.query)
#if($column.queryType == "EQ") #if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
#elseif($queryType == "NE") and $columnName = #{$javaField}
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if> </if>
#elseif($queryType == "GT") #elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
#elseif($queryType == "GTE") and $columnName != #{$javaField}
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if> </if>
#elseif($queryType == "LT") #elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
#elseif($queryType == "LTE") and $columnName &gt; #{$javaField}
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if> </if>
#elseif($queryType == "LIKE") #elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if> <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
#elseif($queryType == "BETWEEN") and $columnName &gt;= #{$javaField}
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if> </if>
#end #elseif($queryType == "LT")
#end <if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
#end and $columnName &lt; #{$javaField}
</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName &lt;= #{$javaField}
</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName like concat('%', #{$javaField}, '%')
</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''">
and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}
</if>
#end
#end
#end
</where> </where>
</select> </select>
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud || $table.tree)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
from ${tableName} a <select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}"
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName} resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
where a.${pkColumn.columnName} = #{${pkColumn.javaField}} #if($table.crud || $table.tree)
#end <include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName as
sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
from ${tableName} a
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
</select> </select>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end> <insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true"
keyProperty="$pkColumn.javaField"#end>
insert into ${tableName} insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if> <if test="$column.javaField != null#if($column.javaType ==
#end 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,
#end </if>
</trim> #end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if> <if test="$column.javaField != null#if($column.javaType ==
#end 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},
#end </if>
</trim> #end
#end
</trim>
</insert> </insert>
<update id="update${ClassName}" parameterType="${ClassName}"> <update id="update${ClassName}" parameterType="${ClassName}">
update ${tableName} update ${tableName}
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName) #if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if> <if test="$column.javaField != null#if($column.javaType ==
#end 'String' && $column.required) and $column.javaField != ''#end">$column.columnName =
#end #{$column.javaField},
</if>
#end
#end
</trim> </trim>
where ${pkColumn.columnName} = #{${pkColumn.javaField}} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update> </update>
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}"> <delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}} delete
from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</delete> </delete>
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String"> <delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
delete from ${tableName} where ${pkColumn.columnName} in delete from ${tableName} where ${pkColumn.columnName} in
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")"> <foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
#{${pkColumn.javaField}} #{${pkColumn.javaField}}
</foreach> </foreach>
</delete> </delete>
#if($table.sub) #if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
delete from ${subTableName} where ${subTableFkName} in
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
#{${subTableFkclassName}}
</foreach>
</delete>
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}"> <delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}} delete from ${subTableName} where ${subTableFkName} in
</delete> <foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
#{${subTableFkclassName}}
</foreach>
</delete>
<insert id="batch${subClassName}"> <delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values delete
<foreach item="item" index="index" collection="list" separator=","> from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end) </delete>
</foreach>
</insert> <insert id="batch${subClassName}">
#end insert into ${subTableName}
</mapper> (#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size())
,#end#end) values
<foreach item="item" index="index" collection="list" separator=",">
(#foreach($column in $subTable.columns) #{item.$column.javaField
}#if($foreach.count != $subTable.columns.size()),#end#end)
</foreach>
</insert>
#end
</mapper>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -17,4 +17,18 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-common</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-remote</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project> </project>

View File

@ -1,4 +1,4 @@
package com.muyu.edition.test.clinet.cllent.config; package com.muyu.efition.clinet.config;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;

View File

@ -0,0 +1,24 @@
package com.muyu.efition.clinet.config;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.edition.domain.RuleEngine;
import com.muyu.goods.edition.remote.RemoteDataManagerService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
@Log4j2
public class AccessConfigRunner implements ApplicationRunner {
@Autowired
private RemoteDataManagerService remoteDataManagerService;
@Override
public void run(ApplicationArguments args) throws Exception {
Result<TableDataInfo<RuleEngine>> list = remoteDataManagerService.list(null);
log.info("远程调用成功,效果为:{}", list);
}
}

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -2,6 +2,7 @@ package com.muyu.edition.constant;
/** /**
* *
*
* @ClassName ConfigCodeConstants * @ClassName ConfigCodeConstants
* @Author * @Author
* @Date 2024/5/4 15:28 * @Date 2024/5/4 15:28
@ -11,14 +12,14 @@ public class ConfigCodeConstants {
* *
*/ */
// public final static String BASE_FILE_PATH="D:/workspace/gtl-ruoyi-server/ruoyi-modules/ruoyi-rule_engine/ruoyi-rule_engine-server/src/main/java/com/ruoyi/ruleEngine/scope/"; // public final static String BASE_FILE_PATH="D:/workspace/gtl-ruoyi-server/ruoyi-modules/ruoyi-rule_engine/ruoyi-rule_engine-server/src/main/java/com/ruoyi/ruleEngine/scope/";
public final static String BASE_FILE_PATH="D:\\woster\\gs1\\gf\\assets-ser\\muyu-modules\\muyu-goods-edition\\muyu-goods-edition-server\\src\\main\\java\\com\\muyu\\edition\\scope\\"; public final static String BASE_FILE_PATH = "D:\\woster\\gs1\\gf\\assets-ser\\muyu-modules\\muyu-goods-edition\\muyu-goods-edition-server\\src\\main\\java\\com\\muyu\\edition\\scope\\";
/** /**
* *
*/ */
public final static String[] CONFIG_FILE_NAME_ARRAY=new String[]{"TestClass.txt","TaskContextHolder.java","DataSetContextHolder.java","RecordContextHolder.java","DataModelContextHolder.java"}; public final static String[] CONFIG_FILE_NAME_ARRAY = new String[]{"TestClass.txt", "TaskContextHolder.java", "DataSetContextHolder.java", "RecordContextHolder.java", "DataModelContextHolder.java"};
public final static String[] CONFIG_FILE_NAME_CODE=new String[]{"ToCode.txt","TaskContextHolder.java","DataSetContextHolder.java","RecordContextHolder.java","DataModelContextHolder.java"}; public final static String[] CONFIG_FILE_NAME_CODE = new String[]{"ToCode.txt", "TaskContextHolder.java", "DataSetContextHolder.java", "RecordContextHolder.java", "DataModelContextHolder.java"};
/** /**
* *
*/ */
public final static String[] CONFIG_FILE_TYPE_ARRAY=new String[]{"测试模版","任务","数据集","资产记录","资产模型"}; public final static String[] CONFIG_FILE_TYPE_ARRAY = new String[]{"测试模版", "任务", "数据集", "资产记录", "资产模型"};
} }

View File

@ -2,6 +2,7 @@ package com.muyu.edition.constant;
/** /**
* *
*
* @ClassName RuleOperationConstants * @ClassName RuleOperationConstants
* @Author * @Author
* @Date 2024/5/4 16:12 * @Date 2024/5/4 16:12
@ -10,13 +11,13 @@ public class RuleOperationConstants {
/** /**
* *
*/ */
public final static String CLASS_NAME="TestClass"; public final static String CLASS_NAME = "TestClass";
/** /**
* *
*/ */
public final static String FILE_SUFFIX=".java"; public final static String FILE_SUFFIX = ".java";
/** /**
* *
*/ */
public final static String METHOD_NAME="ruleTest"; public final static String METHOD_NAME = "ruleTest";
} }

View File

@ -24,9 +24,9 @@ import lombok.experimental.SuperBuilder;
public class Anduser extends BaseEntity { public class Anduser extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
@TableId(value = "id",type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键") @ApiModelProperty(name = "主键", value = "主键")
private Long id; private Long id;
/** /**
@ -51,17 +51,18 @@ public class Anduser extends BaseEntity {
/** /**
* *
*/ */
public static Anduser query(AnduserQueryResp anduserQueryResp){ public static Anduser query(AnduserQueryResp anduserQueryResp) {
return Anduser.builder() return Anduser.builder()
.name(anduserQueryResp.getName()) .name(anduserQueryResp.getName())
.sex(anduserQueryResp.getSex()) .sex(anduserQueryResp.getSex())
.age(anduserQueryResp.getAge()) .age(anduserQueryResp.getAge())
.build(); .build();
} }
/** /**
* *
*/ */
public static Anduser index(AnduserIndexResp anduserIndexResp){ public static Anduser index(AnduserIndexResp anduserIndexResp) {
return Anduser.builder() return Anduser.builder()
.name(anduserIndexResp.getName()) .name(anduserIndexResp.getName())
.sex(anduserIndexResp.getSex()) .sex(anduserIndexResp.getSex())

View File

@ -11,55 +11,60 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author muyu * @author muyu
* @date 2024-05-04 * @date 2024-05-04
*/ */
public class Config extends BaseEntity public class Config extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 编号 */ /**
*
*/
private Long id; private Long id;
/** 版本编码 */ /**
*
*/
@Excel(name = "版本编码") @Excel(name = "版本编码")
private String versionCode; private String versionCode;
/** 规则内容 */ /**
*
*/
@Excel(name = "规则内容") @Excel(name = "规则内容")
private String ruleContent; private String ruleContent;
/** 注释 */ /**
*
*/
@Excel(name = "注释") @Excel(name = "注释")
private String remark; private String remark;
/** 维护编号 */ /**
*
*/
@Excel(name = "维护编号") @Excel(name = "维护编号")
private Long ruleId; private Long ruleId;
public void setId(Long id) public Long getId() {
{ return id;
}
public void setId(Long id) {
this.id = id; this.id = id;
} }
public Long getId() public String getVersionCode() {
{ return versionCode;
return id;
} }
public void setVersionCode(String versionCode)
{ public void setVersionCode(String versionCode) {
this.versionCode = versionCode; this.versionCode = versionCode;
} }
public String getVersionCode() public String getRuleContent() {
{ return ruleContent;
return versionCode;
}
public void setRuleContent(String ruleContent)
{
this.ruleContent = ruleContent;
} }
public String getRuleContent() public void setRuleContent(String ruleContent) {
{ this.ruleContent = ruleContent;
return ruleContent;
} }
@Override @Override
@ -72,24 +77,22 @@ public class Config extends BaseEntity
this.remark = remark; this.remark = remark;
} }
public void setRuleId(Long ruleId) public Long getRuleId() {
{ return ruleId;
this.ruleId = ruleId;
} }
public Long getRuleId() public void setRuleId(Long ruleId) {
{ this.ruleId = ruleId;
return ruleId;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("versionCode", getVersionCode()) .append("versionCode", getVersionCode())
.append("ruleContent", getRuleContent()) .append("ruleContent", getRuleContent())
.append("remark", getRemark()) .append("remark", getRemark())
.append("ruleId", getRuleId()) .append("ruleId", getRuleId())
.toString(); .toString();
} }
} }

View File

@ -13,11 +13,11 @@ public class Cope extends BaseEntity {
*/ */
private String type; private String type;
/** /**
* *
*/ */
private String val; private String val;
/** /**
* *
*/ */
private String code; private String code;

View File

@ -11,41 +11,56 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author muyu * @author muyu
* @date 2024-05-06 * @date 2024-05-06
*/ */
public class Edition extends BaseEntity public class Edition extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键 */ /**
*
*/
private Long id; private Long id;
/** 规则序号 */ /**
*
*/
@Excel(name = "规则序号") @Excel(name = "规则序号")
private Long ruleId; private Long ruleId;
/** 版本类 */ /**
*
*/
@Excel(name = "版本类") @Excel(name = "版本类")
private String versionClass; private String versionClass;
/** 版本名称 */ /**
*
*/
@Excel(name = "版本名称") @Excel(name = "版本名称")
private String name; private String name;
/** 版本编码 */ /**
*
*/
@Excel(name = "版本编码") @Excel(name = "版本编码")
private String versionCode; private String versionCode;
/** 版本状态 */ /**
*
*/
@Excel(name = "是否发布") @Excel(name = "是否发布")
private Integer editionStatus; private Integer editionStatus;
/** 引擎状态 */ /**
*
*/
@Excel(name = "是否激活") @Excel(name = "是否激活")
private String ruleStatus; private String ruleStatus;
@Excel(name = "是否测试") @Excel(name = "是否测试")
private Integer ruleIsTest; private Integer ruleIsTest;
/** 内容 */ /**
*
*/
@Excel(name = "内容描述") @Excel(name = "内容描述")
private String editionContent; private String editionContent;
@ -134,17 +149,17 @@ public class Edition extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("ruleId", getRuleId()) .append("ruleId", getRuleId())
.append("versionClass", getVersionClass()) .append("versionClass", getVersionClass())
.append("name", getName()) .append("name", getName())
.append("versionCode", getVersionCode()) .append("versionCode", getVersionCode())
.append("editionStatus", getEditionStatus()) .append("editionStatus", getEditionStatus())
.append("ruleStatus", getRuleStatus()) .append("ruleStatus", getRuleStatus())
.append("ruleIsTest",getRuleIsTest()) .append("ruleIsTest", getRuleIsTest())
.append("ruleContent",getRuleContent()) .append("ruleContent", getRuleContent())
.append("editionContent", getEditionContent()) .append("editionContent", getEditionContent())
.toString(); .toString();
} }
} }

View File

@ -11,117 +11,123 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author goods * @author goods
* @date 2024-05-02 * @date 2024-05-02
*/ */
public class RuleEngine extends BaseEntity public class RuleEngine extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键 */ /**
*
*/
private Long ruleId; private Long ruleId;
/** 规则名称 */ /**
*
*/
@Excel(name = "规则名称") @Excel(name = "规则名称")
private String ruleName; private String ruleName;
/** 引擎编码 */ /**
*
*/
@Excel(name = "引擎编码") @Excel(name = "引擎编码")
private String ruleCode; private String ruleCode;
/** 规则级别 */ /**
*
*/
@Excel(name = "规则级别") @Excel(name = "规则级别")
private Integer ruleLevel; private Integer ruleLevel;
/** 规则类型 */ /**
*
*/
@Excel(name = "规则类型") @Excel(name = "规则类型")
private Integer ruleType; private Integer ruleType;
/** 是否激活 */ /**
*
*/
@Excel(name = "是否激活") @Excel(name = "是否激活")
private String ruleIsActivate; private String ruleIsActivate;
/** 规则状态 */ /**
*
*/
@Excel(name = "规则状态") @Excel(name = "规则状态")
private String ruleStatus; private String ruleStatus;
/** 规则描述 */ /**
*
*/
@Excel(name = "规则描述") @Excel(name = "规则描述")
private String description; private String description;
public void setRuleId(Long ruleId) public Long getRuleId() {
{ return ruleId;
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId; this.ruleId = ruleId;
} }
public Long getRuleId() public String getRuleName() {
{ return ruleName;
return ruleId;
} }
public void setRuleName(String ruleName)
{ public void setRuleName(String ruleName) {
this.ruleName = ruleName; this.ruleName = ruleName;
} }
public String getRuleName() public String getRuleCode() {
{ return ruleCode;
return ruleName;
} }
public void setRuleCode(String ruleCode)
{ public void setRuleCode(String ruleCode) {
this.ruleCode = ruleCode; this.ruleCode = ruleCode;
} }
public String getRuleCode() public Integer getRuleLevel() {
{ return ruleLevel;
return ruleCode;
} }
public void setRuleLevel(Integer ruleLevel)
{ public void setRuleLevel(Integer ruleLevel) {
this.ruleLevel = ruleLevel; this.ruleLevel = ruleLevel;
} }
public Integer getRuleLevel() public Integer getRuleType() {
{ return ruleType;
return ruleLevel;
} }
public void setRuleType(Integer ruleType)
{ public void setRuleType(Integer ruleType) {
this.ruleType = ruleType; this.ruleType = ruleType;
} }
public Integer getRuleType() public String getRuleIsActivate() {
{ return ruleIsActivate;
return ruleType;
} }
public void setRuleIsActivate(String ruleIsActivate)
{ public void setRuleIsActivate(String ruleIsActivate) {
this.ruleIsActivate = ruleIsActivate; this.ruleIsActivate = ruleIsActivate;
} }
public String getRuleIsActivate() public String getRuleStatus() {
{ return ruleStatus;
return ruleIsActivate;
} }
public void setRuleStatus(String ruleStatus)
{ public void setRuleStatus(String ruleStatus) {
this.ruleStatus = ruleStatus; this.ruleStatus = ruleStatus;
} }
public String getRuleStatus() public String getDescription() {
{ return description;
return ruleStatus;
}
public void setDescription(String description)
{
this.description = description;
} }
public String getDescription() public void setDescription(String description) {
{ this.description = description;
return description;
} }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("ruleId", getRuleId()) .append("ruleId", getRuleId())
.append("ruleName", getRuleName()) .append("ruleName", getRuleName())
.append("ruleCode", getRuleCode()) .append("ruleCode", getRuleCode())

View File

@ -8,12 +8,18 @@ import lombok.experimental.SuperBuilder;
public class EngineConfigResp { public class EngineConfigResp {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 类型 */ /**
*
*/
private String type; private String type;
/** 名称 */ /**
*
*/
private String name; private String name;
/** 代码 */ /**
*
*/
private String code; private String code;
} }

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,21 @@
package com.muyu.goods.edition.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.edition.domain.RuleEngine;
import com.muyu.goods.edition.remote.factory.DataMangFacrory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@FeignClient(
contextId = "RemoteSys",
value = ServiceNameConstants.EDITION_MUYU,
fallbackFactory = DataMangFacrory.class,
path = "/engine"
)
public interface RemoteDataManagerService {
@GetMapping("/list")
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine);
}

View File

@ -0,0 +1,21 @@
package com.muyu.goods.edition.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.edition.domain.RuleEngine;
import com.muyu.goods.edition.remote.RemoteDataManagerService;
import org.springframework.cloud.openfeign.FallbackFactory;
//熔断
public class DataMangFacrory implements FallbackFactory<RemoteDataManagerService> {
@Override
public RemoteDataManagerService create(Throwable cause) {
return new RemoteDataManagerService() {
@Override
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
return Result.error(cause.getMessage());
}
};
}
}

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -12,6 +12,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class MuYuGoodsEditionApplication { public class MuYuGoodsEditionApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MuYuGoodsEditionApplication.class,args); SpringApplication.run(MuYuGoodsEditionApplication.class, args);
} }
} }

View File

@ -25,8 +25,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/config") @RequestMapping("/config")
public class ConfigController extends BaseController public class ConfigController extends BaseController {
{
@Autowired @Autowired
private IConfigService configService; private IConfigService configService;
@ -35,8 +34,7 @@ public class ConfigController extends BaseController
*/ */
@RequiresPermissions("system:config:list") @RequiresPermissions("system:config:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<Config>> list(Config config) public Result<TableDataInfo<Config>> list(Config config) {
{
startPage(); startPage();
List<Config> list = configService.selectConfigList(config); List<Config> list = configService.selectConfigList(config);
return getDataTable(list); return getDataTable(list);
@ -44,11 +42,12 @@ public class ConfigController extends BaseController
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@PostMapping("/listConfigEs/{ruleId}") @PostMapping("/listConfigEs/{ruleId}")
public Result<List<Config>> listConfigEs(@PathVariable Long ruleId){ public Result<List<Config>> listConfigEs(@PathVariable Long ruleId) {
List<Config> list = configService.listConfigEs(ruleId); List<Config> list = configService.listConfigEs(ruleId);
return success(list); return success(list);
} }
@ -59,8 +58,7 @@ public class ConfigController extends BaseController
@RequiresPermissions("system:config:export") @RequiresPermissions("system:config:export")
@Log(title = "引擎", businessType = BusinessType.EXPORT) @Log(title = "引擎", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Config config) public void export(HttpServletResponse response, Config config) {
{
List<Config> list = configService.selectConfigList(config); List<Config> list = configService.selectConfigList(config);
ExcelUtil<Config> util = new ExcelUtil<Config>(Config.class); ExcelUtil<Config> util = new ExcelUtil<Config>(Config.class);
util.exportExcel(response, list, "引擎数据"); util.exportExcel(response, list, "引擎数据");
@ -71,8 +69,7 @@ public class ConfigController extends BaseController
*/ */
@RequiresPermissions("system:config:query") @RequiresPermissions("system:config:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) public Result getInfo(@PathVariable("id") Long id) {
{
return success(configService.selectConfigById(id)); return success(configService.selectConfigById(id));
} }
@ -82,8 +79,7 @@ public class ConfigController extends BaseController
@RequiresPermissions("system:config:add") @RequiresPermissions("system:config:add")
@Log(title = "引擎", businessType = BusinessType.INSERT) @Log(title = "引擎", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result add(@RequestBody Config config) public Result add(@RequestBody Config config) {
{
return toAjax(configService.insertConfig(config)); return toAjax(configService.insertConfig(config));
} }
@ -93,8 +89,7 @@ public class ConfigController extends BaseController
@RequiresPermissions("system:config:edit") @RequiresPermissions("system:config:edit")
@Log(title = "引擎", businessType = BusinessType.UPDATE) @Log(title = "引擎", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result edit(@RequestBody Config config) public Result edit(@RequestBody Config config) {
{
return toAjax(configService.updateConfig(config)); return toAjax(configService.updateConfig(config));
} }
@ -103,24 +98,25 @@ public class ConfigController extends BaseController
*/ */
@RequiresPermissions("system:config:remove") @RequiresPermissions("system:config:remove")
@Log(title = "引擎", businessType = BusinessType.DELETE) @Log(title = "引擎", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) public Result remove(@PathVariable Long[] ids) {
{
return toAjax(configService.deleteConfigByIds(ids)); return toAjax(configService.deleteConfigByIds(ids));
} }
/** /**
* *
*
* @param textData * @param textData
* @return * @return
*/ */
@PostMapping("/testData") @PostMapping("/testData")
public Result<Object> ruleText(@RequestBody TextData textData){ public Result<Object> ruleText(@RequestBody TextData textData) {
return success(configService.testData(textData)); return success(configService.testData(textData));
} }
/** /**
* *
*
* @param id * @param id
* @return * @return
*/ */
@ -130,7 +126,7 @@ public class ConfigController extends BaseController
} }
@PostMapping("queryConfigInfo/{ruleId}") @PostMapping("queryConfigInfo/{ruleId}")
public Result<List<Config>> queryConfigInfo(@PathVariable Long ruleId){ public Result<List<Config>> queryConfigInfo(@PathVariable Long ruleId) {
return success(configService.queryConfigInfo(ruleId)); return success(configService.queryConfigInfo(ruleId));
} }
} }

View File

@ -26,12 +26,12 @@ public class CopeController extends BaseController {
} }
@PostMapping("selType/{name}") @PostMapping("selType/{name}")
public Result<List<Cope>> selType(@PathVariable String name){ public Result<List<Cope>> selType(@PathVariable String name) {
return success(service.selType(name)); return success(service.selType(name));
} }
@PostMapping("selObject") @PostMapping("selObject")
public Result<List<Cope>> selObject(@RequestBody Cope cope){ public Result<List<Cope>> selObject(@RequestBody Cope cope) {
return success(service.selObject(cope)); return success(service.selObject(cope));
} }
} }

View File

@ -23,8 +23,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/edition") @RequestMapping("/edition")
public class EditionController extends BaseController public class EditionController extends BaseController {
{
@Autowired @Autowired
private IEditionService editionService; private IEditionService editionService;
@ -33,8 +32,7 @@ public class EditionController extends BaseController
*/ */
@RequiresPermissions("goods:edition:list") @RequiresPermissions("goods:edition:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<Edition>> list() public Result<TableDataInfo<Edition>> list() {
{
startPage(); startPage();
List<Edition> list = editionService.selectEditionList(); List<Edition> list = editionService.selectEditionList();
return getDataTable(list); return getDataTable(list);
@ -42,11 +40,12 @@ public class EditionController extends BaseController
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@PostMapping("/selectListRuleId/{ruleId}") @PostMapping("/selectListRuleId/{ruleId}")
public Result<List<Edition>> selectListRuleId(@PathVariable Long ruleId){ public Result<List<Edition>> selectListRuleId(@PathVariable Long ruleId) {
return success(editionService.selectListRuleId(ruleId)); return success(editionService.selectListRuleId(ruleId));
} }
@ -56,8 +55,7 @@ public class EditionController extends BaseController
@RequiresPermissions("goods:edition:export") @RequiresPermissions("goods:edition:export")
@Log(title = "规则引擎版本", businessType = BusinessType.EXPORT) @Log(title = "规则引擎版本", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Edition edition) public void export(HttpServletResponse response, Edition edition) {
{
List<Edition> list = editionService.selectEditionList(); List<Edition> list = editionService.selectEditionList();
ExcelUtil<Edition> util = new ExcelUtil<Edition>(Edition.class); ExcelUtil<Edition> util = new ExcelUtil<Edition>(Edition.class);
util.exportExcel(response, list, "规则引擎版本数据"); util.exportExcel(response, list, "规则引擎版本数据");
@ -68,8 +66,7 @@ public class EditionController extends BaseController
*/ */
@RequiresPermissions("goods:edition:query") @RequiresPermissions("goods:edition:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) public Result getInfo(@PathVariable("id") Long id) {
{
return success(editionService.selectEditionById(id)); return success(editionService.selectEditionById(id));
} }
@ -79,8 +76,7 @@ public class EditionController extends BaseController
@RequiresPermissions("goods:edition:add") @RequiresPermissions("goods:edition:add")
@Log(title = "规则引擎版本", businessType = BusinessType.INSERT) @Log(title = "规则引擎版本", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result add(@RequestBody Edition edition) public Result add(@RequestBody Edition edition) {
{
return toAjax(editionService.insertEdition(edition)); return toAjax(editionService.insertEdition(edition));
} }
@ -90,8 +86,7 @@ public class EditionController extends BaseController
@RequiresPermissions("goods:edition:edit") @RequiresPermissions("goods:edition:edit")
@Log(title = "规则引擎版本", businessType = BusinessType.UPDATE) @Log(title = "规则引擎版本", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result edit(@RequestBody Edition edition) public Result edit(@RequestBody Edition edition) {
{
return toAjax(editionService.updateEdition(edition)); return toAjax(editionService.updateEdition(edition));
} }
@ -100,9 +95,8 @@ public class EditionController extends BaseController
*/ */
@RequiresPermissions("goods:edition:remove") @RequiresPermissions("goods:edition:remove")
@Log(title = "规则引擎版本", businessType = BusinessType.DELETE) @Log(title = "规则引擎版本", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) public Result remove(@PathVariable Long[] ids) {
{
return toAjax(editionService.deleteEditionByIds(ids)); return toAjax(editionService.deleteEditionByIds(ids));
} }

View File

@ -23,8 +23,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/engine") @RequestMapping("/engine")
public class RuleEngineController extends BaseController public class RuleEngineController extends BaseController {
{
@Autowired @Autowired
private IRuleEngineService ruleEngineService; private IRuleEngineService ruleEngineService;
@ -33,8 +32,7 @@ public class RuleEngineController extends BaseController
*/ */
@RequiresPermissions("goods:engine:list") @RequiresPermissions("goods:engine:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
{
startPage(); startPage();
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine); List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
return getDataTable(list); return getDataTable(list);
@ -46,8 +44,7 @@ public class RuleEngineController extends BaseController
@RequiresPermissions("goods:engine:export") @RequiresPermissions("goods:engine:export")
@Log(title = "规则引擎", businessType = BusinessType.EXPORT) @Log(title = "规则引擎", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, RuleEngine ruleEngine) public void export(HttpServletResponse response, RuleEngine ruleEngine) {
{
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine); List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
ExcelUtil<RuleEngine> util = new ExcelUtil<RuleEngine>(RuleEngine.class); ExcelUtil<RuleEngine> util = new ExcelUtil<RuleEngine>(RuleEngine.class);
util.exportExcel(response, list, "规则引擎数据"); util.exportExcel(response, list, "规则引擎数据");
@ -58,13 +55,12 @@ public class RuleEngineController extends BaseController
*/ */
@RequiresPermissions("goods:engine:query") @RequiresPermissions("goods:engine:query")
@GetMapping(value = "/{ruleId}") @GetMapping(value = "/{ruleId}")
public Result getInfo(@PathVariable("ruleId") Long ruleId) public Result getInfo(@PathVariable("ruleId") Long ruleId) {
{
return success(ruleEngineService.selectRuleEngineByRuleId(ruleId)); return success(ruleEngineService.selectRuleEngineByRuleId(ruleId));
} }
@PostMapping("selectRuleEngineOne/{ruleId}") @PostMapping("selectRuleEngineOne/{ruleId}")
public Result selectRuleEngineOne(@PathVariable Long ruleId){ public Result selectRuleEngineOne(@PathVariable Long ruleId) {
return success(ruleEngineService.selectRuleEngineOne(ruleId)); return success(ruleEngineService.selectRuleEngineOne(ruleId));
} }
@ -74,8 +70,7 @@ public class RuleEngineController extends BaseController
@RequiresPermissions("goods:engine:add") @RequiresPermissions("goods:engine:add")
@Log(title = "规则引擎", businessType = BusinessType.INSERT) @Log(title = "规则引擎", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result add(@RequestBody RuleEngine ruleEngine) public Result add(@RequestBody RuleEngine ruleEngine) {
{
return toAjax(ruleEngineService.insertRuleEngine(ruleEngine)); return toAjax(ruleEngineService.insertRuleEngine(ruleEngine));
} }
@ -85,8 +80,7 @@ public class RuleEngineController extends BaseController
@RequiresPermissions("goods:engine:edit") @RequiresPermissions("goods:engine:edit")
@Log(title = "规则引擎", businessType = BusinessType.UPDATE) @Log(title = "规则引擎", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result edit(@RequestBody RuleEngine ruleEngine) public Result edit(@RequestBody RuleEngine ruleEngine) {
{
return toAjax(ruleEngineService.updateRuleEngine(ruleEngine)); return toAjax(ruleEngineService.updateRuleEngine(ruleEngine));
} }
@ -95,36 +89,37 @@ public class RuleEngineController extends BaseController
*/ */
@RequiresPermissions("goods:engine:remove") @RequiresPermissions("goods:engine:remove")
@Log(title = "规则引擎", businessType = BusinessType.DELETE) @Log(title = "规则引擎", businessType = BusinessType.DELETE)
@DeleteMapping("/{ruleIds}") @DeleteMapping("/{ruleIds}")
public Result remove(@PathVariable Long[] ruleIds) public Result remove(@PathVariable Long[] ruleIds) {
{
return toAjax(ruleEngineService.deleteRuleEngineByRuleIds(ruleIds)); return toAjax(ruleEngineService.deleteRuleEngineByRuleIds(ruleIds));
} }
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@PostMapping("/description/{ruleId}") @PostMapping("/description/{ruleId}")
public Result<String> description(@PathVariable Integer ruleId){ public Result<String> description(@PathVariable Integer ruleId) {
return success(ruleEngineService.description(ruleId)); return success(ruleEngineService.description(ruleId));
} }
@PutMapping("/updateRuleIsActivate") @PutMapping("/updateRuleIsActivate")
public Result updateRuleIsActivate(@RequestBody RuleEngine ruleEngine){ public Result updateRuleIsActivate(@RequestBody RuleEngine ruleEngine) {
ruleEngineService.updateRuleIsActivate(ruleEngine); ruleEngineService.updateRuleIsActivate(ruleEngine);
return success("改变激活状态"); return success("改变激活状态");
} }
@PutMapping("/updateRuleStatus") @PutMapping("/updateRuleStatus")
public Result updateRuleStatus(@RequestBody RuleEngine ruleEngine){ public Result updateRuleStatus(@RequestBody RuleEngine ruleEngine) {
ruleEngineService.updateRuleStatus(ruleEngine); ruleEngineService.updateRuleStatus(ruleEngine);
return success("改变规则状态"); return success("改变规则状态");
} }
@PostMapping("/spliceNameToCode") @PostMapping("/spliceNameToCode")
public Result spliceNameToCode(@RequestParam String name, @RequestParam String code,@RequestParam Integer level){ public Result spliceNameToCode(@RequestParam String name, @RequestParam String code, @RequestParam Integer level) {
return ruleEngineService.spliceNameToCode(name,code,level); return ruleEngineService.spliceNameToCode(name, code, level);
} }
} }

View File

@ -53,7 +53,6 @@ public class DynamicLoader {
* URLClassLoaderclassjvm * URLClassLoaderclassjvm
* *
* @author Administrator * @author Administrator
*
*/ */
public static class MemoryClassLoader extends URLClassLoader { public static class MemoryClassLoader extends URLClassLoader {
Map<String, byte[]> classBytes = new HashMap<String, byte[]>(); Map<String, byte[]> classBytes = new HashMap<String, byte[]>();

View File

@ -9,6 +9,7 @@ import java.util.Map;
/** /**
* .classmap * .classmap
*
* @ClassName MemoryJavaFileManager * @ClassName MemoryJavaFileManager
* @Author * @Author
* @Date 2024/5/1 20:38 * @Date 2024/5/1 20:38
@ -25,6 +26,30 @@ public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
classBytes = new HashMap<String, byte[]>(); classBytes = new HashMap<String, byte[]>();
} }
static JavaFileObject makeStringSource(String name, String code) {
return new StringInputBuffer(name, code);
}
static URI toURI(String name) {
File file = new File(name);
if (file.exists()) {// 如果文件存在返回他的URI
return file.toURI();
} else {
try {
final StringBuilder newUri = new StringBuilder();
newUri.append("mfm:///");
newUri.append(name.replace('.', '/'));
if (name.endsWith(EXT)) {
newUri.replace(newUri.length() - EXT.length(),
newUri.length(), EXT);
}
return URI.create(newUri.toString());
} catch (Exception exp) {
return URI.create("mfm:///com/sun/script/java/java_source");
}
}
}
public Map<String, byte[]> getClassBytes() { public Map<String, byte[]> getClassBytes() {
return classBytes; return classBytes;
} }
@ -38,6 +63,18 @@ public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
public void flush() throws IOException { public void flush() throws IOException {
} }
@Override
public JavaFileObject getJavaFileForOutput(
Location location, String className,
JavaFileObject.Kind kind, FileObject sibling) throws IOException {
if (kind == JavaFileObject.Kind.CLASS) {
return new ClassOutputBuffer(className);
} else {
return super.getJavaFileForOutput(location, className, kind,
sibling);
}
}
/** /**
* stringsourcejkd * stringsourcejkd
*/ */
@ -95,40 +132,4 @@ public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
}; };
} }
} }
@Override
public JavaFileObject getJavaFileForOutput(
Location location, String className,
JavaFileObject.Kind kind, FileObject sibling) throws IOException {
if (kind == JavaFileObject.Kind.CLASS) {
return new ClassOutputBuffer(className);
} else {
return super.getJavaFileForOutput(location, className, kind,
sibling);
}
}
static JavaFileObject makeStringSource(String name, String code) {
return new StringInputBuffer(name, code);
}
static URI toURI(String name) {
File file = new File(name);
if (file.exists()) {// 如果文件存在返回他的URI
return file.toURI();
} else {
try {
final StringBuilder newUri = new StringBuilder();
newUri.append("mfm:///");
newUri.append(name.replace('.', '/'));
if (name.endsWith(EXT)) {
newUri.replace(newUri.length() - EXT.length(),
newUri.length(), EXT);
}
return URI.create(newUri.toString());
} catch (Exception exp) {
return URI.create("mfm:///com/sun/script/java/java_source");
}
}
}
} }

View File

@ -10,8 +10,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-04 * @date 2024-05-04
*/ */
public interface ConfigMapper public interface ConfigMapper {
{
/** /**
* *
* *

View File

@ -10,8 +10,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-06 * @date 2024-05-06
*/ */
public interface EditionMapper public interface EditionMapper {
{
/** /**
* *
* *

View File

@ -11,8 +11,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-02 * @date 2024-05-02
*/ */
public interface RuleEngineMapper public interface RuleEngineMapper {
{
/** /**
* *
* *

View File

@ -4,6 +4,7 @@ import lombok.Data;
/** /**
* *
*
* @ClassName DataModelContextHolder * @ClassName DataModelContextHolder
* @Author * @Author
* @Version: 1.0 * @Version: 1.0
@ -13,7 +14,7 @@ public class DataModelContextHolder {
private final RecordContextHolder recordContextHolder; private final RecordContextHolder recordContextHolder;
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){ public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
return new DataModelContextHolder(recordContextHolder); return new DataModelContextHolder(recordContextHolder);
} }
} }

View File

@ -4,6 +4,7 @@ import lombok.Data;
/** /**
* *
*
* @ClassName DataSetContextHolder * @ClassName DataSetContextHolder
* @Author * @Author
* @Version: 1.0 * @Version: 1.0
@ -13,7 +14,7 @@ public class DataSetContextHolder {
private final TaskContextHolder taskContextHolder; private final TaskContextHolder taskContextHolder;
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){ public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
return new DataSetContextHolder(taskContextHolder); return new DataSetContextHolder(taskContextHolder);
} }
} }

View File

@ -4,6 +4,7 @@ import lombok.Data;
/** /**
* *
*
* @ClassName RecordContextHolder * @ClassName RecordContextHolder
* @Author * @Author
* @Version: 1.0 * @Version: 1.0
@ -13,7 +14,7 @@ public class RecordContextHolder {
private final DataSetContextHolder dataSetContextHolder; private final DataSetContextHolder dataSetContextHolder;
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){ public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
return new RecordContextHolder(dataSetContextHolder); return new RecordContextHolder(dataSetContextHolder);
} }
} }

View File

@ -2,13 +2,14 @@ package com.muyu.edition.scope;
/** /**
* *
*
* @ClassName TaskContextHolder * @ClassName TaskContextHolder
* @Author * @Author
* @Version: 1.0 * @Version: 1.0
*/ */
public class TaskContextHolder { public class TaskContextHolder {
public static TaskContextHolder build(){ public static TaskContextHolder build() {
return new TaskContextHolder(); return new TaskContextHolder();
} }
} }

View File

@ -12,8 +12,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-04 * @date 2024-05-04
*/ */
public interface IConfigService public interface IConfigService {
{
/** /**
* *
* *
@ -32,6 +31,7 @@ public interface IConfigService
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@ -73,6 +73,7 @@ public interface IConfigService
/** /**
* *
*
* @param id * @param id
* @return * @return
*/ */

View File

@ -10,8 +10,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-06 * @date 2024-05-06
*/ */
public interface IEditionService public interface IEditionService {
{
/** /**
* *
* *
@ -27,6 +26,7 @@ public interface IEditionService
* @return * @return
*/ */
List<Edition> selectListRuleId(Long ruleId); List<Edition> selectListRuleId(Long ruleId);
/** /**
* *
* *

View File

@ -11,8 +11,7 @@ import java.util.List;
* @author muyu * @author muyu
* @date 2024-05-02 * @date 2024-05-02
*/ */
public interface IRuleEngineService public interface IRuleEngineService {
{
/** /**
* *
* *
@ -23,10 +22,12 @@ public interface IRuleEngineService
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
RuleEngine selectRuleEngineOne(Long ruleId); RuleEngine selectRuleEngineOne(Long ruleId);
/** /**
* *
* *

View File

@ -27,8 +27,7 @@ import java.util.stream.Collectors;
* @date 2024-05-04 * @date 2024-05-04
*/ */
@Service @Service
public class ConfigServiceImpl implements IConfigService public class ConfigServiceImpl implements IConfigService {
{
@Autowired @Autowired
private ConfigMapper configMapper; private ConfigMapper configMapper;
@ -39,8 +38,7 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public Config selectConfigById(Long id) public Config selectConfigById(Long id) {
{
return configMapper.selectConfigById(id); return configMapper.selectConfigById(id);
} }
@ -51,13 +49,13 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public List<Config> selectConfigList(Config config) public List<Config> selectConfigList(Config config) {
{
return configMapper.selectConfigList(config); return configMapper.selectConfigList(config);
} }
/** /**
* y * y
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@ -73,8 +71,7 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public int insertConfig(Config config) public int insertConfig(Config config) {
{
return configMapper.insertConfig(config); return configMapper.insertConfig(config);
} }
@ -85,8 +82,7 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public int updateConfig(Config config) public int updateConfig(Config config) {
{
return configMapper.updateConfig(config); return configMapper.updateConfig(config);
} }
@ -97,8 +93,7 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public int deleteConfigByIds(Long[] ids) public int deleteConfigByIds(Long[] ids) {
{
return configMapper.deleteConfigByIds(ids); return configMapper.deleteConfigByIds(ids);
} }
@ -109,8 +104,7 @@ public class ConfigServiceImpl implements IConfigService
* @return * @return
*/ */
@Override @Override
public int deleteConfigById(Long id) public int deleteConfigById(Long id) {
{
return configMapper.deleteConfigById(id); return configMapper.deleteConfigById(id);
} }
@ -121,7 +115,7 @@ public class ConfigServiceImpl implements IConfigService
Config config = configMapper.selectConfigById(textData.getId()); Config config = configMapper.selectConfigById(textData.getId());
String content = config.getRuleContent().replaceAll("\r\n", ""); String content = config.getRuleContent().replaceAll("\r\n", "");
// 对source进行编译生成class文件存放在Map中这里用bytecode接收 // 对source进行编译生成class文件存放在Map中这里用bytecode接收
Map<String, byte[]> bytecode = DynamicLoader.compile(RuleOperationConstants.CLASS_NAME + RuleOperationConstants.FILE_SUFFIX,content ); Map<String, byte[]> bytecode = DynamicLoader.compile(RuleOperationConstants.CLASS_NAME + RuleOperationConstants.FILE_SUFFIX, content);
// 加载class文件到虚拟机中然后通过反射执行 // 加载class文件到虚拟机中然后通过反射执行
@SuppressWarnings("resource") @SuppressWarnings("resource")
@ -141,6 +135,7 @@ public class ConfigServiceImpl implements IConfigService
/** /**
* *
*
* @param id * @param id
* @return * @return
*/ */
@ -148,7 +143,7 @@ public class ConfigServiceImpl implements IConfigService
public EngineConfigResp getScopeInfo(Integer id) { public EngineConfigResp getScopeInfo(Integer id) {
String scope = ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY[id]; String scope = ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY[id];
String type = ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[id]; String type = ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[id];
String path = ConfigCodeConstants.BASE_FILE_PATH+scope; String path = ConfigCodeConstants.BASE_FILE_PATH + scope;
String code = null; String code = null;
try { try {
code = Files.readString(Paths.get(path)); code = Files.readString(Paths.get(path));

View File

@ -37,20 +37,20 @@ public class CopeServiceImpl implements CopeService {
System.out.println(cope); System.out.println(cope);
List<Cope> collect = new ArrayList<>(); List<Cope> collect = new ArrayList<>();
List<Cope> collect1 = new ArrayList<>(); List<Cope> collect1 = new ArrayList<>();
if (cope.getType()!=null && cope.getType()!=""){ if (cope.getType() != null && cope.getType() != "") {
collect = list().stream().filter(c -> c.getType().equals(cope.getType())).collect(Collectors.toList()); collect = list().stream().filter(c -> c.getType().equals(cope.getType())).collect(Collectors.toList());
}else { } else {
collect = list(); collect = list();
} }
if (cope.getVal()!=null && cope.getVal()!=""){ if (cope.getVal() != null && cope.getVal() != "") {
collect1 = list().stream().filter(c -> c.getVal().contains(cope.getVal())).collect(Collectors.toList()); collect1 = list().stream().filter(c -> c.getVal().contains(cope.getVal())).collect(Collectors.toList());
}else { } else {
collect1 = list(); collect1 = list();
} }
List<Cope> copes = new ArrayList<>(); List<Cope> copes = new ArrayList<>();
for (Cope cope1 : collect) { for (Cope cope1 : collect) {
for (Cope cope2 : collect1) { for (Cope cope2 : collect1) {
if (cope1.equals(cope2)){ if (cope1.equals(cope2)) {
copes.add(cope1); copes.add(cope1);
} }
} }

View File

@ -16,8 +16,7 @@ import java.util.stream.Collectors;
* @date 2024-05-06 * @date 2024-05-06
*/ */
@Service @Service
public class EditionServiceImpl implements IEditionService public class EditionServiceImpl implements IEditionService {
{
@Autowired @Autowired
private EditionMapper editionMapper; private EditionMapper editionMapper;
@ -28,8 +27,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public Edition selectEditionById(Long id) public Edition selectEditionById(Long id) {
{
return editionMapper.selectEditionById(id); return editionMapper.selectEditionById(id);
} }
@ -50,8 +48,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public List<Edition> selectEditionList() public List<Edition> selectEditionList() {
{
return editionMapper.selectEditionList(); return editionMapper.selectEditionList();
} }
@ -62,8 +59,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public int insertEdition(Edition edition) public int insertEdition(Edition edition) {
{
return editionMapper.insertEdition(edition); return editionMapper.insertEdition(edition);
} }
@ -74,8 +70,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public int updateEdition(Edition edition) public int updateEdition(Edition edition) {
{
return editionMapper.updateEdition(edition); return editionMapper.updateEdition(edition);
} }
@ -86,8 +81,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public int deleteEditionByIds(Long[] ids) public int deleteEditionByIds(Long[] ids) {
{
return editionMapper.deleteEditionByIds(ids); return editionMapper.deleteEditionByIds(ids);
} }
@ -98,8 +92,7 @@ public class EditionServiceImpl implements IEditionService
* @return * @return
*/ */
@Override @Override
public int deleteEditionById(Long id) public int deleteEditionById(Long id) {
{
return editionMapper.deleteEditionById(id); return editionMapper.deleteEditionById(id);
} }
} }

View File

@ -23,8 +23,7 @@ import java.util.stream.Collectors;
* @date 2024-05-02 * @date 2024-05-02
*/ */
@Service @Service
public class RuleEngineServiceImpl implements IRuleEngineService public class RuleEngineServiceImpl implements IRuleEngineService {
{
@Autowired @Autowired
private RuleEngineMapper ruleEngineMapper; private RuleEngineMapper ruleEngineMapper;
@ -35,13 +34,13 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public RuleEngine selectRuleEngineByRuleId(Long ruleId) public RuleEngine selectRuleEngineByRuleId(Long ruleId) {
{
return ruleEngineMapper.selectRuleEngineByRuleId(ruleId); return ruleEngineMapper.selectRuleEngineByRuleId(ruleId);
} }
/** /**
* *
*
* @param ruleId * @param ruleId
* @return * @return
*/ */
@ -59,8 +58,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine) public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine) {
{
return ruleEngineMapper.selectRuleEngineList(ruleEngine); return ruleEngineMapper.selectRuleEngineList(ruleEngine);
} }
@ -71,8 +69,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public int insertRuleEngine(RuleEngine ruleEngine) public int insertRuleEngine(RuleEngine ruleEngine) {
{
return ruleEngineMapper.insertRuleEngine(ruleEngine); return ruleEngineMapper.insertRuleEngine(ruleEngine);
} }
@ -83,8 +80,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public int updateRuleEngine(RuleEngine ruleEngine) public int updateRuleEngine(RuleEngine ruleEngine) {
{
return ruleEngineMapper.updateRuleEngine(ruleEngine); return ruleEngineMapper.updateRuleEngine(ruleEngine);
} }
@ -95,8 +91,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public int deleteRuleEngineByRuleIds(Long[] ruleIds) public int deleteRuleEngineByRuleIds(Long[] ruleIds) {
{
return ruleEngineMapper.deleteRuleEngineByRuleIds(ruleIds); return ruleEngineMapper.deleteRuleEngineByRuleIds(ruleIds);
} }
@ -107,8 +102,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService
* @return * @return
*/ */
@Override @Override
public int deleteRuleEngineByRuleId(Long ruleId) public int deleteRuleEngineByRuleId(Long ruleId) {
{
return ruleEngineMapper.deleteRuleEngineByRuleId(ruleId); return ruleEngineMapper.deleteRuleEngineByRuleId(ruleId);
} }
@ -119,22 +113,22 @@ public class RuleEngineServiceImpl implements IRuleEngineService
@Override @Override
public void updateRuleIsActivate(RuleEngine ruleEngine) { public void updateRuleIsActivate(RuleEngine ruleEngine) {
if (ruleEngine.getRuleIsActivate().equals("Y")){ if (ruleEngine.getRuleIsActivate().equals("Y")) {
ruleEngine.setRuleIsActivate("N"); ruleEngine.setRuleIsActivate("N");
}else{ } else {
ruleEngine.setRuleIsActivate("Y"); ruleEngine.setRuleIsActivate("Y");
} }
ruleEngineMapper.updateRuleIsActivate(ruleEngine.getRuleId(),ruleEngine.getRuleIsActivate()); ruleEngineMapper.updateRuleIsActivate(ruleEngine.getRuleId(), ruleEngine.getRuleIsActivate());
} }
@Override @Override
public void updateRuleStatus(RuleEngine ruleEngine) { public void updateRuleStatus(RuleEngine ruleEngine) {
if (ruleEngine.getRuleStatus().equals("Y")){ if (ruleEngine.getRuleStatus().equals("Y")) {
ruleEngine.setRuleStatus("N"); ruleEngine.setRuleStatus("N");
}else{ } else {
ruleEngine.setRuleStatus("Y"); ruleEngine.setRuleStatus("Y");
} }
ruleEngineMapper.updateRuleStatus(ruleEngine.getRuleId(),ruleEngine.getRuleStatus()); ruleEngineMapper.updateRuleStatus(ruleEngine.getRuleId(), ruleEngine.getRuleStatus());
} }
@Override @Override
@ -143,13 +137,13 @@ public class RuleEngineServiceImpl implements IRuleEngineService
RuleEditionReq ruleEditionReq = new RuleEditionReq(); RuleEditionReq ruleEditionReq = new RuleEditionReq();
String val = name + "_" + code; String val = name + "_" + code;
String scope = ConfigCodeConstants.CONFIG_FILE_NAME_CODE[0]; String scope = ConfigCodeConstants.CONFIG_FILE_NAME_CODE[0];
String path = ConfigCodeConstants.BASE_FILE_PATH+scope; String path = ConfigCodeConstants.BASE_FILE_PATH + scope;
String cod = null; String cod = null;
try { try {
cod = Files.readString(Paths.get(path)); cod = Files.readString(Paths.get(path));
String s1 = Pattern.compile("this.form.name").matcher(cod).replaceAll(name); String s1 = Pattern.compile("this.form.name").matcher(cod).replaceAll(name);
String s2 = Pattern.compile("this.form.versionCode").matcher(s1).replaceAll(code); String s2 = Pattern.compile("this.form.versionCode").matcher(s1).replaceAll(code);
String s3 = Pattern.compile("parentClass").matcher(s2).replaceAll(stringList.get(level-1)); String s3 = Pattern.compile("parentClass").matcher(s2).replaceAll(stringList.get(level - 1));
ruleEditionReq.setVal(val); ruleEditionReq.setVal(val);
ruleEditionReq.setCode(s3); ruleEditionReq.setCode(s3);
System.out.println(cod); System.out.println(cod);

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,74 @@
<?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.muyu.edition.mapper.ConfigMapper">
<resultMap type="com.muyu.edition.domain.Config" id="ConfigResult">
<result property="id" column="id"/>
<result property="versionCode" column="version_code"/>
<result property="ruleContent" column="rule_content"/>
<result property="remark" column="remark"/>
<result property="ruleId" column="rule_id"/>
</resultMap>
<sql id="selectConfigVo">
select id, version_code, rule_content, remark, rule_id
from config
</sql>
<select id="selectConfigList" parameterType="com.muyu.edition.domain.Config" resultMap="ConfigResult">
<include refid="selectConfigVo"/>
<where>
<if test="versionCode != null and versionCode != ''">and version_code = #{versionCode}</if>
<if test="ruleContent != null and ruleContent != ''">and rule_content = #{ruleContent}</if>
<if test="ruleId != null ">and rule_id = #{ruleId}</if>
</where>
</select>
<select id="selectConfigById" parameterType="Long" resultMap="ConfigResult">
<include refid="selectConfigVo"/>
where id = #{id}
</select>
<select id="listConfigEs" resultType="com.muyu.edition.domain.Config">
<include refid="selectConfigVo"/>
where rule_id = #{ruleId}
</select>
<insert id="insertConfig" parameterType="com.muyu.edition.domain.Config" useGeneratedKeys="true" keyProperty="id">
insert into config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="versionCode != null">version_code,</if>
<if test="ruleContent != null">rule_content,</if>
<if test="ruleId != null">rule_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="versionCode != null">#{versionCode},</if>
<if test="ruleContent != null">#{ruleContent},</if>
<if test="ruleId != null">#{ruleId},</if>
</trim>
</insert>
<update id="updateConfig" parameterType="com.muyu.edition.domain.Config">
update config
<trim prefix="SET" suffixOverrides=",">
<if test="versionCode != null">version_code = #{versionCode},</if>
<if test="ruleContent != null">rule_content = #{ruleContent},</if>
<if test="ruleId != null">rule_id = #{ruleId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteConfigById" parameterType="Long">
delete
from config
where id = #{id}
</delete>
<delete id="deleteConfigByIds" parameterType="String">
delete from config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,11 @@
<?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.muyu.edition.mapper.CopeMapper">
<select id="list" resultType="com.muyu.edition.domain.Cope">
select *
from cope
</select>
</mapper>

View File

@ -0,0 +1,85 @@
<?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.muyu.edition.mapper.EditionMapper">
<resultMap type="com.muyu.edition.domain.Edition" id="EditionResult">
<result property="id" column="id"/>
<result property="ruleId" column="rule_id"/>
<result property="versionClass" column="version_class"/>
<result property="name" column="name"/>
<result property="versionCode" column="version_code"/>
<result property="editionStatus" column="edition_status"/>
<result property="ruleStatus" column="rule_status"/>
<result property="ruleIsTest" column="rule_is_test"/>
<result property="editionContent" column="edition_content"/>
<result property="ruleContent" column="rule_content"/>
</resultMap>
<sql id="selectEditionVo">
select id,
rule_id,
version_class,
name,
version_code,
edition_status,
rule_status,
rule_is_test,
edition_content,
rule_content
from edition
</sql>
<select id="selectEditionList" parameterType="com.muyu.edition.domain.Edition" resultMap="EditionResult">
<include refid="selectEditionVo"/>
</select>
<select id="selectEditionById" parameterType="Long" resultMap="EditionResult">
<include refid="selectEditionVo"/>
where id = #{id}
</select>
<insert id="insertEdition" parameterType="com.muyu.edition.domain.Edition" useGeneratedKeys="true" keyProperty="id">
insert into edition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ruleId != null">rule_id,</if>
<if test="versionClass != null">version_class,</if>
<if test="name != null">name,</if>
<if test="versionCode != null">version_code,</if>
<if test="editionContent != null">edition_content,</if>
<if test="ruleContent != null">rule_content,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ruleId != null">#{ruleId},</if>
<if test="versionClass != null">#{versionClass},</if>
<if test="name != null">#{name},</if>
<if test="versionCode != null">#{versionCode},</if>
<if test="editionContent != null">#{editionContent},</if>
<if test="ruleContent != null">#{ruleContent},</if>
</trim>
</insert>
<update id="updateEdition" parameterType="com.muyu.edition.domain.Edition">
update edition
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="editionContent != null">edition_content = #{editionContent},</if>
<if test="ruleContent != null">rule_content = #{ruleContent},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEditionById" parameterType="Long">
delete
from edition
where id = #{id}
</delete>
<delete id="deleteEditionByIds" parameterType="String">
delete from edition where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,115 @@
<?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.muyu.edition.mapper.RuleEngineMapper">
<resultMap type="com.muyu.edition.domain.RuleEngine" id="RuleEngineResult">
<result property="ruleId" column="rule_id"/>
<result property="ruleName" column="rule_name"/>
<result property="ruleCode" column="rule_code"/>
<result property="ruleLevel" column="rule_level"/>
<result property="ruleType" column="rule_type"/>
<result property="ruleIsActivate" column="rule_is_activate"/>
<result property="ruleStatus" column="rule_status"/>
<result property="description" column="description"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectRuleEngineVo">
select rule_id,
rule_name,
rule_code,
rule_level,
rule_type,
rule_is_activate,
rule_status,
description,
remark
from rule_engine
</sql>
<select id="selectRuleEngineList" parameterType="com.muyu.edition.domain.RuleEngine" resultMap="RuleEngineResult">
<include refid="selectRuleEngineVo"/>
<where>
<if test="ruleName != null and ruleName != ''">and rule_name like concat('%', #{ruleName}, '%')</if>
<if test="ruleLevel != null and ruleLevel != ''">and rule_level = #{ruleLevel}</if>
<if test="ruleType != null and ruleType != ''">and rule_type = #{ruleType}</if>
<if test="ruleIsActivate != null and ruleIsActivate != ''">and rule_is_activate = #{ruleIsActivate}</if>
<if test="ruleStatus != null and ruleStatus != ''">and rule_status = #{ruleStatus}</if>
</where>
</select>
<select id="selectRuleEngineByRuleId" parameterType="Long" resultMap="RuleEngineResult">
<include refid="selectRuleEngineVo"/>
where rule_id = #{ruleId}
</select>
<select id="description" resultType="java.lang.String">
select description
from rule_engine
where rule_id = #{ruleId};
</select>
<insert id="insertRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine" useGeneratedKeys="true"
keyProperty="ruleId">
insert into rule_engine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ruleName != null">rule_name,</if>
<if test="ruleCode != null">rule_code,</if>
<if test="ruleLevel != null">rule_level,</if>
<if test="ruleType != null">rule_type,</if>
<if test="ruleIsActivate != null">rule_is_activate,</if>
<if test="ruleStatus != null">rule_status,</if>
<if test="description != null">description,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ruleName != null">#{ruleName},</if>
<if test="ruleCode != null">#{ruleCode},</if>
<if test="ruleLevel != null">#{ruleLevel},</if>
<if test="ruleType != null">#{ruleType},</if>
<if test="ruleIsActivate != null">#{ruleIsActivate},</if>
<if test="ruleStatus != null">#{ruleStatus},</if>
<if test="description != null">#{description},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine">
update rule_engine
<trim prefix="SET" suffixOverrides=",">
<if test="ruleName != null">rule_name = #{ruleName},</if>
<if test="ruleCode != null">rule_code = #{ruleCode},</if>
<if test="ruleLevel != null">rule_level = #{ruleLevel},</if>
<if test="ruleType != null">rule_type = #{ruleType},</if>
<if test="ruleIsActivate != null">rule_is_activate = #{ruleIsActivate},</if>
<if test="ruleStatus != null">rule_status = #{ruleStatus},</if>
<if test="description != null">description = #{description},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where rule_id = #{ruleId}
</update>
<update id="updateRuleIsActivate">
update rule_engine
set rule_is_activate = #{ruleIsActivate}
where rule_id = #{ruleId};
</update>
<update id="updateRuleStatus">
update rule_engine
set rule_status = #{ruleStatus}
where rule_id = #{ruleId};
</update>
<delete id="deleteRuleEngineByRuleId" parameterType="Long">
delete
from rule_engine
where rule_id = #{ruleId}
</delete>
<delete id="deleteRuleEngineByRuleIds" parameterType="String">
delete from rule_engine where rule_id in
<foreach item="ruleId" collection="array" open="(" separator="," close=")">
#{ruleId}
</foreach>
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-tests</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-test-clinet</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-test-common</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>

View File

@ -1,15 +0,0 @@
package com.muyu.edition.test.clinet.cllent.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import java.rmi.server.RemoteServer;
public class AccessConfigRunner implements ApplicationRunner {
@Autowired
private RemoteServer remoteServer;
@Override
public void run(ApplicationArguments args) throws Exception {
}
}

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-tests</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-test-common</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-tests</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-test-remote</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +0,0 @@
package com.muyu.data.test.remote;
public interface RemoteDataManagerService {
}

View File

@ -1,17 +0,0 @@
package com.muyu.data.test.remote.factory;
import com.muyu.common.core.constant.ServiceNameConstants;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import java.rmi.Remote;
//熔断
@FeignClient(
contextId = "RemoteSys",
value = ServiceNameConstants.TEST_MUYU,
fallbackFactory = DataMangFacrory.class,
path = "/system"
)
public class DataMangFacrory {
}

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-tests</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-test-server</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,24 +0,0 @@
package com.muyu.test.config;
import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.nio.charset.Charset;
@Configuration
public class BloomFilterConfig {
@Value("${bloom-filter-exrcted-insertions}")
private int expectedInsertions;
@Value("${bloom-filter.fpp}")
private double falsePositiveProbability;
@Bean
public BloomFilter<String> bloomFilter() {
return BloomFilter.create(Funnels.stringFunnel(Charset.defaultCharset()),expectedInsertions);
}
}

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu</artifactId>
<version>3.6.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>muyu-goods-tests</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-goods-test-clinet</module>
<module>muyu-goods-test-common</module>
<module>muyu-goods-test-remote</module>
<module>muyu-goods-test-server</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>

View File

@ -1,5 +1,3 @@
import com.muyu.edition.domain.Cope;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -8,7 +6,7 @@ import java.util.stream.Stream;
public class stream { public class stream {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
// stream 获取list // stream 获取list
List<Integer> list = Arrays.asList(1,2,3); List<Integer> list = Arrays.asList(1, 2, 3);
System.out.println(list); System.out.println(list);
Stream<Integer> integerStream = list.stream(); Stream<Integer> integerStream = list.stream();
List<Integer> collect1 = integerStream.collect(Collectors.toList()); List<Integer> collect1 = integerStream.collect(Collectors.toList());
@ -38,7 +36,7 @@ public class stream {
stringList.stream().distinct().forEach(System.out::println); stringList.stream().distinct().forEach(System.out::println);
// sorted 对元素进行排序 // sorted 对元素进行排序
System.out.println("排序"); System.out.println("排序");
stringList.stream().sorted((a,b) -> a.length() - b.length()).forEach(System.out::println); stringList.stream().sorted((a, b) -> a.length() - b.length()).forEach(System.out::println);
// peek 对每个元素进行特定操作 // peek 对每个元素进行特定操作
System.out.println("对每个元素进行特定操作"); System.out.println("对每个元素进行特定操作");
stringList.stream().peek(c -> System.out.println(c.length())).map(p -> p.length() % 2 == 0).forEach(System.out::println); stringList.stream().peek(c -> System.out.println(c.length())).map(p -> p.length() % 2 == 0).forEach(System.out::println);
@ -74,23 +72,6 @@ public class stream {
System.out.println(first.stream().collect(Collectors.toSet())); System.out.println(first.stream().collect(Collectors.toSet()));
//findAny 返回流的任意一个元素 //findAny 返回流的任意一个元素
// peek 修改元素
List<Cope> copes = new ArrayList<>();
for (int i = 1; i <= 3; i++) {
Cope cope = new Cope();
cope.setCode("code"+i);
cope.setType("type"+i);
cope.setVal("val"+i);
copes.add(cope);
}
System.out.println(copes);
Stream<Cope> peek = copes.stream().peek(c -> {
if (c.getVal().contains("1")){
c.setVal("123");
}
});
List<Cope> collect3 = peek.collect(Collectors.toList());
System.out.println(collect3);
//
} }
} }

View File

@ -1,6 +1,5 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class yes { public class yes {

View File

@ -1,27 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.goods.mapper.ConfigMapper"> <mapper namespace="com.muyu.goods.mapper.ConfigMapper">
<resultMap type="com.muyu.edition.domain.Config" id="ConfigResult"> <resultMap type="com.muyu.edition.domain.Config" id="ConfigResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="versionCode" column="version_code" /> <result property="versionCode" column="version_code"/>
<result property="ruleContent" column="rule_content" /> <result property="ruleContent" column="rule_content"/>
<result property="remark" column="remark" /> <result property="remark" column="remark"/>
<result property="ruleId" column="rule_id" /> <result property="ruleId" column="rule_id"/>
</resultMap> </resultMap>
<sql id="selectConfigVo"> <sql id="selectConfigVo">
select id, version_code, rule_content, remark, rule_id from config select id, version_code, rule_content, remark, rule_id
from config
</sql> </sql>
<select id="selectConfigList" parameterType="com.muyu.edition.domain.Config" resultMap="ConfigResult"> <select id="selectConfigList" parameterType="com.muyu.edition.domain.Config" resultMap="ConfigResult">
<include refid="selectConfigVo"/> <include refid="selectConfigVo"/>
<where> <where>
<if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode}</if> <if test="versionCode != null and versionCode != ''">and version_code = #{versionCode}</if>
<if test="ruleContent != null and ruleContent != ''"> and rule_content = #{ruleContent}</if> <if test="ruleContent != null and ruleContent != ''">and rule_content = #{ruleContent}</if>
<if test="ruleId != null "> and rule_id = #{ruleId}</if> <if test="ruleId != null ">and rule_id = #{ruleId}</if>
</where> </where>
</select> </select>
@ -40,12 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="versionCode != null">version_code,</if> <if test="versionCode != null">version_code,</if>
<if test="ruleContent != null">rule_content,</if> <if test="ruleContent != null">rule_content,</if>
<if test="ruleId != null">rule_id,</if> <if test="ruleId != null">rule_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="versionCode != null">#{versionCode},</if> <if test="versionCode != null">#{versionCode},</if>
<if test="ruleContent != null">#{ruleContent},</if> <if test="ruleContent != null">#{ruleContent},</if>
<if test="ruleId != null">#{ruleId},</if> <if test="ruleId != null">#{ruleId},</if>
</trim> </trim>
</insert> </insert>
<update id="updateConfig" parameterType="com.muyu.edition.domain.Config"> <update id="updateConfig" parameterType="com.muyu.edition.domain.Config">
@ -59,7 +60,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteConfigById" parameterType="Long"> <delete id="deleteConfigById" parameterType="Long">
delete from config where id = #{id} delete
from config
where id = #{id}
</delete> </delete>
<delete id="deleteConfigByIds" parameterType="String"> <delete id="deleteConfigByIds" parameterType="String">

Some files were not shown because too many files have changed in this diff Show More