This commit is contained in:
Cauchy
2023-10-24 13:08:01 +08:00
parent 7c9540f3ae
commit b57b196dd5
12 changed files with 502 additions and 520 deletions

View File

@@ -1,33 +1,33 @@
package com.peanut.modules.book.task;
import com.peanut.modules.book.service.ShopSeckillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@Slf4j
@Service
public class SeckillProdScheduled {
@Autowired
ShopSeckillService shopSeckillService;
@Scheduled(cron = "0 0/1 * * * ?")
public void uploadSeckilProd3Days() {
Lock l = new ReentrantLock();
l.lock();
try {
shopSeckillService.uploadSeckilProd3Days();
}catch (Exception e){
e.printStackTrace();
}finally {
l.unlock();
}
}
}
//package com.peanut.modules.book.task;
//
//import com.peanut.modules.book.service.ShopSeckillService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import java.util.concurrent.locks.Lock;
//import java.util.concurrent.locks.ReentrantLock;
//
//@Slf4j
//@Service
//public class SeckillProdScheduled {
// @Autowired
// ShopSeckillService shopSeckillService;
//
// @Scheduled(cron = "0 0/1 * * * ?")
// public void uploadSeckilProd3Days() {
// Lock l = new ReentrantLock();
// l.lock();
// try {
// shopSeckillService.uploadSeckilProd3Days();
// }catch (Exception e){
// e.printStackTrace();
// }finally {
// l.unlock();
// }
//
//
// }
//
//}