Merge remote-tracking branch 'origin/feature/dify' into feature/dify
# Conflicts: # src/test/java/com/zsc/edu/dify/service/system/DeptServiceTest.java # src/test/java/com/zsc/edu/dify/service/system/RoleServiceTest.java # src/test/java/com/zsc/edu/dify/service/system/UserServiceTest.java
This commit is contained in:
commit
6cf9c71abc
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM openjdk:17
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME /tmp
|
||||
ADD target/dify-backend-0.0.1-SNAPSHOT.jar /app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
51
pom.xml
51
pom.xml
@ -9,7 +9,7 @@
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.zsc.edu</groupId>
|
||||
<artifactId>dify</artifactId>
|
||||
<artifactId>dify-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>dify-backend</name>
|
||||
<description>dify-backend</description>
|
||||
@ -31,6 +31,7 @@
|
||||
<mybatis-plus.version>3.5.11</mybatis-plus.version>
|
||||
<mapstruct.version>1.6.2</mapstruct.version>
|
||||
<fastjson.version>2.0.53</fastjson.version>
|
||||
<docker-maven-plugin.version>0.44.0</docker-maven-plugin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
@ -96,7 +97,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>42.6</scope>
|
||||
<version>42.7.3</version> <!-- 使用最新版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@ -118,16 +119,6 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-r2dbc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.r2dbc</groupId>-->
|
||||
<!-- <artifactId>r2dbc-postgresql</artifactId>-->
|
||||
<!-- <version>0.8.13.RELEASE</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
@ -230,6 +221,42 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>${docker-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>docker-build</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- <dockerHost>tcp://127.0.0.1:2375</dockerHost>-->
|
||||
<pushRegistry>registry.cn-hangzhou.aliyuncs.com</pushRegistry>
|
||||
<authConfig>
|
||||
<username>vertoryao</username>
|
||||
<password>71127217311Yao</password>
|
||||
</authConfig>
|
||||
<images>
|
||||
<image>
|
||||
<!-- <name>harry_yao/${project.artifactId}:${project.version}</name>-->
|
||||
<name>registry.cn-hangzhou.aliyuncs.com/harry_yao/${project.artifactId}:latest</name>
|
||||
<registry>registry.cn-hangzhou.aliyuncs.com/harry_yao/${project.artifactId}</registry>
|
||||
<build>
|
||||
<dockerFile>${project.basedir}/Dockerfile</dockerFile>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
<buildArgs>
|
||||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -27,6 +27,7 @@ public class CustomAccessDeniedHandler implements AccessDeniedHandler {
|
||||
@Override
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response,
|
||||
AccessDeniedException ex) throws IOException, ServletException {
|
||||
ex.printStackTrace();
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
ExceptionResult result;
|
||||
if (ex instanceof MissingCsrfTokenException) {
|
||||
|
@ -9,10 +9,12 @@ import com.zsc.edu.dify.modules.system.service.UserService;
|
||||
import io.github.guoshiqiufeng.dify.chat.DifyChat;
|
||||
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.MessagesRequest;
|
||||
import io.github.guoshiqiufeng.dify.chat.dto.response.ChatMessageSendCompletionResponse;
|
||||
import io.github.guoshiqiufeng.dify.chat.dto.response.ChatMessageSendResponse;
|
||||
import io.github.guoshiqiufeng.dify.chat.dto.response.MessageConversationsResponse;
|
||||
import io.github.guoshiqiufeng.dify.core.pojo.DifyPageResult;
|
||||
import io.github.guoshiqiufeng.dify.core.pojo.response.MessagesResponseVO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -86,6 +88,22 @@ public class V1ChatController {
|
||||
request.setUserId(SecurityUtil.getUserInfo().id.toString());
|
||||
return difyChat.conversations(request);
|
||||
}
|
||||
/**
|
||||
* 获取会话的消息列表
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 消息列表
|
||||
*/
|
||||
@PostMapping("/messages/{appid}")
|
||||
@PreAuthorize("hasAuthority('dify:chat:query')")
|
||||
public DifyPageResult<MessagesResponseVO> conversations(
|
||||
@RequestBody MessagesRequest request,
|
||||
@PathVariable String appid
|
||||
) {
|
||||
String apiKey = appEntityService.getApikey(appid);
|
||||
request.setApiKey(apiKey);
|
||||
return difyChat.messages(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止流式消息
|
||||
|
@ -31,7 +31,7 @@ public class RoleController {
|
||||
*
|
||||
* @return 所有角色列表
|
||||
*/
|
||||
@DataPermission
|
||||
// @DataPermission
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAuthority('system:role:query')")
|
||||
public Page<Role> query(RoleQuery query, Page<Role> page) {
|
||||
|
@ -53,6 +53,7 @@ public class UserServiceImpl extends ServiceImpl<UserRepository, User> implement
|
||||
dto.setRoleId(dto.getRoleIds().get(0));
|
||||
userMapper.convert(dto, user);
|
||||
user.setName(dto.getName());
|
||||
user.setPassword(passwordEncoder.encode(dto.password));
|
||||
boolean existsByPhone = count(new LambdaQueryWrapper<User>().eq(User::getPhone, dto.getPhone())) > 0;
|
||||
boolean existsByEmail = count(new LambdaQueryWrapper<User>().eq(User::getEmail, dto.getEmail())) > 0;
|
||||
if (user.getPhone().equals(dto.getPhone()) && existsByPhone) {
|
||||
|
@ -92,9 +92,9 @@ class DeptServiceTest {
|
||||
assertEquals(tmp.getName(), dto.getName());
|
||||
assertEquals(tmp.getId(), dept2.id);
|
||||
// 不能改为其他已存在的同名同代码部门
|
||||
// assertThrows(ConstraintException.class,
|
||||
// () -> service.edit(
|
||||
// new DeptDto(dept3.getName(), "remark",null), dept2.id));
|
||||
assertThrows(ConstraintException.class,
|
||||
() -> service.edit(
|
||||
new DeptDto(dept3.getName(), "remark",null), dept2.id));
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ class RoleServiceTest {
|
||||
assertNotNull(Role.getId());
|
||||
assertEquals(3, service.list(new QueryWrapper<Role>().like("name", "A")).size());
|
||||
// 不能创建其他已存在的同名同代码部门
|
||||
// assertThrows(ConstraintException.class, () -> service.create(new RoleDto(role1.getName(), "remark...", null)));
|
||||
assertThrows(ConstraintException.class, () -> service.create(new RoleDto(role1.getName(), true,"remark...", null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,7 +79,7 @@ public class UserServiceTest {
|
||||
@Test
|
||||
void update() {
|
||||
UserUpdateDto dto = new UserUpdateDto();
|
||||
// dto.setEnable(false);
|
||||
dto.setEnableState(false);
|
||||
dto.setRemark("remark...");
|
||||
dto.setPhone("16786899221");
|
||||
dto.setEmail("@abc.com");
|
||||
|
Loading…
Reference in New Issue
Block a user