Commit 021815ad authored by 薛涛 Toby Xue's avatar 薛涛 Toby Xue 🆒

声明

parent 4a6dd2c4
Pipeline #3595 canceled with stages
# logwire-bo-specification
BO规范定义,包括BO声明、属性声明、Operation声明、Operation实现、OperationEvent实现、LQL等规范的定义,以及项目对产品BO扩展规范的定义。此包无需依赖其他Jar包。
产品组件的开发,仅需依赖于BO规范以及其他组件。
项目对产品组件的扩展,可通过代码开发或BODesigner配置完成。开发是直接写类文件,BODesigner会根据配置生成类文件。
......@@ -7,5 +7,17 @@
<groupId>logwire</groupId>
<artifactId>logwire-bo-sdk</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package logwire.web.bo.annotation;
public @interface Array{
String label() default "";
String size() default ""; //列长度
}
package logwire.web.bo.annotation;
public @interface AuxField {
String label() default "";
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* BO类声明为Model的注解
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface BizModel {
String label() default "";
/**
* 缓存策略说明:
* cache="24h":在BO数据修改/刪除时会清除缓存,使用时先从redis取,
* 如果不存在,再从数据库取并推入缓存,缓存24小时后自动清除。
* cache="true":不会自动失效
* @return
*/
String cache() default "";
/**
* 业务关键字段,输出Debug日志时使用
* @return
*/
String bizKey() default "";
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface BizQueries {
BizQuery[] value();
}
package logwire.web.bo.annotation;
import java.lang.annotation.*;
/**
* 在BO类上的Query注解
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(BizQueries.class)
public @interface BizQuery {
String name();
String label() default "";
/**
* BO LQL语法
* @return
*/
String restrictions();
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 枚举字典声明
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Category {
String label() default "";
}
package logwire.web.bo.annotation;
import logwire.web.bo.field.IChoice;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 声明列属性的枚举字典
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Choice {
Class<? extends IChoice> value();
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {
String label() default "";
String size() default "";
}
package logwire.web.bo.annotation;
public @interface Composite {
String label() default "";
/**
* 组件字段列名前缀
* @return
*/
String prefix() default "";
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 外键字段泛型未指定时使用ForeignKey指定
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ForeignKey {
String referBoName();
}
package logwire.web.bo.annotation;
public @interface Item {
String label() default "";
/**
* 明细表关联主表字段
*
* @return
*/
String relationField();
String referBoName() default "";
/**
* 明细表中用来存储Item名称的字段,用于区分多个明细字段引用同一个BO
*
* @return
*/
String nameField() default "";
/**
* 明细表中用来存储顺序的字段
* @return
*/
String indexField() default "";
/**
* 为true时,主表刪除从表也刪除,否则将关联字段设为空
* @return
*/
boolean cascade() default true;
}
package logwire.web.bo.annotation;
import logwire.web.bo.object.BizObject;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ListOperationProvider {
Class<? extends BizObject> type();
}
package logwire.web.bo.annotation;
public @interface Many {
String label() default "";
String referBoName() default "";
}
package logwire.web.bo.annotation;
import logwire.web.bo.object.BizObject;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ObjectOperationProvider {
Class<? extends BizObject> type();
}
package logwire.web.bo.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Operation {
String label() default "";
OperationArg[] args();
/**
* 对结果做线程缓存,当self、输入参数一致时直接返回上次计算结果
* @return
*/
boolean cached() default false;
}
package logwire.web.bo.annotation;
/**
* Operation参数说明
*/
public @interface OperationArg {
String name();
String label() default "";
}
package logwire.web.bo.annotation;
public @interface OperationParameter {
String label() default "";
String value();
Class<?> type() default String.class;
}
package logwire.web.bo.annotation;
public @interface SlaveMany {
String label() default "";
String referBoName() default "";
String masterFieldName();
}
package logwire.web.bo.annotation;
public @interface Text {
String label() default "";
}
package logwire.web.bo.annotation;
import logwire.web.bo.object.BizObject;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface TypeOperationProvider {
Class<? extends BizObject> type();
}
package logwire.web.bo.eventhandler;
import logwire.web.bo.object.BizObject;
import java.util.List;
public interface ListOperationEventHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default String getQuery() {
return "";
}
default boolean isAfter() {
return true;
}
default int getOrder() {
return 1000;
}
default void doBefore(List<X> xList, Object... args) {
//调用行为同名方法
}
default void doAfter(List<X> xList, Object result, Object... args) {
//调用行为同名方法
}
}
\ No newline at end of file
package logwire.web.bo.eventhandler;
import logwire.web.bo.object.BizObject;
public interface ObjectOperationEventHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default String getQuery() {
return "";
}
default boolean isAfter() {
return true;
}
default int getOrder() {
return 1000;
}
default void doBefore(X x, Object... args) {
//调用行为同名方法
}
default void doAfter(X x, Object result, Object... args) {
//调用行为同名方法
}
}
package logwire.web.bo.eventhandler;
import logwire.web.bo.object.BizObject;
public interface TypeOperationEventHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default String getQuery() {
return "";
}
default boolean isAfter() {
return true;
}
default int getOrder() {
return 1000;
}
default void doBefore(Class<X> xClass, Object... args) {
//调用行为同名方法
}
default void doAfter(Class<X> xClass, Object result, Object... args) {
//调用行为同名方法
}
}
\ No newline at end of file
package logwire.web.bo.field;
public interface BizArray<X> extends Iterable<X> {
void add(X x);
void remove(X x);
void removeIndex(int index);
}
package logwire.web.bo.field;
public interface BizComposite {
}
package logwire.web.bo.field;
import logwire.web.bo.object.BizObject;
public interface BizExpando<X extends BizObject> extends BizComposite {
}
package logwire.web.bo.field;
import logwire.web.bo.object.BizObject;
import logwire.web.bo.list.BizList;
import java.lang.reflect.Field;
import java.util.Map;
public interface BizItem<X extends BizObject> extends Iterable<X> {
boolean isChanged();
X find(String field, Object value);
X find(Map<String, Field> fields);
X create();
X create(Map<String, Field> fields);
BizList<X> findAll(String field, Object value);
BizList<X> findAll(Map fields);
}
package logwire.web.bo.field;
import logwire.web.bo.object.BizObject;
import logwire.web.bo.list.BizList;
public interface BizMany<X extends BizObject> extends Iterable<Object> {
void add(Long id);
void remove(Long id);
void add(X object);
void remove(X object);
void allAll(BizList<X> list);
}
package logwire.web.bo.field;
import logwire.web.bo.object.ModelObject;
public interface BizOne<X extends ModelObject> {
Long getValue();
void setValue(Long value);
X getObject();
}
package logwire.web.bo.field;
public interface BizText {
String getValue();
void setValue(String value);
}
package logwire.web.bo.field;
/**
* 枚举字典接口
*/
public interface IChoice {
String getLabel();
}
package logwire.web.bo.handler;
import logwire.web.bo.object.BizObject;
import java.util.List;
public interface ListOperationHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default String getQuery() {
return "";
}
default int getOrder() {
return 1000;
}
default boolean accept(List<X> xList, Object... args) {
return true;
}
Object execute(List<X> xList, Object... args);
}
package logwire.web.bo.handler;
import logwire.web.bo.object.BizObject;
public interface ObjectOperationHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default String getQuery() {
return "";
}
default int getOrder() {
return 1000;
}
default boolean accept(X x, Object... args) {
return true;
}
Object execute(X x, Object... args);
}
package logwire.web.bo.handler;
import logwire.web.bo.object.BizObject;
public interface TypeOperationHandler<X extends BizObject> {
String getOperation();
boolean isEnabled();
default int getOrder() {
return 1000;
}
default boolean accept(Class<X> xClass, Object... args) {
return true;
}
Object execute(Class<X> xClass, Object... args);
}
package logwire.web.bo.list;
import logwire.web.bo.object.BizObject;
import java.util.Map;
public interface BizList<X extends BizObject> extends Iterable<X> {
X find(String field, Object value);
X find(Map fields);
X find(String query);
X create();
X create(Map fields);
X create(String query);
BizList<X> findAll(String field, Object value);
BizList<X> findAll(Map fields);
BizList<X> findAll(String query);
}
\ No newline at end of file
package logwire.web.bo.object;
import logwire.web.bo.annotation.Column;
import logwire.web.bo.annotation.Composite;
import logwire.web.bo.field.BizExpando;
import logwire.web.bo.field.BizOne;
import java.time.OffsetDateTime;
import java.util.Map;
/**
* BO 生成的Model,audit=false version=true domain=true, 指定ID为主键,非AUTO;audit由BO控制
* BO 子表字段(多对多、数组、大文本)生成的Model,audit/version/domain都为false
*/
public abstract class BizObject extends ModelObject {
/**
* 事务类型 insert/update/delete
*/
String _TX_CODE;
/**
* 当事务类型为update时,记录修改过的字段
*/
Map<String, Object> UPDATED_FIELDS;
@Column(label = "主键")
Long id;// BO 的ID全部为雪花ID
@Column(label = "版本号")
int version;
@Column(label = "BO名称")
String boName;
@Column(label = "创建用户")
BizOne<User> createUser;
@Column(label = "创建时间")
OffsetDateTime createDate;
@Column(label = "最后修改用户")
BizOne<User> updateUser;
@Column(label = "最后修改时间")
OffsetDateTime updateDate;
@Composite(label = "项目扩展字段", prefix = "exp_")
BizExpando exps;
@Column(label = "域")
String domain;
}
package logwire.web.bo.object;
/**
*考虑兼容平台的XML Model
* 用于BO关联平台Model
*/
public abstract class ModelObject{
/**
* @return 返回主键值
*/
abstract Object getId();
}
package logwire.web.bo.object;
import logwire.web.bo.annotation.BizModel;
import logwire.web.bo.annotation.Column;
@BizModel(label = "用户")
public abstract class User extends ModelObject {
@Column()
String userGid;
@Column()
String userXid;
Object getId() {
return userGid;
}
}
\ No newline at end of file
package logwire.web.bo.select;
public interface BizChildSelect extends BizSelect {
}
package logwire.web.bo.select;
public interface BizSelect {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment