Aooms基于 Spring Cloud 的微服務(wù)基礎(chǔ)開發(fā)平臺(tái)
Aooms —— 基于SpringCloud的微服務(wù)基礎(chǔ)開發(fā)平臺(tái)
極速微服務(wù)開發(fā),不止像JFinal一樣簡(jiǎn)單
一、介紹
一款基于SpringCloud的微服務(wù)基礎(chǔ)開發(fā)平臺(tái),旨在降低SpringCloud的復(fù)雜度,像使用JFinal一樣簡(jiǎn)單,但又包含整體解決方案(本人是JFinal用戶,從1.9版本開始現(xiàn)在也一直在使用,因此部分實(shí)現(xiàn)思路會(huì)借鑒JFinal的一些模式,感謝@JFinal作者波總提供這么優(yōu)秀的框架),包含微服務(wù)相關(guān)的完整解決方案同時(shí)附加有權(quán)限管理、報(bào)表自定義、工作流、Cms等套件,可直接使用,Aooms基于Apache Licence 2.0開源協(xié)議,關(guān)于編寫此框架的一些初衷,可通過(guò)此處誕生了解。
演示地址:https://www.yuboon.com/Aooms 服務(wù)器配置有限,請(qǐng)勿壓測(cè)X3,重要的事情說(shuō)三遍
文檔地址:待完善
碼云地址:https://gitee.com/cyb-javaer/Aooms
Github地址:https://github.com/yuboon/Aooms
二、核心功能
(1)極簡(jiǎn)Controller
(2)基于sharding-sphere的多數(shù)據(jù)源支持
(3)基于Mybatis 實(shí)現(xiàn)的 Db + Record 極簡(jiǎn)模式,附帶物理分頁(yè)實(shí)現(xiàn)
(4)基于Consul的服務(wù)注冊(cè)、發(fā)現(xiàn)
(5)服務(wù)熔斷、限流、降級(jí)
(6)服務(wù)客戶端、http客戶端
(7)內(nèi)置各種ID生成器(UUID、snowflake)
(8)穿透一切的數(shù)據(jù)對(duì)象DataBoss
(9)基于J2Cache的緩存
(10) 其他更多功能,等你發(fā)現(xiàn).......
二、內(nèi)置集成系統(tǒng)
(1)權(quán)限管理 (實(shí)現(xiàn)中,基本完成)
(2)內(nèi)容管理系統(tǒng)(規(guī)劃中)
(3)報(bào)表系統(tǒng)(規(guī)劃中)
(4)工作流系統(tǒng)(規(guī)劃中)
(5)微信公眾號(hào)(規(guī)劃中)
(6)..............
三、界面預(yù)覽
四、簡(jiǎn)單Demo
1. Hello World
@RestController
public class HelloWorldController extends AoomsAbstractController {
/**
* 基礎(chǔ)訪問(wèn)
*/
@RequestMapping("/hello")
public void hello(){
String str = "hello world !";
this.renderText(str);
};
/**
* 獲取基本參數(shù)
*/
@RequestMapping("/hello2")
public void hello2(){
String id = getParaString("id");
logger.info("id = {}" , id);
this.renderText(id);
};
/**
* 獲取路徑參數(shù)
*/
@RequestMapping("/hello/{id}")
public void hello3(){
String id = getPathString("id");
logger.info("id = {}" , id);
this.renderText(id);
};
/**
* 上傳文件
*/
@RequestMapping("/hello4")
public void hello4(){
MultipartFile multipartFile = this.getParaFile("upload");
logger.info("fileName = {}", multipartFile.getName());
this.renderText("success");
};
/**
* json輸出
*/
@RequestMapping("/hello5")
public void hello5(){
UserVo userVo = new UserVo();
userVo.setName("zhangsan");
setResultValue("userVo",userVo);
// 輸出json
this.renderJson();
// this.renderJson(); 也可省略不寫,默認(rèn)會(huì)使用JSONRender
};
/**
* json輸出
*/
@RequestMapping("/hello6")
public void hello6(){
UserVo userVo = new UserVo();
userVo.setName("zhangsan");
this.renderJson(userVo);
};
/**
* 文件下載
*/
@RequestMapping("/hello7")
public void hello7(){
this.renderFile("application.yml", this.getClass().getResourceAsStream("/application.yml"));
};
/**
* 圖片輸出
* @return
*/
@RequestMapping("/hello8")
public void hello8(){
this.renderImage("F:/1.png","F:/default.png");
};
/**
* html輸出
* @return
*/
@RequestMapping("/hello9")
public void hello9(){
this.renderHtml("標(biāo)題 alert('hello world !'); ");
};
/**
* 模版頁(yè)面輸出
* @return
*/
@RequestMapping("/hello10")
public void hello10(){
ModelAndView mv = new ModelAndView();
mv.addObject("name","lisi");
mv.setViewName("/demo.html");
this.renderThymeleaf(mv);
};
/**
* 重定向
* @return
*/
@GetMapping("/hello11")
public void hello11(){
this.redirect("https://www.oschina.net");
};
}
2. 用戶管理示例
@RestController
@RequestMapping("/user")
public class UserController extends AoomsAbstractController {
@Autowired
private UserService userService;
@RequestMapping("/findList")
public void findList(){
userService.findList();
};
@RequestMapping("/insert")
public void insert(){
userService.insert();
};
@RequestMapping("/update")
public void update(){
userService.update();
};
@RequestMapping("/delete")
public void delete(){
userService.delete();
};
}
@Service
public class UserService extends GenericService {
@Autowired
private Db db;
public void findList() {
this.setResultValue(AoomsVar.RS_DATA, db.findRecords("UserMapper.findList", SqlPara.SINGLETON));
}
@Transactional
public void insert() {
Record user = Record.empty().setByJsonKey("form");
db.insert("t_user",user);
}
@Transactional
public void update() {
Record user = Record.empty().setByJsonKey("form");
db.update("t_user",user);
}
@Transactional
public void delete() {
db.deleteByPrimaryKey("t_user",getParaString("id"));
}
}
五、框架的一點(diǎn)聲明
關(guān)于框架的一點(diǎn)聲明,框架目前處于開發(fā)階段,會(huì)不定期更新碼云上的代碼同時(shí)會(huì)有系統(tǒng)博客同步更新,另外此項(xiàng)目是帶有學(xué)習(xí)性質(zhì)的摸索、嘗試,是為了給想學(xué)習(xí)微服務(wù)的人一個(gè)學(xué)習(xí)上的幫助,大家一起學(xué)習(xí)、探討,感受一個(gè)微服務(wù)開發(fā)平臺(tái)從0到誕生的過(guò)程,因?yàn)榭赡苡械娜讼雽W(xué)但沒(méi)有方向又或者所在公司技術(shù)體系比較老,不具備微服務(wù)的學(xué)習(xí)環(huán)境,所以構(gòu)建了該工程,希望能幫到一些人同時(shí)對(duì)我自己也是一次鍛煉,預(yù)計(jì)2018年底會(huì)有版本發(fā)出,供大家完整的參考。
