Преглед на файлове

fix 工单内容可为空

zoujiajian преди 3 години
родител
ревизия
8b817f07d7

+ 0 - 2
netflix-dao/src/main/java/com/cyksj/model/entity/WorkOrderChatHistory.java

@@ -3,7 +3,6 @@ package com.cyksj.model.entity;
 import lombok.Getter;
 import lombok.Setter;
 
-import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 
 /*
@@ -41,7 +40,6 @@ public class WorkOrderChatHistory extends BaseEntity {
 	/**
 	 * 发送的内容
 	 */
-	@NotEmpty(message = "回复内容为空")
 	private String content;
 
 	/**

+ 0 - 1
netflix-dao/src/main/java/com/cyksj/model/request/WorkOrderReq.java

@@ -23,7 +23,6 @@ public class WorkOrderReq {
 	@NotNull(message = "请选择车票")
 	private Long relationId;
 
-	@NotEmpty(message = "请描述您遇到的问题")
 	private String content;
 
 	private String imgs;

+ 11 - 3
netflix-service/src/main/java/com/cyksj/service/user/impl/WorkOrderFrontServiceImpl.java

@@ -48,11 +48,15 @@ public class WorkOrderFrontServiceImpl implements WorkOrderFrontService {
 		User user = userService.getById(userId);
 		if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
 		String content = workOrderReq.getContent();
+		String imgs = workOrderReq.getImgs();
+		if (StrUtil.isEmpty(content) && StrUtil.isEmpty(imgs)) {
+			throw BusinessRuntimeException.getInstance("请输入相关内容");
+		}
 		String topic = workOrderReq.getTopic();
 		if (topic.length() > 32) {
 			throw BusinessRuntimeException.getInstance("标题最多输入30字数以内");
 		}
-		if (content.length() > 200) {
+		if (StrUtil.isNotBlank(content) && content.length() > 200) {
 			throw BusinessRuntimeException.getInstance("问题描述最多输入200字数以内");
 		}
 		List<Long> userIds = userService.getRelationUserIdList(userId, user);
@@ -75,7 +79,6 @@ public class WorkOrderFrontServiceImpl implements WorkOrderFrontService {
 		workOrderChatHistory.setUserId(userId);
 		workOrderChatHistory.setWorkOrderId(workOrder.getId());
 		workOrderChatHistory.setContent(content);
-		String imgs = workOrderReq.getImgs();
 		if (StrUtil.isNotBlank(imgs)) {
 			if (!imgs.contains("[") && !imgs.contains("]")) {
 				imgs = String.format("[\"%s\"]", imgs);
@@ -98,8 +101,13 @@ public class WorkOrderFrontServiceImpl implements WorkOrderFrontService {
 		List<Long> userIds = userService.getRelationUserIdList(userId, user);
 		if (!userIds.contains(workOrder.getUserId())) throw BusinessRuntimeException.getInstance("网络错误");
 		String content = history.getContent();
-		if (content.length() > 200) throw BusinessRuntimeException.getInstance("回复内容最多200字数以内");
 		String imgs = history.getImgs();
+		if (StrUtil.isEmpty(content) && StrUtil.isEmpty(imgs)) {
+			throw BusinessRuntimeException.getInstance("请回复相关内容");
+		}
+		if (StrUtil.isNotBlank(content) && content.length() > 200)
+			throw BusinessRuntimeException.getInstance("回复内容最多200字数以内");
+
 		if (StrUtil.isNotBlank(imgs)) {
 			if (!imgs.contains("[") && !imgs.contains("]")) {
 				imgs = String.format("[\"%s\"]", imgs);

+ 5 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/sys/WorkOrderController.java

@@ -128,10 +128,13 @@ public class WorkOrderController {
 		history.setReplyCustomerServiceId(adminId);
 		history.setUserId(workOrder.getUserId());
 		String content = history.getContent();
-		if (content.length() > 200) {
+		String imgs = history.getImgs();
+		if (StrUtil.isEmpty(content) && StrUtil.isEmpty(imgs)) {
+			throw BusinessRuntimeException.getInstance("请回复相关内容");
+		}
+		if (StrUtil.isNotBlank(content) && content.length() > 200) {
 			throw BusinessRuntimeException.getInstance("回复内容最多200字数以内");
 		}
-		String imgs = history.getImgs();
 		if (StrUtil.isNotBlank(imgs)) {
 			if (!imgs.contains("[") && !imgs.contains("]")) {
 				imgs = String.format("[\"%s\"]", imgs);