Compare commits
No commits in common. "6cf9e2a3fd4c321f5ec90df6ddfc4729ce0a573d" and "92ff130b0dc3da88b17e24b279e75c7a621a3c10" have entirely different histories.
6cf9e2a3fd
...
92ff130b0d
@ -12,8 +12,16 @@ public class ExceptionUtil {
|
|||||||
return supplier.get();
|
return supplier.get();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
throw new ApiException("出现错误,请联系工作人员!报错信息:"+e.getMessage());
|
throw new ApiException("服务器错误,请联系工作人员!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T difyNotFoundException(Supplier<T> supplier) throws ApiException {
|
||||||
|
try {
|
||||||
|
return supplier.get();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
throw new ApiException("数据不存在,请检查传递参数是否错误!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,20 @@ import com.baomidou.mybatisplus.annotation.DbType;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import jakarta.activation.DataSource;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Yao
|
* @author Yao
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package com.zsc.edu.dify.modules.dify.controller;
|
package com.zsc.edu.dify.modules.dify.controller;
|
||||||
|
|
||||||
import com.zsc.edu.dify.exception.ApiException;
|
|
||||||
import com.zsc.edu.dify.exception.ExceptionUtil;
|
import com.zsc.edu.dify.exception.ExceptionUtil;
|
||||||
|
import com.zsc.edu.dify.framework.mybatisplus.DataPermission;
|
||||||
import com.zsc.edu.dify.framework.security.SecurityUtil;
|
import com.zsc.edu.dify.framework.security.SecurityUtil;
|
||||||
import com.zsc.edu.dify.modules.dify.service.AppEntityService;
|
import com.zsc.edu.dify.modules.dify.service.AppEntityService;
|
||||||
import com.zsc.edu.dify.modules.operationLog.entity.OperationLogAnnotation;
|
import com.zsc.edu.dify.modules.operationLog.entity.OperationLogAnnotation;
|
||||||
|
import com.zsc.edu.dify.modules.system.service.UserService;
|
||||||
import io.github.guoshiqiufeng.dify.chat.DifyChat;
|
import io.github.guoshiqiufeng.dify.chat.DifyChat;
|
||||||
import io.github.guoshiqiufeng.dify.chat.dto.request.ChatMessageSendRequest;
|
import io.github.guoshiqiufeng.dify.chat.dto.request.ChatMessageSendRequest;
|
||||||
import io.github.guoshiqiufeng.dify.chat.dto.request.MessageConversationsRequest;
|
import io.github.guoshiqiufeng.dify.chat.dto.request.MessageConversationsRequest;
|
||||||
@ -20,9 +21,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanghq
|
* @author yanghq
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -134,17 +132,5 @@ public class V1ChatController {
|
|||||||
difyChat.deleteConversation(conversationId, apiKey,userId);
|
difyChat.deleteConversation(conversationId, apiKey,userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取会话建议
|
|
||||||
* @param messageId
|
|
||||||
* @param appId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/messages/suggested")
|
|
||||||
@PreAuthorize("hasAuthority('dify:chat:query')")
|
|
||||||
public List<String> messagesSuggested(String messageId,String appId){
|
|
||||||
String apiKey = appEntityService.getApikey(appId);
|
|
||||||
String userId = SecurityUtil.getUserInfo().id.toString();
|
|
||||||
return ExceptionUtil.difyException(()->difyChat.messagesSuggested(messageId,apiKey,userId));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -116,15 +116,4 @@ public class V1ServerController {
|
|||||||
return appEntityService.list(queryWrapper);
|
return appEntityService.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据appType获取应用列表
|
|
||||||
* @param appType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/apps/type")
|
|
||||||
@PreAuthorize("hasAuthority('dify:server:query')")
|
|
||||||
@DataPermission
|
|
||||||
public List<AppEntity> getAppsByAppType(Integer appType){
|
|
||||||
return appEntityService.getAppsByAppType(appType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class V1WorkflowController {
|
|||||||
@PreAuthorize("hasAuthority('dify:workflow:info')")
|
@PreAuthorize("hasAuthority('dify:workflow:info')")
|
||||||
public WorkflowInfoResponse info(String workflowRunId, @PathVariable String appId) {
|
public WorkflowInfoResponse info(String workflowRunId, @PathVariable String appId) {
|
||||||
String apiKey =appEntityService.getApikey(appId);
|
String apiKey =appEntityService.getApikey(appId);
|
||||||
return ExceptionUtil.difyException(() -> difyWorkflow.info(workflowRunId, apiKey));
|
return ExceptionUtil.difyNotFoundException(() -> difyWorkflow.info(workflowRunId, apiKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,5 +110,4 @@ public class V1WorkflowController {
|
|||||||
public List<WorkflowData> list(@PathVariable String appId){
|
public List<WorkflowData> list(@PathVariable String appId){
|
||||||
return difyWorkflowService.list(new QueryWrapper<WorkflowData>().eq("app_id",appId));
|
return difyWorkflowService.list(new QueryWrapper<WorkflowData>().eq("app_id",appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.zsc.edu.dify.modules.dify.entity;
|
package com.zsc.edu.dify.modules.dify.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.zsc.edu.dify.framework.json.JsonbTypeHandler;
|
import com.zsc.edu.dify.framework.json.JsonbTypeHandler;
|
||||||
|
import com.zsc.edu.dify.modules.system.vo.MenuVo;
|
||||||
import io.github.guoshiqiufeng.dify.server.dto.response.AppsResponseVO;
|
import io.github.guoshiqiufeng.dify.server.dto.response.AppsResponseVO;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
@ -52,22 +52,4 @@ public class AppEntity extends AppsResponseVO {
|
|||||||
|
|
||||||
@TableField(value = "dept_id", fill = FieldFill.INSERT)
|
@TableField(value = "dept_id", fill = FieldFill.INSERT)
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
private AppType appType;
|
|
||||||
|
|
||||||
public enum AppType implements IEnum<Integer>{
|
|
||||||
WORD(1),
|
|
||||||
PPT(2),
|
|
||||||
SCRAPER(3);
|
|
||||||
|
|
||||||
private final Integer value;
|
|
||||||
|
|
||||||
AppType(int value) {
|
|
||||||
this.value=value;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,4 @@ public interface AppEntityService extends IService<AppEntity> {
|
|||||||
boolean enabledApp(String id);
|
boolean enabledApp(String id);
|
||||||
|
|
||||||
String getApikey(String appId);
|
String getApikey(String appId);
|
||||||
|
|
||||||
List<AppEntity> getAppsByAppType(Integer appType);
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.zsc.edu.dify.modules.dify.service.Impl;
|
package com.zsc.edu.dify.modules.dify.service.Impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zsc.edu.dify.exception.ConstraintException;
|
import com.zsc.edu.dify.exception.ConstraintException;
|
||||||
@ -91,16 +90,4 @@ public class AppEntityServiceImpl extends ServiceImpl<AppEntityRepository, AppEn
|
|||||||
return appEntityRepository.selectApiKey(appId);
|
return appEntityRepository.selectApiKey(appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据appType获取应用
|
|
||||||
* @param appType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<AppEntity> getAppsByAppType(Integer appType) {
|
|
||||||
LambdaQueryWrapper<AppEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.eq(AppEntity::getAppType, appType).eq(AppEntity::isEnabled, true);
|
|
||||||
return this.list(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,7 @@ class DeptServiceTest {
|
|||||||
assertEquals(tmp.getId(), dept2.id);
|
assertEquals(tmp.getId(), dept2.id);
|
||||||
// 不能改为其他已存在的同名同代码部门
|
// 不能改为其他已存在的同名同代码部门
|
||||||
assertThrows(ConstraintException.class,
|
assertThrows(ConstraintException.class,
|
||||||
() -> service.edit(
|
() -> service.edit(new DeptDto(dept3.getName(), true, "remark",null), dept2.id));
|
||||||
new DeptDto(dept3.getName(), true,null, dept3.id), dept2.id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user