增加分享次数,优化音乐下载

This commit is contained in:
menxipeng
2025-08-27 21:28:33 +08:00
parent a179f81542
commit 40234f3694
7 changed files with 125 additions and 18 deletions

View File

@@ -19,6 +19,14 @@ public interface ShareInfoMapper
* @return 【请填写功能名称】
*/
public ShareInfo selectShareInfoById(String id);
/**
* 根据音乐ID查询分享信息
*
* @param musicId 音乐ID
* @return 分享信息
*/
public ShareInfo selectShareInfoByMusicId(String musicId);
/**
* 查询【请填写功能名称】列表

View File

@@ -61,4 +61,12 @@ public interface IShareInfoService
public int deleteShareInfoById(String id);
List<ShareInfo> findShareInfoListPage(ShareInfo shareInfo);
/**
* 增加分享次数
*
* @param musicId 音乐ID
* @return 结果
*/
public int increaseShareCount(String id);
}

View File

@@ -28,9 +28,32 @@ public class ShareInfoServiceImpl implements IShareInfoService
* @return 【请填写功能名称】
*/
@Override
public ShareInfo selectShareInfoById(String id)
{
return shareInfoMapper.selectShareInfoById(id);
public List<ShareInfo> findShareInfoListPage(ShareInfo shareInfo) {
return shareInfoMapper.selectShareInfoListPage(shareInfo);
}
/**
* 增加分享次数
*
* @return 结果
*/
@Override
public int increaseShareCount(String id) {
// 查询是否存在该音乐的分享记录
ShareInfo shareInfo = shareInfoMapper.selectShareInfoById(id);
if (shareInfo != null) {
// 存在记录,更新分享次数
shareInfo.setShareNum(shareInfo.getShareNum() + 1);
shareInfo.setUpdateTime(DateUtils.getNowDate());
return shareInfoMapper.updateShareInfo(shareInfo);
}
return 0;
}
@Override
public ShareInfo selectShareInfoById(String id) {
return null;
}
/**
@@ -95,8 +118,6 @@ public class ShareInfoServiceImpl implements IShareInfoService
return shareInfoMapper.deleteShareInfoById(id);
}
@Override
public List<ShareInfo> findShareInfoListPage(ShareInfo shareInfo) {
return shareInfoMapper.selectShareInfoListPage(shareInfo);
}
}

View File

@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="review" column="review" />
<result property="shareNum" column="share_num" />
</resultMap>
<sql id="selectShareInfoVo">
select id, user_id, share_decs, music_id, share_addr, share_plat, create_time, update_time, is_del, review from share_info
select id, user_id, share_decs, music_id, share_addr, share_plat, create_time, update_time, is_del, review,share_num from share_info
</sql>
<select id="selectShareInfoList" parameterType="ShareInfo" resultMap="ShareInfoResult">
@@ -38,6 +39,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectShareInfoVo"/>
where id = #{id}
</select>
<select id="selectShareInfoByMusicId" parameterType="String" resultMap="ShareInfoResult">
<include refid="selectShareInfoVo"/>
where music_id = #{musicId} limit 1
</select>
<insert id="insertShareInfo" parameterType="ShareInfo" useGeneratedKeys="true" keyProperty="id">
insert into share_info
@@ -77,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="review != null">review = #{review},</if>
<if test="shareNum != null">share_num=#{shareNum}</if>
</trim>
where id = #{id}
</update>