IndexController.java 1.8 KB

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