Explorar o código

feat:ios体力获取及时间格式化统一兼容

hidewnd hai 1 semana
pai
achega
b33fc8925c

+ 1 - 1
yt-ios-lemon/lemon-ios-service/pom.xml

@@ -81,7 +81,7 @@
                 </executions>
                 <configuration>
                     <includeSystemScope>true</includeSystemScope>
-                    <mainClass>com.ytpm.lemonios.LemoniosApplication</mainClass>
+                    <mainClass>com.ytpm.lemonios.LemonIosApplication</mainClass>
                 </configuration>
             </plugin>
         </plugins>

+ 2 - 2
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/LemoniosApplication.java → yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/LemonIosApplication.java

@@ -17,10 +17,10 @@ import org.springframework.web.bind.annotation.RestController;
 })
 @EnableDiscoveryClient
 @EnableFeignClients(basePackages = {"com.ytpm.feign"})
-public class LemoniosApplication
+public class LemonIosApplication
 {
     public static void main( String[] args )
     {
-        SpringApplication.run(LemoniosApplication.class, args);
+        SpringApplication.run(LemonIosApplication.class, args);
     }
 }

+ 29 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/config/JacksonConfig.java

@@ -0,0 +1,29 @@
+package com.ytpm.lemonios.config;
+
+
+import com.ytpm.handle.MultiFormatDateDeserializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Date;
+
+/**
+ * @author lih
+ * @date 2025-10-15 10:22
+ */
+@Configuration
+public class JacksonConfig {
+
+    @Value("${spring.jackson.time-zone:Asia/Shanghai}")
+    private String timeZone;
+
+    @Bean
+    public Jackson2ObjectMapperBuilderCustomizer customJacksonConfig() {
+        return builder -> {
+            // 注册Date类型的序列化器和反序列化器
+            builder.deserializerByType(Date.class, new MultiFormatDateDeserializer(timeZone));
+        };
+    }
+}

+ 7 - 5
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/config/interceptor/HttpInterceptor.java

@@ -1,5 +1,6 @@
 package com.ytpm.lemonios.config.interceptor;
 
+import lombok.NonNull;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -18,11 +19,12 @@ public class HttpInterceptor implements HandlerInterceptor {
     private String applicationNameZh;
 
     @Override
-    public boolean preHandle(HttpServletRequest request,
-                             HttpServletResponse response, Object obj) throws Exception {
+    public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response,
+                             @NonNull Object obj) {
         // 获取客户端IP地址
         String clientIp = getClientIp(request);
-        log.info("{}收到来自客户端[{}]的用户请求", applicationNameZh, clientIp);
+        String requestURI = request.getRequestURI();
+        log.info("{}收到来自客户端[{}]的用户请求:{}", applicationNameZh, clientIp, requestURI);
         return true;
     }
 
@@ -38,8 +40,8 @@ public class HttpInterceptor implements HandlerInterceptor {
      * 请求处理之后调用;在视图渲染之前,controller处理之后。
      */
     @Override
-    public void postHandle(HttpServletRequest request,
-                           HttpServletResponse response, Object obj, ModelAndView mv)
+    public void postHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response,
+                           @NonNull Object obj, ModelAndView mv)
             throws Exception {
         response.setDateHeader("Expires", 0);
         response.setHeader("Buffer", "True");

+ 6 - 2
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/WxController.java

@@ -253,6 +253,7 @@ public class WxController {
         return loginResult;
     }
 
+    @Deprecated
     @ApiOperation("获取微信默认配置项")
     @GetMapping("/defaultConfig")
     public Result<WxDefaultConfig> getWxDefaultConfig(int appType) {
@@ -267,7 +268,7 @@ public class WxController {
     @GetMapping("/addPower")
     @Transactional(rollbackFor = Exception.class)
     @Deprecated
-    public Result<YtDyzUser> addPower(@RequestParam("userId") String userId) {
+    public Result<IosPowerResView> addPower(@RequestParam("userId") String userId) {
 //        appUserMapper.addOnePower(userId);
 //        YtDyzPowerRecord record = new YtDyzPowerRecord();
 //        record.setUserId(userId);
@@ -276,7 +277,10 @@ public class WxController {
 //        record.setType(1);
 //        record.setRemark("增加体力");
 //        appUserMapper.addPowerRecord(record);
-        return Result.resultOk(RepMessage.ADD_SUCCESS);
+        YtDyzUser user = appUserMapper.selectById(userId);
+        IosPowerResView view = new IosPowerResView();
+        view.setPower(user.getPower());
+        return Result.resultOk(RepMessage.ADD_SUCCESS, view);
     }
 
     @ApiOperation("保存应用默认配置")