# rapid-spring **Repository Path**: woostju/rapid-spring ## Basic Information - **Project Name**: rapid-spring - **Description**: A framework to build app rapidly - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-13 - **Last Updated**: 2023-09-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ##来自作者发自肺腑的warning - rapid-spring框架的初衷是加快新项目的构建,及业务代码的编写 - rapid-spring是通用型框架,别加入业务项目相关的功能进来,要抽象,抽象,抽象 - rapid-spring中不要引用springboot框架,不然不能兼容spring-mvc - 以引用包的方式来使用框架,不要copy代码,不然最后将导致框架维护难度加大 - 版本控制要控制好,利用好git的branch和tag,做好API的兼容性 - 添加新功能的时候,尽可能用RapidProperties来控制是否打开该功能 (例如不需要scheduleservice,就不要启用,不然将开启线程池消费job) - 尽可能专人维护,API设计要简单,别让人思考太多,将复杂性封装在框架内 ##Usage 1. Add dependency in your maven pom: ``` com.github.bryx rapid-spring 1.0.2 ``` 2. Init db with scripts: - rapid.mysql.create.sql 3. register Spring Bean - configure RapidProperties ``` @Bean RapidProperties rapidProperties(ApplicationContext applicationContext){ Integer port = applicationContext.getEnvironment().getProperty("server.port", Integer.class); RapidProperties rapidProperties = new RapidProperties(); rapidProperties.setDbType(RapidProperties.DbType.MYSQL); rapidProperties.getDistributedEventConfig().setIdentifier("server-"+port); rapidProperties.getDistributedEventConfig().setGroup("group"+ port/100); rapidProperties.setStoragePath("/Users/jameswu/Documents/storage"); rapidProperties.setScheduleEnabled(true); return rapidProperties; } ``` - scan package com.github.bryx.rapid ``` @SpringBootApplication(scanBasePackages = {"com.github.bryx.rapid"}) ``` ##features 1. 用户部门及RBAC权限控制 - 用户系统 - 部门可以是组和组织机构,用户可以添加到Department中 - 角色绑定权限和用户,系统可根据用户具备的权限进行控制,不推荐直接使用角色控制 - 使用@PreAuthorize注解,控制方法的使用权限 2. 分布式消息组件 - 基于rabbitmq的分布式消息组件, 消息的消费确认模式请配置为manual - 只有在spring bean中注册了@DistributedEventListener注解的应用才会启用 - 通过分组的概念将多个应用组织起来,发送消息时,可发送到组内所有应用或组内一个应用 - 消息没处理完,不会被确认掉,确保消息一定会被消费。请确保listener方法的执行幂等性 3. 引用对象组件 - 返回给前端一个简单对象 - 简单对象引用的对象通过引用对象返回 4. 统一的web api接口 - 通过在springbean的方法上添加注解@WebEndpoint即可暴露接口 - 通过WebEndpointController暴露接口 5. 操作审计 - 通过注解@ActionAudit对方法进行审计,还可传入skipAudit参数来脱敏参数 - domain和action可以使用spel表达式获取参数的值 6. 统一的存储服务 - 前端upload文件获取文件id - 前端通过GET /api/rapid/storage/{id}下载文件 - 文件支持有效时间,系统可清理过期了的文件 7. 类型转换服务 - 使用TypeService, 在不同类型间进行转换 8. 调度服务 - 使用scheduleService, 创建Timer和Cron类型的任务 - 使用@ScheduleJobListener来执行响应的任务 9. spel表达式封装 - ExpressionEvaluator对spel进行封装,用起来更加简单 ##TO-DO: 1. add index on database table 2. query endpoint on storage 3. query endpoint on Schedule Job and Job Record