Compare commits
1 Commits
master
...
weaTable通用
Author | SHA1 | Date |
---|---|---|
|
fbca0f378f | 8 months ago |
@ -0,0 +1,21 @@
|
||||
package com.engine.jclproduct.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/10/25 1:48 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Target({ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface CheckboxPopedom {
|
||||
|
||||
String id() default "";
|
||||
|
||||
String showmethod() default "";
|
||||
|
||||
String popedompara() default "";
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.engine.jclproduct.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/10/25 1:48 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Target({ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface OperatePopedom {
|
||||
|
||||
boolean async() default true;
|
||||
|
||||
String transmethod() default "";
|
||||
|
||||
String otherpara() default "";
|
||||
|
||||
String otherpara2() default "";
|
||||
|
||||
String column() default "";
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.engine.jclproduct.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/10/25 1:48 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface TableTitle {
|
||||
int labelId() default -1;
|
||||
String title();
|
||||
String dataIndex();
|
||||
String key();
|
||||
boolean display() default true;
|
||||
String width() default "";
|
||||
boolean sorter() default false;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.engine.jclproduct.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/10/25 1:48 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface WeaverTableColumn {
|
||||
|
||||
String text() default "";
|
||||
|
||||
int labelId() default -1;
|
||||
|
||||
String width() default "";
|
||||
|
||||
String column() default "";
|
||||
|
||||
boolean display() default true;
|
||||
|
||||
String orderkey() default "";
|
||||
|
||||
String transmethod() default "";
|
||||
|
||||
// 额外参数
|
||||
String otherPara() default "";
|
||||
|
||||
// 多语言转换
|
||||
boolean multiLanguage() default false;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.engine.jclproduct.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/10/25 1:48 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Target({ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface WeaverTableOperate {
|
||||
|
||||
String text() default "";
|
||||
|
||||
int labelId() default -1;
|
||||
|
||||
String href() default "";
|
||||
|
||||
String index() default "0";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.engine.jclproduct.component;
|
||||
|
||||
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
||||
import com.cloudstore.eccom.pc.table.*;
|
||||
import com.engine.jclproduct.annotation.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.general.PageIdConst;
|
||||
import weaver.hrm.User;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class WeaverWeaTable<T> extends WeaTable {
|
||||
|
||||
public WeaverWeaTable(User user, Class clazz) {
|
||||
|
||||
boolean isAnno = clazz.isAnnotationPresent(WeaverTable.class);
|
||||
if (isAnno) {
|
||||
WeaverTable table = (WeaverTable) clazz.getAnnotation(WeaverTable.class);
|
||||
String pageId = table.pageId();
|
||||
super.setPageID(pageId);
|
||||
String pageUid = pageId + "_" + user.getUID();
|
||||
super.setPageUID(pageUid);
|
||||
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
|
||||
super.setPagesize(pageSize);
|
||||
String backfields = table.fields();
|
||||
super.setBackfields(backfields);
|
||||
String sql = table.fromSql();
|
||||
super.setSqlform(sql);
|
||||
String where = table.where();
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
super.setSqlwhere(where);
|
||||
}
|
||||
String orderby = table.orderby();
|
||||
if (StringUtils.isNotBlank(orderby)) {
|
||||
super.setSqlorderby(orderby);
|
||||
}
|
||||
String sortway = table.sortway();
|
||||
if (StringUtils.isNotBlank(sortway)) {
|
||||
super.setSqlsortway(sortway);
|
||||
}
|
||||
String groupby = table.groupby();
|
||||
if (StringUtils.isNotBlank(groupby)) {
|
||||
super.setSqlgroupby(groupby);
|
||||
}
|
||||
boolean distinct = table.distinct();
|
||||
super.setSqlisdistinct(String.valueOf(distinct));
|
||||
String primarykey = table.primarykey();
|
||||
if (StringUtils.isNotBlank(primarykey)) {
|
||||
super.setSqlprimarykey(primarykey);
|
||||
}
|
||||
WeaverTableOperate[] operates = table.operates();
|
||||
if (operates != null && operates.length > 0) {
|
||||
List<WeaTableOperate> operateList = new ArrayList<>();
|
||||
Arrays.stream(operates).forEach(o -> {
|
||||
String text = o.text();
|
||||
int labelId = o.labelId();
|
||||
String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage());
|
||||
if (StringUtils.isNotBlank(htmlLabelName)) {
|
||||
text = htmlLabelName;
|
||||
}
|
||||
WeaTableOperate weaTableOperate = new WeaTableOperate(text, o.href(), o.index());
|
||||
operateList.add(weaTableOperate);
|
||||
});
|
||||
WeaTableOperates weaTableOperates = new WeaTableOperates();
|
||||
OperatePopedom popedoms = table.operatePopedom();
|
||||
WeaTablePopedom popedom = new WeaTablePopedom();
|
||||
if (popedoms != null && !"".equals(popedoms.transmethod())) {
|
||||
popedom.setTransmethod(popedoms.transmethod());
|
||||
popedom.setOtherpara(popedoms.otherpara());
|
||||
weaTableOperates.setPopedom(popedom);
|
||||
}
|
||||
weaTableOperates.setOperate(operateList);
|
||||
super.setOperates(weaTableOperates);
|
||||
}
|
||||
|
||||
WeaTableType weaTableTypeEnum = table.tableType();
|
||||
//设置check是否可用
|
||||
if (weaTableTypeEnum == WeaTableType.CHECKBOX) {
|
||||
super.setTableType(weaTableTypeEnum);
|
||||
CheckboxPopedom checkPopedom = table.checkboxPopedom();
|
||||
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
|
||||
if (checkPopedom != null && !"".equals(checkPopedom.showmethod())) {
|
||||
checkboxpopedom.setShowmethod(checkPopedom.showmethod());
|
||||
checkboxpopedom.setPopedompara(checkPopedom.popedompara());
|
||||
}
|
||||
super.setCheckboxpopedom(checkboxpopedom);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
boolean isanno = f.isAnnotationPresent(WeaverTableColumn.class);
|
||||
if (isanno) {
|
||||
WeaverTableColumn columnAnn = f.getAnnotation(WeaverTableColumn.class);
|
||||
String text = columnAnn.text();
|
||||
int labelId = columnAnn.labelId();
|
||||
String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage());
|
||||
if (StringUtils.isNotBlank(htmlLabelName)) {
|
||||
text = htmlLabelName;
|
||||
}
|
||||
String width = columnAnn.width();
|
||||
String column = columnAnn.column();
|
||||
String orderkey = columnAnn.orderkey();
|
||||
boolean display = columnAnn.display();
|
||||
WeaTableColumn weaTableColumn = new WeaTableColumn(width, text, column, orderkey);
|
||||
String transmethod = columnAnn.transmethod();
|
||||
|
||||
if (StringUtils.isNotBlank(transmethod)) {
|
||||
weaTableColumn.setTransmethod(transmethod);
|
||||
}
|
||||
String otherPara = columnAnn.otherPara();
|
||||
if (StringUtils.isNotBlank(otherPara)) {
|
||||
weaTableColumn.setOtherpara(otherPara);
|
||||
} else {
|
||||
// 未设置其他参数,但是设置了多语言,自动添加其它参数为语言类型
|
||||
if (columnAnn.multiLanguage()) {
|
||||
weaTableColumn.setOtherpara(String.valueOf(user.getLanguage()));
|
||||
}
|
||||
}
|
||||
if (!display) {
|
||||
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
|
||||
}
|
||||
super.getColumns().add(weaTableColumn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue