forked from Q-1515/reggie_parent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
223 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
reggie_server/src/main/java/com/reggie/config/ReidsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.reggie.config; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
@Configuration | ||
@Slf4j | ||
public class ReidsConfiguration { | ||
|
||
@Bean | ||
public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { | ||
|
||
RedisTemplate redisTemplate = new RedisTemplate(); | ||
//设置redis的key序列化器 | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
//设置redis的连接工程 | ||
redisTemplate.setConnectionFactory(connectionFactory); | ||
return redisTemplate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
reggie_server/src/main/java/com/reggie/controller/admin/ShopController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.reggie.controller.admin; | ||
|
||
import com.reggie.result.R; | ||
import com.reggie.service.ShopService; | ||
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.web.bind.annotation.*; | ||
|
||
@RestController("adminShopController") | ||
@RequestMapping("/admin/shop") | ||
@Slf4j | ||
@Api(tags = "店铺操作接口") | ||
public class ShopController { | ||
|
||
@Autowired | ||
private ShopService shopService; | ||
|
||
/** | ||
* 设置营业状态 | ||
* | ||
* @return success | ||
*/ | ||
@PutMapping("/{status}") | ||
@ApiOperation("设置营业状态") | ||
public R<String> setShopOrStatus(@PathVariable Integer status) { | ||
log.info("设置店铺状态为:{}", status); | ||
shopService.setShopStatus(status); | ||
return R.success("店铺状态更新成功"); | ||
} | ||
|
||
|
||
/** | ||
* 获取营业状态 | ||
* | ||
* @return 营业状态 | ||
*/ | ||
@GetMapping("/status") | ||
@ApiOperation("获取营业状态") | ||
public R<Integer> getShopOrStatus() { | ||
Integer shopStatus = null; | ||
try { | ||
shopStatus = shopService.getShopStatus(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
shopStatus = 1; | ||
} | ||
log.info("当前营业状态为{}",shopStatus); | ||
return R.success(shopStatus); | ||
} | ||
|
||
|
||
} |
43 changes: 43 additions & 0 deletions
43
reggie_server/src/main/java/com/reggie/controller/user/ShopController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.reggie.controller.user; | ||
|
||
import com.reggie.result.R; | ||
import com.reggie.service.ShopService; | ||
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.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController("userShopController") | ||
@RequestMapping("/user/shop") | ||
@Slf4j | ||
@Api(tags = "C端-店铺操作接口") | ||
public class ShopController { | ||
|
||
@Autowired | ||
private ShopService shopService; | ||
|
||
/** | ||
* 获取营业状态 | ||
* | ||
* @return 营业状态 | ||
*/ | ||
@GetMapping("/status") | ||
@ApiOperation("获取营业状态") | ||
public R<Integer> getShopOrStatus() { | ||
Integer shopStatus = null; | ||
|
||
try { | ||
shopStatus = shopService.getShopStatus(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
shopStatus = 1; | ||
} | ||
log.info("当前营业状态为{}", shopStatus); | ||
return R.success(shopStatus); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
|
||
import java.util.List; | ||
|
||
/** | ||
* 菜品操作 | ||
*/ | ||
public interface DishService { | ||
|
||
//添加菜品 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
|
||
import java.util.List; | ||
|
||
/** | ||
* 套餐操作 | ||
*/ | ||
public interface SetmealService { | ||
|
||
//新增套餐 | ||
|
14 changes: 14 additions & 0 deletions
14
reggie_server/src/main/java/com/reggie/service/ShopService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.reggie.service; | ||
|
||
/** | ||
* 店铺操作 | ||
*/ | ||
public interface ShopService { | ||
|
||
//设置店铺的营业状态 1为营业 0为打样 | ||
public void setShopStatus(Integer status); | ||
|
||
//获取店铺的营业状态 | ||
public Integer getShopStatus(); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
reggie_server/src/main/java/com/reggie/service/impl/ShopServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.reggie.service.impl; | ||
|
||
import com.reggie.service.ShopService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class ShopServiceImpl implements ShopService { | ||
|
||
public static final String KEY = "SHOP:STATUS"; | ||
|
||
@Autowired | ||
private RedisTemplate redisTemplate; | ||
|
||
|
||
/** | ||
* 设置店铺的营业状态 1为营业 0为打烊 | ||
* | ||
* @param status 营业状态 | ||
*/ | ||
public void setShopStatus(Integer status) { | ||
redisTemplate.opsForValue().set(KEY, status); | ||
log.info("设置店铺营业状态为:{}", status == 1 ? "营业" : "打烊"); | ||
} | ||
|
||
/** | ||
* 获取店铺的营业状态 | ||
* | ||
* @return 店铺的营业状态 | ||
*/ | ||
public Integer getShopStatus() { | ||
return (Integer) redisTemplate.opsForValue().get(KEY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters