瀏覽代碼

Merge remote-tracking branch 'origin/master'

Joburgess 4 年之前
父節點
當前提交
0fbc3318a2
共有 23 個文件被更改,包括 413 次插入280 次删除
  1. 18 9
      cms/src/main/java/com/ym/mec/cms/config/WebMvcConfig.java
  2. 21 14
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/WebMvcConfig.java
  3. 9 12
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java
  4. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  5. 2 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  6. 2 2
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  7. 4 9
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  8. 0 27
      mec-common/common-core/src/main/java/com/ym/mec/common/config/FeignConfiguration.java
  9. 6 64
      mec-common/common-core/src/main/java/com/ym/mec/common/config/LocalFastJsonHttpMessageConverter.java
  10. 92 14
      mec-im/src/main/java/com/ym/config/WebMvcConfig.java
  11. 8 6
      mec-im/src/main/java/com/ym/controller/RoomController.java
  12. 8 5
      mec-im/src/main/java/com/ym/mec/im/message/ExamSongDownloadMessageMessage.java
  13. 24 0
      mec-im/src/main/java/com/ym/mec/im/message/ExamSongDownloadStatusMessage.java
  14. 1 2
      mec-im/src/main/java/com/ym/pojo/DeviceTypeEnum.java
  15. 9 0
      mec-im/src/main/java/com/ym/pojo/ExamSongData.java
  16. 17 18
      mec-im/src/main/java/com/ym/pojo/ExamSongDownloadData.java
  17. 11 27
      mec-im/src/main/java/com/ym/pojo/ExamSongMessage.java
  18. 27 0
      mec-im/src/main/java/com/ym/pojo/ReqDeviceControlData.java
  19. 56 31
      mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java
  20. 15 6
      mec-student/src/main/java/com/ym/mec/student/config/WebMvcConfig.java
  21. 18 10
      mec-task/src/main/java/com/ym/mec/task/config/WebMvcConfig.java
  22. 46 11
      mec-teacher/src/main/java/com/ym/mec/teacher/config/WebMvcConfig.java
  23. 18 9
      mec-web/src/main/java/com/ym/mec/web/config/WebMvcConfig.java

+ 18 - 9
cms/src/main/java/com/ym/mec/cms/config/WebMvcConfig.java

@@ -3,25 +3,34 @@ package com.ym.mec.cms.config;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
 	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
 
 }

+ 21 - 14
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/WebMvcConfig.java

@@ -1,27 +1,34 @@
 package com.ym.mec.auth.config;
 
-import java.util.ArrayList;
-import java.util.List;
-
+import com.ym.mec.common.config.EnumConverterFactory;
+import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
+import java.util.ArrayList;
+import java.util.List;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
-
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
 	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
 }

+ 9 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -320,6 +320,14 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     String getMidiByCourseIdAndUserId(@Param("courseScheduleId") String courseScheduleId, @Param("userId") String userId);
 
     /**
+     * 获取单个用户的examDownloadJson
+     * @param courseScheduleId
+     * @param userId
+     * @return
+     */
+    String getExamJsonByCourseIdAndUserId(@Param("courseScheduleId") Long courseScheduleId, @Param("userId") Integer userId);
+
+    /**
      * @describe 统计课程组下的课程单价
      * @author Joburgess
      * @date 2020.06.11
@@ -372,18 +380,7 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @author zouxuan
      * @param roomId
      */
-    void adjustExamSong(@Param("roomId") Long roomId, @Param("userId") Integer userId, @Param("examSongJson") String examSongJson);
-
-    /**
-     * 获取学员的曲目下载状态
-     * @author zouxuan
-     * @param roomId
-     * @param userId
-     * @return
-     */
-    String getExamSongDownloadStatus(@Param("roomId") Long roomId,
-                                      @Param("userId") String userId);
-
+    int adjustExamSong(@Param("roomId") Long roomId, @Param("userId") Integer userId, @Param("examSongJson") String examSongJson);
 
     /**
      * @describe 统计学员通过双十一活动排课的数量

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -461,5 +461,5 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param musicGroupId
      * @return
      */
-    Map<String,Object> studentClassAuditDetail(String musicGroupId);
+    List<Map<String,Object>> studentClassAuditDetail(String musicGroupId);
 }

+ 2 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3266,9 +3266,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 	}
 
     @Override
-    public Map<String, Object> studentClassAuditDetail(String musicGroupId) {
+    public List<Map<String,Object>> studentClassAuditDetail(String musicGroupId) {
         List<Map<String,Object>> result = new ArrayList<>();
-
         //获取班级列表
         List<ClassGroup> classGroups = classGroupDao.queryClassGroups(musicGroupId, null);
         for (ClassGroup classGroup : classGroups) {
@@ -3281,6 +3280,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             resultMap.put("students",classGroupStudentMapperDao.findCourseStudentNameAndPhoneByClassGroupId(classGroup.getId()));
             result.add(resultMap);
         }
-        return null;
+        return result;
     }
 }

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3346,9 +3346,9 @@
         SELECT COUNT(id_) FROM course_schedule WHERE new_course_id_=#{courseId}
     </select>
     <select id="querySubCourseNumMap" resultType="java.util.Map">
-        SELECT cs.group_type_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
+        SELECT cs.type_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
         WHERE cs.class_group_id_ = #{classGroupId} AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()
-        GROUP BY cs.group_type_
+        GROUP BY cs.type_
     </select>
     <select id="getLock" resultMap="CourseSchedule">
         SELECT * FROM course_schedule WHERE id_ = #{courseId} FOR UPDATE

+ 4 - 9
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -173,15 +173,6 @@
 			AND user_id_ = #{userId}
 		</if>
 	</update>
-	<select id="getExamSongDownloadStatus" resultType="String">
-		SELECT exam_song_download_json_
-		FROM course_schedule_student_payment
-		WHERE course_schedule_id_ = #{roomId}
-		<if test="userId != null">
-			AND user_id_ = #{userId}
-		</if>
-	</select>
-
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM course_schedule_student_payment WHERE id_ = #{id}
@@ -511,6 +502,10 @@
 		SELECT cssp.open_play_midi_ FROM course_schedule_student_payment cssp
 		WHERE cssp.user_id_ = #{userId} AND cssp.course_schedule_id_ = #{courseScheduleId}
 	</select>
+	<select id="getExamJsonByCourseIdAndUserId" resultType="java.lang.String">
+		SELECT cssp.exam_song_download_json_ FROM course_schedule_student_payment cssp
+		WHERE cssp.user_id_ = #{userId} AND cssp.course_schedule_id_ = #{courseScheduleId}
+	</select>
 
     <select id="findGroupCoursesUnitPrice" resultType="java.util.Map">
 		SELECT

+ 0 - 27
mec-common/common-core/src/main/java/com/ym/mec/common/config/FeignConfiguration.java

@@ -1,16 +1,10 @@
 package com.ym.mec.common.config;
 
-import org.springframework.beans.factory.ObjectFactory;
-import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
-import org.springframework.cloud.openfeign.support.SpringDecoder;
-import org.springframework.cloud.openfeign.support.SpringEncoder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 import feign.Logger;
 import feign.RequestInterceptor;
-import feign.codec.Decoder;
-import feign.codec.Encoder;
 
 @Configuration
 public class FeignConfiguration {
@@ -25,25 +19,4 @@ public class FeignConfiguration {
 	public RequestInterceptor requestInterceptor(){
 		return new RequestHeaderConfiguration();
 	}
-	
-	@Bean
-	public Decoder feignDecoder() {
-		return new SpringDecoder(feignHttpMessageConverter());
-	}
-
-	@Bean
-	public Encoder feignEncoder() {
-		return new SpringEncoder(feignHttpMessageConverter());
-	}
-	
-	/**
-     * 设置解码器为fastjson
-     *
-     * @return
-     */
-    private ObjectFactory<HttpMessageConverters> feignHttpMessageConverter() {
-        final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(new LocalFastJsonHttpMessageConverter());
-        return () -> httpMessageConverters;
-    }
-
 }

+ 6 - 64
mec-common/common-core/src/main/java/com/ym/mec/common/config/LocalFastJsonHttpMessageConverter.java

@@ -6,18 +6,12 @@ import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.util.Date;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.HttpInputMessage;
 import org.springframework.http.HttpOutputMessage;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 import org.springframework.http.converter.HttpMessageNotWritableException;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.parser.DefaultJSONParser;
-import com.alibaba.fastjson.parser.JSONToken;
-import com.alibaba.fastjson.parser.ParserConfig;
-import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
 import com.alibaba.fastjson.serializer.JSONSerializer;
 import com.alibaba.fastjson.serializer.ObjectSerializer;
 import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
@@ -33,12 +27,7 @@ public class LocalFastJsonHttpMessageConverter extends FastJsonHttpMessageConver
 
 	@Override
 	protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
-		return read(clazz, null, inputMessage);
-	}
-
-	@Override
-	public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
-		return JSON.parseObject(IOUtils.toString(inputMessage.getBody()), type, CustmerParserConfig.global, getFastJsonConfig().getFeatures());
+		return super.readInternal(clazz, inputMessage);
 	}
 
 	@Override
@@ -46,49 +35,20 @@ public class LocalFastJsonHttpMessageConverter extends FastJsonHttpMessageConver
 
 		OutputStream out = outputMessage.getBody();
 		JsonUtil.getConfig().put(Date.class, new SimpleDateFormatSerializer(FORMAT));
-		// JsonUtil.getConfig().put(String.class, new EmojiSerializer());
-		String text = JsonUtil.toJSONString(obj, EnumFilter.instance, getFastJsonConfig().getSerializerFeatures());
-		byte[] bytes = text.getBytes(getFastJsonConfig().getCharset());
+		//JsonUtil.getConfig().put(String.class, new EmojiSerializer());
+		String text = JsonUtil.toJSONString(obj, EnumFilter.instance, getFeatures());
+		byte[] bytes = text.getBytes(getCharset());
 		out.write(bytes);
 	}
 }
 
-class EmojiSerializer implements ObjectSerializer {
+class EmojiSerializer implements ObjectSerializer{
 
 	@Override
 	public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
 		serializer.write(EmojiParser.parseToUnicode(object.toString()));
 	}
-
-}
-
-class CustmerEnumDeserializer implements ObjectDeserializer {
-
-	@Override
-	public BaseEnum deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
-		Object value = parser.parse();
-		Class clazz = (Class) type;
-
-		for (Object en : clazz.getEnumConstants()) {
-			BaseEnum be = (BaseEnum) en;
-			if (be.getCode() instanceof Integer) {
-				if ((Integer) be.getCode() == Integer.parseInt(value.toString())) {
-					return be;
-				}
-			} else {
-				if (value.equals(String.valueOf(be.getCode()))) {
-					return be;
-				}
-			}
-		}
-		return null;
-	}
-
-	@Override
-	public int getFastMatchToken() {
-		return JSONToken.LITERAL_INT;
-	}
-
+	
 }
 
 class EnumFilter implements ValueFilter {
@@ -112,21 +72,3 @@ class EnumFilter implements ValueFilter {
 		return value;
 	}
 }
-
-class CustmerParserConfig extends ParserConfig {
-	
-	public static CustmerParserConfig global = new CustmerParserConfig();
-
-	@Override
-	public ObjectDeserializer getDeserializer(Class<?> clazz, Type type) {
-		ObjectDeserializer derializer = getDeserializers().get(type);
-		if (derializer != null) {
-			return derializer;
-		}
-		if (BaseEnum.class.isAssignableFrom(clazz)) {
-			putDeserializer(type, new CustmerEnumDeserializer());
-		}
-		return super.getDeserializer(clazz, type);
-	}
-
-}

+ 92 - 14
mec-im/src/main/java/com/ym/config/WebMvcConfig.java

@@ -1,28 +1,106 @@
 package com.ym.config;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
 
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.context.annotation.Primary;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
+import com.ym.mec.common.config.EnumConverterFactory;
+import com.ym.mec.common.enums.BaseEnum;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
-
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
+	}
+
+	@SuppressWarnings("rawtypes")
+	@Bean
+	@Primary
+	public ObjectMapper ObjectMapper() {
+		ObjectMapper objectMapper = new ObjectMapper();
+		// 对于空的对象转json的时候不抛出错误
+		objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+		// 禁用遇到未知属性抛出异常
+		objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+		// 序列化BigDecimal时不使用科学计数法输出
+		objectMapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
+		// 日期和时间格式化
+		JavaTimeModule javaTimeModule = new JavaTimeModule();
+		javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+		javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+		javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
+		javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+		javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+		javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
+
+		// BaseEnum序列化
+		javaTimeModule.addSerializer(BaseEnum.class, new JsonSerializer<BaseEnum>() {
+
+			@Override
+			public void serialize(BaseEnum enumObj, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
+				jsonGenerator.writeString(enumObj.getCode().toString());
+			}
+
+		});
+
+		// Date序列化和反序列化
+		javaTimeModule.addSerializer(Date.class, new JsonSerializer<Date>() {
+			@Override
+			public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+				String formattedDate = formatter.format(date);
+				jsonGenerator.writeString(formattedDate);
+			}
+		});
+
+		javaTimeModule.addDeserializer(Date.class, new JsonDeserializer<Date>() {
+			@Override
+			public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+				String date = jsonParser.getText();
+				try {
+					return format.parse(date);
+				} catch (ParseException e) {
+					throw new RuntimeException(e);
+				}
+			}
+		});
+
+		objectMapper.registerModule(javaTimeModule);
+		return objectMapper;
 	}
 
 }

+ 8 - 6
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -48,6 +48,12 @@ public class RoomController{
         return new BaseResponse<>();
     }
 
+    @RequestMapping(value = "pushDownloadExamSongMsg", method = RequestMethod.POST)
+    public Object pushDownloadExamSongMsg(@RequestBody ExamSongData examSongData) throws Exception {
+        roomService.pushDownloadExamSongMsg(examSongData.getRoomId(),examSongData.getExamSongId());
+        return new BaseResponse<>();
+    }
+
     @RequestMapping(value = "/statusSync")
     public void statusSync(@RequestBody String body) throws Exception {
         ChannelStateNotify notify = JSONObject.parseObject(body, ChannelStateNotify.class);
@@ -138,18 +144,14 @@ public class RoomController{
             result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.MusicMode, data.getMusicModeOn());
         } else if (data.getHandUpOn() != null) {
             result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.HandUp, data.getHandUpOn());
+        }else if (data.getPlaySongOn() != null) {
+            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.PlaySong, data.getPlaySongOn());
         } else {
             throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
         }
         return new BaseResponse<>(result);
     }
 
-    @RequestMapping(value = "pushDownloadExamSongMsg", method = RequestMethod.POST)
-    public Object pushDownloadExamSongMsg(@RequestBody ExamSongData examSongData) throws Exception {
-        roomService.pushDownloadExamSongMsg(examSongData.getRoomId(),examSongData.getExamSongId());
-        return new BaseResponse<>();
-    }
-
     @RequestMapping(value = "adjustExamSong", method = RequestMethod.POST)
     public Object adjustExamSong(@RequestBody ExamSongData examSongData) throws Exception {
         roomService.adjustExamSong(examSongData.getRoomId(),examSongData.getStatus(),examSongData.getExamSongId());

+ 8 - 5
mec-im/src/main/java/com/ym/mec/im/message/ExamSongDownloadMessageMessage.java

@@ -2,12 +2,15 @@ package com.ym.mec.im.message;
 
 import com.ym.mec.im.BaseMessage;
 import com.ym.pojo.ExamSongMessage;
-import org.apache.commons.lang3.StringUtils;
 
 public class ExamSongDownloadMessageMessage extends BaseMessage {
     private ExamSongMessage content;
     private static final transient String TYPE = "DY:examSongDownloadMessage";
 
+    public ExamSongDownloadMessageMessage(ExamSongMessage content) {
+        this.content = content;
+    }
+
     public ExamSongMessage getContent() {
         return content;
     }
@@ -18,10 +21,10 @@ public class ExamSongDownloadMessageMessage extends BaseMessage {
 
     @Override
     public String toString() {
-        return "{\"url\":" + content.getUrl() +
-                ", \"songName\":" + content.getSongName() +
-                ", \"songId\":" + content.getSongId() +
-                '}';
+        return "{\"examSongName\":\"" + content.getExamSongName() +
+                "\", \"examSongId\":\"" + content.getExamSongId() +
+                "\", \"url\":\"" + content.getUrl() +
+                "\"}";
     }
 
     @Override

+ 24 - 0
mec-im/src/main/java/com/ym/mec/im/message/ExamSongDownloadStatusMessage.java

@@ -0,0 +1,24 @@
+package com.ym.mec.im.message;
+
+import com.ym.mec.im.BaseMessage;
+import lombok.Getter;
+import lombok.Setter;
+
+public class ExamSongDownloadStatusMessage extends BaseMessage {
+    private @Setter @Getter Integer status;
+
+    private @Setter @Getter Integer studentId;
+
+    private @Setter @Getter Integer examSongId;
+
+    public ExamSongDownloadStatusMessage(Integer status,Integer studentId,Integer examSongId) {
+        this.status = status;
+        this.studentId = studentId;
+        this.examSongId = examSongId;
+    }
+
+    @Override
+    public String getObjectName() {
+        return "DY:DSMsg";
+    }
+}

+ 1 - 2
mec-im/src/main/java/com/ym/pojo/DeviceTypeEnum.java

@@ -8,6 +8,5 @@ public enum DeviceTypeEnum {
     Camera,
     MusicMode,
     HandUp,
-    ExamSong,
-    PlayMidi,
+    PlaySong,
 }

+ 9 - 0
mec-im/src/main/java/com/ym/pojo/ExamSongData.java

@@ -28,4 +28,13 @@ public class ExamSongData {
 	public void setExamSongId(Integer examSongId) {
 		this.examSongId = examSongId;
 	}
+
+	@Override
+	public String toString() {
+		return "ExamSongData{" +
+				"roomId='" + roomId + '\'' +
+				", examSongId=" + examSongId +
+				", status=" + status +
+				'}';
+	}
 }

+ 17 - 18
mec-im/src/main/java/com/ym/pojo/ExamSongDownloadData.java

@@ -3,15 +3,16 @@ package com.ym.pojo;
 public class ExamSongDownloadData {
 	private Integer status;
 	private String url;
-	private String songName;
-	private Integer songId;
+	private String examSongName;
+	private Integer examSongId;
+	private Boolean enable = false;
 
-	public Integer getSongId() {
-		return songId;
+	public Boolean getEnable() {
+		return enable;
 	}
 
-	public void setSongId(Integer songId) {
-		this.songId = songId;
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
 	}
 
 	public Integer getStatus() {
@@ -30,21 +31,19 @@ public class ExamSongDownloadData {
 		this.url = url;
 	}
 
-	public String getSongName() {
-		return songName;
+	public String getExamSongName() {
+		return examSongName;
 	}
 
-	public void setSongName(String songName) {
-		this.songName = songName;
+	public void setExamSongName(String examSongName) {
+		this.examSongName = examSongName;
 	}
 
-	@Override
-	public String toString() {
-		return "{" +
-				"status=" + status +
-				", url='" + url + '\'' +
-				", songName='" + songName + '\'' +
-				", songId='" + songId + '\'' +
-				'}';
+	public Integer getExamSongId() {
+		return examSongId;
+	}
+
+	public void setExamSongId(Integer examSongId) {
+		this.examSongId = examSongId;
 	}
 }

+ 11 - 27
mec-im/src/main/java/com/ym/pojo/ExamSongMessage.java

@@ -1,20 +1,9 @@
 package com.ym.pojo;
 
-import io.rong.messages.BaseMessage;
-import org.apache.commons.lang3.StringUtils;
-
-public class ExamSongMessage extends BaseMessage {
+public class ExamSongMessage{
     private String url;
-    private String songName;
-    private Integer songId;
-
-    public Integer getSongId() {
-        return songId;
-    }
-
-    public void setSongId(Integer songId) {
-        this.songId = songId;
-    }
+    private String examSongName;
+    private Integer examSongId;
 
     public String getUrl() {
         return url;
@@ -24,24 +13,19 @@ public class ExamSongMessage extends BaseMessage {
         this.url = url;
     }
 
-    public String getSongName() {
-        return songName;
+    public String getExamSongName() {
+        return examSongName;
     }
 
-    public void setSongName(String songName) {
-        this.songName = songName;
+    public void setExamSongName(String examSongName) {
+        this.examSongName = examSongName;
     }
 
-    @Override
-    public String getType() {
-        return "DY:examSongDownloadMessage";
+    public Integer getExamSongId() {
+        return examSongId;
     }
 
-    @Override
-    public String toString() {
-        return "{\"url\":" + url +
-                ", \"songName\":" + songName +
-                ", \"songId\":" + songId +
-                '}';
+    public void setExamSongId(Integer examSongId) {
+        this.examSongId = examSongId;
     }
 }

+ 27 - 0
mec-im/src/main/java/com/ym/pojo/ReqDeviceControlData.java

@@ -11,9 +11,36 @@ public class ReqDeviceControlData {
 	private Boolean microphoneOn;
 	private Boolean musicModeOn;
 	private Boolean handUpOn;
+	private Boolean playSongOn;
 	private String roomId;
 	private String userId;
 	private String ticket;
+	private Integer status;
+	private Integer examSongId;
+
+	public Boolean getPlaySongOn() {
+		return playSongOn;
+	}
+
+	public void setPlaySongOn(Boolean playSongOn) {
+		this.playSongOn = playSongOn;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public Integer getExamSongId() {
+		return examSongId;
+	}
+
+	public void setExamSongId(Integer examSongId) {
+		this.examSongId = examSongId;
+	}
 
 	public Boolean getMusicModeOn() {
 		return musicModeOn;

+ 56 - 31
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -202,7 +202,7 @@ public class RoomServiceImpl implements RoomService {
             display = "display://type=0?userId=" + userId + "?uri=";
         }else {
             //获取学员曲目下载状态
-            userResult.setExamSongDownloadJson(courseScheduleStudentPaymentDao.getExamSongDownloadStatus(courseId,userId));
+            userResult.setExamSongDownloadJson(courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(courseId,sysUser.getId()));
             Room room = roomDao.findByRid(roomId);
             if (room != null) {
                 display = room.getDisplay();
@@ -727,6 +727,17 @@ public class RoomServiceImpl implements RoomService {
                 roomMemberDao.updateMicByRidAndUid(roomId, userId, false);
             } else if (typeEnum.equals(DeviceTypeEnum.HandUp)){
                 roomMemberDao.updateHandByRidAndUid(roomId, userId, false);
+            } else if (typeEnum.equals(DeviceTypeEnum.PlaySong)){
+                long scheduleId = Long.parseLong(roomId.substring(1));
+                ExamSongDownloadData msg;
+                String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, authUser.getId());
+                if(StringUtils.isEmpty(examJson)){
+                    throw new BizException("学员伴奏信息异常");
+                }else {
+                    msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
+                    msg.setEnable(enable);
+                }
+                courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
             }else {
                 roomMemberDao.updateMusicByRidAndUid(roomId, userId, false);
             }
@@ -827,19 +838,26 @@ public class RoomServiceImpl implements RoomService {
         String userId = authUser.getId().toString();
 
         int result;
-        DeviceStateChangedMessage deviceResourceMessage;
+        DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         if (type.equals(DeviceTypeEnum.Camera)) {
             result = roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
-            deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         } else if (type.equals(DeviceTypeEnum.Microphone)){
             result = roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
-            deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         } else if (type.equals(DeviceTypeEnum.HandUp)){
             result = roomMemberDao.updateHandByRidAndUid(roomId, userId, enable);
-            deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
+        } else if (type.equals(DeviceTypeEnum.PlaySong)){
+            long scheduleId = Long.parseLong(roomId.substring(1));
+            ExamSongDownloadData msg;
+            String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, authUser.getId());
+            if(StringUtils.isEmpty(examJson)){
+                throw new BizException("学员伴奏信息异常");
+            }else {
+                msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
+                msg.setEnable(enable);
+            }
+            result = courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
         }else {
             result = roomMemberDao.updateMusicByRidAndUid(roomId, userId, enable);
-            deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         }
         deviceResourceMessage.setUserId(userId);
         imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
@@ -1276,32 +1294,33 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public List<RongyunBasicUserDto> queryNoJoinStu(String roomId) {
-        return courseScheduleStudentPaymentDao.queryNoJoinStu(roomId,roomId.substring(1));
-    }
-
-    @Override
     @Transactional(rollbackFor = Exception.class)
     public void pushDownloadExamSongMsg(String roomId, Integer examSongId) throws Exception {
         SysUser authUser = sysUserFeignService.queryUserInfo();
-        ExamSongDownloadMessageMessage msg = new ExamSongDownloadMessageMessage();
+
         SysExamSong sysExamSong = sysExamSongDao.get(examSongId);
         if(sysExamSong == null){
             throw new BizException("曲目信息不存在");
         }
-        ExamSongMessage examSongMessage = new ExamSongMessage();
-        examSongMessage.setSongName(sysExamSong.getName());
-        examSongMessage.setUrl(sysExamSong.getUrl());
-        examSongMessage.setSongId(examSongId);
-        msg.setContent(examSongMessage);
-        imHelper.publishMessage(authUser.getId().toString(), roomId, msg, 0);
         //学员曲目下载状态改为未下载
         ExamSongDownloadData json = new ExamSongDownloadData();
-        json.setSongName(sysExamSong.getName());
+        json.setExamSongName(sysExamSong.getName());
         json.setUrl(sysExamSong.getUrl());
         json.setStatus(0);
-        json.setSongId(examSongId);
+        json.setExamSongId(examSongId);
         courseScheduleStudentPaymentDao.adjustExamSong(Long.parseLong(roomId.substring(1)),null, JSON.toJSONString(json));
+
+        ExamSongMessage examSongMessage = new ExamSongMessage();
+        examSongMessage.setExamSongName(sysExamSong.getName());
+        examSongMessage.setUrl(sysExamSong.getUrl());
+        examSongMessage.setExamSongId(examSongId);
+        ExamSongDownloadMessageMessage msg = new ExamSongDownloadMessageMessage(examSongMessage);
+        imHelper.publishMessage(authUser.getId().toString(), roomId, msg, 0);
+    }
+
+    @Override
+    public List<RongyunBasicUserDto> queryNoJoinStu(String roomId) {
+        return courseScheduleStudentPaymentDao.queryNoJoinStu(roomId,roomId.substring(1));
     }
 
     @Override
@@ -1312,23 +1331,29 @@ public class RoomServiceImpl implements RoomService {
         }
         SysUser authUser = sysUserFeignService.queryUserInfo();
         long scheduleId = Long.parseLong(roomId.substring(1));
-        CourseSchedule courseSchedule = courseScheduleDao.get(scheduleId);
-
-        //给老师发送学员曲目下载状态
-        DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(DeviceTypeEnum.ExamSong.ordinal(), status==0?false:true);
-        deviceResourceMessage.setUserId(courseSchedule.getActualTeacherId().toString());
-        imHelper.publishMessage(authUser.getId().toString(), roomId, deviceResourceMessage, 1);
 
         SysExamSong sysExamSong = sysExamSongDao.get(examSongId);
         if(sysExamSong == null){
             throw new BizException("曲目信息不存在");
         }
-        ExamSongDownloadData msg = new ExamSongDownloadData();
-        msg.setSongName(sysExamSong.getName());
-        msg.setUrl(sysExamSong.getUrl());
-        msg.setStatus(status);
-        msg.setSongId(examSongId);
+        ExamSongDownloadData msg;
+        String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(scheduleId, authUser.getId());
+        if(StringUtils.isEmpty(examJson)){
+            msg = new ExamSongDownloadData();
+            msg.setExamSongName(sysExamSong.getName());
+            msg.setUrl(sysExamSong.getUrl());
+            msg.setStatus(status);
+            msg.setExamSongId(examSongId);
+        }else {
+            msg = JSON.parseObject(examJson, ExamSongDownloadData.class);
+            msg.setStatus(status);
+        }
         courseScheduleStudentPaymentDao.adjustExamSong(scheduleId,authUser.getId(),JSON.toJSONString(msg));
+
+        //给老师发送学员曲目下载状态
+        CourseSchedule courseSchedule = courseScheduleDao.get(scheduleId);
+        ExamSongDownloadStatusMessage deviceResourceMessage = new ExamSongDownloadStatusMessage(status,authUser.getId(),examSongId);
+        imHelper.publishMessage(authUser.getId().toString(),courseSchedule.getActualTeacherId().toString(), roomId, deviceResourceMessage);
     }
 
     public void updateDisplay(String roomId, String senderId, String display, Integer isIncludeSender) throws Exception {

+ 15 - 6
mec-student/src/main/java/com/ym/mec/student/config/WebMvcConfig.java

@@ -4,12 +4,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
 import com.ym.mec.student.interceptor.MDCInterceptor;
 
@@ -19,6 +22,14 @@ public class WebMvcConfig implements WebMvcConfigurer {
 	@Autowired
 	private MDCInterceptor mdcInterceptor;
 
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
+	@Override
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
+	}
+
 	@Override
 	public void addInterceptors(InterceptorRegistry registry) {
 		// addPathPatterns 用于添加拦截规则, 这里假设拦截 /url 后面的全部链接
@@ -32,15 +43,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
 		registry.addInterceptor(mdcInterceptor).addPathPatterns(includePathPatterns).excludePathPatterns(excludePathPatterns);
 	}
 
-	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
+	@Bean
+	public HttpMessageConverters fastJsonHttpMessageConverters() {
 		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
 		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
 		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
 		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+		return new HttpMessageConverters(converter);
 	}
 
 }

+ 18 - 10
mec-task/src/main/java/com/ym/mec/task/config/WebMvcConfig.java

@@ -3,26 +3,34 @@ package com.ym.mec.task.config;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
-
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
 	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
 
 }

+ 46 - 11
mec-teacher/src/main/java/com/ym/mec/teacher/config/WebMvcConfig.java

@@ -1,17 +1,47 @@
 package com.ym.mec.teacher.config;
 
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
+import com.ym.mec.teacher.interceptor.MDCInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
+import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
-import com.ym.mec.teacher.interceptor.MDCInterceptor;
+import com.ym.mec.common.enums.BaseEnum;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
@@ -28,16 +58,21 @@ public class WebMvcConfig implements WebMvcConfigurer {
 		registry.addInterceptor(mdcInterceptor).addPathPatterns(includePathPatterns).excludePathPatterns(excludePathPatterns);
 	}
 
-
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
 	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
 
 }

+ 18 - 9
mec-web/src/main/java/com/ym/mec/web/config/WebMvcConfig.java

@@ -3,25 +3,34 @@ package com.ym.mec.web.config;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.format.FormatterRegistry;
 import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
 
+	/**
+	 * 枚举类的转换器 addConverterFactory
+	 */
 	@Override
-	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-		// 放在configureMessageConverters方法中对入参的json反序列化无影响
-		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
-		List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
-		fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
-		converter.setSupportedMediaTypes(fastMediaTypes);
-
-		converters.add(converter);
+	public void addFormatters(FormatterRegistry registry) {
+		registry.addConverterFactory(new EnumConverterFactory());
 	}
+	
+	@Bean
+    public HttpMessageConverters fastJsonHttpMessageConverters(){
+		LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
+        List<MediaType> fastMediaTypes =  new ArrayList<MediaType>();
+        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+        converter.setSupportedMediaTypes(fastMediaTypes);
+        return new HttpMessageConverters(converter);
+    }
 
 }