MGTestController.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.malk.mcli.test;
  2. import com.malk.mcli.repository.dao.AyUserAttachmentRelRepository;
  3. import com.malk.server.common.McR;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.context.annotation.Profile;
  7. import org.springframework.validation.annotation.Validated;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11. /**
  12. * 指定运行环境 [参考TestController]
  13. * 1. # MongoDB配置 [yml文件]
  14. * data: mongodb: uri: mongodb://tbread:Teambition999@192.168.31.201:27017/teambition # 固定格式 [连接成功后, 需要为 teambition 库添加 admin 权限才可查询]
  15. * 2. 添加pom依赖 [未全局添加, 子项目单独依赖]
  16. * 3. 添加对应的entity与Dao, 实体通过@Document注解
  17. */
  18. @Profile({"dev", "test"})
  19. @Validated
  20. @RestController
  21. @Slf4j
  22. @RequestMapping("/test/mg")
  23. public class MGTestController {
  24. @Autowired
  25. private AyUserAttachmentRelRepository ayUserAttachmentRelRepository;
  26. @PostMapping("test")
  27. McR test() {
  28. return McR.success(ayUserAttachmentRelRepository.findAll());
  29. }
  30. }