remove package

This commit is contained in:
ccmjga
2025-06-02 08:41:02 +08:00
parent 867e9e53bf
commit de33d29ec7
5 changed files with 6 additions and 3 deletions

View File

@@ -0,0 +1,38 @@
package com.zl.mjga.component;
import com.zl.mjga.exception.BusinessException;
import com.zl.mjga.repository.DepartmentRepository;
import com.zl.mjga.service.DepartmentService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.model.output.structured.Description;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.jooq.generated.mjga.tables.pojos.Department;
import org.springframework.stereotype.Component;
@Description("和部门管理有关的操作工具")
@RequiredArgsConstructor
@Component
public class DepartmentOperatorTool {
private final DepartmentService departmentService;
private final DepartmentRepository departmentRepository;
@Tool(value = "创建部门")
void createDepartment(
@P(value = "部门名称") String departmentName,
@P(value = "上级部门名称", required = false) String parentDepartmentName) {
Department exist = departmentRepository.fetchOneByName(departmentName);
if (exist != null) {
throw new BusinessException("当前部门已存在");
}
if (StringUtils.isNotEmpty(parentDepartmentName)) {
Department parent = departmentRepository.fetchOneByName(parentDepartmentName);
if (parent == null) {
throw new BusinessException("上级部门不存在");
}
}
departmentService.upsertDepartment(new Department(null, departmentName, null));
}
}

View File

@@ -0,0 +1,24 @@
package com.zl.mjga.component;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import lombok.Data;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
@Data
@Component
public class PromptConfiguration {
@jakarta.annotation.Resource private ResourceLoader resourceLoader;
private String system;
@PostConstruct
public void init() throws IOException {
Resource resource = resourceLoader.getResource("classpath:prompt.txt");
system = Files.readString(Paths.get(resource.getURI()));
}
}

View File

@@ -0,0 +1,43 @@
package com.zl.mjga.component;
import com.zl.mjga.dto.urp.UserUpsertDto;
import com.zl.mjga.exception.BusinessException;
import com.zl.mjga.repository.UserRepository;
import com.zl.mjga.service.IdentityAccessService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.model.output.structured.Description;
import lombok.RequiredArgsConstructor;
import org.jooq.generated.mjga.tables.pojos.User;
import org.springframework.stereotype.Component;
@Description("和用户管理有关的操作工具")
@RequiredArgsConstructor
@Component
public class UserOperatorTool {
private final IdentityAccessService identityAccessService;
private final UserRepository userRepository;
@Tool(value = "创建用户或注册用户")
void createUser(@P(value = "用户名") String username) {
User user = userRepository.fetchOneByUsername(username);
if (user != null) {
throw new BusinessException("用户已存在");
}
identityAccessService.upsertUser(new UserUpsertDto(null, username, username, true));
}
@Tool(value = "删除用户")
void deleteUser(@P(value = "用户名") String username) {
userRepository.deleteByUsername(username);
}
@Tool(value = "编辑/更新/更改用户")
void updateUser(
@P(value = "用户名") String username,
@P(value = "密码", required = false) String password,
@P(value = "是否开启", required = false) Boolean enable) {
identityAccessService.upsertUser(new UserUpsertDto(null, username, password, enable));
}
}