123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package com.qmth.ops.biz.service;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.qmth.boot.core.ai.model.llm.LlmAppType;
- import com.qmth.ops.biz.dao.LlmOrgConfigDao;
- import com.qmth.ops.biz.domain.LlmOrgConfig;
- import com.qmth.ops.biz.domain.LlmPromptTemplate;
- import com.qmth.ops.biz.query.LlmOrgConfigQuery;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import javax.annotation.Resource;
- @Service
- public class LlmOrgConfigService extends ServiceImpl<LlmOrgConfigDao, LlmOrgConfig> {
- @Resource
- private LlmOrgConfigDao llmOrgConfigDao;
- public IPage<LlmOrgConfig> query(LlmOrgConfigQuery query) {
- return llmOrgConfigDao.findByQuery(query);
- }
- public int countByPromptTemplate(LlmPromptTemplate template) {
- return llmOrgConfigDao
- .selectCount(new LambdaQueryWrapper<LlmOrgConfig>().eq(LlmOrgConfig::getPromptId, template.getId()));
- }
- public LlmOrgConfig findByOrgAndAppType(Long orgId, LlmAppType appType) {
- return llmOrgConfigDao.selectOne(new LambdaQueryWrapper<LlmOrgConfig>().eq(LlmOrgConfig::getOrgId, orgId)
- .eq(LlmOrgConfig::getAppType, appType));
- }
- @Transactional
- public void updateModelAndPrompt(LlmOrgConfig llmOrgConfig) {
- llmOrgConfigDao.update(llmOrgConfig,
- new LambdaUpdateWrapper<LlmOrgConfig>().set(LlmOrgConfig::getModelId, llmOrgConfig.getModelId())
- .set(LlmOrgConfig::getPromptId, llmOrgConfig.getPromptId())
- .eq(LlmOrgConfig::getOrgId, llmOrgConfig.getOrgId())
- .eq(LlmOrgConfig::getAppType, llmOrgConfig.getAppType()));
- }
- @Transactional
- public void permit(LlmOrgConfig llmOrgConfig, int count) {
- llmOrgConfigDao.permit(llmOrgConfig.getOrgId(), llmOrgConfig.getAppType(), count);
- }
- @Transactional
- public void consume(LlmOrgConfig llmOrgConfig) {
- llmOrgConfigDao.consume(llmOrgConfig.getOrgId(), llmOrgConfig.getAppType());
- }
- }
|