4 Star 7 Fork 2

李文亮 / avalon-erp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

avalon-erp

介绍

后端erp快速开发框架,支持springcloud,自动创建数据库,自动关联表等功能

有需要帮助的地方,可以私加我微信liwenliang3623

安装教程

  1. jdk15+
  2. redis
  3. Nacos
  4. Pulsar 消息服务(可选)
  5. Mysql8+/Postgres15+

使用说明

  1. 配置mysql数据库

image-20220831175009159

  1. 配置postgres数据库

image-20240403151720876

  1. 配置redis
image-20220831175342166
  1. 配置nacos
image-20220831175653078
  1. 配置Pulsar 可选 不启用 需要将 enable 设置为false 否则系统无法启动

image-20220831181255511

支持的字段

  1. 基本字段
BigDecimal,BigInteger,Boolean,Date,DateTime,Double,Float,Html,Image,Integer,Selection(Enum),String,Text,Time
  1. 关联字段
One2one,One2many,Many2one,Many2many

模块的基础文件 

有controller控制层,service服务层,model数据层,同时有个需要继承AbstracModule的子类的模块类

image-20220831190648114

controller层:模块提供对外的接口

service层:对应mysql表结果,一个service对应一个表

model层:用于实现特定功能的数据基础类

DemoModule:模块类用于记录当前所有的service,以及描述模块功能等作用

service层

一个service表示一张表,每张表带自带自增主键字段id,name名称字段,creator创建者id,creatTime创建时间,updater更新人,updateTime更新时间

通用接口

新增

Object insert(RecordRow recordRow)

参数为:map 字段名,值

返回值:主键,目前只有IntegerField,BigIntegerField

修改

public Integer update(RecordRow recordRow) throws AvalonException 

参数为:map 字段名,值

返回值:是影响的行数

删除

public Integer delete(Object id) throws AvalonException

参数为:主键

返回值:是影响的行数

获取一条记录

public RecordRow selectOne(String fields, Object id) throws AvalonException

参数:fields,是字段列表 使用逗号隔开

参数:id 是主键

分页获取

public PageInfo selectPage(PageParam pageParam, String fields,
                           String order, Condition condition)

参数:

pageParam:分页参数

fields:字段列表

order:排序 比如 id desc,name

condition:条件

获取全部

public Record select(List<String> fields, Condition condition, String order)

参数:

fields:字段列表

order:排序 比如 id desc,name

condition:条件

统一接口

image-20220904140544494

HomeController

登录

URL: /login 值需要自己添加到数据库中

参数

{
    "username": "admin",
    "password": "123456"
}

返回值

{
    "id": 1,//userId
    "token": "1c59edf9d93840e994e813329b5470db"
}

serviceController

是服务层增删改查的统一入口

新增

需要在POST头部增加token的值,来自登录接口的返回值token

/model/add

image-20220904140929471

参数:

private String serviceName;//服务名 demo.order
private Map<String, Object> value;//键值对

更新

/model/update

image-20220904141003044

参数:

private String serviceName;//服务名 demo.order
private Map<String, Object> value;//键值对 内部需要包含 主键  否则会报错

删除

/model/delete

image-20220904141205482

参数:

 private String serviceName;
 private Integer id;//主键

获取一条记录

/model/get/detail

image-20220904141324889

参数:

 private String fields; // field,field field.field,field
 private String serviceName;
 private Integer id;//主键

获取分页列表

/model/get/page/condition/object

image-20240403150408450

参数:

{
  page:{
    pageNum:1,//第几页
    pageSize:10//一页10
  },
  fields:"字段列表,用逗号隔开",
  "order":"排序,可以为null",
  condition:[
    {
            "name": "id",
            "value": 1,
            "op": "Equal"
    }
  ]
}

DatabaseController

数据库操作

创建表

/db/create/table/{serviceName}

image-20220904142330528

参数: 服务名

删除表

/db/drop/table/{serviceName}

image-20220904142433518

参数:服务名

升级表

/db/update/table/{serviceName}

image-20220904142533747

demo模块

image-20220904222817017

第一步 创建demo.user.detail表

image-20220904222959629

调用新增接口

/model/add

{
    "serviceName": "demo.user.detail",
    "value": {
        "userId": 1,
        "age": 48,
        "weight": 62
    }
}

这里用不到name,可以重载needDefaultNameField方法,并且返回false,不会创建name字段

@Service
public class UserDetailService extends AbstractService {
    @Override
    public String getServiceName() {
        return "demo.user.detail";
    }

    private final Field userId = Fields.createMany2one("用户","base.user");

    private final Field age = Fields.createInteger("年龄");
    private final Field weight = Fields.createFloat("体重");

    @Override
    public Boolean needDefaultNameField() {
        return false;
    }
}

数据库的结果为:

image-20220904223727541

更新接口

url: /model/update

参数:

{
    "serviceName":"demo.user.detail",
    "value":{
        "id":1,
        "age":20
    }
}

数据库结果值

image-20220904224300899

分页获取接口

/model/get/page/condition/high

参数

{
    "serviceName":"demo.user.detail",
    "fields":"id,age,weight,userId.account",
    "page":{
        "pageNum":1,
        "pageSize":10
    },
    "order":"id desc",
    "condition":[
        {
            "name":"userId.account",
            "value":"admin",
            "op":"Equal",
            "connector":"And"
        },
        {
            "name":"userId",
            "value":1,
            "op":"Equal"
        }
    ]

}

返回值:

{
    "total": 1,
    "pageCur": 1,
    "pageSize": 10,
    "pageCount": 1,
    "nextPage": false,
    "prePage": false,
    "data": [
        {
            "userIdAccount": "admin",
            "weight": 62,
            "id": 1,
            "age": 20
        }
    ]
}

删除接口

url: /model/delete

参数

{
    "serviceName":"demo.user.detail",
    "id":1
}

数据库结果

image-20220904225113911

MIT License Copyright (c) 2022 李文亮 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

后端erp快速开发框架 展开 收起
Java 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/ShinraL/avalon-erp.git
git@gitee.com:ShinraL/avalon-erp.git
ShinraL
avalon-erp
avalon-erp
master

搜索帮助