提交 bbed443b 编写于 作者: Z zhourui

添加爬虫启动状态

上级 5e722127
package com.x.query.assemble.surface.jaxrs.segment;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import org.apache.commons.lang3.BooleanUtils;
class ActionCrawlEnable extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setCms(Config.query().getCrawlCms().getEnable());
wo.setWork(Config.query().getCrawlWork().getEnable());
wo.setWorkCompleted(Config.query().getCrawlWorkCompleted().getEnable());
if (BooleanUtils.isTrue(wo.getCms()) || BooleanUtils.isTrue(wo.getWork())
|| BooleanUtils.isTrue(wo.getWorkCompleted())) {
wo.setEnable(true);
} else {
wo.setEnable(false);
}
result.setData(wo);
return result;
}
}
public static class Wo extends GsonPropertyObject {
private Boolean enable;
private Boolean cms;
private Boolean work;
private Boolean workCompleted;
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public Boolean getCms() {
return cms;
}
public void setCms(Boolean cms) {
this.cms = cms;
}
public Boolean getWork() {
return work;
}
public void setWork(Boolean work) {
this.work = work;
}
public Boolean getWorkCompleted() {
return workCompleted;
}
public void setWorkCompleted(Boolean workCompleted) {
this.workCompleted = workCompleted;
}
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
......
......@@ -68,4 +68,21 @@ public class SegmentAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取当前是否启用了爬虫搜索.", action = ActionCrawlEnable.class)
@GET
@Path("crawl/enable")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void crawlEnable(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionCrawlEnable.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionCrawlEnable().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
/**
*
*/
/**
* @author zhour
*
*/
package com.x.query.assemble.surface.jaxrs.segment;
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册