org.springframework.cloud
diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/FileController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/FileController.java
new file mode 100644
index 000000000..d2f7f28e2
--- /dev/null
+++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/FileController.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.controller;
+
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
+import com.pig4cloud.common.minio.service.MinioTemplate;
+import com.pig4cloud.pigx.common.core.constant.CommonConstants;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018-12-30
+ *
+ * 文件管理
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping("/file")
+public class FileController {
+ private final MinioTemplate minioTemplate;
+
+ /**
+ * 上传文件
+ *
+ * @param file 资源
+ * @return R(bucketName, filename)
+ */
+ @PostMapping("/upload")
+ public R upload(@RequestParam("file") MultipartFile file) {
+ String originalFilename = file.getOriginalFilename();
+ String newName = RandomUtil.randomString(16) + originalFilename;
+
+ Map resultMap = new HashMap<>(4);
+ resultMap.put("bucketName", CommonConstants.BUCKET_NAME);
+ resultMap.put("fileName", newName);
+
+ try {
+ minioTemplate.putObject(CommonConstants.BUCKET_NAME, newName, file.getInputStream());
+ } catch (Exception e) {
+ log.error("上传失败", e);
+ return R.builder().code(CommonConstants.FAIL)
+ .msg(e.getLocalizedMessage()).build();
+ }
+ return R.builder().data(resultMap).build();
+ }
+
+ /**
+ * 获取文件
+ *
+ * @param fileName 文件空间/名称
+ * @param response
+ * @return
+ */
+ @GetMapping("/{fileName}")
+ public R file(@PathVariable String fileName, HttpServletResponse response) {
+ String[] nameArray = StrUtil.split(fileName, StrUtil.DASHED);
+
+ try (InputStream inputStream = minioTemplate.getObject(nameArray[0], nameArray[1])) {
+ response.setContentType("application/octet-stream; charset=UTF-8");
+ IoUtil.copy(inputStream, response.getOutputStream());
+ } catch (Exception e) {
+ log.error("文件读取异常", e);
+ return R.builder().code(CommonConstants.FAIL)
+ .msg(e.getLocalizedMessage()).build();
+ }
+
+ return R.builder().build();
+ }
+}
diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm b/pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
index 958d72980..9bd08062c 100755
--- a/pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
+++ b/pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
@@ -16,8 +16,7 @@
*/
package ${package}.${moduleName}.controller;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
@@ -26,8 +25,6 @@ import ${package}.${moduleName}.service.${className}Service;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
-import java.util.Map;
-
/**
* ${comments}
diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm b/pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm
index 0b2d23611..dfcc4a293 100755
--- a/pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm
+++ b/pigx-visual/pigx-codegen/src/main/resources/template/Entity.java.vm
@@ -34,8 +34,8 @@ import java.time.LocalDateTime;
* @date ${datetime}
*/
@Data
-@EqualsAndHashCode(callSuper = true)
@TableName("${tableName}")
+@EqualsAndHashCode(callSuper = true)
public class ${className} extends Model<${className}> {
private static final long serialVersionUID = 1L;
diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm b/pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm
index d1ca0db44..b5c347de6 100755
--- a/pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm
+++ b/pigx-visual/pigx-codegen/src/main/resources/template/Service.java.vm
@@ -16,8 +16,6 @@
*/
package ${package}.${moduleName}.service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import ${package}.${moduleName}.entity.${className};
diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm b/pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm
index e0f7181fe..616862dd6 100755
--- a/pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm
+++ b/pigx-visual/pigx-codegen/src/main/resources/template/ServiceImpl.java.vm
@@ -16,10 +16,9 @@
*/
package ${package}.${moduleName}.service.impl;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.mapper.${className}Mapper;
import ${package}.${moduleName}.service.${className}Service;
import org.springframework.stereotype.Service;
diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm b/pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm
index bb76c5b6f..44ac11a3d 100644
--- a/pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm
+++ b/pigx-visual/pigx-codegen/src/main/resources/template/menu.sql.vm
@@ -1,13 +1,13 @@
-- 该脚本不要执行,请完善 ID 对应关系,注意层级关系 !!!!
-- 菜单SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '', '0', '${pathName}', 'icon-bangzhushouji', '菜单ID', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理');
-- 菜单对应按钮SQL
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '菜单ID', null, '${moduleName}_${pathName}_add', '1', null, '1', '子按钮ID1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '菜单ID', null, '${moduleName}_${pathName}_edit', '1', null, '1', '子按钮ID2', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改');
-insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
+insert into `sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '菜单ID', null, '${moduleName}_${pathName}_del', '1', null, '1', '子按钮ID3', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除');