外卖项目day05-店铺营业状态设置和实现----1
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
package com.sky.controller.admin;
|
||||||
|
|
||||||
|
import com.sky.result.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api(tags = "店铺相关的接口")
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/admin/shop/")
|
||||||
|
@RestController
|
||||||
|
public class ShopController {
|
||||||
|
|
||||||
|
public static final String SHOP_STATUS = "SHOP_STATUS";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@PutMapping("/{status}")
|
||||||
|
@ApiOperation("设置营业状态")
|
||||||
|
public Result setStatus(@PathVariable Integer status){
|
||||||
|
log.info("设置营业状态:{}",status==1?"营业中":"打烊中");
|
||||||
|
//经常要查的,数量又少的,直接保存到非关系型数据库中即可!!!redis
|
||||||
|
redisTemplate.opsForValue().set(SHOP_STATUS,status);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@SpringBootTest //让springboot识别测试类,并能调用IOC容器
|
//@SpringBootTest //让springboot识别测试类,并能调用IOC容器
|
||||||
public class SpringDateRedisTest {
|
public class SpringDateRedisTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate redisTemplate;
|
private RedisTemplate redisTemplate;
|
||||||
|
|||||||
Reference in New Issue
Block a user