#AI
zhou zhou
11 小时以前 51877df13075ad10ef51107f15bcd21f1661febe
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
package com.vincent.rsf.server.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vincent.rsf.server.system.entity.AiModelRoute;
import com.vincent.rsf.server.system.mapper.AiModelRouteMapper;
import com.vincent.rsf.server.system.service.AiModelRouteService;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
 
@Service("aiModelRouteService")
public class AiModelRouteServiceImpl extends ServiceImpl<AiModelRouteMapper, AiModelRoute> implements AiModelRouteService {
 
    @Override
    public AiModelRoute getTenantRoute(Long tenantId, Long id) {
        if (tenantId == null || id == null) {
            return null;
        }
        return this.getOne(new LambdaQueryWrapper<AiModelRoute>()
                .eq(AiModelRoute::getTenantId, tenantId)
                .eq(AiModelRoute::getId, id)
                .last("limit 1"));
    }
 
    @Override
    public List<AiModelRoute> listAvailableRoutes(Long tenantId, String routeCode) {
        Date now = new Date();
        return this.list(new LambdaQueryWrapper<AiModelRoute>()
                .eq(AiModelRoute::getTenantId, tenantId)
                .eq(AiModelRoute::getRouteCode, routeCode)
                .eq(AiModelRoute::getStatus, 1)
                .and(wrapper -> wrapper.isNull(AiModelRoute::getCooldownUntil).or().le(AiModelRoute::getCooldownUntil, now))
                .orderByAsc(AiModelRoute::getPriority, AiModelRoute::getId));
    }
}