2 changed files with 53 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||||
|
package com.ruoyi.web.controller; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import com.ruoyi.common.core.controller.BaseController; |
||||
|
import com.ruoyi.common.core.domain.AjaxResult; |
||||
|
import com.alibaba.fastjson2.JSON; |
||||
|
import org.springframework.data.redis.core.RedisTemplate; |
||||
|
|
||||
|
/** |
||||
|
* 导弹发射参数(角度、距离)Redis 存取 |
||||
|
* key: missile:params:{roomId}:{routeId}:{platformId}, value: JSON |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/system/missile-params") |
||||
|
public class MissileParamsController extends BaseController { |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisTemplate<String, Object> redisTemplate; |
||||
|
|
||||
|
@PreAuthorize("@ss.hasPermi('system:routes:query')") |
||||
|
@GetMapping |
||||
|
public AjaxResult get(Long roomId, Long routeId, Long platformId) { |
||||
|
if (roomId == null || routeId == null || platformId == null) { |
||||
|
return AjaxResult.error("参数不完整"); |
||||
|
} |
||||
|
String key = "missile:params:" + roomId + ":" + routeId + ":" + platformId; |
||||
|
Object val = redisTemplate.opsForValue().get(key); |
||||
|
if (val != null) { |
||||
|
return success(JSON.parseObject(val.toString())); |
||||
|
} |
||||
|
return success(); |
||||
|
} |
||||
|
|
||||
|
@PreAuthorize("@ss.hasPermi('system:routes:edit')") |
||||
|
@PostMapping |
||||
|
public AjaxResult save(@RequestBody java.util.Map<String, Object> body) { |
||||
|
Object roomId = body.get("roomId"); |
||||
|
Object routeId = body.get("routeId"); |
||||
|
Object platformId = body.get("platformId"); |
||||
|
if (roomId == null || routeId == null || platformId == null) { |
||||
|
return AjaxResult.error("参数不完整"); |
||||
|
} |
||||
|
String key = "missile:params:" + roomId + ":" + routeId + ":" + platformId; |
||||
|
redisTemplate.opsForValue().set(key, JSON.toJSONString(body)); |
||||
|
return success(); |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 378 B |
Loading…
Reference in new issue