介绍
在业务中我们经常能遇到这种场景,我们的数据是通过调用第三方接口获取的,在业务系统中没有对应的存储模型,但是我们又需要展示这些数据,这时候可以利用传输模型不建表的特性完成这个功能。
定义传输模型
package pro.shushi.pamirs.demo.api.tmodel;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.TransientModel;
@Model.model(DemoCreateOrder.MODEL_MODEL)
@Model(displayName = "下单页面模型")
public class DemoCreateOrder extends TransientModel {
public static final String MODEL_MODEL = "demo.DemoCreateOrder";
@Field.Integer
@Field(displayName ="下单人uid")
private Long userId;
}
定义action,由于传输模型用于表现层和应用层之间的数据交互,本身不会存储,没有默认的数据管理器,只有数据构造器,所以需要手动添加所需的queryOne、create、update等方法
注意:传输模型没有数据管理器能力,所以不提供类似queryPage的方法,后续版本考虑支持中
package pro.shushi.pamirs.demo.core.action;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.demo.api.tmodel.DemoCreateOrder;
import pro.shushi.pamirs.meta.annotation.Action;
import pro.shushi.pamirs.meta.annotation.Function;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.api.dto.condition.Pagination;
import pro.shushi.pamirs.meta.api.dto.wrapper.IWrapper;
import pro.shushi.pamirs.meta.constant.FunctionConstants;
import pro.shushi.pamirs.meta.enmu.FunctionOpenEnum;
import pro.shushi.pamirs.meta.enmu.FunctionTypeEnum;
import pro.shushi.pamirs.meta.enmu.ViewTypeEnum;
import static pro.shushi.pamirs.meta.enmu.FunctionOpenEnum.*;
@Component
@Model.model(DemoCreateOrder.MODEL_MODEL)
public class DemoCreateOrderAction {
@Function.Advanced(type = FunctionTypeEnum.QUERY)
@Function.fun(FunctionConstants.queryByEntity)
@Function(openLevel = {LOCAL, REMOTE, API})
public DemoCreateOrder queryOne(DemoCreateOrder query) {
return query;
}
@Action.Advanced(name = FunctionConstants.create, managed = true)
@Action(displayName = "创建", label = "确定", summary = "添加", bindingType = ViewTypeEnum.FORM)
@Function(name = FunctionConstants.create)
@Function.fun(FunctionConstants.create)
public DemoCreateOrder create(DemoCreateOrder data) {
return data;
}
@Action.Advanced(name = FunctionConstants.update, managed = true)
@Action(displayName = "确定", summary = "修改", bindingType = ViewTypeEnum.FORM)
@Function(name = FunctionConstants.update)
@Function.fun(FunctionConstants.update)
public DemoCreateOrder update(DemoCreateOrder data) {
return data;
}
}
Oinone社区 作者:nation原创文章,如若转载,请注明出处:https://doc.oinone.top/backend/11327.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验