提交 c2e3ba7e 编写于 作者: zhouweidong's avatar zhouweidong

定时任务支持调用实体行为

上级 762bef2f
......@@ -7,13 +7,34 @@ import com.baomidou.jobs.api.JobsResponse;
import com.baomidou.jobs.exception.JobsException;
import com.baomidou.jobs.handler.IJobsHandler;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
<#assign hasDEAction=false>
<#if item.getPSDataEntity?? && item.getPSDataEntity()?? && item.getPSDEAction?? && item.getPSDEAction()??>
<#assign hasDEAction=true>
<#assign de=item.getPSDataEntity()>
<#assign deaction=item.getPSDEAction()>
</#if>
@Slf4j
@Component("${item.codeName}JobHandler")
public class ${item.codeName}JobHandler implements IJobsHandler {
public class ${item.codeName}JobHandler implements IJobsHandler {
<#if hasDEAction>
@Autowired
@Lazy
protected ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.service.I${de.getCodeName()}Service ${srfcaseformat(de.getCodeName(),'l_u2lC')}Service;
</#if>
@Override
public JobsResponse execute(String tenantId, String param) throws JobsException {
System.out.println("执行 DemoJobHandler tenantId=" + tenantId + ",param=" + param);
<#if hasDEAction>
${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName} entity=new ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain.${de.codeName}();
entity.set("tenantid",tenantId);
entity.set("param",param);
${srfcaseformat(de.getCodeName(),'l_u2lC')}Service.${srfmethodname(deaction.getCodeName())}(entity);
</#if>
log.info("执行 DemoJobHandler tenantId=" + tenantId + ",param=" + param);
return JobsResponse.ok();
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册