|
|
@@ -12,22 +12,27 @@ import com.webflux.launchadmin.mysql.service.sourceMaterial.data.sql.Where;
|
|
|
import com.webflux.launchcommon.returnObj.Paged;
|
|
|
import com.webflux.launchcommon.returnObj.RStatus;
|
|
|
import com.webflux.launchcommon.utils.R;
|
|
|
+import io.r2dbc.spi.Parameter;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
|
import org.springframework.data.relational.core.query.Criteria;
|
|
|
import org.springframework.data.relational.core.query.Query;
|
|
|
import org.springframework.data.relational.core.query.Update;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
@@ -36,6 +41,71 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
@Resource
|
|
|
private R2dbcEntityTemplate template;
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Mono<Boolean> ArticleData(){
|
|
|
+ int size=50;
|
|
|
+ Query query = Query.query(Criteria.where("status").is(1));
|
|
|
+ return template.count(query, ArticleData.class).flatMap(fm -> {
|
|
|
+ long page = fm % 50L;
|
|
|
+ long page0 = fm / 50L;
|
|
|
+ if (page > 0) {
|
|
|
+ page0++;
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
+ while (i < page0) {
|
|
|
+ // 循环体
|
|
|
+ refreshInitialization(i, size).subscribe();
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return Mono.just(true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public Mono<Boolean> refreshInitialization(Integer page ,Integer size){
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ return getArticle(page, size,Criteria.empty())
|
|
|
+ .switchIfEmpty(Mono.just(List.of()))
|
|
|
+ .flatMap(articleData -> {
|
|
|
+ if (articleData.isEmpty()) {
|
|
|
+ return Mono.just(false);
|
|
|
+ }
|
|
|
+ articleData.forEach(articleData1 -> {
|
|
|
+ Article article = new Article(null,
|
|
|
+ articleData1.primaryKey(),
|
|
|
+ articleData1.articleName(),
|
|
|
+ Objects.nonNull(articleData1.creatTime()) ? articleData1.creatTime().format(dateTimeFormatter) : "",
|
|
|
+ articleData1.author(),
|
|
|
+ articleData1.tagName(),
|
|
|
+ Objects.nonNull(articleData1.type()) && articleData1.type() == 1 ? articleData1.musicUrl() : "",
|
|
|
+ articleData1.musicName(),
|
|
|
+ Objects.nonNull(articleData1.type()) && articleData1.type() == 2 ? articleData1.musicUrl() : "",
|
|
|
+ articleData1.content(),
|
|
|
+ "",
|
|
|
+ "",
|
|
|
+ ZonedDateTime.now(),
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ "",
|
|
|
+ Objects.nonNull(articleData1.type()) && articleData1.type() == 1 ? "图文" : "视频"//类型:图文/相册/视频
|
|
|
+ );
|
|
|
+ template.insert(article).subscribe();
|
|
|
+ });
|
|
|
+ return Mono.just(true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public Mono<List<ArticleData>> getArticle(Integer page ,Integer size, Criteria empty){
|
|
|
+
|
|
|
+ return template.select(Query.query(empty.and("status").is(1))
|
|
|
+ .offset((long) (page - 1) * size)
|
|
|
+ .limit(size), ArticleData.class)
|
|
|
+ .collectList().switchIfEmpty(Mono.just(List.of()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Mono<RStatus<Paged<Classification>>> getClassificationList() {
|
|
|
return sourceMaterialInterface.page(List.of(), Classification.class, 1000, 1);
|
|
|
@@ -189,10 +259,10 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
StringBuilder startSqlCount= new StringBuilder(" SELECT id FROM article WHERE deleted_at IS NULL ");
|
|
|
StringBuilder stringBuilder =new StringBuilder();
|
|
|
Criteria empty =Criteria.empty();
|
|
|
- if(Objects.nonNull(articleReq.getClassificationId())){
|
|
|
- Long classificationId = articleReq.getClassificationId();
|
|
|
- empty = empty.and("classification_id").is(classificationId);
|
|
|
- }
|
|
|
+// if(Objects.nonNull(articleReq.getClassificationId())){
|
|
|
+// Long classificationId = articleReq.getClassificationId();
|
|
|
+// empty = empty.and("classification_id").is(classificationId);
|
|
|
+// }
|
|
|
if(Objects.nonNull(articleReq.getLabelId())){
|
|
|
Long labelId = articleReq.getLabelId();
|
|
|
empty = empty.and("id").is(labelId);
|
|
|
@@ -208,6 +278,10 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
stringBuilder.append(" AND title like ");
|
|
|
stringBuilder.append("%").append(articleReq.getTitle()).append("%");
|
|
|
}
|
|
|
+ if(Objects.nonNull(articleReq.getType()) && !"".equals(articleReq.getType().trim())){
|
|
|
+ stringBuilder.append(" AND type = ");
|
|
|
+ stringBuilder.append("'").append(articleReq.getType()).append("'");
|
|
|
+ }
|
|
|
if(Objects.nonNull(articleReq.getAuthor()) && !"".equals(articleReq.getAuthor().trim())){
|
|
|
stringBuilder.append(" AND author like ");
|
|
|
stringBuilder.append("%").append(articleReq.getAuthor()).append("%");
|