同步操作将从 yuboon/Aooms 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
极速微服务开发,像JFinal一样简单
一款基于SpringCloud的微服务基础开发平台,旨在降低SpringCloud的复杂度,像使用JFinal一样简单(本人是JFinal用户,从1.9版本开始现在也一直在使用,因此部分实现思路会借鉴JFinal的一些模式,感谢@JFinal作者波总提供这么优秀的框架),包含微服务相关的完整解决方案同时附加有权限管理、报表自定义、工作流、Cms等套件,可直接使用,Aooms基于Apache Licence 2.0开源协议,关于编写此框架的一些初衷,可通过此处诞生了解。
package net.aooms.example.controller;
import net.aooms.core.web.AoomsAbstractController;
import net.aooms.example.vo.UserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
/**
* HelloWorld
* Created by 风象南(cheereebo) on 2018-09-12
*/
@RestController
public class HelloWorldController extends AoomsAbstractController {
/**
* 基础访问
*/
@RequestMapping("/hello")
public void hello(){
String str = "hello world !";
this.renderText(str);
};
/**
* 获取基本参数
*/
@RequestMapping("/hello2")
public void hello2(){
String id = getParaString("id");
logger.info("id = {}" , id);
this.renderText(id);
};
/**
* 获取路径参数
*/
@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(); 也可省略不写,默认会使用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("<html><h1>标题</h1> <script>alert('hello world !');</script> </html>");
};
/**
* 模版页面输出
* @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");
};
}
package net.aooms.example.controller;
import net.aooms.core.web.AoomsAbstractController;
import net.aooms.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* simple crud
* Created by 风象南(cheereebo) on 2018-09-12
*/
@RestController
public class CRUDController extends AoomsAbstractController {
@Autowired
private UserService userService;
/**
* 查询
* @return
*/
@RequestMapping("/findList")
public void findList(){
userService.findList();
};
/**
* 新增
* @return
*/
@RequestMapping("/insert")
public void insert(){
userService.insert();
};
/**
* 修改
* @return
*/
@RequestMapping("/update")
public void update(){
userService.update();
};
/**
* 删除
* @return
*/
@RequestMapping("/delete")
public void delete(){
userService.delete();
};
}
package net.aooms.example.service;
import net.aooms.core.AoomsConstants;
import net.aooms.core.id.IDGenerator;
import net.aooms.core.module.mybatis.Db;
import net.aooms.core.module.mybatis.SqlPara;
import net.aooms.core.record.PagingRecord;
import net.aooms.core.record.Record;
import net.aooms.core.service.GenericService;
import net.aooms.example.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* simple crud service
* Created by 风象南(cheereebo) on 2018-09-17
*/
@Service
public class UserService extends GenericService {
@Autowired
private Db db;
public void findList() {
PagingRecord pagingRecord = db.findList("UserMapper.findList", SqlPara.fromDataBoss());
{
// 返回值
this.setResultValue(AoomsConstants.Result.DATA,pagingRecord);
}
}
@Transactional
public void insert() {
// record 模式
Record record1 = Record.NEW();
record1.set(AoomsConstants.ID,IDGenerator.getLongValue());
record1.set("name","lisi3");
db.insert("user",record1);
UserVo userVo = new UserVo();
userVo.setId(IDGenerator.getLongValue());
userVo.setName("wangwu");
Record record2 = Record.NEW().fromBean(userVo);
// fromDataBoss(prefix) 该方法可将参数 满足model.xxx 规则的参数构造成record属性
// 例:http://xxx/insert?record.id=1&record.name=zhangsan&model.role=3&code=02,
// 通过 fromDataBoss 将提取id,name,role三个属性的值,不会提取code值
record2.fromDataBoss("model"); // model为参数prefix 格式:model.role , 将会通过model取到role值
db.insert("user",record2);
}
@Transactional
public void update() {
// record 模式
Record record = db.findByPrimaryKey("user","root");
if(record != null){
record.set("name","zhaoliu");
db.update("user",record);
}
}
@Transactional
public void delete() {
db.deleteByPrimaryKey("user","root1");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="UserMapper">
<!-- 二级缓存 -->
<cache type="net.aooms.core.module.mybatis.J2CacheSupport" eviction="LRU" flushInterval="60000" size="512" readOnly="true"/>
<sql id="columns">
id,name
</sql>
<select id="findList" resultType="net.aooms.core.record.Record">
SELECT <include refid="columns" /> FROM USER
</select>
<select id="updateById" resultType="int">
update user set name = '123' where id = #{id}
</select>
<select id="findAll" resultType="net.aooms.core.record.Record">
select * from t_order
</select>
</mapper>
https://my.oschina.net/cccyb?tab=newest&catalogId=5736543 持续关注,不定期会有更新
关于框架的一点声明,框架目前处于开发阶段,会不定期更新码云上的代码同时会有系统博客同步更新,另外此项目是带有学习性质的摸索、尝试,是为了给想学习微服务的人一个学习上的帮助,大家一起学习、探讨,感受一个微服务开发平台从0到诞生的过程,因为可能有的人想学但没有方向又或者所在公司技术体系比较老,不具备微服务的学习环境,所以构建了该工程,希望能帮到一些人同时对我自己也是一次锻炼,预计2018年底会有版本发出,供大家完整的参考。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。