admin
2021-10-14 932777e9d6dc8dc5d9edbfc9117639ae02d96956
src/main/java/org/yeshi/utils/generater/vo/service/ServiceImplInfoVO.java
@@ -1,16 +1,22 @@
package org.yeshi.utils.generater.vo.service;
import org.springframework.stereotype.Service;
import org.yeshi.utils.FreemarkerUtils;
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 ServiceImplInfoVO extends BaseData {
    private List<String> importList;
    private ClassInfo service;
    private ClassInfo dao;
    //方法列表
@@ -26,6 +32,12 @@
        private ClassInfo service;
        private ClassInfo query;
        private ClassInfo daoQuery;
        private ClassInfo exception;
        public Builder setException(ClassInfo exception) {
            this.exception = exception;
            return this;
        }
        public Builder setEntity(Class entity) {
            this.entity = entity;
@@ -119,7 +131,7 @@
            serviceData.setPackageName(packageName);
            serviceData.setDaoQuery(daoQuery);
            serviceData.setQuery(query);
            List<String> importList = new ArrayList<>();
            //设置接口
            List<ServiceMetodInfoVO> metodInfoVOList = new ArrayList<>();
            /*******添加方法开始*******/
@@ -149,6 +161,13 @@
            params = new ArrayList<>();
            params.add(serviceData.getEntity().getName() + " " + StringUtil.firstCharToLower(serviceData.getEntity().getName()));
            metodInfo = new ServiceMetodInfoVO("public", "void", "add", StringUtil.concat(params, ","));
            if (exception != null) {
                metodInfo.setExceptions(exception.getName());
                importList.add(exception.getClazz());
            } else {
                metodInfo.setExceptions("Exception");
                importList.add(Exception.class.getName());
            }
            metodInfo.setContent(FreemarkerUtils.generateInputStream(serviceData, getClass().getClassLoader().getResourceAsStream(getMethodContentTemplatePath("add"))));
            metodInfoVOList.add(metodInfo);
            //update方法
@@ -165,6 +184,20 @@
            metodInfoVOList.add(metodInfo);
            /*******添加方法结束*******/
            importList.add(Resource.class.getName());
            importList.add(Service.class.getName());
            importList.add(Date.class.getName());
            importList.add(BeanUtil.class.getName());
            importList.add(List.class.getName());
            importList.add(serviceData.getDao().getClazz());
            importList.add(entity.getName());
            importList.add(service.getClazz());
            importList.add(query.getClazz());
            importList.add(daoQuery.getClazz());
            serviceData.setImportList(importList);
            serviceData.setMetodInfoList(metodInfoVOList);
            return serviceData;
        }
@@ -210,5 +243,13 @@
    public void setQuery(ClassInfo query) {
        this.query = query;
    }
    public List<String> getImportList() {
        return importList;
    }
    public void setImportList(List<String> importList) {
        this.importList = importList;
    }
}