gateway tomcat去除
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package org.xyzh.workcase.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
import org.xyzh.common.auth.contants.AuthContants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WebSocket握手拦截器
|
||||
* 从网关传递的请求头中获取已验证的用户信息
|
||||
*/
|
||||
@Component
|
||||
public class WebSocketAuthInterceptor implements HandshakeInterceptor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WebSocketAuthInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response,
|
||||
WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
|
||||
|
||||
log.info("WebSocket握手开始,URI: {}", request.getURI());
|
||||
|
||||
try {
|
||||
// 从网关传递的请求头中获取用户ID(网关已完成token验证)
|
||||
String userId = extractUserIdFromRequest(request);
|
||||
|
||||
if (!StringUtils.hasText(userId)) {
|
||||
log.warn("WebSocket握手失败:请求头中未找到用户ID,网关认证可能失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 可选:也获取token,供后续使用
|
||||
String token = extractTokenFromRequest(request);
|
||||
|
||||
// 将用户信息存储到WebSocket会话属性中,供后续使用
|
||||
attributes.put("userId", userId);
|
||||
if (StringUtils.hasText(token)) {
|
||||
attributes.put("token", token);
|
||||
}
|
||||
|
||||
log.info("WebSocket握手成功,userId: {}", userId);
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("WebSocket握手异常", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response,
|
||||
WebSocketHandler wsHandler, Exception exception) {
|
||||
if (exception != null) {
|
||||
log.error("WebSocket握手后发生异常", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从网关传递的请求头中提取用户ID
|
||||
*/
|
||||
private String extractUserIdFromRequest(ServerHttpRequest request) {
|
||||
if (request instanceof ServletServerHttpRequest) {
|
||||
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
|
||||
|
||||
// 从网关传递的请求头获取(标准微服务架构方式)
|
||||
String userId = servletRequest.getHeaders().getFirst(AuthContants.USER_ID_ATTRIBUTE);
|
||||
if (StringUtils.hasText(userId)) {
|
||||
log.debug("从网关请求头获取用户ID: {}", userId);
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
|
||||
log.warn("未能从请求头中获取用户ID");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从请求头中提取token(可选)
|
||||
*/
|
||||
private String extractTokenFromRequest(ServerHttpRequest request) {
|
||||
if (request instanceof ServletServerHttpRequest) {
|
||||
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
|
||||
|
||||
// 从网关传递的请求头获取
|
||||
String token = servletRequest.getHeaders().getFirst(AuthContants.TOKEN_ATTRIBUTE);
|
||||
if (StringUtils.hasText(token)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
// 也支持从Authorization头获取
|
||||
String authHeader = servletRequest.getHeaders().getFirst("Authorization");
|
||||
if (StringUtils.hasText(authHeader)) {
|
||||
if (authHeader.startsWith("Bearer ")) {
|
||||
return authHeader.substring(7);
|
||||
}
|
||||
return authHeader;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.xyzh.workcase.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
@@ -14,6 +15,9 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
|
||||
@EnableWebSocketMessageBroker
|
||||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Autowired
|
||||
private WebSocketAuthInterceptor webSocketAuthInterceptor;
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||
// 配置消息代理
|
||||
@@ -29,9 +33,15 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
// 注册STOMP端点
|
||||
registry.addEndpoint("/ws/chat")
|
||||
.setAllowedOriginPatterns("*") // 允许跨域
|
||||
.withSockJS(); // 支持SockJS降级方案
|
||||
// 原生WebSocket端点(不使用SockJS)
|
||||
registry.addEndpoint("/workcase/ws/chat")
|
||||
.setAllowedOriginPatterns("*")
|
||||
.addInterceptors(webSocketAuthInterceptor);
|
||||
|
||||
// SockJS端点(用于不支持WebSocket的浏览器降级)
|
||||
registry.addEndpoint("/workcase/ws/chat-sockjs")
|
||||
.setAllowedOriginPatterns("*")
|
||||
.addInterceptors(webSocketAuthInterceptor)
|
||||
.withSockJS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.xyzh.workcase.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -13,9 +15,18 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
import org.xyzh.api.ai.dto.ChatPrepareData;
|
||||
import org.xyzh.api.ai.dto.TbChat;
|
||||
import org.xyzh.api.ai.dto.TbChatMessage;
|
||||
import org.xyzh.api.workcase.dto.TbChatRoomDTO;
|
||||
import org.xyzh.api.workcase.dto.TbChatRoomMemberDTO;
|
||||
import org.xyzh.api.workcase.dto.TbChatRoomMessageDTO;
|
||||
import org.xyzh.api.workcase.dto.TbCustomerServiceDTO;
|
||||
import org.xyzh.api.workcase.dto.TbWordCloudDTO;
|
||||
import org.xyzh.api.workcase.dto.TbWorkcaseDTO;
|
||||
import org.xyzh.api.workcase.service.ChatRoomService;
|
||||
import org.xyzh.api.workcase.service.WorkcaseChatService;
|
||||
import org.xyzh.api.workcase.vo.ChatMemberVO;
|
||||
import org.xyzh.api.workcase.vo.ChatRoomMessageVO;
|
||||
import org.xyzh.api.workcase.vo.ChatRoomVO;
|
||||
import org.xyzh.api.workcase.vo.CustomerServiceVO;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.utils.validation.ValidationResult;
|
||||
@@ -28,7 +39,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* @description 工单对话控制器
|
||||
* - AI对话管理
|
||||
* - AI对话管理(智能问答)
|
||||
* - ChatRoom聊天室管理(实时IM)
|
||||
* - 微信客服消息接收
|
||||
* - 词云管理
|
||||
* @filename WorkcaseChatController.java
|
||||
@@ -44,9 +56,13 @@ public class WorkcaseChatContorller {
|
||||
@Autowired
|
||||
private WorkcaseChatService workcaseChatService;
|
||||
|
||||
@Autowired
|
||||
private ChatRoomService chatRoomService;
|
||||
|
||||
// ========================= AI对话管理 =========================
|
||||
|
||||
@Operation(summary = "创建对话")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:create')")
|
||||
@PostMapping
|
||||
public ResultDomain<TbChat> createChat(@RequestBody TbChat chat) {
|
||||
ValidationResult vr = ValidationUtils.validate(chat, Arrays.asList(
|
||||
@@ -59,6 +75,7 @@ public class WorkcaseChatContorller {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新对话")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:update')")
|
||||
@PutMapping
|
||||
public ResultDomain<TbChat> updateChat(@RequestBody TbChat chat) {
|
||||
ValidationResult vr = ValidationUtils.validate(chat, Arrays.asList(
|
||||
@@ -71,12 +88,14 @@ public class WorkcaseChatContorller {
|
||||
}
|
||||
|
||||
@Operation(summary = "查询对话列表")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:list')")
|
||||
@PostMapping("/list")
|
||||
public ResultDomain<TbChat> getChatList(@RequestBody TbChat filter) {
|
||||
return workcaseChatService.getChatList(filter);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取对话消息列表")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:message')")
|
||||
@PostMapping("/message/list")
|
||||
public ResultDomain<TbChatMessage> getChatMessageList(@RequestBody TbChat filter) {
|
||||
ValidationResult vr = ValidationUtils.validate(filter, Arrays.asList(
|
||||
@@ -89,6 +108,7 @@ public class WorkcaseChatContorller {
|
||||
}
|
||||
|
||||
@Operation(summary = "准备对话会话")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:stream')")
|
||||
@PostMapping("/prepare")
|
||||
public ResultDomain<String> prepareChatMessageSession(@RequestBody ChatPrepareData prepareData) {
|
||||
ValidationResult vr = ValidationUtils.validate(prepareData, Arrays.asList(
|
||||
@@ -102,18 +122,21 @@ public class WorkcaseChatContorller {
|
||||
}
|
||||
|
||||
@Operation(summary = "流式对话(SSE)")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:stream')")
|
||||
@GetMapping(value = "/stream/{sessionId}", produces = "text/event-stream")
|
||||
public SseEmitter streamChatMessage(@PathVariable String sessionId) {
|
||||
return workcaseChatService.streamChatMessageWithSse(sessionId);
|
||||
}
|
||||
|
||||
@Operation(summary = "停止对话")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:stream')")
|
||||
@PostMapping("/stop/{taskId}")
|
||||
public ResultDomain<Boolean> stopChat(@RequestBody TbChat filter, @PathVariable String taskId) {
|
||||
return workcaseChatService.stopChatMessageByTaskId(filter, taskId);
|
||||
}
|
||||
|
||||
@Operation(summary = "评论对话消息")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:message')")
|
||||
@PostMapping("/comment")
|
||||
public ResultDomain<Boolean> commentChatMessage(@RequestBody TbChat filter,
|
||||
@RequestParam String messageId, @RequestParam String comment) {
|
||||
@@ -123,43 +146,233 @@ public class WorkcaseChatContorller {
|
||||
// ========================= 对话分析 =========================
|
||||
|
||||
@Operation(summary = "分析对话(AI预填工单信息)")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:analyze')")
|
||||
@GetMapping("/analyze/{chatId}")
|
||||
public ResultDomain<TbWorkcaseDTO> analyzeChat(@PathVariable String chatId) {
|
||||
return workcaseChatService.analyzeChat(chatId);
|
||||
}
|
||||
|
||||
@Operation(summary = "总结对话")
|
||||
@PreAuthorize("hasAuthority('workcase:chat:analyze')")
|
||||
@PostMapping("/summary/{chatId}")
|
||||
public ResultDomain<TbWorkcaseDTO> summaryChat(@PathVariable String chatId) {
|
||||
return workcaseChatService.summaryChat(chatId);
|
||||
}
|
||||
|
||||
// ========================= ChatRoom聊天室管理(实时IM) =========================
|
||||
|
||||
@Operation(summary = "创建聊天室")
|
||||
@PreAuthorize("hasAuthority('workcase:room:create')")
|
||||
@PostMapping("/room")
|
||||
public ResultDomain<TbChatRoomDTO> createChatRoom(@RequestBody TbChatRoomDTO chatRoom) {
|
||||
ValidationResult vr = ValidationUtils.validate(chatRoom, Arrays.asList(
|
||||
ValidationUtils.requiredString("workcaseId", "工单ID"),
|
||||
ValidationUtils.requiredString("guestId", "来客ID")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.createChatRoom(chatRoom);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新聊天室")
|
||||
@PreAuthorize("hasAuthority('workcase:room:update')")
|
||||
@PutMapping("/room")
|
||||
public ResultDomain<TbChatRoomDTO> updateChatRoom(@RequestBody TbChatRoomDTO chatRoom) {
|
||||
ValidationResult vr = ValidationUtils.validate(chatRoom, Arrays.asList(
|
||||
ValidationUtils.requiredString("roomId", "聊天室ID")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.updateChatRoom(chatRoom);
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭聊天室")
|
||||
@PreAuthorize("hasAuthority('workcase:room:close')")
|
||||
@PostMapping("/room/{roomId}/close")
|
||||
public ResultDomain<Boolean> closeChatRoom(@PathVariable String roomId, @RequestParam String closedBy) {
|
||||
return chatRoomService.closeChatRoom(roomId, closedBy);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取聊天室详情")
|
||||
@PreAuthorize("hasAuthority('workcase:room:view')")
|
||||
@GetMapping("/room/{roomId}")
|
||||
public ResultDomain<TbChatRoomDTO> getChatRoomById(@PathVariable String roomId) {
|
||||
return chatRoomService.getChatRoomById(roomId);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询聊天室")
|
||||
@PreAuthorize("hasAuthority('workcase:room:view')")
|
||||
@PostMapping("/room/page")
|
||||
public ResultDomain<ChatRoomVO> getChatRoomPage(@RequestBody PageRequest<TbChatRoomDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
ValidationUtils.requiredNumber("pageParam.page", "页码", 1, null),
|
||||
ValidationUtils.requiredNumber("pageParam.pageSize", "每页数量", 1, 100)
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.getChatRoomPage(pageRequest);
|
||||
}
|
||||
|
||||
// ========================= ChatRoom成员管理 =========================
|
||||
|
||||
@Operation(summary = "添加聊天室成员")
|
||||
@PreAuthorize("hasAuthority('workcase:room:member')")
|
||||
@PostMapping("/room/member")
|
||||
public ResultDomain<TbChatRoomMemberDTO> addChatRoomMember(@RequestBody TbChatRoomMemberDTO member) {
|
||||
ValidationResult vr = ValidationUtils.validate(member, Arrays.asList(
|
||||
ValidationUtils.requiredString("roomId", "聊天室ID"),
|
||||
ValidationUtils.requiredString("userId", "用户ID")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.addChatRoomMember(member);
|
||||
}
|
||||
|
||||
@Operation(summary = "移除聊天室成员")
|
||||
@PreAuthorize("hasAuthority('workcase:room:member')")
|
||||
@DeleteMapping("/room/member/{memberId}")
|
||||
public ResultDomain<Boolean> removeChatRoomMember(@PathVariable String memberId) {
|
||||
return chatRoomService.removeChatRoomMember(memberId);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取聊天室成员列表")
|
||||
@PreAuthorize("hasAuthority('workcase:room:member')")
|
||||
@GetMapping("/room/{roomId}/members")
|
||||
public ResultDomain<ChatMemberVO> getChatRoomMemberList(@PathVariable String roomId) {
|
||||
return chatRoomService.getChatRoomMemberList(roomId);
|
||||
}
|
||||
|
||||
// ========================= ChatRoom消息管理 =========================
|
||||
|
||||
@Operation(summary = "发送聊天室消息")
|
||||
@PreAuthorize("hasAuthority('workcase:room:message')")
|
||||
@PostMapping("/room/message")
|
||||
public ResultDomain<TbChatRoomMessageDTO> sendMessage(@RequestBody TbChatRoomMessageDTO message) {
|
||||
ValidationResult vr = ValidationUtils.validate(message, Arrays.asList(
|
||||
ValidationUtils.requiredString("roomId", "聊天室ID"),
|
||||
ValidationUtils.requiredString("senderId", "发送者ID"),
|
||||
ValidationUtils.requiredString("content", "消息内容")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.sendMessage(message);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询聊天室消息")
|
||||
@PreAuthorize("hasAuthority('workcase:room:message')")
|
||||
@PostMapping("/room/message/page")
|
||||
public ResultDomain<ChatRoomMessageVO> getChatMessagePage(@RequestBody PageRequest<TbChatRoomMessageDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
ValidationUtils.requiredNumber("pageParam.page", "页码", 1, null),
|
||||
ValidationUtils.requiredNumber("pageParam.pageSize", "每页数量", 1, 100)
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.getChatMessagePage(pageRequest);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除聊天室消息")
|
||||
@PreAuthorize("hasAuthority('workcase:room:message')")
|
||||
@DeleteMapping("/room/message/{messageId}")
|
||||
public ResultDomain<Boolean> deleteRoomMessage(@PathVariable String messageId) {
|
||||
return chatRoomService.deleteMessage(messageId);
|
||||
}
|
||||
|
||||
// ========================= 客服人员管理 =========================
|
||||
|
||||
@Operation(summary = "添加客服人员")
|
||||
@PostMapping("/customer-service")
|
||||
public ResultDomain<TbCustomerServiceDTO> addCustomerService(@RequestBody TbCustomerServiceDTO customerService) {
|
||||
ValidationResult vr = ValidationUtils.validate(customerService, Arrays.asList(
|
||||
ValidationUtils.requiredString("userId", "员工ID")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.addCustomerService(customerService);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新客服人员")
|
||||
@PutMapping("/customer-service")
|
||||
public ResultDomain<TbCustomerServiceDTO> updateCustomerService(@RequestBody TbCustomerServiceDTO customerService) {
|
||||
ValidationResult vr = ValidationUtils.validate(customerService, Arrays.asList(
|
||||
ValidationUtils.requiredString("userId", "员工ID")
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.updateCustomerService(customerService);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除客服人员")
|
||||
@DeleteMapping("/customer-service/{userId}")
|
||||
public ResultDomain<Boolean> deleteCustomerService(@PathVariable String userId) {
|
||||
return chatRoomService.deleteCustomerService(userId);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询客服人员")
|
||||
@PostMapping("/customer-service/page")
|
||||
public ResultDomain<CustomerServiceVO> getCustomerServicePage(@RequestBody PageRequest<TbCustomerServiceDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
ValidationUtils.requiredNumber("pageParam.page", "页码", 1, null),
|
||||
ValidationUtils.requiredNumber("pageParam.pageSize", "每页数量", 1, 100)
|
||||
));
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
return chatRoomService.getCustomerServicePage(pageRequest);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新客服在线状态")
|
||||
@PostMapping("/customer-service/{userId}/status")
|
||||
public ResultDomain<Boolean> updateCustomerServiceStatus(@PathVariable String userId, @RequestParam String status) {
|
||||
return chatRoomService.updateCustomerServiceStatus(userId, status);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取可接待客服列表")
|
||||
@GetMapping("/customer-service/available")
|
||||
public ResultDomain<CustomerServiceVO> getAvailableCustomerServices() {
|
||||
return chatRoomService.getAvailableCustomerServices();
|
||||
}
|
||||
|
||||
@Operation(summary = "自动分配客服")
|
||||
@PostMapping("/room/{roomId}/assign")
|
||||
public ResultDomain<CustomerServiceVO> assignCustomerService(@PathVariable String roomId) {
|
||||
return chatRoomService.assignCustomerService(roomId);
|
||||
}
|
||||
|
||||
// ========================= 微信客服消息回调 =========================
|
||||
|
||||
@Operation(summary = "微信客服消息回调验证(GET)")
|
||||
@GetMapping("/kefu/callback")
|
||||
public String kefuCallbackVerify(
|
||||
@RequestParam("msg_signature") String msgSignature,
|
||||
@RequestParam("timestamp") String timestamp,
|
||||
@RequestParam("nonce") String nonce,
|
||||
@RequestParam("echostr") String echostr) {
|
||||
// TODO: 验证签名并返回 echostr
|
||||
// 实际应使用微信提供的加解密工具验证
|
||||
return echostr;
|
||||
}
|
||||
// @Operation(summary = "微信客服消息回调验证(GET)")
|
||||
// @GetMapping("/kefu/callback")
|
||||
// public String kefuCallbackVerify(
|
||||
// @RequestParam("msg_signature") String msgSignature,
|
||||
// @RequestParam("timestamp") String timestamp,
|
||||
// @RequestParam("nonce") String nonce,
|
||||
// @RequestParam("echostr") String echostr) {
|
||||
// // TODO: 验证签名并返回 echostr
|
||||
// // 实际应使用微信提供的加解密工具验证
|
||||
// return echostr;
|
||||
// }
|
||||
|
||||
@Operation(summary = "微信客服消息回调(POST)")
|
||||
@PostMapping("/kefu/callback")
|
||||
public String kefuCallback(
|
||||
@RequestParam("msg_signature") String msgSignature,
|
||||
@RequestParam("timestamp") String timestamp,
|
||||
@RequestParam("nonce") String nonce,
|
||||
@RequestBody String xmlBody) {
|
||||
// TODO: 解密消息,调用同步接口拉取消息
|
||||
// 收到回调后,应调用 kefuMessageService.syncMessages() 拉取新消息
|
||||
// 然后通过 processMessages() 处理消息
|
||||
return "success";
|
||||
}
|
||||
// @Operation(summary = "微信客服消息回调(POST)")
|
||||
// @PostMapping("/kefu/callback")
|
||||
// public String kefuCallback(
|
||||
// @RequestParam("msg_signature") String msgSignature,
|
||||
// @RequestParam("timestamp") String timestamp,
|
||||
// @RequestParam("nonce") String nonce,
|
||||
// @RequestBody String xmlBody) {
|
||||
// // TODO: 解密消息,调用同步接口拉取消息
|
||||
// // 收到回调后,应调用 kefuMessageService.syncMessages() 拉取新消息
|
||||
// // 然后通过 processMessages() 处理消息
|
||||
// return "success";
|
||||
// }
|
||||
|
||||
// ========================= 词云管理 =========================
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.xyzh.workcase.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -42,6 +43,7 @@ public class WorkcaseController {
|
||||
// ========================= 工单管理 =========================
|
||||
|
||||
@Operation(summary = "创建工单")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:create')")
|
||||
@PostMapping
|
||||
public ResultDomain<TbWorkcaseDTO> createWorkcase(@RequestBody TbWorkcaseDTO workcase) {
|
||||
ValidationResult vr = ValidationUtils.validate(workcase, Arrays.asList(
|
||||
@@ -55,6 +57,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新工单")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:update')")
|
||||
@PutMapping
|
||||
public ResultDomain<TbWorkcaseDTO> updateWorkcase(@RequestBody TbWorkcaseDTO workcase) {
|
||||
ValidationResult vr = ValidationUtils.validate(workcase, Arrays.asList(
|
||||
@@ -67,6 +70,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "删除工单")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:update')")
|
||||
@DeleteMapping("/{workcaseId}")
|
||||
public ResultDomain<TbWorkcaseDTO> deleteWorkcase(@PathVariable String workcaseId) {
|
||||
TbWorkcaseDTO workcase = new TbWorkcaseDTO();
|
||||
@@ -75,18 +79,21 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "获取工单详情")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:view')")
|
||||
@GetMapping("/{workcaseId}")
|
||||
public ResultDomain<TbWorkcaseDTO> getWorkcaseById(@PathVariable String workcaseId) {
|
||||
return workcaseService.getWorkcaseById(workcaseId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询工单列表")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:view')")
|
||||
@PostMapping("/list")
|
||||
public ResultDomain<TbWorkcaseDTO> getWorkcaseList(@RequestBody TbWorkcaseDTO filter) {
|
||||
return workcaseService.getWorkcaseList(filter);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询工单")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:view')")
|
||||
@PostMapping("/page")
|
||||
public ResultDomain<TbWorkcaseDTO> getWorkcasePage(@RequestBody PageRequest<TbWorkcaseDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
@@ -123,6 +130,7 @@ public class WorkcaseController {
|
||||
// ========================= 工单处理过程 =========================
|
||||
|
||||
@Operation(summary = "创建工单处理过程")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:process')")
|
||||
@PostMapping("/process")
|
||||
public ResultDomain<TbWorkcaseProcessDTO> createWorkcaseProcess(@RequestBody TbWorkcaseProcessDTO process) {
|
||||
ValidationResult vr = ValidationUtils.validate(process, Arrays.asList(
|
||||
@@ -136,6 +144,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新工单处理过程")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:process')")
|
||||
@PutMapping("/process")
|
||||
public ResultDomain<TbWorkcaseProcessDTO> updateWorkcaseProcess(@RequestBody TbWorkcaseProcessDTO process) {
|
||||
ValidationResult vr = ValidationUtils.validate(process, Arrays.asList(
|
||||
@@ -148,6 +157,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "删除工单处理过程")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:process')")
|
||||
@DeleteMapping("/process/{processId}")
|
||||
public ResultDomain<TbWorkcaseProcessDTO> deleteWorkcaseProcess(@PathVariable String processId) {
|
||||
TbWorkcaseProcessDTO process = new TbWorkcaseProcessDTO();
|
||||
@@ -156,12 +166,14 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "查询工单处理过程列表")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:process')")
|
||||
@PostMapping("/process/list")
|
||||
public ResultDomain<TbWorkcaseProcessDTO> getWorkcaseProcessList(@RequestBody TbWorkcaseProcessDTO filter) {
|
||||
return workcaseService.getWorkcaseProcessList(filter);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询工单处理过程")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:process')")
|
||||
@PostMapping("/process/page")
|
||||
public ResultDomain<TbWorkcaseProcessDTO> getWorkcaseProcessPage(@RequestBody PageRequest<TbWorkcaseProcessDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
@@ -177,6 +189,7 @@ public class WorkcaseController {
|
||||
// ========================= 工单设备管理 =========================
|
||||
|
||||
@Operation(summary = "创建工单设备")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:device')")
|
||||
@PostMapping("/device")
|
||||
public ResultDomain<TbWorkcaseDeviceDTO> createWorkcaseDevice(@RequestBody TbWorkcaseDeviceDTO device) {
|
||||
ValidationResult vr = ValidationUtils.validate(device, Arrays.asList(
|
||||
@@ -190,6 +203,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "更新工单设备")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:device')")
|
||||
@PutMapping("/device")
|
||||
public ResultDomain<TbWorkcaseDeviceDTO> updateWorkcaseDevice(@RequestBody TbWorkcaseDeviceDTO device) {
|
||||
ValidationResult vr = ValidationUtils.validate(device, Arrays.asList(
|
||||
@@ -203,6 +217,7 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "删除工单设备")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:device')")
|
||||
@DeleteMapping("/device/{workcaseId}/{device}")
|
||||
public ResultDomain<TbWorkcaseDeviceDTO> deleteWorkcaseDevice(@PathVariable String workcaseId, @PathVariable String device) {
|
||||
TbWorkcaseDeviceDTO deviceDTO = new TbWorkcaseDeviceDTO();
|
||||
@@ -212,12 +227,14 @@ public class WorkcaseController {
|
||||
}
|
||||
|
||||
@Operation(summary = "查询工单设备列表")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:device')")
|
||||
@PostMapping("/device/list")
|
||||
public ResultDomain<TbWorkcaseDeviceDTO> getWorkcaseDeviceList(@RequestBody TbWorkcaseDeviceDTO filter) {
|
||||
return workcaseService.getWorkcaseDeviceList(filter);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询工单设备")
|
||||
@PreAuthorize("hasAuthority('workcase:ticket:device')")
|
||||
@PostMapping("/device/page")
|
||||
public ResultDomain<TbWorkcaseDeviceDTO> getWorkcaseDevicePage(@RequestBody PageRequest<TbWorkcaseDeviceDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
|
||||
@@ -7,7 +7,7 @@ server:
|
||||
# ================== Auth ====================
|
||||
auth:
|
||||
enabled: true
|
||||
gate-way: true
|
||||
gateway-mode: true
|
||||
whitelist:
|
||||
- /swagger-ui/**
|
||||
- /swagger-ui.html
|
||||
|
||||
Reference in New Issue
Block a user