咨询等功能完善
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.ConsultInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 咨询列Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-14
|
||||
*/
|
||||
public interface ConsultInfoMapper
|
||||
{
|
||||
/**
|
||||
* 查询咨询列
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 咨询列
|
||||
*/
|
||||
public ConsultInfo selectConsultInfoById(String id);
|
||||
|
||||
/**
|
||||
* 查询咨询列列表
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 咨询列集合
|
||||
*/
|
||||
public List<ConsultInfo> selectConsultInfoList(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 新增咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertConsultInfo(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 修改咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateConsultInfo(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 删除咨询列
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConsultInfoById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除咨询列
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConsultInfoByIds(String[] ids);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.ConsultInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 咨询列Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-14
|
||||
*/
|
||||
public interface IConsultInfoService
|
||||
{
|
||||
/**
|
||||
* 查询咨询列
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 咨询列
|
||||
*/
|
||||
public ConsultInfo selectConsultInfoById(String id);
|
||||
|
||||
/**
|
||||
* 查询咨询列列表
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 咨询列集合
|
||||
*/
|
||||
public List<ConsultInfo> selectConsultInfoList(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 新增咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertConsultInfo(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 修改咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateConsultInfo(ConsultInfo consultInfo);
|
||||
|
||||
/**
|
||||
* 批量删除咨询列
|
||||
*
|
||||
* @param ids 需要删除的咨询列主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConsultInfoByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除咨询列信息
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConsultInfoById(String id);
|
||||
}
|
||||
@@ -87,4 +87,17 @@ public interface IMusicInfoService
|
||||
MusicInfo editMixMusicInfo(MusicMaxReq param);
|
||||
|
||||
List<MusicInfo> selectMusicInfoByReId(String reId);
|
||||
|
||||
/**
|
||||
* 获取下一首播放的音乐ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param currentMusicId 当前播放的音乐ID,用于顺序播放时获取下一首
|
||||
* @return 下一首音乐ID
|
||||
*/
|
||||
String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId,String reId, String currentMusicId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.ConsultInfo;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.mapper.ConsultInfoMapper;
|
||||
import com.ruoyi.system.service.IConsultInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 咨询列Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-14
|
||||
*/
|
||||
@Service
|
||||
public class ConsultInfoServiceImpl implements IConsultInfoService
|
||||
{
|
||||
@Autowired
|
||||
private ConsultInfoMapper consultInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询咨询列
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 咨询列
|
||||
*/
|
||||
@Override
|
||||
public ConsultInfo selectConsultInfoById(String id)
|
||||
{
|
||||
return consultInfoMapper.selectConsultInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询咨询列列表
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 咨询列
|
||||
*/
|
||||
@Override
|
||||
public List<ConsultInfo> selectConsultInfoList(ConsultInfo consultInfo)
|
||||
{
|
||||
return consultInfoMapper.selectConsultInfoList(consultInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertConsultInfo(ConsultInfo consultInfo)
|
||||
{
|
||||
consultInfo.setCreateTime(DateUtils.getNowDate());
|
||||
return consultInfoMapper.insertConsultInfo(consultInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改咨询列
|
||||
*
|
||||
* @param consultInfo 咨询列
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateConsultInfo(ConsultInfo consultInfo)
|
||||
{
|
||||
consultInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return consultInfoMapper.updateConsultInfo(consultInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除咨询列
|
||||
*
|
||||
* @param ids 需要删除的咨询列主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteConsultInfoByIds(String[] ids)
|
||||
{
|
||||
return consultInfoMapper.deleteConsultInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除咨询列信息
|
||||
*
|
||||
* @param id 咨询列主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteConsultInfoById(String id)
|
||||
{
|
||||
return consultInfoMapper.deleteConsultInfoById(id);
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,106 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
return musicInfoMapper.selectMusicInfoByReId(reId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一首播放的音乐ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param currentMusicId 当前播放的音乐ID,用于顺序播放时获取下一首
|
||||
* @return 下一首音乐ID
|
||||
*/
|
||||
@Override
|
||||
public String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId, String reId, String currentMusicId) {
|
||||
List<MusicInfo> musicList = null;
|
||||
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
break;
|
||||
case 2: // 分类播放
|
||||
if (categoryId == null || categoryId.isEmpty()) {
|
||||
return null; // 分类播放必须提供分类ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId);
|
||||
break;
|
||||
case 3: // 推荐播放
|
||||
if (reId == null || reId.isEmpty()) {
|
||||
return null; // 推荐播放必须提供推荐ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
break;
|
||||
case 4: // 收藏播放
|
||||
if (collectId == null || collectId.isEmpty()) {
|
||||
return null; // 收藏播放必须提供收藏ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicByCollectId(collectId);
|
||||
break;
|
||||
case 5: // 喜欢播放
|
||||
musicList = musicInfoMapper.selectLikeMusicByUser(userId);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果列表为空,返回null
|
||||
if (musicList == null || musicList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 打印调试信息:列表大小和当前音乐ID
|
||||
System.out.println("播放列表大小: " + musicList.size() + ", 当前音乐ID: " + currentMusicId);
|
||||
|
||||
// 根据播放模式获取下一首音乐ID
|
||||
if (playMode == 1) { // 顺序播放
|
||||
// 按照ID排序列表
|
||||
musicList.sort((a, b) -> {
|
||||
Long idA = a.getMusicId();
|
||||
Long idB = b.getMusicId();
|
||||
return idA.compareTo(idB);
|
||||
});
|
||||
|
||||
// 打印排序后的ID列表,用于调试
|
||||
for (MusicInfo music : musicList) {
|
||||
System.out.println(music.getMusicId());
|
||||
}
|
||||
|
||||
// 如果没有当前音乐ID,返回列表中的第一首
|
||||
if (currentMusicId == null || currentMusicId.isEmpty()) {
|
||||
return musicList.get(0).getMusicId().toString();
|
||||
}
|
||||
|
||||
// 查找当前音乐在列表中的位置
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < musicList.size(); i++) {
|
||||
if (musicList.get(i).getMusicId().toString().equals(currentMusicId)) {
|
||||
currentIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 如果找到当前音乐,返回下一首;否则返回第一首
|
||||
if (currentIndex != -1) {
|
||||
int nextIndex = (currentIndex + 1) % musicList.size(); // 循环播放
|
||||
return musicList.get(nextIndex).getMusicId().toString();
|
||||
} else {
|
||||
String firstMusicId = musicList.get(0).getMusicId().toString();
|
||||
System.out.println("未找到当前音乐,返回第一首: " + firstMusicId);
|
||||
return firstMusicId;
|
||||
}
|
||||
} else if (playMode == 2) { // 随机播放
|
||||
// 生成随机索引
|
||||
int randomIndex = (int) (Math.random() * musicList.size());
|
||||
String randomMusicId = musicList.get(randomIndex).getMusicId().toString();
|
||||
System.out.println("随机播放,索引: " + randomIndex + ", ID: " + randomMusicId);
|
||||
return randomMusicId;
|
||||
} else {
|
||||
return null; // 不支持的播放模式
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: 待完善
|
||||
public Map<String, String> getMixMusicInfo(String musicId){
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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.ruoyi.system.mapper.ConsultInfoMapper">
|
||||
|
||||
<resultMap type="ConsultInfo" id="ConsultInfoResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="subTitle" column="sub_title" />
|
||||
<result property="bannerImg" column="banner_img" />
|
||||
<result property="rotaImg" column="rota_img" />
|
||||
<result property="content" column="content" />
|
||||
<result property="author" column="author" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="isDel" column="is_del" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectConsultInfoVo">
|
||||
select id, title, sub_title, banner_img, rota_img, content, author, create_time, update_time, is_del from consult_info
|
||||
</sql>
|
||||
|
||||
<select id="selectConsultInfoList" parameterType="ConsultInfo" resultMap="ConsultInfoResult">
|
||||
<include refid="selectConsultInfoVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="subTitle != null and subTitle != ''"> and sub_title = #{subTitle}</if>
|
||||
<if test="bannerImg != null and bannerImg != ''"> and banner_img = #{bannerImg}</if>
|
||||
<if test="rotaImg != null and rotaImg != ''"> and rota_img = #{rotaImg}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
<if test="author != null and author != ''"> and author = #{author}</if>
|
||||
<if test="isDel != null "> and is_del = #{isDel}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectConsultInfoById" parameterType="String" resultMap="ConsultInfoResult">
|
||||
<include refid="selectConsultInfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertConsultInfo" parameterType="ConsultInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into consult_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">title,</if>
|
||||
<if test="subTitle != null">sub_title,</if>
|
||||
<if test="bannerImg != null">banner_img,</if>
|
||||
<if test="rotaImg != null">rota_img,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="author != null">author,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="isDel != null">is_del,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">#{title},</if>
|
||||
<if test="subTitle != null">#{subTitle},</if>
|
||||
<if test="bannerImg != null">#{bannerImg},</if>
|
||||
<if test="rotaImg != null">#{rotaImg},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="author != null">#{author},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="isDel != null">#{isDel},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateConsultInfo" parameterType="ConsultInfo">
|
||||
update consult_info
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="subTitle != null">sub_title = #{subTitle},</if>
|
||||
<if test="bannerImg != null">banner_img = #{bannerImg},</if>
|
||||
<if test="rotaImg != null">rota_img = #{rotaImg},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="author != null">author = #{author},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="isDel != null">is_del = #{isDel},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteConsultInfoById" parameterType="String">
|
||||
delete from consult_info where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteConsultInfoByIds" parameterType="String">
|
||||
delete from consult_info where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -102,7 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
mi.img_addr as musicImgAddr,
|
||||
mi.music_addr as musicAddr,
|
||||
mi.music_id as musicId,
|
||||
mi.author as musicAuthor
|
||||
mi.author as musicAuthor,
|
||||
mi.music_type as musicType
|
||||
FROM share_info si
|
||||
left join shop_user su on si.user_id = su.user_id
|
||||
LEFT JOIN music_info mi on si.music_id = mi.music_id
|
||||
|
||||
Reference in New Issue
Block a user