Procházet zdrojové kódy

refactor(store): 将H5ScrmController改为RestController并返回R对象

- 将@Controller注解替换为@RestController
- 修改userAgreement和privacyPolicy方法返回类型为R
- 移除了ModelAndView的使用,直接返回数据对象
- 添加了@ResponseBody和相关导入包
- 简化了用户协议和隐私政策接口的响应方式
xw před 1 týdnem
rodič
revize
3414428fa2

+ 8 - 16
fs-user-app/src/main/java/com/fs/app/controller/store/H5ScrmController.java

@@ -1,15 +1,17 @@
 package com.fs.app.controller.store;
 
 import cn.hutool.json.JSONUtil;
+import com.fs.common.core.domain.R;
 import com.fs.hisStore.config.AgreementConfig;
 import com.fs.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
-@Controller
+@RestController
 @RequestMapping(value="/store/h5")
 public class H5ScrmController
 {
@@ -19,28 +21,18 @@ public class H5ScrmController
 
 
     @GetMapping("/userAgreement")
-    public ModelAndView userAgreement( )
+    public R userAgreement( )
     {
-
         String json=configService.selectConfigByKey("his.agreementConfig");
         AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
-
-        ModelAndView mv=new ModelAndView();
-        mv.addObject("userAgreement", config.getUserRegister());
-        mv.setViewName("userAgreement");
-        //return R.ok().put("userAgreement", config.getUserRegister());
-        return mv;
+        return R.ok().put("userAgreement", config.getUserRegister());
     }
     @GetMapping("/privacyPolicy")
-    public ModelAndView privacyPolicy( )
+    public R privacyPolicy( )
     {
         String json=configService.selectConfigByKey("his.agreementConfig");
         AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
-        ModelAndView mv=new ModelAndView();
-        mv.addObject("privacyPolicy", config.getUserPrivacy());
-        mv.setViewName("privacyPolicy");
-        //return R.ok().put("privacyPolicy", config.getUserPrivacy());
-        return mv;
+        return R.ok().put("privacyPolicy", config.getUserPrivacy());
     }
     @GetMapping("/doctorRegister")
     public ModelAndView doctorRegister( )