格式化代码
This commit is contained in:
		| @@ -4,8 +4,9 @@ import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 输出信息对象 | ||||
|  * @author tajochen | ||||
|  * | ||||
|  * @param <T> | ||||
|  * @author tajochen | ||||
|  */ | ||||
| public class EncapsulationObejct<T> implements Serializable { | ||||
|  | ||||
| @@ -50,10 +51,6 @@ public class EncapsulationObejct<T> implements Serializable { | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "EncapsulationObejct{" + | ||||
|                 "status=" + status + | ||||
|                 ", msg='" + msg + '\'' + | ||||
|                 ", data=" + data + | ||||
|                 '}'; | ||||
|         return "EncapsulationObejct{" + "status=" + status + ", msg='" + msg + '\'' + ", data=" + data + '}'; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import java.util.Properties; | ||||
|  | ||||
| /** | ||||
|  * 输出信息封装 | ||||
|  * | ||||
|  * @author tajochen | ||||
|  */ | ||||
| @Component | ||||
| @@ -30,6 +31,7 @@ public class OutputEncapsulation { | ||||
|  | ||||
|     /** | ||||
|      * 读取多国语言文件 | ||||
|      * | ||||
|      * @return | ||||
|      */ | ||||
|     public static MessageSource messageSource() { | ||||
| @@ -50,6 +52,7 @@ public class OutputEncapsulation { | ||||
|  | ||||
|     /** | ||||
|      * 封装输出数据 | ||||
|      * | ||||
|      * @param promptMessageEnum | ||||
|      * @param obj | ||||
|      * @return | ||||
| @@ -58,12 +61,12 @@ public class OutputEncapsulation { | ||||
|  | ||||
|         EncapsulationObejct encapsulationObejct = new EncapsulationObejct(); | ||||
|         encapsulationObejct.setStatus(promptMessageEnum.getCode()); | ||||
|         encapsulationObejct.setMsg(messageSource().getMessage(promptMessageEnum.getText(),null,locale)); | ||||
|         encapsulationObejct.setMsg(messageSource().getMessage(promptMessageEnum.getText(), null, locale)); | ||||
|         encapsulationObejct.setData(obj); | ||||
|  | ||||
|         ObjectMapper objectMapper = new ObjectMapper(); | ||||
|         // 忽略无法转换的对象 | ||||
|         objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false); | ||||
|         objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); | ||||
|         // 忽略json字符串中不识别的属性 | ||||
|         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||||
|         // 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准 | ||||
| @@ -82,15 +85,16 @@ public class OutputEncapsulation { | ||||
|  | ||||
|     /** | ||||
|      * 输出请求值检验错误信息 | ||||
|      * | ||||
|      * @param fieldErrors | ||||
|      * @return | ||||
|      */ | ||||
|     public static String outputEncapsulationErrorList(List<FieldError> fieldErrors, Locale locale){ | ||||
|     public static String outputEncapsulationErrorList(List<FieldError> fieldErrors, Locale locale) { | ||||
|         List<String> errorMsg = new ArrayList<>(); | ||||
|         for (FieldError fieldError : fieldErrors) { | ||||
|             String errMessage = fieldError.getDefaultMessage().subSequence(1,fieldError.getDefaultMessage().length()-1).toString(); | ||||
|             errorMsg.add(messageSource().getMessage(errMessage,null,locale)); | ||||
|             String errMessage = fieldError.getDefaultMessage().subSequence(1, fieldError.getDefaultMessage().length() - 1).toString(); | ||||
|             errorMsg.add(messageSource().getMessage(errMessage, null, locale)); | ||||
|         } | ||||
|         return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,errorMsg,locale); | ||||
|         return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, errorMsg, locale); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user