RiceMonkeyTextController.java 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.izouma.nineth.web;
  2. import com.izouma.nineth.dto.R;
  3. import com.izouma.nineth.repo.SysConfigRepo;
  4. import com.izouma.nineth.service.SysConfigService;
  5. import lombok.AllArgsConstructor;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import java.util.Random;
  10. @RestController
  11. @RequestMapping("/MonkeyText")
  12. @AllArgsConstructor
  13. public class RiceMonkeyTextController extends BaseController {
  14. private SysConfigService sysConfigService;
  15. private SysConfigRepo sysConfigRepo;
  16. @GetMapping("/test")
  17. public R<String> monkeyText(){
  18. String rice_monkey_text = sysConfigService.getString("rice_monkey_text");
  19. String[] strings = rice_monkey_text.split(",");
  20. int length = strings.length;
  21. Random random = new Random();
  22. int i = random.nextInt(length);
  23. String s = strings[i];
  24. return R.success(s);
  25. }
  26. }