package com.brframework.generate.template; import com.brframework.generate.BaseUtil; import com.brframework.generate.Constant; import com.brframework.generate.base.JavaFile; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * @Author: ljr * @Date: 2019/8/14 17:44 * @Description: */ public class DaoClassFile extends JavaFile { public DaoClassFile(String route, String packageDir, String entity, String function, Map notes) { fileDir = route + "/" + Constant.PACKAGE_DAO + "/" + function; fileName = BaseUtil.getClassWithModule(entity, Constant.MODULE_DAO) + Constant.SUFFIX_CLASS_TYPE; packageDir = BaseUtil.toPackage(packageDir); filePackageName = packageDir + "." + Constant.PACKAGE_DAO + "." + function; type = Constant.INTERFACE_TYPE; name = BaseUtil.getClassWithModule(entity, Constant.MODULE_DAO ); List imports = getImports(packageDir, function, entity); List classAnnotations = getClassAnnotations(); List extendss = getExtendss(entity); List implementss = getImplementss(); List fields = getFields(); List methods = getMethods(); super.init(imports, notes, classAnnotations, extendss, implementss, fields, methods); } public List getImports(String mainPackage, String function, String entity){ List imports = new LinkedList<>(); String commonRepository = "CommonRepository"; imports.add(BaseUtil.getImportName(mainPackage, function, entity, Constant.PACKAGE_ENTITY).toString()); imports.add("com.brframework.commondb.core." + commonRepository); imports.add("org.springframework.stereotype.Repository"); return imports; } public List getClassAnnotations(){ List classAnnotations = new LinkedList<>(); classAnnotations.add("Repository"); return classAnnotations; } public List getExtendss(String entity){ List extendss = new LinkedList<>(); extendss.add("CommonRepository"); return extendss; } public List getImplementss(){ List implementss = new LinkedList<>(); return implementss; } public List getFields(){ List fields = new LinkedList<>(); return fields; } public List getMethods(){ List methods = new LinkedList<>(); //methods,lombok不需要方法 return methods; } }