| | |
| | | */ |
| | | String title(); |
| | | |
| | | String serviceCode(); |
| | | |
| | | /** |
| | | * description api |
| | | * @return |
| | |
| | | |
| | | String[] value() default {}; |
| | | |
| | | Class<?> cmdPublishClass(); |
| | | Class<?> cmdDocClass(); |
| | | } |
| New file |
| | |
| | | package com.java110.doc.entity; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class CmdDocDto implements Serializable { |
| | | |
| | | /** |
| | | * api title |
| | | * |
| | | * @return |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * description api |
| | | * |
| | | * @return |
| | | */ |
| | | private String description; |
| | | |
| | | |
| | | /** |
| | | * api version |
| | | * |
| | | * @return |
| | | */ |
| | | private String version; |
| | | |
| | | /** |
| | | * http method |
| | | * |
| | | * @return |
| | | */ |
| | | private String httpMethod; |
| | | |
| | | /** |
| | | * request url |
| | | * |
| | | * @return |
| | | */ |
| | | private String url; |
| | | |
| | | private String resource; |
| | | |
| | | private String author; |
| | | |
| | | private Class<?> cmdClass; |
| | | |
| | | private String serviceCode; |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = title; |
| | | } |
| | | |
| | | public String getDescription() { |
| | | return description; |
| | | } |
| | | |
| | | public void setDescription(String description) { |
| | | this.description = description; |
| | | } |
| | | |
| | | public String getVersion() { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(String version) { |
| | | this.version = version; |
| | | } |
| | | |
| | | public String getHttpMethod() { |
| | | return httpMethod; |
| | | } |
| | | |
| | | public void setHttpMethod(String httpMethod) { |
| | | this.httpMethod = httpMethod; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | public void setUrl(String url) { |
| | | this.url = url; |
| | | } |
| | | |
| | | public String getResource() { |
| | | return resource; |
| | | } |
| | | |
| | | public void setResource(String resource) { |
| | | this.resource = resource; |
| | | } |
| | | |
| | | public String getAuthor() { |
| | | return author; |
| | | } |
| | | |
| | | public void setAuthor(String author) { |
| | | this.author = author; |
| | | } |
| | | |
| | | public Class<?> getCmdClass() { |
| | | return cmdClass; |
| | | } |
| | | |
| | | public void setCmdClass(Class<?> cmdClass) { |
| | | this.cmdClass = cmdClass; |
| | | } |
| | | |
| | | public String getServiceCode() { |
| | | return serviceCode; |
| | | } |
| | | |
| | | public void setServiceCode(String serviceCode) { |
| | | this.serviceCode = serviceCode; |
| | | } |
| | | } |
| | |
| | | package com.java110.doc.registrar; |
| | | |
| | | import com.java110.doc.entity.CmdDocDto; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | /** |
| | | * 保存cmdDocs |
| | | */ |
| | | private static final List<Map> cmdDocs = new ArrayList<Map>(); |
| | | private static final List<CmdDocDto> cmdDocs = new ArrayList<CmdDocDto>(); |
| | | |
| | | /** |
| | | * 添加cmd文档 |
| | | * |
| | | * @param doc |
| | | */ |
| | | public static void addCmdDoc(Map doc) { |
| | | public static void addCmdDoc(CmdDocDto doc) { |
| | | cmdDocs.add(doc); |
| | | } |
| | | } |
| | |
| | | AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent; |
| | | AnnotationMetadata annotationMetadata = beanDefinition.getMetadata(); |
| | | |
| | | |
| | | Map<String, Object> attributes = annotationMetadata |
| | | .getAnnotationAttributes( |
| | | Java110ApiDoc.class.getCanonicalName()); |
| | |
| | | package com.java110.doc.registrar; |
| | | |
| | | import com.java110.doc.annotation.Java110ApiDoc; |
| | | import com.java110.doc.annotation.Java110CmdDoc; |
| | | import com.java110.doc.annotation.Java110CmdDocDiscovery; |
| | | import com.java110.doc.entity.CmdDocDto; |
| | | import org.springframework.beans.factory.BeanClassLoaderAware; |
| | | import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; |
| | | import org.springframework.beans.factory.config.BeanDefinition; |
| | |
| | | * api 文档 注入类 |
| | | * Created by wuxw on 2018/7/2. |
| | | */ |
| | | public class Java110CmdDocDiscoveryRegistrar implements ImportBeanDefinitionRegistrar,ResourceLoaderAware, BeanClassLoaderAware { |
| | | public class Java110CmdDocDiscoveryRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware, BeanClassLoaderAware { |
| | | |
| | | private ResourceLoader resourceLoader; |
| | | |
| | | private ClassLoader classLoader; |
| | | |
| | | public Java110CmdDocDiscoveryRegistrar(){ |
| | | public Java110CmdDocDiscoveryRegistrar() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { |
| | | try { |
| | | registerListener(importingClassMetadata,registry); |
| | | registerListener(importingClassMetadata, registry); |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } catch (InvocationTargetException e) { |
| | |
| | | |
| | | /** |
| | | * 注册侦听 |
| | | * |
| | | * @param metadata |
| | | * @param registry |
| | | */ |
| | |
| | | Map<String, Object> attrs = metadata |
| | | .getAnnotationAttributes(Java110CmdDocDiscovery.class.getName()); |
| | | |
| | | Object cmdPublishClassObj = attrs.get("cmdPublishClass"); |
| | | Object cmdPublishClassObj = attrs.get("cmdDocClass"); |
| | | |
| | | //Assert.notNull(cmdPublishClassObj,"Java110CmdDiscovery 没有配置 cmdPublishClass 属性"); |
| | | |
| | | Class<?> cmdPublishClass = (Class<?>) cmdPublishClassObj; |
| | | |
| | | AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter( |
| | | Java110ApiDoc.class); |
| | | Java110CmdDoc.class); |
| | | |
| | | scanner.addIncludeFilter(annotationTypeFilter); |
| | | basePackages = getBasePackages(metadata); |
| | |
| | | AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent; |
| | | AnnotationMetadata annotationMetadata = beanDefinition.getMetadata(); |
| | | |
| | | |
| | | Map<String, Object> attributes = annotationMetadata |
| | | .getAnnotationAttributes( |
| | | Java110CmdDoc.class.getCanonicalName()); |
| | | |
| | | String beanName = getListenerName(attributes,beanDefinition); |
| | | String serviceCode = attributes.get("serviceCode").toString(); |
| | | String beanName = getListenerName(attributes, beanDefinition); |
| | | CmdDocDto cmdDocDto = new CmdDocDto(); |
| | | cmdDocDto.setCmdClass(candidateComponent.getClass()); |
| | | cmdDocDto.setDescription(attributes.get("description").toString()); |
| | | cmdDocDto.setAuthor(attributes.get("author").toString()); |
| | | cmdDocDto.setResource(attributes.get("resource").toString()); |
| | | cmdDocDto.setTitle(attributes.get("title").toString()); |
| | | cmdDocDto.setUrl(attributes.get("url").toString()); |
| | | cmdDocDto.setVersion(attributes.get("version").toString()); |
| | | cmdDocDto.setHttpMethod(attributes.get("httpMethod").toString()); |
| | | cmdDocDto.setServiceCode(attributes.get("serviceCode").toString()); |
| | | |
| | | |
| | | /*BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(beanDefinition, beanName); |
| | | BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry);*/ |
| | | // Method method = cmdPublishClass.getMethod("addListener", CmdListenerDto.class); |
| | | // method.invoke(null,new CmdListenerDto(beanName,serviceCode)); |
| | | Method method = cmdPublishClass.getMethod("addCmdDoc", CmdDocDto.class); |
| | | method.invoke(null, cmdDocDto); |
| | | } |
| | | } |
| | | } |
| | |
| | | beanDefinition.getMetadata().getClassName(), |
| | | Java110CmdDocDiscoveryRegistrar.this.classLoader); |
| | | return !target.isAnnotation(); |
| | | } |
| | | catch (Exception ex) { |
| | | } catch (Exception ex) { |
| | | this.logger.error( |
| | | "Could not load target class: " |
| | | + beanDefinition.getMetadata().getClassName(), |
| | |
| | | |
| | | /** |
| | | * 获取名称 |
| | | * |
| | | * @param listeners |
| | | * @param beanDefinition |
| | | * @return |
| | | */ |
| | | private String getListenerName(Map<String, Object> listeners,AnnotatedBeanDefinition beanDefinition) { |
| | | private String getListenerName(Map<String, Object> listeners, AnnotatedBeanDefinition beanDefinition) { |
| | | if (listeners == null) { |
| | | String shortClassName = ClassUtils.getShortName(beanDefinition.getBeanClassName()); |
| | | return Introspector.decapitalize(shortClassName); |
| | |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.event.cmd.ServiceCmdEventPublishing; |
| | | import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing; |
| | | import com.java110.doc.annotation.Java110ApiDocDiscovery; |
| | | import com.java110.doc.annotation.Java110CmdDocDiscovery; |
| | | import com.java110.doc.registrar.ApiDocCmdPublishing; |
| | | import com.java110.doc.registrar.ApiDocPublishing; |
| | | import com.java110.service.init.ServiceStartInit; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | |
| | | basePackages = {"com.java110.acct.cmd"}) |
| | | @EnableFeignClients(basePackages = {"com.java110.intf.community","com.java110.intf.common","com.java110.intf.store", |
| | | "com.java110.intf.fee","com.java110.intf.order","com.java110.intf.user"}) |
| | | |
| | | //文档 |
| | | @Java110CmdDocDiscovery(basePackages = {"com.java110.acct.cmd"},cmdDocClass = ApiDocCmdPublishing.class) |
| | | public class AcctServiceApplicationStart { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(AcctServiceApplicationStart.class); |
| | |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.event.cmd.ServiceCmdEventPublishing; |
| | | import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing; |
| | | import com.java110.doc.annotation.Java110CmdDocDiscovery; |
| | | import com.java110.doc.registrar.ApiDocCmdPublishing; |
| | | import com.java110.service.init.ServiceStartInit; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | |
| | | basePackages = {"com.java110.user.cmd"}) |
| | | @EnableFeignClients(basePackages = {"com.java110.intf.community","com.java110.intf.common","com.java110.intf.store", |
| | | "com.java110.intf.fee","com.java110.intf.order"}) |
| | | |
| | | // 文档 |
| | | @Java110CmdDocDiscovery(basePackages = {"com.java110.user.cmd"},cmdDocClass = ApiDocCmdPublishing.class) |
| | | public class UserServiceApplicationStart { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(UserServiceApplicationStart.class); |
| | |
| | | description = "登录功能 主要用于 员工 或者管理员登录使用", |
| | | httpMethod = "post", |
| | | url = "/app/login.pcUserLogin", |
| | | resource = "user", |
| | | author = "吴学文" |
| | | resource = "userDoc", |
| | | author = "吴学文", |
| | | serviceCode = "login.pcUserLogin" |
| | | ) |
| | | |
| | | @Java110ParamsDoc(params = { |
| | |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.core.trace.Java110FeignClientInterceptor; |
| | | import com.java110.core.trace.Java110RestTemplateInterceptor; |
| | | import com.java110.doc.annotation.Java110ApiDocDiscovery; |
| | | import com.java110.doc.annotation.Java110CmdDocDiscovery; |
| | | import com.java110.doc.registrar.ApiDocCmdPublishing; |
| | | import com.java110.doc.registrar.ApiDocPublishing; |
| | | import com.java110.intf.dev.ICacheV1InnerServiceSMO; |
| | | import com.java110.service.init.ServiceStartInit; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | |
| | | "com.java110.user.cmd" |
| | | }) |
| | | @EnableAsync |
| | | //文档 |
| | | @Java110ApiDocDiscovery(basePackages = {"com.java110.api.rest"},apiDocClass = ApiDocPublishing.class) |
| | | @Java110CmdDocDiscovery(basePackages = { |
| | | "com.java110.acct.cmd", |
| | | "com.java110.common.cmd", |
| | | "com.java110.community.cmd", |
| | | "com.java110.dev.cmd", |
| | | "com.java110.fee.cmd", |
| | | "com.java110.job.cmd", |
| | | "com.java110.oa.cmd", |
| | | "com.java110.order.cmd", |
| | | "com.java110.report.cmd", |
| | | "com.java110.store.cmd", |
| | | "com.java110.user.cmd" |
| | | }, |
| | | cmdDocClass = ApiDocCmdPublishing.class) |
| | | public class BootApplicationStart { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(BootApplicationStart.class); |
| | |
| | | import com.java110.boot.smo.IApiServiceSMO; |
| | | import com.java110.core.base.controller.BaseController; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.doc.annotation.Java110ApiDoc; |
| | | import com.java110.doc.annotation.Java110RequestMappingDoc; |
| | | import com.java110.doc.annotation.Java110RequestMappingsDoc; |
| | | import com.java110.intf.user.IUserInnerServiceSMO; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.vo.ResultVo; |
| | |
| | | @RestController |
| | | @RequestMapping(path = "/api") |
| | | @Api(value = "对外统一提供服务接口服务") |
| | | @Java110ApiDoc( |
| | | title = "HC小区管理系统api接口文档", |
| | | description = "HC小区管理系统api接口文档", |
| | | company="Java110工作室", |
| | | version = "v1.4" |
| | | ) |
| | | |
| | | @Java110RequestMappingsDoc( |
| | | mappingsDocs = { |
| | | @Java110RequestMappingDoc(name="用户中心",resource = "user",url="http://127.0.0.1:8008/userDoc",seq = 1), |
| | | @Java110RequestMappingDoc(name="账户中心",resource = "acct",url="http://127.0.0.1:8008/acctDoc",seq = 2), |
| | | @Java110RequestMappingDoc(name="通用中心",resource = "common",url="http://127.0.0.1:8008/commonDoc",seq = 3), |
| | | @Java110RequestMappingDoc(name="小区中心",resource = "community",url="http://127.0.0.1:8008/communityDoc",seq = 4), |
| | | @Java110RequestMappingDoc(name="开发中心",resource = "dev",url="http://127.0.0.1:8008/devDoc",seq = 5), |
| | | @Java110RequestMappingDoc(name="费用中心",resource = "fee",url="http://127.0.0.1:8008/feeDoc",seq = 6), |
| | | @Java110RequestMappingDoc(name="定时任务",resource = "job",url="http://127.0.0.1:8008/jobDoc",seq = 7), |
| | | @Java110RequestMappingDoc(name="oa",resource = "oa",url="http://127.0.0.1:8008/oaDoc",seq = 8), |
| | | @Java110RequestMappingDoc(name="订单中心",resource = "order",url="http://127.0.0.1:8008/orderDoc",seq = 9), |
| | | @Java110RequestMappingDoc(name="报表中心",resource = "report",url="http://127.0.0.1:8008/reportDoc",seq = 10), |
| | | @Java110RequestMappingDoc(name="商户中心",resource = "store",url="http://127.0.0.1:8008/storeDoc",seq = 11), |
| | | } |
| | | ) |
| | | public class RestApi extends BaseController { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(RestApi.class); |