浏览代码

清洗1、 视频数量
2、用户视频列表
3、获取用户公开信息

zhaoxian 11 月之前
父节点
当前提交
b042f80a74
共有 18 个文件被更改,包括 987 次插入2 次删除
  1. 12 2
      ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java
  2. 1 0
      ruixuan-framework/src/main/java/com/ruixuan/framework/config/SecurityConfig.java
  3. 98 0
      ruixuan-live/src/main/java/com/ruixuan/open/controller/KuaishouOpenPhotoListController.java
  4. 51 0
      ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenPhotoCount.java
  5. 74 0
      ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenPhotoList.java
  6. 53 0
      ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenUserInfo.java
  7. 31 0
      ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenPhotoCountMapper.java
  8. 32 0
      ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenPhotoListMapper.java
  9. 31 0
      ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenUserInfoMapper.java
  10. 32 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenPhotoCountService.java
  11. 31 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenPhotoListService.java
  12. 31 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenUserInfoService.java
  13. 83 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenPhotoCountServiceImpl.java
  14. 109 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenPhotoListServiceImpl.java
  15. 81 0
      ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenUserInfoServiceImpl.java
  16. 68 0
      ruixuan-live/src/main/resources/mapper/open/KuaishouOpenPhotoCountMapper.xml
  17. 95 0
      ruixuan-live/src/main/resources/mapper/open/KuaishouOpenPhotoListMapper.xml
  18. 74 0
      ruixuan-live/src/main/resources/mapper/open/KuaishouOpenUserInfoMapper.xml

+ 12 - 2
ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java

@@ -302,7 +302,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         date.setTime(timestamp);
         return DateFormatUtils.format(date, YYYYMMDD);
     }
-
+    /**
+     * 时间戳转换为字符串
+     *
+     * @param time
+     * @return
+     */
+    public static String timestamptoMinutesAndSecondsStr(Long timestamp) {
+        Date date = new Date();
+        date.setTime(timestamp);
+        return DateFormatUtils.format(date, YYYY_MM_DD_HH_MM_SS);
+    }
 
     /**
      * 返回 日期-天数 的string 日期
@@ -520,6 +530,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     }
 
     public static void main(String[] args) {
-        System.out.println(getHour("2023-02-01 23:10:12"));
+        System.out.println(timestamptoMinutesAndSecondsStr(1661851245589L));
     }
 }

+ 1 - 0
ruixuan-framework/src/main/java/com/ruixuan/framework/config/SecurityConfig.java

@@ -131,6 +131,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/jy/material/**").permitAll()
                 .antMatchers("/jy/report/**").permitAll()
                 .antMatchers("/testVideo/**").permitAll()
+                .antMatchers("/open/**").permitAll()
 
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()

+ 98 - 0
ruixuan-live/src/main/java/com/ruixuan/open/controller/KuaishouOpenPhotoListController.java

@@ -0,0 +1,98 @@
+package com.ruixuan.open.controller;
+
+import com.ruixuan.common.core.controller.BaseController;
+import com.ruixuan.common.core.page.TableDataInfo;
+import com.ruixuan.common.utils.Result;
+import com.ruixuan.open.entity.KuaishouOpenPhotoList;
+import com.ruixuan.open.service.IKuaishouOpenPhotoCountService;
+import com.ruixuan.open.service.IKuaishouOpenPhotoListService;
+import com.ruixuan.open.service.IKuaishouOpenUserInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 用户视频列Controller
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+@Api(tags = "用户视频列表")
+@RestController
+@RequestMapping("/open/photo")
+public class KuaishouOpenPhotoListController extends BaseController {
+    @Autowired
+    private IKuaishouOpenPhotoListService openPhotoListService;
+
+    @Autowired
+    private IKuaishouOpenPhotoCountService openPhotoCountService;
+
+    @Autowired
+    private IKuaishouOpenUserInfoService openUserInfoService;
+
+    /**
+     * 查询用户视频列列表
+     */
+    @GetMapping("/list")
+    @ApiOperation(value = "查询用户视频列列表")
+    public TableDataInfo list(KuaishouOpenPhotoList kuaishouOpenPhotoList) {
+        startPage();
+        List<KuaishouOpenPhotoList> list = openPhotoListService.selectKuaishouOpenPhotoListList(kuaishouOpenPhotoList);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 查询用户视频列列表
+     */
+    @GetMapping("/insertKuaishouOpenPhotoList")
+    @ApiOperation(value = "新增视频列表")
+    public Result insertKuaishouOpenPhotoList(@ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId) {
+        try {
+            openPhotoListService.insertKuaishouOpenPhotoList(userId, "0");
+            return Result.success();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("插入失败!");
+        }
+    }
+
+    /**
+     * 新增视频数量
+     */
+    @GetMapping("/insertKuaishouOpenPhotoCount")
+    @ApiOperation(value = "新增视频数量")
+    public Result insertKuaishouOpenPhotoCount(@ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId) {
+        try {
+            openPhotoCountService.insertKuaishouOpenPhotoCount(userId);
+            return Result.success();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("插入失败!");
+        }
+    }
+
+
+    /**
+     * 获取用户公开信息
+     */
+    @GetMapping("/insertKuaishouOpenUserInfo")
+    @ApiOperation(value = "获取用户公开信息")
+    public Result insertKuaishouOpenUserInfo(@ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId) {
+        try {
+            openUserInfoService.insertKuaishouOpenUserInfo(userId);
+            return Result.success();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Result.error("插入失败!");
+        }
+    }
+
+}

+ 51 - 0
ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenPhotoCount.java

@@ -0,0 +1,51 @@
+package com.ruixuan.open.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * 视频数量对象 kuaishou_open_photo_count
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+
+@Data
+@ApiModel(value = "KuaishouOpenPhotoCount", description = "视频数量对象")
+public class KuaishouOpenPhotoCount {
+
+    /**
+     * $column.columnComment
+     */
+    private Long id;
+
+    /**
+     * 达人ID
+     */
+    private Long promoterId;
+
+    /**
+     * 公开视频数量
+     */
+    private Long publicCount;
+
+    /**
+     * 仅好友可见视频数量
+     */
+    private Long friendCount;
+
+    /**
+     * 仅自己可见视频数量
+     */
+    private Long privateCount;
+
+    /**
+     * 视频总量
+     */
+    private Long allCount;
+
+    private String createTime;
+
+    private String updateTime;
+
+}

+ 74 - 0
ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenPhotoList.java

@@ -0,0 +1,74 @@
+package com.ruixuan.open.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * 用户视频列对象 kuaishou_open_photo_list
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+@Data
+@ApiModel(value = "KuaishouOpenPhotoList", description = "用户视频列对象")
+public class KuaishouOpenPhotoList {
+    /**
+     * $column.columnComment
+     */
+    private Long id;
+
+    /**
+     * 达人id
+     */
+    private Long promoterId;
+
+    /**
+     * 作品id
+     */
+    private String photoId;
+
+    /**
+     * 作品标题
+     */
+    private String caption;
+
+    /**
+     * 作品封面
+     */
+    private String cover;
+
+    /**
+     * 作品播放链接
+     */
+    private String playUrl;
+
+    /**
+     * 作品创建时间
+     */
+    private String photoCreateTime;
+
+    /**
+     * 作品点赞数
+     */
+    private Long likeCount;
+
+    /**
+     * 作品评论数
+     */
+    private Long commentCount;
+
+    /**
+     * 作品观看数
+     */
+    private Long viewCount;
+
+    /**
+     * 作品状态(是否还在处理中,不能观看)1-true,0-false
+     */
+    private String pending;
+
+    private String createTime;
+
+    private String updateTime;
+
+}

+ 53 - 0
ruixuan-live/src/main/java/com/ruixuan/open/entity/KuaishouOpenUserInfo.java

@@ -0,0 +1,53 @@
+package com.ruixuan.open.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * 用户公开信息对象 kuaishou_open_user_info
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+
+@Data
+@ApiModel(value = "KuaishouOpenPhotoCount", description = "视频数量对象")
+public class KuaishouOpenUserInfo {
+
+    private Long id;
+
+    /**
+     * 达人ID
+     */
+    private Long promoterId;
+
+    /**
+     * 用户昵称
+     */
+    private String name;
+
+    /**
+     * 用户性别,"F"为女性,"M"为男性,"其他"为未知
+     */
+    private String sex;
+
+    /**
+     * 用户头像地址
+     */
+    private String head;
+
+    /**
+     * 用户高清大头像地址
+     */
+    private String bigHead;
+
+    /**
+     * 用户的openId,同一个用户在同一个开发者主体下返回的openId是一致的
+     */
+    private String openId;
+
+    private String createTime;
+
+    private String updateTime;
+
+}

+ 31 - 0
ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenPhotoCountMapper.java

@@ -0,0 +1,31 @@
+package com.ruixuan.open.mapper;
+
+import com.ruixuan.open.entity.KuaishouOpenPhotoCount;
+
+import java.util.List;
+
+/**
+ * 视频数量Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface KuaishouOpenPhotoCountMapper {
+    /**
+     * 查询视频数量
+     *
+     * @param id 视频数量主键
+     * @return 视频数量
+     */
+    public KuaishouOpenPhotoCount selectKuaishouOpenPhotoCountById(Long id);
+
+    /**
+     * 查询视频数量列表
+     *
+     * @param kuaishouOpenPhotoCount 视频数量
+     * @return 视频数量集合
+     */
+    public List<KuaishouOpenPhotoCount> selectKuaishouOpenPhotoCountList(KuaishouOpenPhotoCount kuaishouOpenPhotoCount);
+
+    void insertKuaishouOpenPhotoCount(KuaishouOpenPhotoCount photoCount);
+}

+ 32 - 0
ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenPhotoListMapper.java

@@ -0,0 +1,32 @@
+package com.ruixuan.open.mapper;
+
+import com.ruixuan.open.entity.KuaishouOpenPhotoList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 用户视频列Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface KuaishouOpenPhotoListMapper {
+    /**
+     * 查询用户视频列
+     *
+     * @param id 用户视频列主键
+     * @return 用户视频列
+     */
+    public KuaishouOpenPhotoList selectKuaishouOpenPhotoListById(Long id);
+
+    /**
+     * 查询用户视频列列表
+     *
+     * @param kuaishouOpenPhotoList 用户视频列
+     * @return 用户视频列集合
+     */
+    public List<KuaishouOpenPhotoList> selectKuaishouOpenPhotoListList(KuaishouOpenPhotoList kuaishouOpenPhotoList);
+
+    void replaceBatchKuaishouOpenPhotoList(@Param("list") List<KuaishouOpenPhotoList> list);
+}

+ 31 - 0
ruixuan-live/src/main/java/com/ruixuan/open/mapper/KuaishouOpenUserInfoMapper.java

@@ -0,0 +1,31 @@
+package com.ruixuan.open.mapper;
+
+import com.ruixuan.open.entity.KuaishouOpenUserInfo;
+
+import java.util.List;
+
+/**
+ * 用户公开信息Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface KuaishouOpenUserInfoMapper {
+    /**
+     * 查询用户公开信息
+     *
+     * @param id 用户公开信息主键
+     * @return 用户公开信息
+     */
+    public KuaishouOpenUserInfo selectKuaishouOpenUserInfoById(Long id);
+
+    /**
+     * 查询用户公开信息列表
+     *
+     * @param kuaishouOpenUserInfo 用户公开信息
+     * @return 用户公开信息集合
+     */
+    public List<KuaishouOpenUserInfo> selectKuaishouOpenUserInfoList(KuaishouOpenUserInfo kuaishouOpenUserInfo);
+
+    void insertKuaishouOpenUserInfo(KuaishouOpenUserInfo userInfo);
+}

+ 32 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenPhotoCountService.java

@@ -0,0 +1,32 @@
+package com.ruixuan.open.service;
+
+import com.ruixuan.open.entity.KuaishouOpenPhotoCount;
+
+import java.util.List;
+
+/**
+ * 视频数量Service接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface IKuaishouOpenPhotoCountService {
+    /**
+     * 查询视频数量
+     *
+     * @param id 视频数量主键
+     * @return 视频数量
+     */
+    public KuaishouOpenPhotoCount selectKuaishouOpenPhotoCountById(Long id);
+
+    /**
+     * 查询视频数量列表
+     *
+     * @param kuaishouOpenPhotoCount 视频数量
+     * @return 视频数量集合
+     */
+    public List<KuaishouOpenPhotoCount> selectKuaishouOpenPhotoCountList(KuaishouOpenPhotoCount kuaishouOpenPhotoCount);
+
+    void insertKuaishouOpenPhotoCount(Long userId);
+
+}

+ 31 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenPhotoListService.java

@@ -0,0 +1,31 @@
+package com.ruixuan.open.service;
+
+import com.ruixuan.open.entity.KuaishouOpenPhotoList;
+
+import java.util.List;
+
+/**
+ * 用户视频列Service接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface IKuaishouOpenPhotoListService {
+    /**
+     * 查询用户视频列
+     *
+     * @param id 用户视频列主键
+     * @return 用户视频列
+     */
+    public KuaishouOpenPhotoList selectKuaishouOpenPhotoListById(Long id);
+
+    /**
+     * 查询用户视频列列表
+     *
+     * @param kuaishouOpenPhotoList 用户视频列
+     * @return 用户视频列集合
+     */
+    public List<KuaishouOpenPhotoList> selectKuaishouOpenPhotoListList(KuaishouOpenPhotoList kuaishouOpenPhotoList);
+
+    void insertKuaishouOpenPhotoList(Long userId, String cursor);
+}

+ 31 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/IKuaishouOpenUserInfoService.java

@@ -0,0 +1,31 @@
+package com.ruixuan.open.service;
+
+import com.ruixuan.open.entity.KuaishouOpenUserInfo;
+
+import java.util.List;
+
+/**
+ * 用户公开信息Service接口
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+public interface IKuaishouOpenUserInfoService {
+    /**
+     * 查询用户公开信息
+     *
+     * @param id 用户公开信息主键
+     * @return 用户公开信息
+     */
+    public KuaishouOpenUserInfo selectKuaishouOpenUserInfoById(Long id);
+
+    /**
+     * 查询用户公开信息列表
+     *
+     * @param kuaishouOpenUserInfo 用户公开信息
+     * @return 用户公开信息集合
+     */
+    public List<KuaishouOpenUserInfo> selectKuaishouOpenUserInfoList(KuaishouOpenUserInfo kuaishouOpenUserInfo);
+
+    void insertKuaishouOpenUserInfo(Long userId);
+}

+ 83 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenPhotoCountServiceImpl.java

@@ -0,0 +1,83 @@
+package com.ruixuan.open.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kuaishou.merchant.open.api.KsMerchantApiException;
+import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
+import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
+import com.kuaishou.merchant.open.api.request.video.OpenPhotoCountRequest;
+import com.kuaishou.merchant.open.api.response.video.OpenPhotoCountResponse;
+import com.ruixuan.open.entity.KuaishouOpenPhotoCount;
+import com.ruixuan.open.mapper.KuaishouOpenPhotoCountMapper;
+import com.ruixuan.open.service.IKuaishouOpenPhotoCountService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 视频数量Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+@Slf4j
+@Service
+public class KuaishouOpenPhotoCountServiceImpl implements IKuaishouOpenPhotoCountService {
+    @Autowired
+    private KuaishouOpenPhotoCountMapper kuaishouOpenPhotoCountMapper;
+
+    /**
+     * 查询视频数量
+     *
+     * @param id 视频数量主键
+     * @return 视频数量
+     */
+    @Override
+    public KuaishouOpenPhotoCount selectKuaishouOpenPhotoCountById(Long id) {
+        return kuaishouOpenPhotoCountMapper.selectKuaishouOpenPhotoCountById(id);
+    }
+
+    /**
+     * 查询视频数量列表
+     *
+     * @param kuaishouOpenPhotoCount 视频数量
+     * @return 视频数量
+     */
+    @Override
+    public List<KuaishouOpenPhotoCount> selectKuaishouOpenPhotoCountList(KuaishouOpenPhotoCount kuaishouOpenPhotoCount) {
+        return kuaishouOpenPhotoCountMapper.selectKuaishouOpenPhotoCountList(kuaishouOpenPhotoCount);
+    }
+
+
+    @Override
+    public void insertKuaishouOpenPhotoCount(Long userId) {
+        try {
+            String url = "https://openapi.kwaixiaodian.com";
+            String appKey = "ks690458118961229051";
+            String signSecret = "6ef1e2a231733bb0c38fb2bf0f50e45b";
+            String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJAhhjrjfDtPkuAuUN5pOWY1hl3SUdOrNORPbgFhIJ1uxNFUrKSaCTdaOcWUvlLqPOZWnnR-1_wWga0cNw-ZsmuYBoSdJTaZfTbRbe4zPS88hU0zxRHIiBA8uLLXu_BaAsO7k5WZayprQWLkUi_G-cvvV_XJMVzBCgFMAE";
+
+            AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
+
+            OpenPhotoCountRequest request = new OpenPhotoCountRequest();
+            request.setAccessToken(accessToken);
+            //请求的API版本号,目前版本为1
+            request.setApiMethodVersion(1L);
+
+            OpenPhotoCountResponse response = client.execute(request);
+            JSONObject resultJson = JSONObject.parseObject(GsonUtils.toJSON(response));
+            String code = resultJson.getString("code");
+            if ("1".equals(code)) {
+                KuaishouOpenPhotoCount photoCount = JSONObject.parseObject(resultJson.getJSONObject("data").toJSONString(), KuaishouOpenPhotoCount.class);
+                photoCount.setPromoterId(userId);
+                kuaishouOpenPhotoCountMapper.insertKuaishouOpenPhotoCount(photoCount);
+            } else {
+                log.error("===新增视频数量(open.photo.count)失败,userID:{},信息:{}", userId, resultJson.getString("msg"));
+            }
+        } catch (KsMerchantApiException e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 109 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenPhotoListServiceImpl.java

@@ -0,0 +1,109 @@
+package com.ruixuan.open.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
+import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
+import com.kuaishou.merchant.open.api.request.video.OpenPhotoListRequest;
+import com.kuaishou.merchant.open.api.response.video.OpenPhotoListResponse;
+import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.open.entity.KuaishouOpenPhotoList;
+import com.ruixuan.open.mapper.KuaishouOpenPhotoListMapper;
+import com.ruixuan.open.service.IKuaishouOpenPhotoListService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 用户视频列Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+@Slf4j
+@Service
+public class KuaishouOpenPhotoListServiceImpl implements IKuaishouOpenPhotoListService {
+    @Autowired
+    private KuaishouOpenPhotoListMapper kuaishouOpenPhotoListMapper;
+
+    /**
+     * 查询用户视频列
+     *
+     * @param id 用户视频列主键
+     * @return 用户视频列
+     */
+    @Override
+    public KuaishouOpenPhotoList selectKuaishouOpenPhotoListById(Long id) {
+        return kuaishouOpenPhotoListMapper.selectKuaishouOpenPhotoListById(id);
+    }
+
+    /**
+     * 查询用户视频列列表
+     *
+     * @param kuaishouOpenPhotoList 用户视频列
+     * @return 用户视频列
+     */
+    @Override
+    public List<KuaishouOpenPhotoList> selectKuaishouOpenPhotoListList(KuaishouOpenPhotoList kuaishouOpenPhotoList) {
+        return kuaishouOpenPhotoListMapper.selectKuaishouOpenPhotoListList(kuaishouOpenPhotoList);
+    }
+
+    @Override
+    public void insertKuaishouOpenPhotoList(Long userId, String cursor) {
+        try {
+            String url = "https://openapi.kwaixiaodian.com";
+
+            String appKey = "ks690458118961229051";
+            String signSecret = "6ef1e2a231733bb0c38fb2bf0f50e45b";
+            String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJAhhjrjfDtPkuAuUN5pOWY1hl3SUdOrNORPbgFhIJ1uxNFUrKSaCTdaOcWUvlLqPOZWnnR-1_wWga0cNw-ZsmuYBoSdJTaZfTbRbe4zPS88hU0zxRHIiBA8uLLXu_BaAsO7k5WZayprQWLkUi_G-cvvV_XJMVzBCgFMAE";
+
+            AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
+
+            OpenPhotoListRequest request = new OpenPhotoListRequest();
+            request.setAccessToken(accessToken);
+            request.setApiMethodVersion(1L);
+
+            //游标,用于分页,值为作品id。分页查询时,传上一页create_time最小的photo_id。第一页不传此参数。
+            request.setCursor(cursor);
+            //数量,默认为20,最大不超过200
+            request.setCount(20);
+
+            OpenPhotoListResponse response = client.execute(request);
+            JSONObject resultJson = JSONObject.parseObject(GsonUtils.toJSON(response));
+            String code = resultJson.getString("code");
+            String minPhotoId = null;
+            if ("1".equals(code)) {
+                List<KuaishouOpenPhotoList> list = new ArrayList<>();
+                JSONArray jsonArray = resultJson.getJSONObject("data").getJSONArray("videoList");
+                Long min = jsonArray.getJSONObject(0).getLong("createTime");
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    JSONObject obj = jsonArray.getJSONObject(i);
+                    KuaishouOpenPhotoList photo = JSONObject.parseObject(obj.toJSONString(), KuaishouOpenPhotoList.class);
+                    //获取最小
+                    if (obj.getLong("createTime") < min) {
+                        min = obj.getLong("createTime");
+                        minPhotoId = photo.getPhotoId();
+                    }
+                    photo.setPromoterId(userId);
+                    photo.setPhotoCreateTime(DateUtils.timestamptoMinutesAndSecondsStr(obj.getLong("createTime")));
+                    photo.setPending(String.valueOf(obj.getBoolean("pending") ? 1 : 0));
+                    list.add(photo);
+                }
+                if (list.size() > 0) {
+                    kuaishouOpenPhotoListMapper.replaceBatchKuaishouOpenPhotoList(list);
+                }
+                if (jsonArray.size() == 20) {
+                    insertKuaishouOpenPhotoList(userId, minPhotoId);
+                }
+            } else {
+                log.error("===新增视频列表(open.photo.list)失败,userID:{},信息:{}", userId, resultJson.getString("msg"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 81 - 0
ruixuan-live/src/main/java/com/ruixuan/open/service/impl/KuaishouOpenUserInfoServiceImpl.java

@@ -0,0 +1,81 @@
+package com.ruixuan.open.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kuaishou.merchant.open.api.KsMerchantApiException;
+import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
+import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
+import com.kuaishou.merchant.open.api.request.user.OpenUserInfoGetRequest;
+import com.kuaishou.merchant.open.api.response.user.OpenUserInfoGetResponse;
+import com.ruixuan.open.entity.KuaishouOpenUserInfo;
+import com.ruixuan.open.mapper.KuaishouOpenUserInfoMapper;
+import com.ruixuan.open.service.IKuaishouOpenUserInfoService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 用户公开信息Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2024-07-09
+ */
+@Slf4j
+@Service
+public class KuaishouOpenUserInfoServiceImpl implements IKuaishouOpenUserInfoService {
+    @Autowired
+    private KuaishouOpenUserInfoMapper kuaishouOpenUserInfoMapper;
+
+    /**
+     * 查询用户公开信息
+     *
+     * @param id 用户公开信息主键
+     * @return 用户公开信息
+     */
+    @Override
+    public KuaishouOpenUserInfo selectKuaishouOpenUserInfoById(Long id) {
+        return kuaishouOpenUserInfoMapper.selectKuaishouOpenUserInfoById(id);
+    }
+
+    /**
+     * 查询用户公开信息列表
+     *
+     * @param kuaishouOpenUserInfo 用户公开信息
+     * @return 用户公开信息
+     */
+    @Override
+    public List<KuaishouOpenUserInfo> selectKuaishouOpenUserInfoList(KuaishouOpenUserInfo kuaishouOpenUserInfo) {
+        return kuaishouOpenUserInfoMapper.selectKuaishouOpenUserInfoList(kuaishouOpenUserInfo);
+    }
+
+    @Override
+    public void insertKuaishouOpenUserInfo(Long userId) {
+        try {
+            String url = "https://openapi.kwaixiaodian.com";
+            String appKey = "ks690458118961229051";
+            String signSecret = "6ef1e2a231733bb0c38fb2bf0f50e45b";
+            String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJAhhjrjfDtPkuAuUN5pOWY1hl3SUdOrNORPbgFhIJ1uxNFUrKSaCTdaOcWUvlLqPOZWnnR-1_wWga0cNw-ZsmuYBoSdJTaZfTbRbe4zPS88hU0zxRHIiBA8uLLXu_BaAsO7k5WZayprQWLkUi_G-cvvV_XJMVzBCgFMAE";
+
+            AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
+
+            OpenUserInfoGetRequest request = new OpenUserInfoGetRequest();
+            request.setAccessToken(accessToken);
+            request.setApiMethodVersion(1L);
+
+            OpenUserInfoGetResponse response = client.execute(request);
+            JSONObject resultJson = JSONObject.parseObject(GsonUtils.toJSON(response));
+            String code = resultJson.getString("code");
+            if ("1".equals(code)) {
+                KuaishouOpenUserInfo userInfo = JSONObject.parseObject(resultJson.getJSONObject("data").toJSONString(), KuaishouOpenUserInfo.class);
+                userInfo.setPromoterId(userId);
+                kuaishouOpenUserInfoMapper.insertKuaishouOpenUserInfo(userInfo);
+            } else {
+                log.error("===获取用户公开信息(open.user.info.get)失败,userID:{},信息:{}", userId, resultJson.getString("msg"));
+            }
+        } catch (KsMerchantApiException e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 68 - 0
ruixuan-live/src/main/resources/mapper/open/KuaishouOpenPhotoCountMapper.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruixuan.open.mapper.KuaishouOpenPhotoCountMapper">
+
+    <resultMap type="com.ruixuan.open.entity.KuaishouOpenPhotoCount" id="KuaishouOpenPhotoCountResult">
+        <result property="id" column="id"/>
+        <result property="promoterId" column="promoter_id"/>
+        <result property="publicCount" column="public_count"/>
+        <result property="friendCount" column="friend_count"/>
+        <result property="privateCount" column="private_count"/>
+        <result property="allCount" column="all_count"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectKuaishouOpenPhotoCountVo">
+        select id,
+               promoter_id,
+               public_count,
+               friend_count,
+               private_count,
+               all_count,
+               create_time,
+               update_time
+        from kuaishou_open_photo_count
+    </sql>
+
+    <select id="selectKuaishouOpenPhotoCountList" resultMap="KuaishouOpenPhotoCountResult">
+        <include refid="selectKuaishouOpenPhotoCountVo"/>
+        <where>
+            <if test="promoterId != null ">and promoter_id = #{promoterId}</if>
+            <if test="publicCount != null ">and public_count = #{publicCount}</if>
+            <if test="friendCount != null ">and friend_count = #{friendCount}</if>
+            <if test="privateCount != null ">and private_count = #{privateCount}</if>
+            <if test="allCount != null ">and all_count = #{allCount}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouOpenPhotoCountById" resultMap="KuaishouOpenPhotoCountResult">
+        <include refid="selectKuaishouOpenPhotoCountVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertKuaishouOpenPhotoCount" useGeneratedKeys="true" keyProperty="id">
+        insert into kuaishou_open_photo_count
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">promoter_id,</if>
+            <if test="publicCount != null">public_count,</if>
+            <if test="friendCount != null">friend_count,</if>
+            <if test="privateCount != null">private_count,</if>
+            <if test="allCount != null">all_count,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">#{promoterId},</if>
+            <if test="publicCount != null">#{publicCount},</if>
+            <if test="friendCount != null">#{friendCount},</if>
+            <if test="privateCount != null">#{privateCount},</if>
+            <if test="allCount != null">#{allCount},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+
+</mapper>

+ 95 - 0
ruixuan-live/src/main/resources/mapper/open/KuaishouOpenPhotoListMapper.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruixuan.open.mapper.KuaishouOpenPhotoListMapper">
+
+    <resultMap type="com.ruixuan.open.entity.KuaishouOpenPhotoList" id="KuaishouOpenPhotoListResult">
+        <result property="id" column="id"/>
+        <result property="promoterId" column="promoter_id"/>
+        <result property="photoId" column="photo_id"/>
+        <result property="caption" column="caption"/>
+        <result property="cover" column="cover"/>
+        <result property="playUrl" column="play_url"/>
+        <result property="photoCreateTime" column="photo_create_time"/>
+        <result property="likeCount" column="like_count"/>
+        <result property="commentCount" column="comment_count"/>
+        <result property="viewCount" column="view_count"/>
+        <result property="pending" column="pending"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+    <sql id="selectKuaishouOpenPhotoListVo">
+        select id,
+               promoter_id,
+               photo_id,
+               caption,
+               cover,
+               play_url,
+               photo_create_time,
+               like_count,
+               comment_count,
+               view_count,
+               pending,
+               create_time,
+               update_time
+        from kuaishou_open_photo_list
+    </sql>
+
+    <select id="selectKuaishouOpenPhotoListList"
+            resultMap="KuaishouOpenPhotoListResult">
+
+        <include refid="selectKuaishouOpenPhotoListVo"/>
+        <where>
+            <if test="promoterId != null ">and promoter_id = #{promoterId}</if>
+            <if test="photoId != null  and photoId != ''">and photo_id = #{photoId}</if>
+            <if test="caption != null  and caption != ''">and caption = #{caption}</if>
+            <if test="cover != null  and cover != ''">and cover = #{cover}</if>
+            <if test="playUrl != null  and playUrl != ''">and play_url = #{playUrl}</if>
+            <if test="photoCreateTime != null  and photoCreateTime != ''">and photo_create_time = #{photoCreateTime}
+            </if>
+            <if test="likeCount != null ">and like_count = #{likeCount}</if>
+            <if test="commentCount != null ">and comment_count = #{commentCount}</if>
+            <if test="viewCount != null ">and view_count = #{viewCount}</if>
+            <if test="pending != null  and pending != ''">and pending = #{pending}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouOpenPhotoListById" resultMap="KuaishouOpenPhotoListResult">
+        <include refid="selectKuaishouOpenPhotoListVo"/>
+        where id = #{id}
+    </select>
+
+
+    <insert id="replaceBatchKuaishouOpenPhotoList">
+        replace into kuaishou_open_photo_list(
+        promoter_id,
+        photo_id,
+        caption,
+        cover,
+        play_url,
+        photo_create_time,
+        like_count,
+        comment_count,
+        view_count,
+        pending
+        )
+        values
+        <foreach collection="list" item="photo" separator=",">
+            (
+            #{photo.promoterId},
+            #{photo.photoId},
+            #{photo.caption},
+            #{photo.cover},
+            #{photo.playUrl},
+            #{photo.photoCreateTime},
+            #{photo.likeCount},
+            #{photo.commentCount},
+            #{photo.viewCount},
+            #{photo.pending}
+            )
+        </foreach>
+    </insert>
+
+
+</mapper>

+ 74 - 0
ruixuan-live/src/main/resources/mapper/open/KuaishouOpenUserInfoMapper.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruixuan.open.mapper.KuaishouOpenUserInfoMapper">
+
+    <resultMap type="com.ruixuan.open.entity.KuaishouOpenUserInfo" id="KuaishouOpenUserInfoResult">
+        <result property="id" column="id"/>
+        <result property="promoterId" column="promoter_id"/>
+        <result property="name" column="name"/>
+        <result property="sex" column="sex"/>
+        <result property="head" column="head"/>
+        <result property="bigHead" column="big_head"/>
+        <result property="openId" column="open_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectKuaishouOpenUserInfoVo">
+        select id,
+               promoter_id,
+               name,
+               sex,
+               head,
+               big_head,
+               open_id,
+               create_time,
+               update_time
+        from kuaishou_open_user_info
+    </sql>
+
+    <select id="selectKuaishouOpenUserInfoList"
+            resultMap="KuaishouOpenUserInfoResult">
+        <include refid="selectKuaishouOpenUserInfoVo"/>
+        <where>
+            <if test="promoterId != null ">and promoter_id = #{promoterId}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="sex != null  and sex != ''">and sex = #{sex}</if>
+            <if test="head != null  and head != ''">and head = #{head}</if>
+            <if test="bigHead != null  and bigHead != ''">and big_head = #{bigHead}</if>
+            <if test="openId != null  and openId != ''">and open_id = #{openId}</if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouOpenUserInfoById" resultMap="KuaishouOpenUserInfoResult">
+        <include refid="selectKuaishouOpenUserInfoVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertKuaishouOpenUserInfo" useGeneratedKeys="true" keyProperty="id">
+        insert into kuaishou_open_user_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">promoter_id,</if>
+            <if test="name != null">name,</if>
+            <if test="sex != null">sex,</if>
+            <if test="head != null">head,</if>
+            <if test="bigHead != null">big_head,</if>
+            <if test="openId != null">open_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">#{promoterId},</if>
+            <if test="name != null">#{name},</if>
+            <if test="sex != null">#{sex},</if>
+            <if test="head != null">#{head},</if>
+            <if test="bigHead != null">#{bigHead},</if>
+            <if test="openId != null">#{openId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+
+</mapper>