|
@@ -0,0 +1,65 @@
|
|
|
+package com.nosum.deliver.author.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.nosum.common.base.domain.PageInfo;
|
|
|
+import com.nosum.deliver.author.domain.po.Author;
|
|
|
+import com.nosum.deliver.author.domain.po.AuthorVideo;
|
|
|
+import com.nosum.deliver.author.service.AuthorService;
|
|
|
+import com.nosum.deliver.author.service.AuthorVideoService;
|
|
|
+import org.bson.types.ObjectId;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 作者信息服务层实现类.
|
|
|
+ *
|
|
|
+ * @author Young
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AuthorVideoServiceImpl implements AuthorVideoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void save(AuthorVideo authorVideo) {
|
|
|
+ mongoTemplate.save(authorVideo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<AuthorVideo> getPage(PageInfo<AuthorVideo> pageInfo, AuthorVideo authorVideo) {
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(authorVideo.getFinderUin())) {
|
|
|
+ criteria.and("finderUin").is(authorVideo.getFinderUin());
|
|
|
+ }
|
|
|
+
|
|
|
+ Query query = Query.query(criteria);
|
|
|
+ query.skip((pageInfo.getPage() - 1) * pageInfo.getSize());
|
|
|
+ query.limit((int) pageInfo.getSize());
|
|
|
+
|
|
|
+ long total = mongoTemplate.count(query, AuthorVideo.class);
|
|
|
+ if (total == 0) {
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ return pageInfo.setRecord(mongoTemplate.find(query, AuthorVideo.class)).setTotal(total);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AuthorVideo getById(ObjectId id) {
|
|
|
+ return mongoTemplate.findById(id, AuthorVideo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void remove(ObjectId id) {
|
|
|
+ mongoTemplate.remove(Query.query(Criteria.where("id").is(id)), AuthorVideo.class);
|
|
|
+ }
|
|
|
+}
|