parent
6d8e0c47cb
commit
91bb52a8bf
8
pom.xml
8
pom.xml
|
|
@ -55,6 +55,7 @@
|
||||||
<redisson.version>3.12.0</redisson.version>
|
<redisson.version>3.12.0</redisson.version>
|
||||||
<screw.version>1.0.5</screw.version>
|
<screw.version>1.0.5</screw.version>
|
||||||
<activiti.version>7.1.0.M4</activiti.version>
|
<activiti.version>7.1.0.M4</activiti.version>
|
||||||
|
<retry.version>1.3.2</retry.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
@ -151,6 +152,13 @@
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--重试机制-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.retry</groupId>
|
||||||
|
<artifactId>spring-retry</artifactId>
|
||||||
|
<version>${retry.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xjs</groupId>
|
<groupId>com.xjs</groupId>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,12 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--重试机制-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.retry</groupId>
|
||||||
|
<artifactId>spring-retry</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
||||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.retry.annotation.EnableRetry;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,6 +18,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@EnableRetry //启动重试机制
|
||||||
public class XjsWarningApp {
|
public class XjsWarningApp {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(XjsWarningApp.class, args);
|
SpringApplication.run(XjsWarningApp.class, args);
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.core.io.ByteArrayResource;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
|
import org.springframework.mail.MailException;
|
||||||
import org.springframework.mail.SimpleMailMessage;
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.retry.annotation.Retryable;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.thymeleaf.TemplateEngine;
|
import org.thymeleaf.TemplateEngine;
|
||||||
|
|
@ -58,6 +60,7 @@ public class MailServer {
|
||||||
* @param mailBean 邮箱实体
|
* @param mailBean 邮箱实体
|
||||||
*/
|
*/
|
||||||
@MailLog
|
@MailLog
|
||||||
|
@Retryable(maxAttempts = 2, value = MailException.class) //当抛出MailException异常时,该方法重试两次
|
||||||
public Boolean sendMail(MailBean mailBean) {
|
public Boolean sendMail(MailBean mailBean) {
|
||||||
|
|
||||||
if (redisService.hasKey(MAIL_STATUS)) {
|
if (redisService.hasKey(MAIL_STATUS)) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,17 @@
|
||||||
package com.xjs.zol.controller;
|
package com.xjs.zol.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.xjs.validation.group.SelectGroup;
|
||||||
|
import com.xjs.web.MyBaseController;
|
||||||
|
import com.xjs.zol.pojo.ZolPhone;
|
||||||
|
import com.xjs.zol.service.ZolPhoneService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
@ -12,7 +23,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("zol-phone")
|
@RequestMapping("zol-phone")
|
||||||
@Api(tags = "爬虫模块-中关村手机")
|
@Api(tags = "爬虫模块-中关村手机")
|
||||||
public class ZolPhoneController {
|
public class ZolPhoneController extends MyBaseController<ZolPhone> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZolPhoneService zolPhoneService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissions("webmagic:zol-phone:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("查询中关村手机列表")
|
||||||
|
public AjaxResult list(@Validated({SelectGroup.class}) ZolPhone zolPhone) {
|
||||||
|
IPage<ZolPhone> page=zolPhoneService.selectZolPhoneByPage(startPageMP(),zolPhone);
|
||||||
|
return AjaxResult.success(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.xjs.zol.service;
|
package com.xjs.zol.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xjs.zol.pojo.ZolPhone;
|
import com.xjs.zol.pojo.ZolPhone;
|
||||||
|
|
||||||
|
|
@ -9,4 +11,11 @@ import com.xjs.zol.pojo.ZolPhone;
|
||||||
* @since 2022-04-18
|
* @since 2022-04-18
|
||||||
*/
|
*/
|
||||||
public interface ZolPhoneService extends IService<ZolPhone> {
|
public interface ZolPhoneService extends IService<ZolPhone> {
|
||||||
|
/**
|
||||||
|
* 分页查询中关村手机数据
|
||||||
|
* @param startPageMP mp封装的前端通用参数
|
||||||
|
* @param zolPhone 实体
|
||||||
|
* @return page对象
|
||||||
|
*/
|
||||||
|
IPage<ZolPhone> selectZolPhoneByPage(Page<ZolPhone> startPageMP, ZolPhone zolPhone);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,43 @@
|
||||||
package com.xjs.zol.service.impl;
|
package com.xjs.zol.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.xjs.zol.mapper.ZolPhoneMapper;
|
import com.xjs.zol.mapper.ZolPhoneMapper;
|
||||||
import com.xjs.zol.pojo.ZolPhone;
|
import com.xjs.zol.pojo.ZolPhone;
|
||||||
import com.xjs.zol.service.ZolPhoneService;
|
import com.xjs.zol.service.ZolPhoneService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 爬虫数据中关村手机service实现
|
* 爬虫数据中关村手机service实现
|
||||||
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-04-18
|
* @since 2022-04-18
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ZolPhoneServiceImpl extends ServiceImpl<ZolPhoneMapper, ZolPhone> implements ZolPhoneService {
|
public class ZolPhoneServiceImpl extends ServiceImpl<ZolPhoneMapper, ZolPhone> implements ZolPhoneService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<ZolPhone> selectZolPhoneByPage(Page<ZolPhone> startPageMP, ZolPhone zolPhone) {
|
||||||
|
String condition = zolPhone.getCondition();
|
||||||
|
|
||||||
|
LambdaQueryWrapper<ZolPhone> wr = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
//根据时间查询
|
||||||
|
boolean b = Objects.nonNull(zolPhone.getCreateTime()) && Objects.nonNull(zolPhone.getEndCreateTime());
|
||||||
|
wr.between(b, ZolPhone::getCreateTime, zolPhone.getCreateTime(), zolPhone.getEndCreateTime());
|
||||||
|
|
||||||
|
//通用查询/组合查询
|
||||||
|
wr.and(StringUtils.isNotEmpty(condition), obj -> {
|
||||||
|
obj.like(ZolPhone::getPhoneName, condition)
|
||||||
|
.or()
|
||||||
|
.like(ZolPhone::getDescription, condition);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.page(startPageMP,wr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue