小程序点歌 新增获取正在演唱歌曲接口

This commit is contained in:
SongZhang 2024-07-12 15:46:47 +08:00
parent 41c264d325
commit a25e86fcc0
4 changed files with 26 additions and 3 deletions

View File

@ -60,7 +60,9 @@ public class LoginFilter implements Filter {
// 点歌部分不需要登录
"/cashierService/song/detail",
"/cashierService/song/record",
"/cashierService/song"
"/cashierService/song",
"/cashierService/song/singing",
"/cashierService/login/test"
);
@Autowired

View File

@ -60,6 +60,11 @@ public class ShopSongController {
return Result.successWithData(shopSongService.getRecord(openId, page, size, state, isDesc));
}
/**
* 获取正在播放的歌曲
* @param openId 用户id
* @return 歌曲信息
*/
@GetMapping("/singing")
public Result getSinging(
@RequestHeader("openId") String openId
@ -68,6 +73,12 @@ public class ShopSongController {
}
/**
* 创建订单
* @param openId 用户信息
* @param songOrderDTO 订单信息
* @return result
*/
@PostMapping
public Result createOrder(
@RequestHeader("openId") String openId,

View File

@ -64,6 +64,6 @@ public interface TbShopSongOrderMapper {
" a.open_id = #{openId} and a.state in (1, 2, 3)")
List<Map<String, Object>> selectActiveOrderByUserId(@Param("openId") String openId);
@Select("SELECT song_name, id FROM `tb_shop_song_order` where open_id=#{openId} and state=2 limit 1")
@Select("SELECT a.song_name songName, a.id, b.img FROM `tb_shop_song_order` as a left join tb_shop_song as b on a.song_id=b.id where open_id=#{openId} and state=2 limit 1")
Map<String, Object> selectSinging(@Param("openId") String openId);
}

View File

@ -28,6 +28,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -136,7 +137,16 @@ public class TbShopSongServiceImpl implements TbShopSongService{
@Override
public Object getSinging(String openId) {
return shopSongOrderMapper.selectSinging(openId);
Map<String, Object> map = shopSongOrderMapper.selectSinging(openId);
if (map == null) {
return new HashMap<String, Object>(){{
put("songName", "");
put("id", "");
put("img", "");
}};
}else {
return map;
}
}
}