parent
3a1b4c2153
commit
33a9edea14
@ -0,0 +1,22 @@
|
|||||||
|
package com.xjs.business.webmagic;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.webmagic.factory.RemoteWebmagicZolFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部 调用 中关村数据 爬虫定时任务feign
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-18
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteWebmagicZolFeign",
|
||||||
|
value = ServiceNameConstants.BUSINESS_WEBMAGIC_SERVICE,
|
||||||
|
fallbackFactory = RemoteWebmagicZolFactory.class)
|
||||||
|
public interface RemoteWebmagicZolFeign {
|
||||||
|
|
||||||
|
@GetMapping("/zol/taskForPRC")
|
||||||
|
R<Long> ZolPhoneTaskForRPC();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.xjs.business.webmagic.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.webmagic.RemoteWebmagicZolFeign;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部 调用 中关村数据 爬虫定时任务feign降级
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-18
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class RemoteWebmagicZolFactory implements FallbackFactory<RemoteWebmagicZolFeign> {
|
||||||
|
@Override
|
||||||
|
public RemoteWebmagicZolFeign create(Throwable cause) {
|
||||||
|
return () -> {
|
||||||
|
log.error("中关村数据爬虫定时任务降级");
|
||||||
|
return R.fail("中关村数据爬虫定时任务降级");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.xjs.job.task.webmagic;
|
||||||
|
|
||||||
|
import com.xjs.business.webmagic.RemoteWebmagicZolFeign;
|
||||||
|
import com.xjs.job.aop.TaskLog;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬虫 中关村数据 定时任务
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-18
|
||||||
|
*/
|
||||||
|
@Component("ZolTask")
|
||||||
|
@Log4j2
|
||||||
|
public class ZolTask {
|
||||||
|
@Resource
|
||||||
|
private RemoteWebmagicZolFeign remoteWebmagicZolFeign;
|
||||||
|
|
||||||
|
|
||||||
|
@TaskLog(name = "微信搜狗爬虫任务")
|
||||||
|
public void zol(){
|
||||||
|
log.info("---------------爬虫-中关村数据定时任务Start-------------------");
|
||||||
|
|
||||||
|
remoteWebmagicZolFeign.ZolPhoneTaskForRPC();
|
||||||
|
|
||||||
|
log.info("---------------爬虫-中关村数据定时任务end---------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.xjs.zol.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.zol.task.ZolTask;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬虫中关村controller
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("zol")
|
||||||
|
@Api(tags = "爬虫模块-中关村")
|
||||||
|
public class ZolController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZolTask zolTask;
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------内部调用rpc-------------------------------------
|
||||||
|
@GetMapping("taskForPRC")
|
||||||
|
@ApiOperation("供定时任务服务RPC远程调用")
|
||||||
|
public R<Long> ZolPhoneTaskForRPC() {
|
||||||
|
Long aLong = zolTask.reptileZol();
|
||||||
|
return R.ok(aLong);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue