PropertyAppLoginController.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.java110.app.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.app.smo.propertyLogin.impl.wxLogin.IPropertyAppLoginSMO;
  4. import com.java110.app.smo.wxLogin.IWxLoginSMO;
  5. import com.java110.core.base.controller.BaseController;
  6. import com.java110.core.context.IPageData;
  7. import com.java110.core.context.PageData;
  8. import com.java110.utils.constant.CommonConstant;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.http.HttpStatus;
  13. import org.springframework.http.ResponseEntity;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import javax.servlet.http.HttpServletRequest;
  19. /**
  20. * 微信小程序登录处理类
  21. */
  22. @RestController
  23. @RequestMapping(path = "/app")
  24. public class PropertyAppLoginController extends BaseController {
  25. private final static Logger logger = LoggerFactory.getLogger(PropertyAppLoginController.class);
  26. @Autowired
  27. private IPropertyAppLoginSMO propertyAppLoginSMOImpl;
  28. /**
  29. * 微信登录接口
  30. *
  31. * @param postInfo
  32. * @param request
  33. */
  34. @RequestMapping(path = "/loginProperty", method = RequestMethod.POST)
  35. public ResponseEntity<String> loginProperty(@RequestBody String postInfo, HttpServletRequest request) {
  36. /*IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA);*/
  37. IPageData pd = PageData.newInstance().builder("", "", "", postInfo,
  38. "login", "", "", "",
  39. request.getHeader("APP_ID"));
  40. ResponseEntity<String> responseEntity = propertyAppLoginSMOImpl.doLogin(pd);
  41. if(responseEntity.getStatusCode() != HttpStatus.OK){
  42. return responseEntity;
  43. }
  44. JSONObject outParam = JSONObject.parseObject(responseEntity.getBody());
  45. pd.setToken(outParam.getString("token"));
  46. request.setAttribute(CommonConstant.CONTEXT_PAGE_DATA,pd);
  47. return responseEntity;
  48. }
  49. }