浏览代码

用户消费记录接口不存在

lyhzzz 2 年之前
父节点
当前提交
33dccdf59a

+ 39 - 0
src/main/java/com/fdkankan/ucenter/controller/app/SceneApiController.java

@@ -1,19 +1,40 @@
 package com.fdkankan.ucenter.controller.app;
 
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.JwtUtil;
+import com.fdkankan.common.util.SecurityUtil;
 import com.fdkankan.ucenter.common.Result;
+import com.fdkankan.ucenter.constant.LoginConstant;
+import com.fdkankan.ucenter.entity.User;
 import com.fdkankan.ucenter.service.ISceneProService;
+import com.fdkankan.ucenter.service.IUserService;
+import com.fdkankan.ucenter.service.impl.LoginService;
+import com.fdkankan.ucenter.vo.request.LoginParam;
+import com.fdkankan.ucenter.vo.response.LoginVo;
+import com.fdkankan.ucenter.vo.response.UserVo;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 @RestController
 @RequestMapping("/scene")
 public class SceneApiController {
 
     @Autowired
     ISceneProService sceneProService;
+    @Autowired
+    IUserService userService;
+    @Value("${main.url}")
+    private String mainUrl;
+    @Autowired
+    LoginService loginService;
 
     /**
      * 获取指定场景信息
@@ -23,4 +44,22 @@ public class SceneApiController {
     public Result getInfo(@RequestParam(required = false) String num){
         return Result.success( sceneProService.getInfo(num) );
     }
+
+    //app调用 跳转到官网消费页面
+    @RequestMapping("goConsumptionPage")
+    public void goConsumptionPage(HttpServletRequest request, HttpServletResponse response) throws Exception{
+        String phoneNum = request.getParameter("phoneNum");
+        String password = request.getParameter("password");
+        String lang = request.getParameter("lang");
+
+        if(StringUtils.isEmpty(phoneNum) || StringUtils.isEmpty(password)){
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
+        }
+        LoginParam param = new LoginParam();
+        param.setPhoneNum(phoneNum);
+        param.setPassword(password);
+        LoginVo loginVo = loginService.login(param);
+        //登录成功
+        response.sendRedirect(mainUrl + "mobile.html?token="+ loginVo.getToken() + "&app" + (lang == null ? "" : "&lang=" + lang)+"#/consumption/0" );
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/ucenter/exception/GlobalExceptionHandler.java

@@ -30,7 +30,7 @@ public class GlobalExceptionHandler {
     @ResponseBody
     @ExceptionHandler(value = BusinessException.class)
     public Result businessExceptionHandler(BusinessException e) {
-        log.info("业务异常code:{},message:{}", e.getCode(), e.getMessage());
+        log.error("业务异常code:{},message:{}", e.getCode(), e.getMessage());
         return Result.failure(e.getCode(), e.getMessage());
     }
 }

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/impl/LoginService.java

@@ -53,7 +53,7 @@ public class LoginService {
     @Value("${main.url}")
     private String mainUrl;
 
-    public Object login(LoginParam param) {
+    public LoginVo login(LoginParam param) {
         if (StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getPhoneNum())){
             throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
         }