From fac5d01bfcddfc8edef0a5fd3d401b1fe383fe16 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 29 三月 2022 16:48:15 +0800
Subject: [PATCH] 采用配置文件自动化生成代码

---
 src/main/java/org/yeshi/utils/generater/vo/service/ServiceInfoVO.java |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/yeshi/utils/generater/vo/service/ServiceInfoVO.java b/src/main/java/org/yeshi/utils/generater/vo/service/ServiceInfoVO.java
index 39c3b29..3374de1 100644
--- a/src/main/java/org/yeshi/utils/generater/vo/service/ServiceInfoVO.java
+++ b/src/main/java/org/yeshi/utils/generater/vo/service/ServiceInfoVO.java
@@ -1,15 +1,20 @@
 package org.yeshi.utils.generater.vo.service;
 
+import org.springframework.stereotype.Service;
 import org.yeshi.utils.StringUtil;
+import org.yeshi.utils.bean.BeanUtil;
 import org.yeshi.utils.generater.entity.BaseData;
 import org.yeshi.utils.generater.entity.ClassInfo;
 import org.yeshi.utils.generater.util.EntityUtil;
 
+import javax.annotation.Resource;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 public class ServiceInfoVO extends BaseData {
+    private List<String> importList;
     private ClassInfo service;
     //鏂规硶鍒楄〃
     private List<ServiceMetodInfoVO> metodInfoList;
@@ -21,6 +26,7 @@
         private String packageName;
         private ClassInfo service;
         private ClassInfo query;
+        private ClassInfo exception;
 
 
         public Builder setEntity(Class entity) {
@@ -43,6 +49,10 @@
             return this;
         }
 
+        public Builder setException(ClassInfo exception) {
+            this.exception = exception;
+            return this;
+        }
 
         private String getRemarksLine(String content) {
             return "\t * " + content + "\n";
@@ -98,6 +108,7 @@
             serviceData.setQuery(query);
             //璁剧疆鎺ュ彛
             List<ServiceMetodInfoVO> metodInfoVOList = new ArrayList<>();
+            List<String> importList = new ArrayList<>();
             /*******娣诲姞鏂规硶寮�濮�*******/
             List<String> params = null;
             ServiceMetodInfoVO metodInfo = null;
@@ -121,12 +132,20 @@
             params.add(identifyId.getType().getSimpleName() + " id");
             metodInfo = new ServiceMetodInfoVO("public", serviceData.getEntity().getName(), "get", StringUtil.concat(params, ","));
             metodInfo.setNote(getMethodRemarks("get"));
+
             metodInfoVOList.add(metodInfo);
             //add鏂规硶
             params = new ArrayList<>();
             params.add(serviceData.getEntity().getName() + " " + StringUtil.firstCharToLower(serviceData.getEntity().getName()));
             metodInfo = new ServiceMetodInfoVO("public", "void", "add", StringUtil.concat(params, ","));
             metodInfo.setNote(getMethodRemarks("add"));
+            if (exception != null) {
+                metodInfo.setExceptions(exception.getName());
+                importList.add(exception.getClazz());
+            } else {
+                metodInfo.setExceptions("Exception");
+                importList.add(Exception.class.getName());
+            }
             metodInfoVOList.add(metodInfo);
             //update鏂规硶
             params = new ArrayList<>();
@@ -143,6 +162,17 @@
 
             /*******娣诲姞鏂规硶缁撴潫*******/
             serviceData.setMetodInfoList(metodInfoVOList);
+
+
+            importList.add(Resource.class.getName());
+            importList.add(Date.class.getName());
+            importList.add(BeanUtil.class.getName());
+            importList.add(List.class.getName());
+            importList.add(entity.getName());
+            importList.add(service.getClazz());
+            importList.add(query.getClazz());
+
+            serviceData.setImportList(importList);
 
             return serviceData;
         }
@@ -172,4 +202,12 @@
     public void setQuery(ClassInfo query) {
         this.query = query;
     }
+
+    public List<String> getImportList() {
+        return importList;
+    }
+
+    public void setImportList(List<String> importList) {
+        this.importList = importList;
+    }
 }

--
Gitblit v1.8.0