Browse Source

修改作者基本信息

Young 2 years ago
parent
commit
8907fcda90

+ 53 - 0
src/main/java/com/nosum/deliver/author/controller/AuthorVideoAdminController.java

@@ -0,0 +1,53 @@
+package com.nosum.deliver.author.controller;
+
+import com.nosum.common.base.domain.PageInfo;
+import com.nosum.common.base.domain.Result;
+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.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * 作者信息接口层.
+ *
+ * @author Young
+ */
+@RestController
+@RequestMapping("/admin/author-video")
+public class AuthorVideoAdminController {
+
+    @Autowired
+    private AuthorVideoService authorVideoService;
+
+    @PostMapping("/save")
+    public Result<Void> save(@RequestBody AuthorVideo authorVideo) {
+        authorVideoService.save(authorVideo);
+        return Result.createWithSuccessMessage();
+    }
+
+    @GetMapping("/{id}")
+    public Result<AuthorVideo> get(@PathVariable("id") ObjectId id) {
+        return Result.createWithModel(authorVideoService.getById(id));
+    }
+
+
+    @GetMapping("/page")
+    public Result<AuthorVideo> page(AuthorVideo authorVideo) {
+        PageInfo<AuthorVideo> pageInfo = authorVideoService.getPage(PageInfo.withRequest(), authorVideo);
+        return Result.createWithPaging(pageInfo.getRecord(), pageInfo);
+    }
+
+
+    @DeleteMapping("/{id}")
+    public Result<Void> remove(@PathVariable("id") ObjectId id) {
+        authorVideoService.remove(id);
+        return Result.createWithSuccessMessage();
+    }
+
+}

+ 8 - 1
src/main/java/com/nosum/deliver/author/domain/po/Author.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 import org.bson.types.ObjectId;
 import org.springframework.data.annotation.Id;
+import org.springframework.data.annotation.Transient;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.time.LocalDateTime;
@@ -33,7 +34,13 @@ public class Author {
     /**
      * 粉丝数
      */
-    private Integer fansCount =0 ;
+    private Integer fansCount = 0;
+
+    /**
+     * 粉丝数搜索
+     */
+    @Transient
+    private String fansCountStr;
 
     /**
      * 投放条数

+ 13 - 0
src/main/java/com/nosum/deliver/author/domain/po/AuthorVideo.java

@@ -31,11 +31,24 @@ public class AuthorVideo {
     private String link;
 
     /**
+     * feedId
+     */
+    private String feedId;
+
+    /**
      * 作者
      */
     private String finderUin;
 
     /**
+     * 状态
+     * 0 未投放
+     * 1 投放中
+     * 2 取消投放
+     */
+    private Integer status;
+
+    /**
      * 发布时间
      */
     private LocalDateTime sendTime;

+ 40 - 0
src/main/java/com/nosum/deliver/author/service/AuthorVideoService.java

@@ -0,0 +1,40 @@
+package com.nosum.deliver.author.service;
+
+import com.nosum.common.base.domain.PageInfo;
+import com.nosum.deliver.author.domain.po.Author;
+import com.nosum.deliver.author.domain.po.AuthorVideo;
+import org.bson.types.ObjectId;
+
+/**
+ * 作者 VIDEO 服务层.
+ *
+ * @author Young
+ */
+public interface AuthorVideoService {
+
+    /**
+     * 保存作者 VIDEO.
+     *
+     * @param authorVideo 视频
+     */
+    void save(AuthorVideo authorVideo);
+
+    /**
+     * 作者视频分页查询.
+     *
+     * @param pageInfo 分页实体
+     * @param author   作者
+     * @return 分页列表
+     */
+    PageInfo<AuthorVideo> getPage(PageInfo<AuthorVideo> pageInfo, AuthorVideo author);
+
+    /**
+     * 根据 ID 查询作者信息.
+     *
+     * @param id ID
+     * @return 作者信息
+     */
+    AuthorVideo getById(ObjectId id);
+
+    void remove(ObjectId id);
+}

+ 15 - 1
src/main/java/com/nosum/deliver/author/service/impl/AuthorServiceImpl.java

@@ -1,6 +1,7 @@
 package com.nosum.deliver.author.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+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.service.AuthorService;
@@ -43,7 +44,20 @@ public class AuthorServiceImpl implements AuthorService {
 
     @Override
     public PageInfo<Author> getPage(PageInfo<Author> pageInfo, Author author) {
-        Query query = new Query();
+        Criteria criteria = new Criteria();
+
+        if (StrUtil.isNotBlank(author.getFinderUin())) {
+            criteria.and("finderUin").is(author.getFinderUin());
+        }
+        if (StrUtil.isNotBlank(author.getFansCountStr())) {
+            String[] split = author.getFansCountStr().split("-");
+            if (split.length > 1) {
+                criteria.and("fansCount").gte(Long.valueOf(split[0])).lte(Long.valueOf(split[1]));
+            } else {
+                criteria.and("fansCount").gte(Long.valueOf(split[0]));
+            }
+        }
+        Query query = Query.query(criteria);
         query.skip((pageInfo.getPage() - 1) * pageInfo.getSize());
         query.limit((int) pageInfo.getSize());
 

+ 65 - 0
src/main/java/com/nosum/deliver/author/service/impl/AuthorVideoServiceImpl.java

@@ -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);
+    }
+}