后端erp快速开发框架,支持springcloud,自动创建数据库,自动关联表等功能
有需要帮助的地方,可以私加我微信liwenliang3623
BigDecimal,BigInteger,Boolean,Date,DateTime,Double,Float,Html,Image,Integer,Selection(Enum),String,Text,Time
One2one,One2many,Many2one,Many2many
有controller控制层,service服务层,model数据层,同时有个需要继承AbstracModule的子类的模块类
controller层:模块提供对外的接口
service层:对应mysql表结果,一个service对应一个表
model层:用于实现特定功能的数据基础类
DemoModule:模块类用于记录当前所有的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:条件
URL: /login 值需要自己添加到数据库中
参数
{
"username": "admin",
"password": "123456"
}
返回值
{
"id": 1,//userId
"token": "1c59edf9d93840e994e813329b5470db"
}
是服务层增删改查的统一入口
需要在POST头部增加token的值,来自登录接口的返回值token
/model/add
参数:
private String serviceName;//服务名 demo.order
private Map<String, Object> value;//键值对
/model/update
参数:
private String serviceName;//服务名 demo.order
private Map<String, Object> value;//键值对 内部需要包含 主键 否则会报错
/model/delete
参数:
private String serviceName;
private Integer id;//主键
/model/get/detail
参数:
private String fields; // field,field field.field,field
private String serviceName;
private Integer id;//主键
/model/get/page/condition/object
参数:
{
page:{
pageNum:1,//第几页
pageSize:10//一页10条
},
fields:"字段列表,用逗号隔开",
"order":"排序,可以为null",
condition:[
{
"name": "id",
"value": 1,
"op": "Equal"
}
]
}
数据库操作
/db/create/table/{serviceName}
参数: 服务名
/db/drop/table/{serviceName}
参数:服务名
/db/update/table/{serviceName}
/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;
}
}
数据库的结果为:
url: /model/update
参数:
{
"serviceName":"demo.user.detail",
"value":{
"id":1,
"age":20
}
}
数据库结果值
/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
}
数据库结果
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。