点歌相关接口

This commit is contained in:
张松
2025-03-01 11:21:23 +08:00
parent 076c215278
commit 7a15a48e04
10 changed files with 476 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.ShopSong;
/**
* 点歌-歌曲表 映射层。
*
* @author zs
* @since 2025-03-01
*/
public interface ShopSongMapper extends BaseMapper<ShopSong> {
}

View File

@@ -0,0 +1,63 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.account.dto.song.ShopSongAddDTO;
import com.czg.account.dto.song.ShopSongEditDTO;
import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopSong;
import com.czg.account.service.ShopSongService;
import com.czg.service.account.mapper.ShopSongMapper;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 点歌-歌曲表 服务层实现。
*
* @author zs
* @since 2025-03-01
*/
@Service
public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> implements ShopSongService{
@Resource
private RedisService redisService;
@Override
public Boolean add(Long shopId, ShopSongAddDTO shopSongAddDTO) {
ShopSong shopSong = BeanUtil.copyProperties(shopSongAddDTO, ShopSong.class);
shopSong.setShopId(shopId);
return save(shopSong);
}
@Override
public Boolean edit(Long shopId, ShopSongEditDTO shopSongEditDTO) {
ShopSong shopSong = getOne(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, shopSongEditDTO.getId()));
if (shopSong == null) {
throw new ApiNotPrintException("歌曲列表不存在");
}
BeanUtil.copyProperties(shopSongEditDTO, shopSong);
return updateById(shopSong);
}
@Override
public String getSongUrl(Long shopId) {
String code;
String key = RedisCst.getSongUrlKey(shopId);
if(redisService.hasKey(key)){
code = (String) redisService.get(key);
}else {
code = RandomStringUtils.randomAlphanumeric(12);
redisService.set(key, code);
redisService.set(key, shopId);
}
return code;
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.ShopSongMapper">
</mapper>