IndexController.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.sckw.auth.controller;
  2. import com.sckw.auth.model.vo.req.LoginReqVo;
  3. import com.sckw.auth.model.vo.req.RegisterReqVo;
  4. import com.sckw.auth.service.IIndexService;
  5. import com.sckw.core.web.response.HttpResult;
  6. import com.sckw.system.api.RemoteUserService;
  7. import com.sckw.system.api.feign.RemoteUserFService;
  8. import org.apache.dubbo.config.annotation.DubboReference;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. @RestController
  12. @RequestMapping("/auth")
  13. public class IndexController {
  14. @Autowired
  15. private RemoteUserFService remoteUserFService;
  16. @DubboReference(version = "2.0.0", group = "design", check = false)
  17. private RemoteUserService remoteUserService;
  18. @Autowired
  19. private IIndexService indexService;
  20. @GetMapping("/index")
  21. public String index() {
  22. //auth 服务 调用 system服务提供的feign接口
  23. return remoteUserFService.getUserInfo("312");
  24. }
  25. @GetMapping("/getUserInfo")
  26. public String getUserInfo(String account) {
  27. //auth 服务 调用example实现的dubbo接口
  28. return remoteUserService.getUserInfoV1(account);
  29. }
  30. /**
  31. * 登录
  32. */
  33. @PostMapping("/login")
  34. public HttpResult login(@RequestBody LoginReqVo reqVo) {
  35. return HttpResult.ok(indexService.login(reqVo));
  36. }
  37. /**
  38. * @param reqDto 注册入参
  39. * @return HttpResult
  40. * @desc: 用户注册
  41. * @author: czh
  42. * @date: 2023/6/16
  43. */
  44. @PostMapping("/register")
  45. public HttpResult register(@RequestBody RegisterReqVo reqDto) {
  46. indexService.register(reqDto);
  47. return HttpResult.ok();
  48. }
  49. }