puzhibing
2026-09-28 d5a8e1c054431418fa895928ae2e3429295a9865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.ruoyi.system.controller;
 
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.system.task.AliyunChatHistorySyncTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * 阿里云聊天历史同步控制器
 *
 * @author ruoyi
 */
@Api(tags = "阿里云聊天历史同步")
@RestController
@RequestMapping("/system/aliyun/chat")
public class AliyunChatSyncController extends BaseController {
 
    @Autowired
    private AliyunChatHistorySyncTask syncTask;
 
    /**
     * 手动触发同步
     */
    @ApiOperation("手动同步聊天历史")
    @Log(title = "聊天历史同步", businessType = BusinessType.OTHER)
    @PostMapping("/sync")
    public AjaxResult syncNow(@RequestParam String startTime, @RequestParam String endTime) {
        try {
            syncTask.syncChatHistoryByDateRange(startTime, endTime);
            return success("同步成功");
        } catch (Exception e) {
            return error("同步失败: " + e.getMessage());
        }
    }
 
    /**
     * 同步昨天的数据
     */
    @ApiOperation("同步昨天的聊天历史")
    @Log(title = "聊天历史同步", businessType = BusinessType.OTHER)
    @PostMapping("/sync/yesterday")
    public AjaxResult syncYesterday() {
        try {
            syncTask.syncChatHistory();
            return success("同步成功");
        } catch (Exception e) {
            return error("同步失败: " + e.getMessage());
        }
    }
}