123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /*
- * ********************************************************************************************************************
- *
- * iFHS7.
- * ;BBMBMBMc rZMBMBR BMB
- * MBEr:;PBM, 7MBMMEOBB: BBB RBW
- * XK: BO SB. :SZ MBM. c;; ir BBM :FFr :SSF: ;xBMB:r iuGXv. i:. iF2;
- * DBBM0r. :D S7 ;XMBMB GMBMu. MBM: BMB MBMBBBMBMS WMBMBMBBK MBMBMBM BMBRBMBW .MBMBMBMBB
- * :JMRMMD .. , 1MMRM1; ;MBMBBR: MBM ;MB: BMB: MBM. RMBr sBMH BM0 UMB, BMB. KMBv
- * ;. XOW B1; :uM: 1RE, i .2BMBs rMB. MBO MBO JMB; MBB MBM BBS 7MBMBOBM: MBW :BMc
- * OBRJ.SEE MRDOWOR, 3DE:7OBM . ;BMB RMR7BM BMB MBB. BMB ,BMR .BBZ MMB rMB, BMM rMB7
- * :FBRO0D0 RKXSXPR. JOKOOMPi BMBSSWBMB; BMBB: MBMB0ZMBMS .BMBOXRBMB MBMDE RBM2;SMBM; MBB xBM2
- * iZGE O0SHSPO. uGZ7. sBMBMBDL :BMO OZu:BMBK, rRBMB0; ,EBMB xBMBr:ER. RDU :OO;
- * ,BZ, 1D0 RPSFHXR. xWZ .SMr . .BBB
- * :0BMRDG RESSSKR. 2WOMBW; BMBMR
- * i0BM: SWKHKGO MBDv
- * .UB OOGDM. MK, Copyright (c) 2015-2019. 斯伯坦机器人
- * , XMW ..
- * r All rights reserved.
- *
- * ********************************************************************************************************************
- */
- package com.sybotan.service.json
- import com.alibaba.fastjson.JSON
- import com.alibaba.fastjson.PropertyNamingStrategy
- import com.alibaba.fastjson.serializer.NameFilter
- import com.alibaba.fastjson.serializer.SerializeConfig
- import com.alibaba.fastjson.serializer.SerializerFeature
- import com.alibaba.fastjson.support.config.FastJsonConfig
- import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
- import com.sybotan.base.utils.SJsonUtil
- import org.springframework.http.MediaType
- import springfox.documentation.swagger.web.SwaggerResource
- import springfox.documentation.swagger.web.UiConfiguration
- /**
- *
- */
- open class SJsonHttpMessageConverter : FastJsonHttpMessageConverter() {
- /**
- * 属性名命名规则
- */
- var propertyNamingStrategy : PropertyNamingStrategy
- get() = SJsonUtil.serializeConfig.propertyNamingStrategy
- set(value) {
- SJsonUtil.serializeConfig.propertyNamingStrategy = value
- } // Set propertyNamingStrategy
- init {
- val fastJsonConfig = FastJsonConfig()
- fastJsonConfig.dateFormat = JSON.DEFFAULT_DATE_FORMAT
- fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect)
- this.fastJsonConfig = fastJsonConfig;
- val nameFilter = NameFilter({ obj, name, value -> name })
- //val nameFilter = { `object`, name, value -> name }
- SJsonUtil.serializeConfig.addFilter(UiConfiguration::class.java, nameFilter)
- SJsonUtil.serializeConfig.addFilter(SwaggerResource::class.java, nameFilter)
- // serializeConfig.addFilter(MetricsEndpoint.MetricResponse::class.java, nameFilter)
- // serializeConfig.addFilter(EnvironmentEndpoint.EnvironmentDescriptor::class.java, nameFilter)
- fastJsonConfig.serializeConfig = SJsonUtil.serializeConfig
- val fastMediaTypes = ArrayList<MediaType>()
- fastMediaTypes.add(MediaType.APPLICATION_JSON)
- fastMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED)
- fastMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM)
- fastMediaTypes.add(MediaType.TEXT_HTML)
- fastMediaTypes.add(MediaType("application", "vnd.spring-boot.actuator.v2+json"))
- this.supportedMediaTypes = fastMediaTypes;
- } // Init
- } // Class SJsonHttpMessageConverter
|