From 163b6fd373e43438fce4b5ed3cabf434ca019cc0 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sat, 23 Mar 2024 21:29:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BF=AE=E6=94=B9):=20=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=8F=AA=E8=83=BD=E5=9C=A8=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E4=B8=AD=E5=AE=9A=E4=B9=89=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=AB=E7=9A=84=E5=8A=9E=E6=B3=95=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 +++ pom.xml | 2 +- spzx-common/common-service/pom.xml | 12 +++-- .../atguigu/config/RedisConfiguration.java | 33 +++++++------ .../atguigu/config/ResourceConfiguration.java | 6 +-- .../atguigu/config/WebMvcConfiguration.java | 25 ---------- .../handler/GlobalExceptionHandler.java | 2 +- .../interceptor/LoginAuthInterceptor.java | 8 +-- .../atguigu/config/RedisConfiguration.class | Bin 7022 -> 7459 bytes .../config/ResourceConfiguration.class | Bin 1586 -> 1558 bytes .../atguigu/config/WebMvcConfiguration.class | Bin 4211 -> 2984 bytes .../handler/GlobalExceptionHandler.class | Bin 5109 -> 5107 bytes .../interceptor/LoginAuthInterceptor.class | Bin 3465 -> 3487 bytes .../com/atguigu/json/JacksonObjectMapper.java | 46 ------------------ .../atguigu/json/JacksonObjectMapper.class | Bin 2465 -> 0 bytes .../spzx/manger/MangerApplication.java | 8 ++- .../service/impl/SysUserServiceImpl.java | 3 +- .../src/main/resources/application-dev.yml | 4 -- .../src/main/resources/application.yml | 4 +- .../src/main/resources/logback-spring.xml | 15 +++--- .../target/classes/application-dev.yml | 4 -- spzx-manager/target/classes/application.yml | 4 +- .../spzx/manger/MangerApplication.class | Bin 970 -> 1333 bytes .../service/impl/SysUserServiceImpl.class | Bin 4371 -> 4271 bytes .../target/classes/logback-spring.xml | 15 +++--- .../spzx/model/entity/base/BaseEntity.java | 6 +-- .../spzx/model/entity/base/BaseEntity.class | Bin 3518 -> 3650 bytes 27 files changed, 73 insertions(+), 131 deletions(-) create mode 100644 .gitignore delete mode 100644 spzx-common/common-util/src/main/java/com/atguigu/json/JacksonObjectMapper.java delete mode 100644 spzx-common/common-util/target/classes/com/atguigu/json/JacksonObjectMapper.class diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e2211d --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +**/target/ +.idea +*.iml +*.class +*Test.java +**/test/ +logs \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3800150..e518e0a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 17 UTF-8 8.0.32 - 2.0.21 + 2.0.47 1.18.20 3.0.1 2.1.0 diff --git a/spzx-common/common-service/pom.xml b/spzx-common/common-service/pom.xml index 9d8c274..26539f1 100644 --- a/spzx-common/common-service/pom.xml +++ b/spzx-common/common-service/pom.xml @@ -24,6 +24,11 @@ spzx-model 1.0-SNAPSHOT + + com.atguigu + common-util + 1.0-SNAPSHOT + org.springframework.boot @@ -34,11 +39,10 @@ org.springframework.boot spring-boot-starter-data-redis + - com.atguigu - common-util - 1.0-SNAPSHOT - compile + org.springframework.boot + spring-boot-configuration-processor diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/RedisConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/RedisConfiguration.java index 155eee0..bc4da51 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/RedisConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/RedisConfiguration.java @@ -35,15 +35,16 @@ public class RedisConfiguration { * 使用StringRedisSerializer序列化为字符串 */ @Bean - public RedisTemplate redisTemplate(LettuceConnectionFactory factory) { + public RedisTemplate redisTemplate(LettuceConnectionFactory connectionFactory) { RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(factory); - // 设置key序列化为String + redisTemplate.setConnectionFactory(connectionFactory); + // 设置key序列化为string redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setHashKeySerializer(new StringRedisSerializer()); - // 设置value序列化为JSON,使用GenericJackson2JsonRedisSerializer替换默认的序列化 + // 设置value序列化为JSON,使用GenericJackson2JsonRedisSerializer替换默认序列化 redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + return redisTemplate; } @@ -62,29 +63,31 @@ public class RedisConfiguration { .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer)) .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(serializer)); - return RedisCacheManager.builder(factory).cacheDefaults(redisCacheConfiguration).build(); + RedisCacheManager cacheManager = RedisCacheManager.builder(factory) + .cacheDefaults(redisCacheConfiguration).build(); + return cacheManager; } /** * 指定的日期模式 */ public Jackson2JsonRedisSerializer jsonRedisSerializer() { - // LocalDatetime序列化,默认不兼容jdk8日期序列化 - JavaTimeModule javaTimeModule = new JavaTimeModule(); - javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - ObjectMapper mapper = new ObjectMapper(); - // 设置Object访问权限 + // 设置ObjectMapper访问权限 mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); // 记录序列化之后的数据类型,方便反序列化 mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL); // 关闭默认的日期格式化方式,默认UTC日期格式 yyyy-MM-dd’T’HH:mm:ss.SSS mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - mapper.registerModule(javaTimeModule); + // LocalDatetime序列化,默认不兼容jdk8日期序列化 + JavaTimeModule timeModule = new JavaTimeModule(); + timeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + timeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + timeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + timeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + + mapper.registerModule(timeModule); return new Jackson2JsonRedisSerializer<>(mapper, Object.class); } } \ No newline at end of file diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java index af41f00..7559018 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java @@ -7,9 +7,9 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry @Configuration @Slf4j public class ResourceConfiguration extends WebMvcConfiguration { - protected void addResourceHandlers(ResourceHandlerRegistry registry) { - log.info("ResourceConfiguration===>设置静态资源映射..."); + public void addResourceHandlers(ResourceHandlerRegistry registry) { + log.info("设置静态资源映射"); registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } -} +} \ No newline at end of file diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java index 0998452..34b8283 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java @@ -1,21 +1,14 @@ package com.atguigu.config; -import com.atguigu.constant.LocalDateTimeConstant; import com.atguigu.interceptor.LoginAuthInterceptor; -import com.atguigu.json.JacksonObjectMapper; import com.atguigu.properties.InterceptorsProperties; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.stereotype.Component; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -import java.text.SimpleDateFormat; -import java.util.List; - @Component @Slf4j public class WebMvcConfiguration extends WebMvcConfigurationSupport { @@ -48,22 +41,4 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport { registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/**") .excludePathPatterns(interceptorsProperties.getNoAuthUrls()); } - - /** - * 扩展Spring MVC框架的消息转化器 - * - * @param converters 转换器 - */ - public void extendMessageConverters(List> converters) { - log.info("WebMvcConfiguration===>扩展消息转换器..."); - // 创建一个消息转换器对象 - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - // 需要为消息转换器设置一个对象转换器,对象转换器可以将Java对象序列化为json数据 - converter.setObjectMapper(new JacksonObjectMapper()); - // 添加条件判断,只应用于特定的请求路径 - converter.getObjectMapper().setDateFormat(new SimpleDateFormat(LocalDateTimeConstant.DEFAULT_DATE_TIME_SECOND_FORMAT)); - - // 将自己的消息转化器加入容器中 - converters.add(converter); - } } \ No newline at end of file diff --git a/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java b/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java index 202e696..3c4d76d 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java @@ -67,7 +67,7 @@ public class GlobalExceptionHandler { String username = message.split(" ")[2]; // 错误信息 String errorMessage = username + MessageConstant.ALREADY_EXISTS; - return Result.error(exception.getMessage()); + return Result.error(errorMessage); } else { return Result.error(MessageConstant.UNKNOWN_ERROR); } diff --git a/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java b/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java index 73af3e9..6869f7d 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java @@ -39,15 +39,15 @@ public class LoginAuthInterceptor implements HandlerInterceptor { } // 获取用户信息不存在 - String userinfoString = (String) redisTemplate.opsForValue().get(token); - if (StringUtils.isEmpty(userinfoString)) { + Object sysUserObject = redisTemplate.opsForValue().get(token); + String sysUserString = JSON.toJSONString(sysUserObject); + if (sysUserObject == null) { InterceptorUtil.unLoginInterceptor(response); return false; } // 将用户信息放到ThreadLocal中 - SysUser sysUser = JSON.parseObject(userinfoString, SysUser.class); - BaseContext.setSysUser(sysUser); + BaseContext.setSysUser(JSON.parseObject(sysUserString, SysUser.class)); // 更新Redis过期时间 redisTemplate.expire(token, 7, TimeUnit.DAYS); diff --git a/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class b/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class index 7b1ee255b629cfcaeeae56dce46111ccb3109649..862691fb8a3034f3522a173610712fd29082acab 100644 GIT binary patch delta 1898 zcmZuy`FB%A6#gdLOOt7uhBhTox`a|nleX;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&4by&`*mAQF1?*uycDH*1r^fJl@*GSb-h8gpci`q~!S_>#HJ*O~f+S9h diff --git a/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class b/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class index 4f4fcc7fb707188cc6dbcca375c8d355d969f262..c087841a9f6994a8a20b7523f5735673bcd96cf3 100644 GIT binary patch delta 21 dcmdnQGmU4$az=@X2PHP%sbXPdoE*-28vt262l4;_ delta 70 zcmV-M0J;B`46+Q6r!_QEWpi(Ja${vfZ*FF3XLWL6bZKvHJv}`>=&ru!y{_q68tf=fYmVwn;%LPcKd7C}{ovD9Ueq~qoO7Ywp+i@kR^0J-_l$Q*y(YRWv%m_g zS|Mv}u%7e>a>M4l-(;6uiFqwGW2rFE8*UTm%-?!4(2_K$2^vx*Qmm(7(Jw4g|J{FB kp5FH~0#uT>L!p#^p*bNpmT2)eqNiK?(roU3KE+`GUl`CPAqlon29 z!*g-1JrOl%3YMCb5rAF9bh*%t!we;cY6?O6r-ET^O^ZPFa)XQv#G*#)dKfAqyq_zkI$$boS}YM&w{uh78BfNz zDIvt*otZ6_%`mxcDlPFKj|yeG785nHW}WC|STab@8oz%{C{)?p+z^X37={dvJ{KG) zm649%goLOIG3X4n|4;yi1ysX=J%$}MEd}?51>fK5(EWR1=OclW5|S<$Fc}tF%#^7` zl@`sQ2|Eu_Amwcu!PqA55t2qQkIv*1nBmqg}H$ z`qO{W=xy>f5xKZc3+voWB?-2FcAgfkcFr_UAQLSf>Kmeeya)_usI_4Sc2a-loP)*= zOL3MI3XK@G4(~YFs1=W7wQUg_xu>y;+ z63b8x4_09lR$K8)NewjQ;zjQ=t`PGo%{mwj1oRrNThK4EFD;;Mngi+yx|Xo(2)KR* z%$tXKDgMT=nxgLqmX3-8EPbRO_b#pvbPNzu-!6NncXLEY$Jv-LdM)wiQBkC z$=xMZww7Y;UcvM*E!?Nqh76o|ur+@;RiqJ5vD^6$ske}X9cJ0d9#AR8Jft}r9_7#Y GG4KOHA(09I diff --git a/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class b/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class index 77fa4b24fd304015769650051cd35bb75c587ccc..f2554035483f2f3da0df1698b5f79e7806f89994 100644 GIT binary patch delta 123 zcmeyW{#kv)W+Bdv49pCy3=9mGllKToi%97RMQ&q=W;OED-Ng{kz+lB9$ujw^kiLg8 zg9k%CP?-r(u_^-}LpMVYP@^sb8$&OU#R4*bp@5+fNP}1<41ElY48ja*4E;b^CWZ+> QQ4R*iKMcl`Q-mi106MxB_W%F@ delta 125 zcmeyY{#AX$W+Bea49pCy3=9m`llKToi^=E+MQ&q=W;OED-Ng{kz+lCqy^XF7#JCZ88jIBfwD{t S6M&)|42*vmOeZG^PXqw1R2Ulo diff --git a/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class b/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class index 09fccf0de9a59023fc1067317e9071aa88986a08..810943cba5b88cc3e7e411a7287e401a1912ffaa 100644 GIT binary patch delta 852 zcmZXS%TH5L5Qo3}E|*&p(Nrq|gTzD;OaMughl2RP`lwPXiueL6f;_aXD88zqC_Xmc zKfr`Fi2;l@E{Ho5{|fi6T(~j8IHzrDh>LUPch20I`DX5!t$0`Ae*5!z8EEItf;(pf zUD{}O*yFL64*!Qy74*^*ky!M2ES(%4AM&S-&2C<{I_&e`8x4Ur_In)QpzoNG(rykr zL_Cgg)bBUP%T938p~oY}DUHgvR;B;TthY~l^m4}EYQ?v7)8}yxTO*iEj7>}?VpFMj zDv@+K&jp8z9+$Z6&sjb8pvM&w{%@<&9MWj?8?+5eP4=K(6-?zrq5~s|!L%eQoD0a` z1Dmu*izUli(^YgfswC1d)U!j**F@B`aj)J(^$a=>lqjAi68l5 zf*WErZjzLkQIR|4HXwItzooQucZ(giv$VE2Vf!m3by;eR`LI*onWgIsvLCAbz_zfp zj$?~NKN9aX=Oxx)%>Ptclj&kR5$cEvX-rt-G%`T5)Y_G!=*d?qP)JQuvJ_dGTTDt< zO5Ns;WDE%16nBNPTym6&vgo3Ld*ZdFN-g*0&f$T?gfLgAaWaG)LRxTzY6o2;55=iQ zli{(bpds~;N=OZOB5SQ7-f0o5_oqC|kB2_-S+dM5XBWiksL{GP)DFSy%r&Nl2pO~3 znOW@2EOurVI#Wn9JePen-WnD34{t`aLJX@0{zrTvt^l+7e=fQjtyv6|l-FkIUt&Pv VYB^l>O4O8eUW(OuReU?I;V%%{htL23 delta 840 zcmY+COHY$g5Qd-A@7Bu)Q82}d^%CMjZU&;!a1#^}gQB)n6z^g|KtL%4@m3UX$nvb* zXyTd;Vzjs*tl9Y={0*+uIA4n(i!<}i%sKD8GdUkhXG?>tf4(gPjl5k5el!e+2EE0s z2{m!lq1mN{V|vNhr8~^_P%9@K+FVZ3uHTy@g{L{=(CKoPbBd^*v!eR2Rb|Iq;&kaj zE3vPY3ohN*ih{A^@aRM`K9x$Ol4C(G(c^I0zY`~`-%E0JQD5h0Ps>Yxz$B{x~I zgpP-r8deC`*%3QS^c{i9EM>-g#4f7O(zrr>ofC1g954UO{)n}WQ=jPg!uf7=Dl+sd(#p%u_)Hh7clckOq*E zQ*20eTEJ%ejOY0c(IYiWj+rH~vE5)!XR~N*$xY?$(d#sn$*tIf|Hd-c$1>N(@~Shu z5W894R`1b;GvM{sQ49ed+)J diff --git a/spzx-common/common-util/src/main/java/com/atguigu/json/JacksonObjectMapper.java b/spzx-common/common-util/src/main/java/com/atguigu/json/JacksonObjectMapper.java deleted file mode 100644 index b1abf54..0000000 --- a/spzx-common/common-util/src/main/java/com/atguigu/json/JacksonObjectMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.atguigu.json; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; -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 java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; - -import static com.atguigu.constant.LocalDateTimeConstant.*; -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; - -/** - * 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象 - * 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象] - * 从Java对象生成JSON的过程称为 [序列化Java对象到JSON] - */ -public class JacksonObjectMapper extends ObjectMapper { - public JacksonObjectMapper() { - super(); - // 收到未知属性时不报异常 - this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); - - // 反序列化时,属性不存在的兼容处理 - this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - - SimpleModule simpleModule = new SimpleModule() - .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))) - .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))) - .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))) - .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))) - .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))) - .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))); - - // 注册功能模块 例如,可以添加自定义序列化器和反序列化器 - this.registerModule(simpleModule); - } -} diff --git a/spzx-common/common-util/target/classes/com/atguigu/json/JacksonObjectMapper.class b/spzx-common/common-util/target/classes/com/atguigu/json/JacksonObjectMapper.class deleted file mode 100644 index 5f5fd5028c6748cfa7e153e8d971b2f4fa66f283..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2465 zcmbVOZBr9h6n-v57q+X=*ebPFMG-!sJO#1`+d-}Q4bC<*<3bUGIW|Mo8=bZDL*Za?ZfBp?%3EyiNV2Bo-n#pCk zVU-(Z(Xl zvSSV;7xHKt<}A8H62IERlICc5KO zQ3SV+i1yMOrqJzE2$fsqNS~&kOa}qGjryLRH*f)C3}a;>-v|?>jXYww7YS5*ERytJ z#HSiA8TbsB8ScDaJlp0+ezfE>ry*Ne^BC%pr$Id5aHxfi^+`m-RfhQh_iIk6Q59y^ zs@1C^=^u1lQ3ZdU;X;K!=cc4)=xq%RHyGAW)+}Gvg<0|3+qZ6-B~`_}@D5Gk4q=L6 z^d-G!lgZgq>FUPDVy&iQ8c_{120q6u!?lhd`;J@V(rhHeyRqq+qlCp!b_!YdJHeRU0JPi z&x-|>!4~yfx02ujI3|lR4PP*v>u`QO+%(){Sm`T!-Chl0kwNcdPR9aF4NGquRnt_% zgMN%EXs^)~h9SR37CleLvNE~$&YIsU#cXTB3RlM}OqI%q1~#zCaE4OZ`I+H)e~Ij< z=r@gz7?$2GTRrqThIMSIFs0sKj|zXco}>!VD84bU4O%v5T~W5wCOjG(47tD^aP-gM zQ1py^hR~{0q8&4muxycP)b@nC!}qEr3HxQ8F@WhY6Q#ude GyZ-_C{|tWs diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/MangerApplication.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/MangerApplication.java index 74257de..dfd7c12 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/MangerApplication.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/MangerApplication.java @@ -1,15 +1,21 @@ package com.atguigu.spzx.manger; +import lombok.extern.slf4j.Slf4j; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; @SpringBootApplication -@EnableCaching +@EnableTransactionManagement // 开启注解方式的事务管理 +@EnableCaching// 开启缓存注解 @EnableScheduling @ComponentScan("com.atguigu") +@MapperScan("com.atguigu.spzx.manger.mapper") +@Slf4j public class MangerApplication { public static void main(String[] args) { SpringApplication.run(MangerApplication.class, args); diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/SysUserServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/SysUserServiceImpl.java index bcecf18..2ff7b62 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/SysUserServiceImpl.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/SysUserServiceImpl.java @@ -1,6 +1,5 @@ package com.atguigu.spzx.manger.service.impl; -import com.alibaba.fastjson.JSON; import com.atguigu.constant.ExceptionConstant; import com.atguigu.exception.BunnyException; import com.atguigu.lib.MD5; @@ -66,7 +65,7 @@ public class SysUserServiceImpl implements SysUserService { } // 登录成功 String token = UUID.randomUUID().toString().replaceAll("-", ""); - redisTemplate.opsForValue().set(token, JSON.toJSONString(sysUser), 7, TimeUnit.DAYS); + redisTemplate.opsForValue().set(token, sysUser, 7, TimeUnit.DAYS); // 返回loginVo对象 return LoginVo.builder().token(token).build(); } diff --git a/spzx-manager/src/main/resources/application-dev.yml b/spzx-manager/src/main/resources/application-dev.yml index b494140..b31cc35 100644 --- a/spzx-manager/src/main/resources/application-dev.yml +++ b/spzx-manager/src/main/resources/application-dev.yml @@ -11,12 +11,8 @@ bunny: port: 6379 database: 2 - spzx: noAuthUrls: - /admin/system/index/login - /admin/system/index/generateValidateCode - /v3/** -# jackson: -# date-format: yyyy-MM-dd HH:mm:ss -# time-zone: GMT+8 \ No newline at end of file diff --git a/spzx-manager/src/main/resources/application.yml b/spzx-manager/src/main/resources/application.yml index 6ee6c3b..85506e2 100644 --- a/spzx-manager/src/main/resources/application.yml +++ b/spzx-manager/src/main/resources/application.yml @@ -14,6 +14,7 @@ spring: url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true username: ${bunny.datasource.username} password: "${bunny.datasource.password}" + data: redis: host: ${bunny.redis.host} @@ -28,12 +29,11 @@ logging: pattern: dateformat: HH:mm:ss:SSS file: - path: " logs/${spring.application.name}" + path: "logs/${spring.application.name}" mybatis: type-aliases-package: com.atguigu.spzx.model mapper-locations: classpath:mapper/*.xml - # config-location: classpath:mybatis-config.xml configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case: true diff --git a/spzx-manager/src/main/resources/logback-spring.xml b/spzx-manager/src/main/resources/logback-spring.xml index eb59d34..acce308 100644 --- a/spzx-manager/src/main/resources/logback-spring.xml +++ b/spzx-manager/src/main/resources/logback-spring.xml @@ -4,7 +4,7 @@ logback - + @@ -12,13 +12,14 @@ - + - + - + @@ -45,11 +46,11 @@ - + - - + + diff --git a/spzx-manager/target/classes/application-dev.yml b/spzx-manager/target/classes/application-dev.yml index b494140..b31cc35 100644 --- a/spzx-manager/target/classes/application-dev.yml +++ b/spzx-manager/target/classes/application-dev.yml @@ -11,12 +11,8 @@ bunny: port: 6379 database: 2 - spzx: noAuthUrls: - /admin/system/index/login - /admin/system/index/generateValidateCode - /v3/** -# jackson: -# date-format: yyyy-MM-dd HH:mm:ss -# time-zone: GMT+8 \ No newline at end of file diff --git a/spzx-manager/target/classes/application.yml b/spzx-manager/target/classes/application.yml index 6ee6c3b..85506e2 100644 --- a/spzx-manager/target/classes/application.yml +++ b/spzx-manager/target/classes/application.yml @@ -14,6 +14,7 @@ spring: url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true username: ${bunny.datasource.username} password: "${bunny.datasource.password}" + data: redis: host: ${bunny.redis.host} @@ -28,12 +29,11 @@ logging: pattern: dateformat: HH:mm:ss:SSS file: - path: " logs/${spring.application.name}" + path: "logs/${spring.application.name}" mybatis: type-aliases-package: com.atguigu.spzx.model mapper-locations: classpath:mapper/*.xml - # config-location: classpath:mybatis-config.xml configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case: true diff --git a/spzx-manager/target/classes/com/atguigu/spzx/manger/MangerApplication.class b/spzx-manager/target/classes/com/atguigu/spzx/manger/MangerApplication.class index 9ecda2a89eb666d35b9bd91f3d13b1df08a4f5a8..a79aa7a09fef73c26a33e3685552c43b1dbf392a 100644 GIT binary patch delta 540 zcmZWlyH3ME5S)t@l3132Kmy?ro*_JAiijpagFqBX1sybpWloNqbL2A!Xj1V3k$;0G zLLfwesOk72#M%gmpt#$az1^AHeM>#)`rF6z3xFML_H>PPbPQoQg{*-Qj53UQzA%-0 zUTvCnPYByT;8x)I*9;k92VW_M(sI4YFS+S*Da<{WD^**m|Lv@0kV4+T7{(bi*Aooc ze?_6e9y94}%XOp^?1r!GmK}EAb6bJWr6Oy`lO~ta3wR9oB|mfRymt5E_TLv|T zYWF=Ko+j>GhSk`qb$v#C%2aLNp`Z2%HF&#i`$ra+)K|2;R)q)R!Vwo0)xNo^v}iEf zrw~21U$}LLofS3Z1A{ zkM(lVg8J&ym?bY@o=%bx0n%9bvLQSdi;`S6^@PEDP){$`+ delta 232 zcmYLDy$-=(6g{_9ZNHFG6!lwU7m0|?WHuW-h6ga14bs=JbZCgd19bC3;(Q;8;hd9` zd(XMIP^GKN_u~m*jaja2$<9(_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ager/target/classes/logback-spring.xml b/spzx-manager/target/classes/logback-spring.xml index eb59d34..acce308 100644 --- a/spzx-manager/target/classes/logback-spring.xml +++ b/spzx-manager/target/classes/logback-spring.xml @@ -4,7 +4,7 @@ logback - + @@ -12,13 +12,14 @@ - + - + - + @@ -45,11 +46,11 @@ - + - - + + diff --git a/spzx-model/src/main/java/com/atguigu/spzx/model/entity/base/BaseEntity.java b/spzx-model/src/main/java/com/atguigu/spzx/model/entity/base/BaseEntity.java index 74d2286..0504088 100644 --- a/spzx-model/src/main/java/com/atguigu/spzx/model/entity/base/BaseEntity.java +++ b/spzx-model/src/main/java/com/atguigu/spzx/model/entity/base/BaseEntity.java @@ -1,5 +1,6 @@ package com.atguigu.spzx.model.entity.base; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -8,15 +9,14 @@ import java.util.Date; @Data public class BaseEntity implements Serializable { - @Schema(description = "唯一标识") private Long id; - // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Schema(description = "创建时间") private Date createTime; - // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Schema(description = "修改时间") private Date updateTime; diff --git a/spzx-model/target/classes/com/atguigu/spzx/model/entity/base/BaseEntity.class b/spzx-model/target/classes/com/atguigu/spzx/model/entity/base/BaseEntity.class index 23bdb8cc47650006befd56a96d0a715981a72fd9..5963d824fafe1a9fabbc02c111393c9c544aae4c 100644 GIT binary patch delta 1275 zcmah|OHUI~7(FxXOy4R3MMY735lfniaiOg!B9Dr+Jba6C9R z#KeE#LJ(u(g2czlz3~V516;Z@o;x!swT`h#=brE0?{Us|zq{7?aeMH~ulH*J`f+zT z_(RUd$7f4=Voo!v`O1BLF|nY{7K~Ccp%sgzs#cvR9HTu_s_0rZCBawLs&p+%Xnnw6 zJd=s%a=X&$q^>6oaS7W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