refactor(jpa): 将 Helper 类重命名为 DatabaseHelper 并调整包结构
- 将 Helper 类从 com.lanyuanxiaoyao.service.template.jpa 包迁移至 helper 子包 - 重命名类名为 DatabaseHelper 以更准确地表达其功能 - 同步更新测试类中的引用和类名使用
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.template.jpa;
|
||||
package com.lanyuanxiaoyao.service.template.jpa.helper;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import java.io.IOException;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
*/
|
||||
public class Helper {
|
||||
public class DatabaseHelper {
|
||||
public static void generateDDL(
|
||||
Set<String> entityPackages,
|
||||
String ddlFilePath,
|
||||
@@ -65,7 +65,7 @@ public class Helper {
|
||||
|
||||
for (String className : scanEntityPackage(entityPackages)) {
|
||||
try {
|
||||
var entityClass = ClassUtils.forName(className, Helper.class.getClassLoader());
|
||||
var entityClass = ClassUtils.forName(className, DatabaseHelper.class.getClassLoader());
|
||||
metadataSources.addAnnotatedClass(entityClass);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Failed to load entity class: " + className, e);
|
||||
@@ -106,7 +106,7 @@ public class Helper {
|
||||
public static void generateBasicFiles(Set<String> entityPackages, String projectRootPackage, String projectRootPath, boolean override) throws IOException {
|
||||
for (String className : scanEntityPackage(entityPackages)) {
|
||||
try {
|
||||
var entityClass = ClassUtils.forName(className, Helper.class.getClassLoader());
|
||||
var entityClass = ClassUtils.forName(className, DatabaseHelper.class.getClassLoader());
|
||||
var name = entityClass.getSimpleName();
|
||||
|
||||
// Repository
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lanyuanxiaoyao.service.template.jpa;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.jpa.helper.DatabaseHelper;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -18,7 +19,7 @@ public class HelperTest {
|
||||
|
||||
public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
// 通过反射调用Helper类中的private静态方法camelConvert
|
||||
var camelConvert = Helper.class.getDeclaredMethod("camelConvert", String.class);
|
||||
var camelConvert = DatabaseHelper.class.getDeclaredMethod("camelConvert", String.class);
|
||||
camelConvert.setAccessible(true);
|
||||
|
||||
// 测试用例集合
|
||||
|
||||
Reference in New Issue
Block a user