点歌相关接口

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,94 @@
package com.czg.controller.admin;
import com.czg.account.dto.song.BaseShopSongDTO;
import com.czg.account.dto.song.ShopSongAddDTO;
import com.czg.account.dto.song.ShopSongEditDTO;
import com.czg.account.entity.ShopSong;
import com.czg.account.service.ShopSongService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 点歌相关接口
* @author Administrator
*/
@RestController
@RequestMapping("/admin/shopSong")
public class ShopSongController {
@Resource
private ShopSongService shopSongService;
/**
* 点歌页面地址
* @return url
*/
@SaAdminCheckPermission(value = "shopSong:url", name = "点歌页面地址")
@GetMapping("/url")
public CzgResult<String> getSongUrl(){
return CzgResult.success(shopSongService.getSongUrl(StpKit.USER.getShopId()));
}
/**
* 歌曲列表
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopSong:list", name = "店铺歌曲查询")
@GetMapping
public CzgResult<Page<ShopSong>> list(){
return CzgResult.success(shopSongService.page(PageUtil.buildPage(), new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).orderBy(ShopSong::getCreateTime, false)));
}
/**
* 歌曲详情
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopSong:detail", name = "店铺歌曲详情")
@GetMapping("/detail")
public CzgResult<ShopSong> detail(@RequestParam Integer id){
return CzgResult.success(shopSongService.getOne(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, id)));
}
/**
* 店铺歌曲新增
* @param shopSongAddDTO 歌曲数据
* @return 是否成功
*/
@SaAdminCheckPermission(value = "shopSong:add", name = "店铺歌曲新增")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated ShopSongAddDTO shopSongAddDTO){
return CzgResult.success(shopSongService.add(StpKit.USER.getShopId(), shopSongAddDTO));
}
/**
* 歌曲修改
* @param shopSongEditDTO 修改信息
* @return 是否成功
*/
@SaAdminCheckPermission(value = "shopSong:edit", name = "店铺歌曲修改")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated ShopSongEditDTO shopSongEditDTO){
return CzgResult.success(shopSongService.edit(StpKit.USER.getShopId(), shopSongEditDTO));
}
/**
* 歌曲删除
* @param shopSongEditDTO 删除信息
* @return 是否成功
*/
@SaAdminCheckPermission(value = "shopSong:del", name = "店铺歌曲删除")
@DeleteMapping
public CzgResult<Boolean> delete(@RequestBody @Validated BaseShopSongDTO shopSongEditDTO){
return CzgResult.success(shopSongService.remove(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, shopSongEditDTO.getId())));
}
}