add sms code

This commit is contained in:
2025-07-30 19:04:45 +08:00
parent 7d4ba584a8
commit ed696e7c90
15 changed files with 729 additions and 1 deletions

View File

@@ -0,0 +1,45 @@
package com.ttstd.videotablet.controller;
import com.ttstd.videotablet.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
//引入 redis
@Autowired
private StringRedisTemplate stringRedisTemplate;
@GetMapping("/")
public Result getMethodName() {
return Result.ok().message("Welcome to Yijiantong");
}
/**
* 存储
*
* @return
*/
@PostMapping("/set")
public Result setRedis(@RequestParam(value = "username") String username) {
//存储 key-value 键值对: "username"-"jaychou"
stringRedisTemplate.opsForValue().set("username", username);
return Result.ok().message("redis 存储成功!");
}
/**
* 读取
*
* @return
*/
@GetMapping("/get")
public Result getRedis(@RequestParam(value = "username") String username) {
//通过 key 值读取 value
String result = stringRedisTemplate.opsForValue().get(username);
return Result.ok().data("username", result);
}
}