zhou zhou
10 小时以前 80a6d9236ade191a5de0975abe4de5a6e7e63915
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.vincent.rsf.server.ai.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.ai.entity.AiCallLog;
import com.vincent.rsf.server.ai.service.AiCallLogService;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.system.controller.BaseController;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Arrays;
import java.util.Map;
 
@RestController
@RequiredArgsConstructor
public class AiCallLogController extends BaseController {
 
    private final AiCallLogService aiCallLogService;
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @PostMapping("/aiCallLog/page")
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<AiCallLog, BaseParam> pageParam = new PageParam<>(baseParam, AiCallLog.class);
        return R.ok().add(aiCallLogService.page(pageParam, pageParam.buildWrapper(true)
                .eq("tenant_id", getTenantId())
                .eq("deleted", 0)));
    }
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @PostMapping("/aiCallLog/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(aiCallLogService.list(new LambdaQueryWrapper<AiCallLog>()
                .eq(AiCallLog::getTenantId, getTenantId())
                .eq(AiCallLog::getDeleted, 0)
                .orderByDesc(AiCallLog::getId)));
    }
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @PostMapping({"/aiCallLog/many/{ids}", "/aiCallLogs/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(aiCallLogService.list(new LambdaQueryWrapper<AiCallLog>()
                .eq(AiCallLog::getTenantId, getTenantId())
                .eq(AiCallLog::getDeleted, 0)
                .in(AiCallLog::getId, Arrays.asList(ids))));
    }
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @GetMapping("/aiCallLog/{id}")
    public R get(@PathVariable("id") Long id) {
        return R.ok().add(aiCallLogService.getOne(new LambdaQueryWrapper<AiCallLog>()
                .eq(AiCallLog::getId, id)
                .eq(AiCallLog::getTenantId, getTenantId())
                .eq(AiCallLog::getDeleted, 0)
                .last("limit 1")));
    }
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @GetMapping("/aiCallLog/stats")
    public R stats() {
        return R.ok().add(aiCallLogService.getObserveStats(getTenantId()));
    }
 
    @PreAuthorize("hasAuthority('system:aiCallLog:list')")
    @GetMapping("/aiCallLog/{id}/mcpLogs")
    public R listMcpLogs(@PathVariable("id") Long id) {
        return R.ok().add(aiCallLogService.listMcpLogs(id, getTenantId()));
    }
}