| | |
| | | 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; |
| | | //方法列表 |
| | |
| | | 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; |
| | |
| | | serviceData.setPackageName(packageName); |
| | | serviceData.setDaoQuery(daoQuery); |
| | | serviceData.setQuery(query); |
| | | |
| | | List<String> importList = new ArrayList<>(); |
| | | //设置接口 |
| | | List<ServiceMetodInfoVO> metodInfoVOList = new ArrayList<>(); |
| | | /*******添加方法开始*******/ |
| | |
| | | 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方法 |
| | |
| | | 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; |
| | | } |
| | |
| | | public void setQuery(ClassInfo query) { |
| | | this.query = query; |
| | | } |
| | | |
| | | public List<String> getImportList() { |
| | | return importList; |
| | | } |
| | | |
| | | public void setImportList(List<String> importList) { |
| | | this.importList = importList; |
| | | } |
| | | } |
| | | |