店铺营业状态设置业务代码开发
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package com.sky.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 RedisConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
log.info("开始创建redis模板对象...");
|
||||||
|
RedisTemplate redisTemplate = new RedisTemplate();
|
||||||
|
//设置redis的连接工厂对象
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
//设置redis key的序列化器
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,16 +47,35 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Docket docket() {
|
public Docket docket1() {
|
||||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||||
.title("苍穹外卖项目接口文档")
|
.title("苍穹外卖项目接口文档")
|
||||||
.version("2.0")
|
.version("2.0")
|
||||||
.description("苍穹外卖项目接口文档")
|
.description("苍穹外卖项目接口文档")
|
||||||
.build();
|
.build();
|
||||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.groupName("管理端接口")
|
||||||
.apiInfo(apiInfo)
|
.apiInfo(apiInfo)
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("com.sky.controller"))
|
.apis(RequestHandlerSelectors.basePackage("com.sky.controller.admin"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
return docket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket docket2() {
|
||||||
|
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||||
|
.title("苍穹外卖项目接口文档")
|
||||||
|
.version("2.0")
|
||||||
|
.description("苍穹外卖项目接口文档")
|
||||||
|
.build();
|
||||||
|
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.groupName("用户端接口")
|
||||||
|
.apiInfo(apiInfo)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.sky.controller.user"))
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build();
|
.build();
|
||||||
return docket;
|
return docket;
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.sky.controller.admin;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sky.result.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
@RestController("adminShopController")
|
||||||
|
@RequestMapping("/admin/shop")
|
||||||
|
@Api(tags = "店铺相关接口")
|
||||||
|
@Slf4j
|
||||||
|
public class ShopController {
|
||||||
|
|
||||||
|
|
||||||
|
public static final String KEY = "SHOP_STATUS";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置店铺的营业状态
|
||||||
|
* @param status
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/{status}")
|
||||||
|
@ApiOperation("设置店铺的营业状态")
|
||||||
|
public Result setStatus(@PathVariable Integer status){
|
||||||
|
log.info("设置店铺的营业状态:{}", status == 1?"营业中":"打烊中");
|
||||||
|
redisTemplate.opsForValue().set(KEY,status);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取店铺的营业状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/status")
|
||||||
|
@ApiOperation("获取店铺的营业状态")
|
||||||
|
public Result<Integer> getStatus( ){
|
||||||
|
|
||||||
|
Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
|
||||||
|
log.info("获取店铺的营业状态:{}", status == 1?"营业中":"打烊中");
|
||||||
|
return Result.success(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.sky.controller.user;
|
||||||
|
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
@RestController("userShopController")
|
||||||
|
@RequestMapping("/user/shop")
|
||||||
|
@Api(tags = "店铺相关接口")
|
||||||
|
@Slf4j
|
||||||
|
public class ShopController {
|
||||||
|
|
||||||
|
public static final String KEY = "SHOP_STATUS";
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取店铺的营业状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/status")
|
||||||
|
@ApiOperation("获取店铺的营业状态")
|
||||||
|
public Result<Integer> getStatus( ){
|
||||||
|
|
||||||
|
Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
|
||||||
|
log.info("获取店铺的营业状态:{}", status == 1?"营业中":"打烊中");
|
||||||
|
return Result.success(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,3 +12,9 @@ sky:
|
|||||||
access-key-id: LTAI5tPB4TemZaPXduvaV89G
|
access-key-id: LTAI5tPB4TemZaPXduvaV89G
|
||||||
access-key-secret: 0oqBHnXTw4C2bIeuVdEJCpMNvXtaB5
|
access-key-secret: 0oqBHnXTw4C2bIeuVdEJCpMNvXtaB5
|
||||||
bucket-name: web-tlias-901
|
bucket-name: web-tlias-901
|
||||||
|
|
||||||
|
redis:
|
||||||
|
host: localhost
|
||||||
|
port: 6379
|
||||||
|
password: 123456
|
||||||
|
database: 10
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ spring:
|
|||||||
url: jdbc:mysql://${sky.datasource.host}:${sky.datasource.port}/${sky.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
url: jdbc:mysql://${sky.datasource.host}:${sky.datasource.port}/${sky.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||||
username: ${sky.datasource.username}
|
username: ${sky.datasource.username}
|
||||||
password: ${sky.datasource.password}
|
password: ${sky.datasource.password}
|
||||||
|
redis:
|
||||||
|
host: ${sky.redis.host}
|
||||||
|
port: ${sky.redis.port}
|
||||||
|
password: ${sky.redis.password}
|
||||||
|
database: ${sky.redis.database}
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
#mapper配置文件
|
#mapper配置文件
|
||||||
|
|||||||
Reference in New Issue
Block a user