提交 d9163c27 编写于 作者: sq3536's avatar sq3536

action

上级 b8979205
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.action.IPSDEAction;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class DEActionModel extends BaseModel{
public DEActionModel(EntityModel entityModel, IPSDEAction action)
{
this.opt=action;
this.entity=entityModel;
this.setCodeName(action.getCodeName());
this.setName(action.getName());
this.setId(String.format("%1$s-%2$s",entity.getCodeName(),action.getCodeName()));
}
private EntityModel entity;
}
......@@ -244,7 +244,15 @@ public class EntityModel extends BaseModel {
}
private List<DEActionModel> actions;
public EntityModel addAction(DEActionModel action)
{
if(actions==null)
actions=new ArrayList<>();
actions.add(action);
return this;
}
public String getDsName()
{
......@@ -256,6 +264,16 @@ public class EntityModel extends BaseModel {
return dsName;
}
public String getDataSource()
{
String dsName=this.getDataEntity().getDSLink();
if(StringUtils.isEmpty(dsName)||"DEFAULT".equalsIgnoreCase(dsName))
dsName=null;
else
dsName=dsName.toLowerCase();
return dsName;
}
public String getTableName(String dsType)
......@@ -676,6 +694,31 @@ public class EntityModel extends BaseModel {
this.addPOSchema(dsType, poSchema);
}
}
Set<String> ignoActions=new HashSet<String>(){{
add("get");
add("create");
add("update");
add("remove");
add("save");
add("getdraft");
add("checkkey");
add("createbatch");
add("savebatch");
add("updatebatch");
add("removebatch");
}};
if(this.getDataEntity().getAllPSDEActions()!=null)
{
this.getDataEntity().getAllPSDEActions().forEach(item->{
String tag=item.getCodeName().toLowerCase();
if(ignoActions.contains(tag))
return;
addAction(new DEActionModel(this,item));
});
}
}
}
package {{packageName}}.{{entity.module}}.service;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.math.BigInteger;
public interface I{{entity.codeName}}Service
{
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import com.baomidou.mybatisplus.extension.service.IService;
impott om.baomidou.dynamic.datasource.annotation.DS;
import {{packageName}}.{{entity.module}}.domain.{{entity.codeName}};
import {{packageName}}.{{entity.module}}.filter.{{entity.codeName}}SearchContext;
{{#dataSource}}
@DS("{{entity.dataSource}}")
{{/dataSource}}
public interface I{{entity.codeName}}Service extends IService<{{entity.codeName}}> {
{{entity.codeName}} get({{entity.keyField.type.java}} key);
List<{{entity.codeName}}> getByIds(Collection<{{entity.keyField.type.java}}> idList);
List<{{entity.codeName}}> getByEntities(Collection<{{entity.codeName}}> entities);
{{entity.codeName}} getDraft({{entity.codeName}} et);
boolean checkKey({{entity.codeName}} et);
boolean create({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true)
{{/enableEntityCache}}
boolean createBatch(List<{{entity.codeName}}> list);
boolean update({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true)
{{/enableEntityCache}}
boolean updateBatch(List<{{entity.codeName}}> list);
boolean save({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true)
{{/enableEntityCache}}
boolean saveBatch(List<{{entity.codeName}}> list);
boolean remove({{entity.keyField.type.java}} key);
{{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true)
{{/enableEntityCache}}
boolean removeBatch(Collection<{{entity.keyField.type.java}}> idList);
{{#entity.actions}}
{{entity.codeName}} {{codeName.camelCase}}({{entity.codeName}} et);
boolean {{codeName.camelCase}}Batch(List<{{entity.codeName}}> list);
{{/entity.actions}}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册