AG-Admin整体说明

AG-Admin是基于Spring Cloud实现的前后端分离的后台管理信息系统,具备用户管理、部门管理、菜单管理等多个模块,支持多业务系统并行开发,可以作为后台管理系统的脚手架。代码简洁,架构清晰,适合学习和直接项目中使用。核心技术采用Eureka、Fegin、Ribbon、Zuul、Hystrix、Security、OAth、Mybatis、Ace-cache等主要框架和中间件,前端采用Layui组件。

模块说明

img

架构详解

监控

利用Spring Boot Admin 来监控各个独立Service的运行状态;利用Hystrix Dashboard来实时查看接口的运行状态和调用频率等。

负载均衡

将服务保留的rest进行代理和网关控制,除了平常经常使用的node.js、nginx外,Spring Cloud系列的zuul和rebbion,可以帮我们进行正常的网关管控和负载均衡。

服务注册与调用

基于Eureka来实现的服务注册与调用,在Spring Cloud中使用Feign, 我们可以做到使用HTTP请求远程服务时能与调用本地方法一样的编码体验,开发者完全感知不到这是远程方法,更感知不到这是个HTTP请求。

熔断机智

因为采取了服务的分布,为了避免服务之间的调用“雪蹦”,我采用了Hystrix的作为熔断器,避免了服务之间的“雪蹦”。


项目结构

├─ace-security
│  │  
│  ├─ace-admin----------------管理端服务层
│  │  
│  ├─ace-gate-----------------网关负载中心
│  │    
│  ├─ace-center---------------服务注册中心
│  │   
│  ├─ace-monitor--------------监控中心
│  │
│  ├─ace-config---------------配置中心
│  │
│  └─ace-api------------------公共服务接口包

AG-Admin启动指南

启动指南

部署须知

运行步骤

运行博客


AG-Admin开发手手册

1. 后端开发流程

举例:用户管理模块开发

服务层

到此完成后端的开发

ui层

至此完成前端页面开发

网关拉通

2. 快速开发技巧

后续会做成代码生成器。

后端

@Service
public class UserBiz extends BaseBiz<UserMapper,User> {
}

// 记得修改requestmapping的对象标志,前端会用
@Controller
@RequestMapping("user")
public class UserController extends BaseController<UserBiz,User> {
    @RequestMapping(value = "/page",method = RequestMethod.GET)
    @ResponseBody
    public TableResultResponse<User> page(@RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1")int offset, String name){
        Example example = new Example(User.class);
        if(StringUtils.isNotBlank(name)) {
            example.createCriteria().andLike("name", "%" + name + "%");
            example.createCriteria().andLike("username", "%" + name + "%");
        }
        int count = baseBiz.selectCountByExample(example);
        PageHelper.startPage(offset, limit);
        return new TableResultResponse<User>(count,baseBiz.selectByExample(example));
    }
}

前端ui

var groupType = {
    baseUrl: "/back/groupType",
    entity: "groupType",
    tableId: "groupTypeTable",
    toolbarId: "toolbar",
    unique: "id",
    order: "asc",
    currentItem: {}
};
变为 ==>
var user = {
    baseUrl: "/back/user",
    entity: "user",
    tableId: "userTable",
    toolbarId: "toolbar",
    unique: "id",
    order: "asc",
    currentItem: {}
};
<script type="text/javascript" src="ag/group/group_type.js"></script>
==>
<script type="text/javascript" src="ag/user/user.js"></script>

3. 页面授权过程