歌曲订单管理
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.dto.shop.TbShopSongOrderQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopSongOrder;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopSongOrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (TbShopSongOrder)表控制层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-08 09:24:23
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "歌曲订单管理")
|
||||
@RequestMapping("/api/tbShopSongOrder")
|
||||
public class TbShopSongOrderController{
|
||||
private final RedisUtils redisUtils;
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private TbShopSongOrderService tbShopSongOrderService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
* @param tbShopSongOrder 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping
|
||||
@ApiOperation("获取歌曲列表 分页")
|
||||
@AnonymousGetMapping
|
||||
public ResponseEntity<Object> selectAll(TbShopSongOrderQueryCriteria tbShopSongOrder) {
|
||||
String code = "";
|
||||
if(redisUtils.hasKey(CacheKey.SONG_URL + tbShopSongOrder.getShopId())){
|
||||
code = (String) redisUtils.get(CacheKey.SONG_URL + tbShopSongOrder.getShopId());
|
||||
}
|
||||
Map<String, Object> stringObjectMap = tbShopSongOrderService.queryAll(tbShopSongOrder);
|
||||
stringObjectMap.put("songUrl",code);
|
||||
return new ResponseEntity<>(stringObjectMap, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("createUrl")
|
||||
@ApiOperation("更新歌手页地址")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> createUrl(String shopId) {
|
||||
String key = RandomStringUtils.randomAlphanumeric(8);
|
||||
redisUtils.set(CacheKey.SONG_URL + shopId, key);
|
||||
redisUtils.set(CacheKey.SONG_URL + key, shopId);
|
||||
return new ResponseEntity<>(key,HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("订单详情")
|
||||
public ResponseEntity<Object> selectOne(@PathVariable Serializable id) {
|
||||
return new ResponseEntity<>(tbShopSongOrderService.getById(id),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌手页 歌曲列表
|
||||
* @param key 有效key
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping("songs")
|
||||
@AnonymousGetMapping
|
||||
public ResponseEntity<Object> singerSongs(String key) {
|
||||
String shopId="";
|
||||
if (redisUtils.hasKey(CacheKey.SONG_URL + key)) {
|
||||
shopId = (String)redisUtils.get(CacheKey.SONG_URL + key);
|
||||
}else {
|
||||
throw new BadRequestException("地址已失效,请重新获取地址。");
|
||||
}
|
||||
return new ResponseEntity<>(tbShopSongOrderService.singerSongs(Integer.valueOf(shopId)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下一首
|
||||
* @param shopId 店铺Id
|
||||
*/
|
||||
@PostMapping("next")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> next(@RequestBody Integer shopId) {
|
||||
tbShopSongOrderService.next(shopId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user