package org.yeshi.utils.generater.vo.service;
|
|
import org.yeshi.utils.generater.entity.BaseData;
|
import org.yeshi.utils.generater.util.EntityUtil;
|
import org.yeshi.utils.generater.util.NameUtil;
|
|
import java.lang.reflect.Field;
|
|
public class QueryVO extends BaseData {
|
private String className;
|
|
public static class Builder {
|
private Class entity;
|
private String packageName;
|
|
|
public Builder setEntity(Class entity) {
|
this.entity = entity;
|
return this;
|
}
|
|
public Builder setPackageName(String packageName) {
|
this.packageName = packageName;
|
return this;
|
}
|
|
private void validParams() throws Exception {
|
if (entity == null) {
|
throw new Exception("entity不能为空");
|
}
|
if (packageName == null) {
|
throw new Exception("packageName不能为空");
|
}
|
}
|
|
|
public QueryVO build() throws Exception {
|
validParams();
|
Field identifyId = EntityUtil.getIdentifyId(entity);
|
if (identifyId == null) {
|
throw new Exception("尚未找到主键属性");
|
}
|
QueryVO vo = new QueryVO();
|
vo.setPackageName(packageName);
|
vo.setClassName(NameUtil.getDefaultQueryName(entity));
|
return vo;
|
}
|
|
}
|
|
public String getClassName() {
|
return className;
|
}
|
|
public void setClassName(String className) {
|
this.className = className;
|
}
|
}
|