完善c端接口
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
package com.ruoyi.web.controller.back;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||
import com.ruoyi.common.utils.MusicUtil;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.config.AliConfig;
|
||||
import com.ruoyi.system.mapper.MusicInfoMapper;
|
||||
import com.ruoyi.system.mapper.ShopUserMapper;
|
||||
import com.ruoyi.system.service.ShopUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -12,20 +20,33 @@ import javax.servlet.http.HttpServletResponse;
|
||||
@RestController
|
||||
public class FileController {
|
||||
|
||||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
@Autowired
|
||||
private MusicInfoMapper musicInfoMapper;
|
||||
|
||||
/**
|
||||
* 下载OSS文件
|
||||
*/
|
||||
@GetMapping("/download/{objectName}/{fileName}")
|
||||
public void downloadOssFile(@PathVariable String objectName,@PathVariable String fileName, HttpServletResponse response) {
|
||||
@GetMapping("/download/{objectName}")
|
||||
public void downloadOssFile(@PathVariable String objectName, HttpServletResponse response) {
|
||||
try {
|
||||
String[] file = objectName.split("file/download");
|
||||
String ossPath = objectName.split("file/download")[1];
|
||||
// 获取文件字节
|
||||
if (objectName.equals("musicFile")){
|
||||
if (objectName.equals("musicFile")) {
|
||||
//TODO:// 获取是否是vip 音乐,检查用户登录状态
|
||||
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
ShopUser shopUser = shopUserMapper.selectShopUserByUserId(userId);
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByPath(objectName);
|
||||
if (musicInfo.getVip() != null && musicInfo.getVip() == 1) {
|
||||
// 判断用户vip
|
||||
if (!MusicUtil.getShopIsVip(shopUser)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] data = AliConfig.ossDown(objectName+"/"+fileName);
|
||||
String fileName = ossPath.substring(objectName.lastIndexOf("/") + 1);
|
||||
byte[] data = AliConfig.ossDown(ossPath);
|
||||
// 设置响应头,支持中文文件名
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
||||
@@ -36,7 +57,8 @@ public class FileController {
|
||||
try {
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"msg\":\"下载失败: " + e.getMessage() + "\"}");
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ public class MusicSceneController extends BaseController
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:scene:add')")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MusicScene musicScene)
|
||||
{
|
||||
return toAjax(musicSceneService.insertMusicScene(musicScene));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.ruoyi.web.controller.back;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||
import com.ruoyi.system.config.AliConfig;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/back/upload")
|
||||
public class UploadOSSController extends BaseController {
|
||||
|
||||
|
||||
@PostMapping("/music/file")
|
||||
public AjaxResult addFile(
|
||||
@RequestParam("file") MultipartFile file
|
||||
) throws IOException {
|
||||
// 1. 处理文件上传
|
||||
if (file != null && !file.isEmpty()) {
|
||||
// 保存文件逻辑
|
||||
return AjaxResult.error("文件不能为空");
|
||||
}
|
||||
|
||||
return AjaxResult.success(AliConfig.ossUp("musicFile/" , file.getOriginalFilename(), file.getInputStream()));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/musicImg/file")
|
||||
public AjaxResult addMusicImgFile(
|
||||
@RequestParam("file") MultipartFile file
|
||||
) throws IOException {
|
||||
// 1. 处理文件上传
|
||||
if (file != null && !file.isEmpty()) {
|
||||
// 保存文件逻辑
|
||||
return AjaxResult.error("文件不能为空");
|
||||
}
|
||||
return AjaxResult.success(AliConfig.ossUp("musicImg/" , file.getOriginalFilename(), file.getInputStream()));
|
||||
}
|
||||
|
||||
@PostMapping("/config/file")
|
||||
public AjaxResult addConfigFile(
|
||||
@RequestParam("file") MultipartFile file
|
||||
) throws IOException {
|
||||
// 1. 处理文件上传
|
||||
if (file != null && !file.isEmpty()) {
|
||||
// 保存文件逻辑
|
||||
return AjaxResult.error("文件不能为空");
|
||||
}
|
||||
return AjaxResult.success(AliConfig.ossUp("config/" , file.getOriginalFilename(), file.getInputStream()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,5 +67,13 @@ public class IndexController extends BaseController {
|
||||
return AjaxResult.success(recommendInfoService.findRecommendBindMusic());
|
||||
}
|
||||
|
||||
@GetMapping("/re/music/{reId}")
|
||||
// 获取推荐音乐
|
||||
public TableDataInfo getRecommendMusicByReId(@PathVariable String reId){
|
||||
startPage();
|
||||
List<MusicInfo> list = recommendInfoService.findRecommendMusicByReId(reId);
|
||||
return getDataTableData(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package com.ruoyi.web.controller.client;
|
||||
|
||||
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||
import com.ruoyi.common.core.domain.entity.MusicScene;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.service.IMusicInfoService;
|
||||
import com.ruoyi.system.service.IMusicSceneService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/client/music")
|
||||
@RestController
|
||||
@@ -22,6 +23,8 @@ public class MusicController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IMusicInfoService musicService;
|
||||
@Autowired
|
||||
private IMusicSceneService musicSceneService;
|
||||
|
||||
// 根据分类获取音乐
|
||||
@RequestMapping("/cate/music")
|
||||
@@ -84,7 +87,31 @@ public class MusicController extends BaseController {
|
||||
@RequestMapping("/getMusicInfo/{musicId}")
|
||||
public AjaxResult getMusicInfo(@PathVariable String musicId){
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(musicService.getMusicInfo(userId,musicId));
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(userId, musicId);
|
||||
if (musicInfo != null){
|
||||
return AjaxResult.success(musicInfo);
|
||||
}else {
|
||||
return new AjaxResult(HttpStatus.USER_VIP_EXPIRE, "请开通会员");
|
||||
}
|
||||
}
|
||||
|
||||
// 新增用户混音
|
||||
@RequestMapping("/add/mixMusic")
|
||||
public AjaxResult addMixMusicInfo(@RequestBody Map<String,String> param){
|
||||
MusicInfo newMusic = musicService.addMixMusicInfo(param);
|
||||
if (newMusic != null){
|
||||
return AjaxResult.success(newMusic);
|
||||
}
|
||||
return AjaxResult.error("混音错误");
|
||||
}
|
||||
|
||||
// 获取场景音乐
|
||||
@GetMapping("/scene/list")
|
||||
public TableDataInfo list(MusicScene musicScene)
|
||||
{
|
||||
startPage();
|
||||
List<MusicScene> list = musicSceneService.selectMusicSceneList(musicScene);
|
||||
return getDataTableData(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -134,3 +134,8 @@ xss:
|
||||
ali:
|
||||
accessKeyId: LTAI5tDWWzwqxumUXTFnkQFd
|
||||
accessKeySecret: KOD3y6OxbHJ23wxAf68NFpUQXCQEPX
|
||||
umApp:
|
||||
appAliKey: 204918113
|
||||
appAliSecret: v4UrIhhLZlo0adpmevyCfvThGFbrRer0
|
||||
androidKey: 687b2df479267e0210b79b6f
|
||||
IOSKey: 687b2e1679267e0210b79b70
|
||||
@@ -20,15 +20,41 @@ public class AliKeyConfig implements InitializingBean {
|
||||
@Value("${ali.accessKeySecret}")
|
||||
public String accessKeySecret;
|
||||
|
||||
@Value("${umApp.appAliKey}")
|
||||
public String umAppAliKey;
|
||||
|
||||
@Value("${umApp.appAliSecret}")
|
||||
public String umAppAliSecret;
|
||||
|
||||
|
||||
@Value("${umApp.androidKey}")
|
||||
public String umAppAndroidKey;
|
||||
|
||||
@Value("${umApp.IOSKey}")
|
||||
public String umAppIOSKey;
|
||||
|
||||
|
||||
// 终端ID
|
||||
public static String ACCESS_KEY_ID;
|
||||
|
||||
public static String ACCESS_KEY_SECRET;
|
||||
|
||||
public static String UMApp_Android_Key;
|
||||
|
||||
public static String UMApp_IOS_Key;
|
||||
|
||||
public static String UMApp_AliKey;
|
||||
|
||||
public static String UMApp_AliSecret;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
ACCESS_KEY_ID = this.accessKeyId;
|
||||
ACCESS_KEY_SECRET = this.accessKeySecret;
|
||||
UMApp_Android_Key = this.umAppAndroidKey;
|
||||
UMApp_IOS_Key = this.umAppIOSKey;
|
||||
UMApp_AliKey = this.umAppAliKey;
|
||||
UMApp_AliSecret = this.umAppAliSecret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -91,4 +91,8 @@ public class HttpStatus
|
||||
* 系统警告消息
|
||||
*/
|
||||
public static final int WARN = 601;
|
||||
|
||||
|
||||
// 用户过期或未开通VIP
|
||||
public static final int USER_VIP_EXPIRE = 801;
|
||||
}
|
||||
|
||||
@@ -72,4 +72,6 @@ public class MusicInfo extends BaseEntity
|
||||
|
||||
private UserCollect userCollect;
|
||||
|
||||
private MusicSceneRelate musicScene;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 music_scene
|
||||
@@ -11,6 +10,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
* @author ruoyi
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Data
|
||||
public class MusicScene extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -30,6 +30,10 @@ public class MusicScene extends BaseEntity
|
||||
@Excel(name = "音乐地址")
|
||||
private String musicAddr;
|
||||
|
||||
/** 音乐地址 */
|
||||
@Excel(name = "图片地址")
|
||||
private String imgAddr;
|
||||
|
||||
/** 创建人 */
|
||||
@Excel(name = "创建人")
|
||||
private String creator;
|
||||
@@ -42,88 +46,5 @@ public class MusicScene extends BaseEntity
|
||||
@Excel(name = "1删除")
|
||||
private Long isDel;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setSceneId(Long sceneId)
|
||||
{
|
||||
this.sceneId = sceneId;
|
||||
}
|
||||
|
||||
public Long getSceneId()
|
||||
{
|
||||
return sceneId;
|
||||
}
|
||||
|
||||
public void setScene(String scene)
|
||||
{
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
public String getScene()
|
||||
{
|
||||
return scene;
|
||||
}
|
||||
|
||||
public void setMusicAddr(String musicAddr)
|
||||
{
|
||||
this.musicAddr = musicAddr;
|
||||
}
|
||||
|
||||
public String getMusicAddr()
|
||||
{
|
||||
return musicAddr;
|
||||
}
|
||||
|
||||
public void setCreator(String creator)
|
||||
{
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getCreator()
|
||||
{
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setModify(String modify)
|
||||
{
|
||||
this.modify = modify;
|
||||
}
|
||||
|
||||
public String getModify()
|
||||
{
|
||||
return modify;
|
||||
}
|
||||
|
||||
public void setIsDel(Long isDel)
|
||||
{
|
||||
this.isDel = isDel;
|
||||
}
|
||||
|
||||
public Long getIsDel()
|
||||
{
|
||||
return isDel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("sceneId", getSceneId())
|
||||
.append("scene", getScene())
|
||||
.append("musicAddr", getMusicAddr())
|
||||
.append("creator", getCreator())
|
||||
.append("modify", getModify())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("isDel", getIsDel())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 music_scene_relate
|
||||
@@ -11,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
* @author ruoyi
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Data
|
||||
public class MusicSceneRelate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -20,48 +22,17 @@ public class MusicSceneRelate extends BaseEntity
|
||||
|
||||
/** 音乐id */
|
||||
@Excel(name = "音乐id")
|
||||
private Long musicId;
|
||||
private String musicId;
|
||||
|
||||
/** 场景id */
|
||||
@Excel(name = "场景id")
|
||||
private Long sceneId;
|
||||
private String sceneIds;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
private Long userId;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
private String sceneInfo;
|
||||
|
||||
public void setMusicId(Long musicId)
|
||||
{
|
||||
this.musicId = musicId;
|
||||
}
|
||||
private String sourceMusicId;
|
||||
|
||||
public Long getMusicId()
|
||||
{
|
||||
return musicId;
|
||||
}
|
||||
|
||||
public void setSceneId(Long sceneId)
|
||||
{
|
||||
this.sceneId = sceneId;
|
||||
}
|
||||
|
||||
public Long getSceneId()
|
||||
{
|
||||
return sceneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("musicId", getMusicId())
|
||||
.append("sceneId", getSceneId())
|
||||
.toString();
|
||||
}
|
||||
private List<MusicScene> musicScenes;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
public enum DeviceTypeEnum {
|
||||
ANDROID,
|
||||
IOS
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class MusicUtil {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前时间 n 天后的日期
|
||||
*
|
||||
* @param n 天数(正数表示未来,负数表示过去)
|
||||
* @return n 天后的 Date 对象
|
||||
*/
|
||||
@@ -19,7 +21,39 @@ public class MusicUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getDateAfterNDays(1));;
|
||||
System.out.println(getDateAfterNDays(1));
|
||||
;
|
||||
}
|
||||
|
||||
// 判断用户是否是vip
|
||||
public static boolean getShopIsVip(ShopUser shopUser) {
|
||||
if (shopUser.getVip() != null && shopUser.getVip() == 1) {
|
||||
Date startTime = shopUser.getVipStartTime();
|
||||
Date endTime = shopUser.getVipEndTime();
|
||||
return isCurrentTimeInRange(startTime, endTime);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查当前时间是否在指定的时间范围内
|
||||
*
|
||||
* @param startDate 开始时间
|
||||
* @param endDate 结束时间
|
||||
* @return true 如果当前时间在范围内,否则 false
|
||||
*/
|
||||
public static boolean isCurrentTimeInRange(Date startDate, Date endDate) {
|
||||
Date now = new Date(); // 获取当前时间
|
||||
|
||||
// 处理跨越日期的情况(结束时间早于开始时间)
|
||||
if (endDate.before(startDate)) {
|
||||
// 当前时间 >= 开始时间 或 当前时间 <= 结束时间
|
||||
return now.after(startDate) || now.before(endDate) || now.equals(startDate) || now.equals(endDate);
|
||||
} else {
|
||||
// 开始时间 <= 当前时间 <= 结束时间
|
||||
return (now.after(startDate) || now.equals(startDate)) && (now.before(endDate) || now.equals(endDate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.config;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.enums.DeviceTypeEnum;
|
||||
import com.ruoyi.common.utils.uuid.UUID;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
@@ -25,14 +26,12 @@ import java.util.Map;
|
||||
@Component
|
||||
public class UmengConfig {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static CloseableHttpResponse send(String token){
|
||||
|
||||
public static CloseableHttpResponse send(String token,String deviceTypeUp){
|
||||
if (deviceTypeUp.equals(DeviceTypeEnum.ANDROID.name())){
|
||||
|
||||
}
|
||||
//687b2df479267e0210b79b6f
|
||||
String umAppkey = "687b2e1679267e0210b79b70";
|
||||
String appKey = "204918113";
|
||||
@@ -94,10 +93,11 @@ public class UmengConfig {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
CloseableHttpResponse sss = send("1234");
|
||||
String reponseContent = EntityUtils.toString(sss.getEntity());
|
||||
System.out.println(reponseContent);
|
||||
System.out.println(sss.getStatusLine().getReasonPhrase());
|
||||
System.out.println(DeviceTypeEnum.ANDROID.name());
|
||||
// CloseableHttpResponse sss = send("1234");
|
||||
// String reponseContent = EntityUtils.toString(sss.getEntity());
|
||||
// System.out.println(reponseContent);
|
||||
// System.out.println(sss.getStatusLine().getReasonPhrase());
|
||||
}
|
||||
|
||||
private static String getSignString(HttpPost httpPost) {
|
||||
|
||||
@@ -68,6 +68,8 @@ public interface MusicInfoMapper
|
||||
|
||||
List<MusicInfo> selectMusicInfoByIds(List<Long> musicIdList);
|
||||
|
||||
List<MusicInfo> selectMusicInfoByIdsLimit(List<Long> musicIdList);
|
||||
|
||||
List<MusicInfo> selectRecommendMusic();
|
||||
|
||||
List<MusicInfo> selectMusicByCollectId(String collectId);
|
||||
@@ -83,4 +85,8 @@ public interface MusicInfoMapper
|
||||
List<MusicInfo> selectHistoryMusicByUser(Long userId);
|
||||
|
||||
MusicInfo selectByMusicId(String musicId);
|
||||
|
||||
List<MusicInfo> selectRecommendMusicByReId(String reId);
|
||||
|
||||
MusicInfo selectByPath(String path);
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface MusicSceneMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMusicSceneByIds(String[] ids);
|
||||
|
||||
List<MusicScene> selectMusicSceneBySceneIds(String[] sceneArray);
|
||||
}
|
||||
|
||||
@@ -12,51 +12,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface MusicSceneRelateMapper
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public MusicSceneRelate selectMusicSceneRelateById(String id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param musicSceneRelate 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<MusicSceneRelate> selectMusicSceneRelateList(MusicSceneRelate musicSceneRelate);
|
||||
int insertMusicSceneRelate(MusicSceneRelate musicSceneRelate);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param musicSceneRelate 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMusicSceneRelate(MusicSceneRelate musicSceneRelate);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param musicSceneRelate 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMusicSceneRelate(MusicSceneRelate musicSceneRelate);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMusicSceneRelateById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMusicSceneRelateByIds(String[] ids);
|
||||
MusicSceneRelate selectByMusicId(String musicId);
|
||||
}
|
||||
|
||||
@@ -80,4 +80,6 @@ public interface IMusicInfoService
|
||||
List<MusicInfo> findHistoryMusicByUser(Long userId);
|
||||
|
||||
MusicInfo getMusicInfo(Long userId, String musicId);
|
||||
|
||||
MusicInfo addMixMusicInfo(Map<String, String> param);
|
||||
}
|
||||
|
||||
@@ -66,4 +66,6 @@ public interface IRecommendInfoService
|
||||
List<MusicInfo> findRecommendMusic();
|
||||
|
||||
List<RecommendInfo> findRecommendBindMusic();
|
||||
|
||||
List<MusicInfo> findRecommendMusicByReId(String reId);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@ public class CShopUserServiceImpl implements ShopUserService {
|
||||
case "3":
|
||||
// 一键 todo: 完善功能
|
||||
String uMtoken = shopUser.getUMtoken();
|
||||
umengConfig.send(uMtoken);
|
||||
String deviceType = shopUser.getDeviceType();
|
||||
String deviceTypeUp = deviceType.toUpperCase();
|
||||
umengConfig.send(uMtoken,deviceTypeUp);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||
import com.ruoyi.common.core.domain.entity.UserCollect;
|
||||
import com.ruoyi.common.core.domain.entity.UserLikeMusic;
|
||||
import com.ruoyi.common.core.domain.entity.*;
|
||||
import com.ruoyi.common.enums.Audio;
|
||||
import com.ruoyi.common.enums.MusicType;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MusicUtil;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.config.AliConfig;
|
||||
import com.ruoyi.system.mapper.MusicInfoMapper;
|
||||
import com.ruoyi.system.mapper.UserCollectMapper;
|
||||
import com.ruoyi.system.mapper.UserLikeMusicMapper;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.IMusicInfoService;
|
||||
import com.ruoyi.system.service.IUserHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,6 +34,13 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
private UserLikeMusicMapper userLikeMusicMapper;
|
||||
@Autowired
|
||||
private UserCollectMapper userCollectMapper;
|
||||
@Autowired
|
||||
private MusicSceneMapper musicSceneMapper;
|
||||
@Autowired
|
||||
private MusicSceneRelateMapper relateMapper;
|
||||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -173,6 +176,14 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public MusicInfo getMusicInfo(Long userId, String musicId) {
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
|
||||
if (musicInfo.getVip() != null && musicInfo.getVip()==1){
|
||||
ShopUser shopUser = shopUserMapper.selectShopUserByUserId(userId);
|
||||
if (!MusicUtil.getShopIsVip(shopUser)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询是否是用户喜欢
|
||||
UserLikeMusic userLikeMusic = userLikeMusicMapper.selectUserLikeMusicAndUserId(userId, musicId);
|
||||
if (userLikeMusic != null){
|
||||
@@ -184,7 +195,53 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
musicInfo.setCollect(true);
|
||||
musicInfo.setUserCollect(userCollect);
|
||||
}
|
||||
|
||||
// 判断是否是是混音
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())){
|
||||
// 查询混音相关信息
|
||||
MusicSceneRelate relateInfo = relateMapper.selectByMusicId(musicId);
|
||||
String sceneIds = relateInfo.getSceneIds();
|
||||
String[] sceneArray = sceneIds.split(",");
|
||||
List<MusicScene> musicScenes = musicSceneMapper.selectMusicSceneBySceneIds(sceneArray);
|
||||
relateInfo.setMusicScenes(musicScenes);
|
||||
musicInfo.setMusicScene(relateInfo);
|
||||
}
|
||||
return musicInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicInfo addMixMusicInfo(Map<String, String> param) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
String musicId = param.get("musicId");
|
||||
String sceneIds = param.get("sceneIds");
|
||||
String sceneJson = param.get("sceneJson");
|
||||
// 新增混音音乐标签
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
if (musicInfo != null){
|
||||
long newMusicId = IdUtil.getSnowflakeNextId();
|
||||
musicInfo.setMusicId(newMusicId);
|
||||
musicInfo.setMusicType(MusicType.MIXING.getMusicType());
|
||||
musicInfoMapper.insertMusicInfo(musicInfo);
|
||||
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
||||
musicSceneRelate.setMusicId(String.valueOf(newMusicId));
|
||||
musicSceneRelate.setSceneIds(sceneIds);
|
||||
musicSceneRelate.setUserId(userId);
|
||||
musicSceneRelate.setSceneInfo(sceneJson);
|
||||
musicSceneRelate.setSourceMusicId(musicId);
|
||||
return musicInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//TODO: 待完善
|
||||
public Map<String, String> getMixMusicInfo(String musicId){
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())){
|
||||
// 获取混音信息
|
||||
relateMapper.selectByMusicId(musicId);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,28 +20,15 @@ public class MusicSceneRelateServiceImpl implements IMusicSceneRelateService
|
||||
@Autowired
|
||||
private MusicSceneRelateMapper musicSceneRelateMapper;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
|
||||
@Override
|
||||
public MusicSceneRelate selectMusicSceneRelateById(String id)
|
||||
{
|
||||
return musicSceneRelateMapper.selectMusicSceneRelateById(id);
|
||||
public MusicSceneRelate selectMusicSceneRelateById(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param musicSceneRelate 【请填写功能名称】
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<MusicSceneRelate> selectMusicSceneRelateList(MusicSceneRelate musicSceneRelate)
|
||||
{
|
||||
return musicSceneRelateMapper.selectMusicSceneRelateList(musicSceneRelate);
|
||||
public List<MusicSceneRelate> selectMusicSceneRelateList(MusicSceneRelate musicSceneRelate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,39 +43,19 @@ public class MusicSceneRelateServiceImpl implements IMusicSceneRelateService
|
||||
return musicSceneRelateMapper.insertMusicSceneRelate(musicSceneRelate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param musicSceneRelate 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMusicSceneRelate(MusicSceneRelate musicSceneRelate)
|
||||
{
|
||||
return musicSceneRelateMapper.updateMusicSceneRelate(musicSceneRelate);
|
||||
public int updateMusicSceneRelate(MusicSceneRelate musicSceneRelate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicSceneRelateByIds(String[] ids)
|
||||
{
|
||||
return musicSceneRelateMapper.deleteMusicSceneRelateByIds(ids);
|
||||
public int deleteMusicSceneRelateByIds(String[] ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicSceneRelateById(String id)
|
||||
{
|
||||
return musicSceneRelateMapper.deleteMusicSceneRelateById(id);
|
||||
public int deleteMusicSceneRelateById(String id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.ruoyi.common.core.domain.entity.MusicScene;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.mapper.MusicSceneMapper;
|
||||
import com.ruoyi.system.service.IMusicSceneService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -55,6 +57,8 @@ public class MusicSceneServiceImpl implements IMusicSceneService
|
||||
public int insertMusicScene(MusicScene musicScene)
|
||||
{
|
||||
musicScene.setCreateTime(DateUtils.getNowDate());
|
||||
musicScene.setSceneId(IdUtil.getSnowflakeNextId());
|
||||
musicScene.setCreator(SecurityUtils.getUsername());
|
||||
return musicSceneMapper.insertMusicScene(musicScene);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,10 +129,16 @@ public class RecommendInfoServiceImpl implements IRecommendInfoService
|
||||
reMusicMap.forEach((reId,rmcs) -> {
|
||||
RecommendInfo recommendInfo = recommendInfoMapper.selectRecommendInfoById(reId);
|
||||
List<Long> musicIdList = rmcs.stream().map(MusicRecommend::getMusicId).collect(Collectors.toList());
|
||||
musicIdList = musicIdList.stream().limit(10).collect(Collectors.toList());
|
||||
List<MusicInfo> musicInfos = musicInfoMapper.selectMusicInfoByIds(musicIdList);
|
||||
recommendInfo.setMusics(musicInfos);
|
||||
result.add(recommendInfo);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MusicInfo> findRecommendMusicByReId(String reId) {
|
||||
return musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,4 +163,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectByMusicId" resultMap="MusicInfoResult">
|
||||
SELECT * FROM music_info where music_id=#{musicId}
|
||||
</select>
|
||||
|
||||
<select id="selectMusicInfoByIdsLimit" resultType="com.ruoyi.common.core.domain.entity.MusicInfo">
|
||||
SELECT * from music_info where music_info.music_id in
|
||||
<foreach item="id" collection="collection" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectRecommendMusicByReId" resultMap="MusicInfoResult">
|
||||
SELECT mi.* FROM music_recommend mr LEFT JOIN music_info mi on mr.music_id=mi.music_id WHERE mr.recommend_id=#{reId} and mi.is_del=0
|
||||
</select>
|
||||
|
||||
<select id="selectByPath" resultMap="MusicInfoResult">
|
||||
<include refid="selectMusicInfoVo" /> where music_addr=#{path} and is_del=0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="scene" column="scene" />
|
||||
<result property="musicAddr" column="music_addr" />
|
||||
<result property="imgAddr" column="img_addr" />
|
||||
<result property="creator" column="creator" />
|
||||
<result property="modify" column="modify" />
|
||||
<result property="createTime" column="create_time" />
|
||||
@@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMusicSceneVo">
|
||||
select id, scene_id, scene, music_addr, creator, modify, create_time, update_time, is_del from music_scene
|
||||
select id, scene_id, scene, music_addr, creator, modify, create_time, update_time, is_del,img_addr from music_scene
|
||||
</sql>
|
||||
|
||||
<select id="selectMusicSceneList" parameterType="MusicScene" resultMap="MusicSceneResult">
|
||||
@@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="isDel != null">is_del,</if>
|
||||
<if test="imgAddr != null">img_addr,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
@@ -58,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="isDel != null">#{isDel},</if>
|
||||
<if test="imgAddr != null">#{imgAddr},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -72,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="isDel != null">is_del = #{isDel},</if>
|
||||
<if test="imgAddr != null">img_addr = #{imgAddr},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -86,4 +90,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectMusicSceneBySceneIds" resultMap="MusicSceneResult">
|
||||
<include refid="selectMusicSceneVo" /> where scene_id in
|
||||
<foreach collection="array" item="sceneId" open="(" separator="," close=")">
|
||||
#{sceneId}
|
||||
</foreach>
|
||||
and is_del=0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -7,55 +7,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="MusicSceneRelate" id="MusicSceneRelateResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="musicId" column="music_id" />
|
||||
<result property="sceneId" column="scene_id" />
|
||||
<result property="sceneIds" column="scene_ids" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="sceneInfo" column="scene_info" />
|
||||
<result property="sourceMusicId" column="source_music_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMusicSceneRelateVo">
|
||||
select id, music_id, scene_id from music_scene_relate
|
||||
select id, music_id, scene_ids,user_id,scene_info,source_music_id from music_scene_relate
|
||||
</sql>
|
||||
|
||||
<select id="selectMusicSceneRelateList" parameterType="MusicSceneRelate" resultMap="MusicSceneRelateResult">
|
||||
<include refid="selectMusicSceneRelateVo"/>
|
||||
<where>
|
||||
<if test="musicId != null "> and music_id = #{musicId}</if>
|
||||
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMusicSceneRelateById" parameterType="String" resultMap="MusicSceneRelateResult">
|
||||
<include refid="selectMusicSceneRelateVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMusicSceneRelate" parameterType="MusicSceneRelate" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into music_scene_relate
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="musicId != null">music_id,</if>
|
||||
<if test="sceneId != null">scene_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="musicId != null">#{musicId},</if>
|
||||
<if test="sceneId != null">#{sceneId},</if>
|
||||
</trim>
|
||||
<insert id="insertMusicSceneRelate">
|
||||
INSERT INTO music_scene_relate(music_id, scene_ids, user_id, scene_info,source_music_id) VALUE (#{musicId},#{sceneIds},#{userId},#{sceneInfo},#{sourceMusicId})
|
||||
</insert>
|
||||
|
||||
<update id="updateMusicSceneRelate" parameterType="MusicSceneRelate">
|
||||
update music_scene_relate
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="musicId != null">music_id = #{musicId},</if>
|
||||
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<select id="selectByMusicId" resultType="com.ruoyi.common.core.domain.entity.MusicSceneRelate">
|
||||
|
||||
<delete id="deleteMusicSceneRelateById" parameterType="String">
|
||||
delete from music_scene_relate where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMusicSceneRelateByIds" parameterType="String">
|
||||
delete from music_scene_relate where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user