完善c端接口

This commit is contained in:
menxipeng
2025-07-19 14:20:38 +08:00
parent 40f49732a6
commit 028ccf4408
34 changed files with 1278 additions and 126 deletions

View File

@@ -63,12 +63,12 @@ public class AliConfig {
//String templateParam = "{\"name\":\"" + shopUser.getUsername() + "\",\"number\":\""+ shopUser.getPhone() +"\"}";
String templateParam = "您的验证码为:"+ shopUser.getCode() +",请勿泄露于他人!";
String templateParam = "{'code':"+ code + "}";
// 构造API请求对象请替换请求参数值
SendSmsRequest sendSmsRequest = new SendSmsRequest()
.setPhoneNumbers(shopUser.getPhone())
.setSignName("阿里云短信测试")
.setSignName("北京盛兴平商贸")
.setTemplateCode("SMS_323405385")
.setTemplateParam(templateParam); // TemplateParam为序列化后的JSON字符串。

View File

@@ -10,12 +10,12 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@@ -25,10 +25,10 @@ import java.util.Map;
@Component
public class UmengConfig {
public CloseableHttpResponse send(String token){
String umAppkey = "xxxx";
String appKey = "5df88f83570df3b8d40012337";
String appSecret = "xxxx";
public static CloseableHttpResponse send(String token){
String umAppkey = "5df88f83570df3b8d40012337";
String appKey = "LTAI5tDWWzwqxumUXTFnkQFd";
String appSecret = "KOD3y6OxbHJ23wxAf68NFpUQXCQEPX";
// 下面的url要和阿里云云市场购买的商品对应
String url = "https://verify5.market.alicloudapi.com/api/v1/mobile/info?appkey=" + umAppkey;
HttpPost httpPost = new HttpPost(url);
@@ -85,8 +85,11 @@ public class UmengConfig {
public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException {
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());
}
private static String getSignString(HttpPost httpPost) {

View File

@@ -0,0 +1,64 @@
package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.MusicCollect;
import java.util.List;
/**
* 【请填写功能名称】Mapper接口
*
* @author ruoyi
* @date 2025-07-18
*/
public interface MusicCollectMapper
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public MusicCollect selectMusicCollectById(String id);
/**
* 查询【请填写功能名称】列表
*
* @param musicCollect 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<MusicCollect> selectMusicCollectList(MusicCollect musicCollect);
/**
* 新增【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
public int insertMusicCollect(MusicCollect musicCollect);
/**
* 修改【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
public int updateMusicCollect(MusicCollect musicCollect);
/**
* 删除【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deleteMusicCollectById(String id);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteMusicCollectByIds(String[] ids);
int delBindMusic(MusicCollect musicCollect);
}

View File

@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.CategoryInfo;
import com.ruoyi.common.core.domain.entity.MusicInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -68,4 +69,16 @@ public interface MusicInfoMapper
List<MusicInfo> selectMusicInfoByIds(List<Long> musicIdList);
List<MusicInfo> selectRecommendMusic();
List<MusicInfo> selectMusicByCollectId(String collectId);
int insertLikeMusic(@Param("userId") Long userId,@Param("musicId") String musicId);
List<MusicInfo> selectLikeMusicByUser(Long userId);
int delLikeMusic(@Param("userId") Long userId,@Param("musicId") String musicId);
int insertHistory(@Param("userId") Long userId,@Param("musicId") String musicId);
List<MusicInfo> selectHistoryMusicByUser(Long userId);
}

View File

@@ -0,0 +1,64 @@
package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.ShareInfo;
import java.util.List;
/**
* 【请填写功能名称】Mapper接口
*
* @author ruoyi
* @date 2025-07-19
*/
public interface ShareInfoMapper
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public ShareInfo selectShareInfoById(String id);
/**
* 查询【请填写功能名称】列表
*
* @param shareInfo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<ShareInfo> selectShareInfoList(ShareInfo shareInfo);
public List<ShareInfo> selectShareInfoListPage(ShareInfo shareInfo);
/**
* 新增【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
public int insertShareInfo(ShareInfo shareInfo);
/**
* 修改【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
public int updateShareInfo(ShareInfo shareInfo);
/**
* 删除【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deleteShareInfoById(String id);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteShareInfoByIds(String[] ids);
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.UserHistory;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -59,4 +60,6 @@ public interface UserHistoryMapper
* @return 结果
*/
public int deleteUserHistoryByIds(String[] ids);
int deleteUserHistoryByMusicId(@Param("musicIds") String[] musicIds,@Param("userId") Long userId);
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.MusicCollect;
import java.util.List;
/**
* 【请填写功能名称】Service接口
*
* @author ruoyi
* @date 2025-07-18
*/
public interface IMusicCollectService
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public MusicCollect selectMusicCollectById(String id);
/**
* 查询【请填写功能名称】列表
*
* @param musicCollect 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<MusicCollect> selectMusicCollectList(MusicCollect musicCollect);
/**
* 新增【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
public int insertMusicCollect(MusicCollect musicCollect);
/**
* 修改【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
public int updateMusicCollect(MusicCollect musicCollect);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键集合
* @return 结果
*/
public int deleteMusicCollectByIds(String[] ids);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deleteMusicCollectById(String id);
}

View File

@@ -65,4 +65,16 @@ public interface IMusicInfoService
List<MusicInfo> findMusicByCate(CategoryInfo categoryInfo);
List<MusicInfo> selectMusicInfoByCid(String categoryId);
List<MusicInfo> findMusicByCollectId(String collectId);
int addLikeMusic(String musicId);
List<MusicInfo> findLikeMusicByUser(Long userId);
int cancelLikeMusic(String musicId);
int addHistoryMusic(String musicId);
List<MusicInfo> findHistoryMusicByUser(Long userId);
}

View File

@@ -0,0 +1,64 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.ShareInfo;
import java.util.List;
/**
* 【请填写功能名称】Service接口
*
* @author ruoyi
* @date 2025-07-19
*/
public interface IShareInfoService
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public ShareInfo selectShareInfoById(String id);
/**
* 查询【请填写功能名称】列表
*
* @param shareInfo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<ShareInfo> selectShareInfoList(ShareInfo shareInfo);
/**
* 新增【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
public int insertShareInfo(ShareInfo shareInfo);
/**
* 修改【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
public int updateShareInfo(ShareInfo shareInfo);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键集合
* @return 结果
*/
public int deleteShareInfoByIds(String[] ids);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deleteShareInfoById(String id);
List<ShareInfo> findShareInfoListPage(ShareInfo shareInfo);
}

View File

@@ -1,5 +1,6 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.MusicCollect;
import com.ruoyi.common.core.domain.entity.UserCollect;
import java.util.List;
@@ -59,4 +60,6 @@ public interface IUserCollectService
* @return 结果
*/
public int deleteUserCollectById(Long id);
int cancelBindMusic(MusicCollect musicCollect);
}

View File

@@ -59,4 +59,8 @@ public interface IUserHistoryService
* @return 结果
*/
public int deleteUserHistoryById(String id);
int insertHistory(Long userId, String musicId);
int deleteUserHistoryByMusicId(String[] musicId);
}

View File

@@ -39,7 +39,7 @@ public class CShopUserServiceImpl implements ShopUserService {
}
case "2":
// 验证码
String code = redisCache.getCacheObject(shopUser.getPhone());
String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
String reqCode = shopUser.getCode();
if (code.equals(reqCode)){
// 登录
@@ -68,6 +68,9 @@ public class CShopUserServiceImpl implements ShopUserService {
member.setPhone(shopUser.getPhone());
member.setPassword(IdUtil.fastUUID());
member.setUsername(shopUser.getUsername());
member.setDeviceId(shopUser.getDeviceId());
member.setDeviceType(shopUser.getDeviceType());
member.setHeadImg("/file/download/user/head.jpg");
int insertCount = shopUserMapper.insert(member);
if (insertCount > 0){
return member;

View File

@@ -0,0 +1,94 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.MusicCollect;
import com.ruoyi.system.mapper.MusicCollectMapper;
import com.ruoyi.system.service.IMusicCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 【请填写功能名称】Service业务层处理
*
* @author ruoyi
* @date 2025-07-18
*/
@Service
public class MusicCollectServiceImpl implements IMusicCollectService
{
@Autowired
private MusicCollectMapper musicCollectMapper;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
@Override
public MusicCollect selectMusicCollectById(String id)
{
return musicCollectMapper.selectMusicCollectById(id);
}
/**
* 查询【请填写功能名称】列表
*
* @param musicCollect 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<MusicCollect> selectMusicCollectList(MusicCollect musicCollect)
{
return musicCollectMapper.selectMusicCollectList(musicCollect);
}
/**
* 新增【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
@Override
public int insertMusicCollect(MusicCollect musicCollect)
{
return musicCollectMapper.insertMusicCollect(musicCollect);
}
/**
* 修改【请填写功能名称】
*
* @param musicCollect 【请填写功能名称】
* @return 结果
*/
@Override
public int updateMusicCollect(MusicCollect musicCollect)
{
return musicCollectMapper.updateMusicCollect(musicCollect);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键
* @return 结果
*/
@Override
public int deleteMusicCollectByIds(String[] ids)
{
return musicCollectMapper.deleteMusicCollectByIds(ids);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
@Override
public int deleteMusicCollectById(String id)
{
return musicCollectMapper.deleteMusicCollectById(id);
}
}

View File

@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.config.AliConfig;
import com.ruoyi.system.mapper.MusicInfoMapper;
import com.ruoyi.system.service.IMusicInfoService;
import com.ruoyi.system.service.IUserHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -29,6 +30,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
@Autowired
private MusicInfoMapper musicInfoMapper;
/**
* 查询音乐信息
*
@@ -126,5 +128,36 @@ public class MusicInfoServiceImpl implements IMusicInfoService
return musicInfoMapper.selectMusicInfoByCid(categoryId);
}
@Override
public List<MusicInfo> findMusicByCollectId(String collectId) {
return musicInfoMapper.selectMusicByCollectId(collectId);
}
@Override
public int addLikeMusic(String musicId) {
Long userId = SecurityUtils.getUserId();
return musicInfoMapper.insertLikeMusic(userId,musicId);
}
@Override
public List<MusicInfo> findLikeMusicByUser(Long userId) {
return musicInfoMapper.selectLikeMusicByUser(userId);
}
@Override
public int cancelLikeMusic(String musicId) {
Long userId = SecurityUtils.getUserId();
return musicInfoMapper.delLikeMusic(userId,musicId);
}
@Override
public int addHistoryMusic(String musicId) {
Long userId = SecurityUtils.getUserId();
return musicInfoMapper.insertHistory(userId,musicId);
}
@Override
public List<MusicInfo> findHistoryMusicByUser(Long userId) {
return musicInfoMapper.selectHistoryMusicByUser(userId);
}
}

View File

@@ -0,0 +1,102 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.ShareInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.ShareInfoMapper;
import com.ruoyi.system.service.IShareInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 【请填写功能名称】Service业务层处理
*
* @author ruoyi
* @date 2025-07-19
*/
@Service
public class ShareInfoServiceImpl implements IShareInfoService
{
@Autowired
private ShareInfoMapper shareInfoMapper;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
@Override
public ShareInfo selectShareInfoById(String id)
{
return shareInfoMapper.selectShareInfoById(id);
}
/**
* 查询【请填写功能名称】列表
*
* @param shareInfo 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<ShareInfo> selectShareInfoList(ShareInfo shareInfo)
{
return shareInfoMapper.selectShareInfoList(shareInfo);
}
/**
* 新增【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
@Override
public int insertShareInfo(ShareInfo shareInfo)
{
shareInfo.setCreateTime(DateUtils.getNowDate());
return shareInfoMapper.insertShareInfo(shareInfo);
}
/**
* 修改【请填写功能名称】
*
* @param shareInfo 【请填写功能名称】
* @return 结果
*/
@Override
public int updateShareInfo(ShareInfo shareInfo)
{
shareInfo.setUpdateTime(DateUtils.getNowDate());
return shareInfoMapper.updateShareInfo(shareInfo);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键
* @return 结果
*/
@Override
public int deleteShareInfoByIds(String[] ids)
{
return shareInfoMapper.deleteShareInfoByIds(ids);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
@Override
public int deleteShareInfoById(String id)
{
return shareInfoMapper.deleteShareInfoById(id);
}
@Override
public List<ShareInfo> findShareInfoListPage(ShareInfo shareInfo) {
return shareInfoMapper.selectShareInfoListPage(shareInfo);
}
}

View File

@@ -1,7 +1,11 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.domain.entity.MusicCollect;
import com.ruoyi.common.core.domain.entity.UserCollect;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.MusicCollectMapper;
import com.ruoyi.system.mapper.UserCollectMapper;
import com.ruoyi.system.service.IUserCollectService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +24,8 @@ public class UserCollectServiceImpl implements IUserCollectService
{
@Autowired
private UserCollectMapper userCollectMapper;
@Autowired
private MusicCollectMapper musicCollectMapper;
/**
* 查询用户收藏音乐
@@ -54,6 +60,9 @@ public class UserCollectServiceImpl implements IUserCollectService
@Override
public int insertUserCollect(UserCollect userCollect)
{
Long userId = SecurityUtils.getUserId();
userCollect.setCollectId(IdUtil.getSnowflakeNextId());
userCollect.setUserId(userId);
userCollect.setCreateTime(DateUtils.getNowDate());
return userCollectMapper.insertUserCollect(userCollect);
}
@@ -94,4 +103,9 @@ public class UserCollectServiceImpl implements IUserCollectService
{
return userCollectMapper.deleteUserCollectById(id);
}
@Override
public int cancelBindMusic(MusicCollect musicCollect) {
return musicCollectMapper.delBindMusic(musicCollect);
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.UserHistory;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.UserHistoryMapper;
import com.ruoyi.system.service.IUserHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -91,4 +92,15 @@ public class UserHistoryServiceImpl implements IUserHistoryService
{
return userHistoryMapper.deleteUserHistoryById(id);
}
@Override
public int insertHistory(Long userId, String musicId) {
return 0;
}
@Override
public int deleteUserHistoryByMusicId(String[] musicIds) {
Long userId = SecurityUtils.getUserId();
return userHistoryMapper.deleteUserHistoryByMusicId(musicIds,userId);
}
}

View File

@@ -0,0 +1,65 @@
<?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.MusicCollectMapper">
<resultMap type="MusicCollect" id="MusicCollectResult">
<result property="id" column="id" />
<result property="musicId" column="music_id" />
<result property="collectId" column="collect_id" />
</resultMap>
<sql id="selectMusicCollectVo">
select id, music_id, collect_id from music_collect
</sql>
<select id="selectMusicCollectList" parameterType="MusicCollect" resultMap="MusicCollectResult">
<include refid="selectMusicCollectVo"/>
<where>
<if test="musicId != null "> and music_id = #{musicId}</if>
<if test="collectId != null "> and collect_id = #{collectId}</if>
</where>
</select>
<select id="selectMusicCollectById" parameterType="String" resultMap="MusicCollectResult">
<include refid="selectMusicCollectVo"/>
where id = #{id}
</select>
<insert id="insertMusicCollect" parameterType="MusicCollect" useGeneratedKeys="true" keyProperty="id">
insert into music_collect
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="musicId != null">music_id,</if>
<if test="collectId != null">collect_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="musicId != null">#{musicId},</if>
<if test="collectId != null">#{collectId},</if>
</trim>
</insert>
<update id="updateMusicCollect" parameterType="MusicCollect">
update music_collect
<trim prefix="SET" suffixOverrides=",">
<if test="musicId != null">music_id = #{musicId},</if>
<if test="collectId != null">collect_id = #{collectId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMusicCollectById" parameterType="String">
delete from music_collect where id = #{id}
</delete>
<delete id="deleteMusicCollectByIds" parameterType="String">
delete from music_collect where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="delBindMusic">
delete from music_collect where music_id= #{musicId} and collect_id=#{collectId}
</delete>
</mapper>

View File

@@ -135,4 +135,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRecommendMusic" resultMap="MusicInfoResult">
SELECT mi.* FROM music_recommend mr LEFT JOIN music_info mi on mr.music_id = mi.music_id and mi.is_del=0
</select>
<select id="selectMusicByCollectId" resultMap="MusicInfoResult">
SELECT * FROM music_collect mc left join music_info mi on mi.music_id=mc.music_id WHERE mi.is_del=0 and mc.collect_id =#{collectId}
</select>
<insert id="insertLikeMusic">
INSERT INTO user_like_music(music_id, user_id) values (#{musicId},#{userId})
</insert>
<select id="selectLikeMusicByUser" resultMap="MusicInfoResult">
SELECT * FROM user_like_music ulm LEFT JOIN music_info mi on ulm.music_id=mi.music_id WHERE ulm.user_id=#{userId} and mi.is_del=0
</select>
<delete id="delLikeMusic">
DELETE FROM user_like_music where music_id=#{musicId} and user_id=#{userId}
</delete>
<insert id="insertHistory">
INSERT INTO user_history(user_id, music_id) value (#{userId},#{musicId})
</insert>
<select id="selectHistoryMusicByUser" resultMap="MusicInfoResult">
SELECT * FROM user_history ulm LEFT JOIN music_info mi on ulm.music_id=mi.music_id WHERE ulm.user_id=#{userId} and mi.is_del=0
</select>
</mapper>

View File

@@ -0,0 +1,110 @@
<?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.ShareInfoMapper">
<resultMap type="ShareInfo" id="ShareInfoResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="shareDecs" column="share_decs" />
<result property="musicId" column="music_id" />
<result property="shareAddr" column="share_addr" />
<result property="sharePlat" column="share_plat" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="review" column="review" />
</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
</sql>
<select id="selectShareInfoList" parameterType="ShareInfo" resultMap="ShareInfoResult">
<include refid="selectShareInfoVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="shareDecs != null and shareDecs != ''"> and share_decs = #{shareDecs}</if>
<if test="musicId != null "> and music_id = #{musicId}</if>
<if test="shareAddr != null and shareAddr != ''"> and share_addr = #{shareAddr}</if>
<if test="sharePlat != null and sharePlat != ''"> and share_plat = #{sharePlat}</if>
<if test="isDel != null "> and is_del = #{isDel}</if>
<if test="review != null "> and review = #{review}</if>
</where>
</select>
<select id="selectShareInfoById" parameterType="String" resultMap="ShareInfoResult">
<include refid="selectShareInfoVo"/>
where id = #{id}
</select>
<insert id="insertShareInfo" parameterType="ShareInfo" useGeneratedKeys="true" keyProperty="id">
insert into share_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="shareDecs != null">share_decs,</if>
<if test="musicId != null">music_id,</if>
<if test="shareAddr != null">share_addr,</if>
<if test="sharePlat != null">share_plat,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="review != null">review,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="shareDecs != null">#{shareDecs},</if>
<if test="musicId != null">#{musicId},</if>
<if test="shareAddr != null">#{shareAddr},</if>
<if test="sharePlat != null">#{sharePlat},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="review != null">#{review},</if>
</trim>
</insert>
<update id="updateShareInfo" parameterType="ShareInfo">
update share_info
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="shareDecs != null">share_decs = #{shareDecs},</if>
<if test="musicId != null">music_id = #{musicId},</if>
<if test="shareAddr != null">share_addr = #{shareAddr},</if>
<if test="sharePlat != null">share_plat = #{sharePlat},</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>
<if test="review != null">review = #{review},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteShareInfoById" parameterType="String">
delete from share_info where id = #{id}
</delete>
<delete id="deleteShareInfoByIds" parameterType="String">
delete from share_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectShareInfoListPage" resultType="com.ruoyi.common.core.domain.entity.ShareInfo">
SELECT
su.username as username,
su.nickname as nickname,
su.head_img as headImg,
si.share_decs as shareDecs,
mi.name as `musicName`,
mi.img_addr as musicImgAddr,
mi.music_addr as musicAddr,
mi.author as musicAuthor
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
WHERE mi.is_del=0
</select>
</mapper>

View File

@@ -2,17 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.system.mapper.ShopUserMapper">
<select id="selectShopUserByPhone" resultType="com.ruoyi.common.core.domain.entity.ShopUser">
SELECT * FROM shop_user where phone = #{phone}
</select>
<select id="selectShopUserByUsername" resultType="com.ruoyi.common.core.domain.entity.ShopUser">
SELECT * FROM shop_user where username = #{username}
</select>
<select id="selectShopUserByUsernameAndPass" resultType="com.ruoyi.common.core.domain.entity.ShopUser">
SELECT * FROM shop_user where username = #{username} and password = #{password}
</select>
<!-- Insert -->
<insert id="insert" parameterType="com.ruoyi.common.core.domain.entity.ShopUser" useGeneratedKeys="true" keyProperty="id">
@@ -30,6 +19,9 @@
<if test="status != null">status,</if>
<if test="vip != null">vip,</if>
<if test="online != null">online,</if>
<if test="deviceId != null">device_id,</if>
<if test="deviceType != null">device_type,</if>
<if test="headImg != null">head_img,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
@@ -44,6 +36,9 @@
<if test="status != null">#{status},</if>
<if test="vip != null">#{vip},</if>
<if test="online != null">#{online},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="headImg != null">#{headImg},</if>
</trim>
</insert>
@@ -61,13 +56,16 @@
<result property="status" column="status" />
<result property="vip" column="vip" />
<result property="online" column="online" />
<result property="deviceId" column="device_id" />
<result property="deviceType" column="device_type" />
<result property="headImg" column="head_img" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
</resultMap>
<sql id="selectShopUserVo">
select id, user_id, username, password, phone, nickname, sex, birthday, addr, register_time, status, vip, online, create_time, update_time, is_del from shop_user
select id, user_id, username, password,device_type,device_id, phone, nickname, sex, birthday, addr, register_time, status, vip, online, create_time, update_time, is_del,head_img from shop_user
</sql>
<select id="selectShopUserList" parameterType="ShopUser" resultMap="ShopUserResult">
@@ -89,6 +87,20 @@
</where>
</select>
<select id="selectShopUserByPhone" resultMap="ShopUserResult">
SELECT * FROM shop_user where phone = #{phone}
</select>
<select id="selectShopUserByUsername" resultMap="ShopUserResult">
SELECT * FROM shop_user where username = #{username}
</select>
<select id="selectShopUserByUsernameAndPass" resultMap="ShopUserResult">
SELECT * FROM shop_user where username = #{username} and password = #{password}
</select>
<select id="selectShopUserById" parameterType="String" resultMap="ShopUserResult">
<include refid="selectShopUserVo"/>
where id = #{id}

View File

@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="UserCollect" id="UserCollectResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="musicId" column="music_id" />
<result property="collectId" column="collect_id" />
<result property="collectName" column="collect_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
@@ -15,14 +15,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserCollectVo">
select id, user_id, music_id, collect_name, create_time, update_time, collect_type from user_collect
select id, user_id, collect_id, collect_name, create_time, update_time, collect_type from user_collect
</sql>
<select id="selectUserCollectList" parameterType="UserCollect" resultMap="UserCollectResult">
<include refid="selectUserCollectVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="musicId != null "> and music_id = #{musicId}</if>
<if test="collectId != null "> and collect_id = #{collectId}</if>
<if test="collectName != null and collectName != ''"> and collect_name like concat('%', #{collectName}, '%')</if>
<if test="collectType != null and collectType != ''"> and collect_type = #{collectType}</if>
</where>
@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="userId != null">user_id,</if>
<if test="musicId != null">music_id,</if>
<if test="collectId != null">collect_id,</if>
<if test="collectName != null">collect_name,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
@@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="userId != null">#{userId},</if>
<if test="musicId != null">#{musicId},</if>
<if test="collectId != null">#{collectId},</if>
<if test="collectName != null">#{collectName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update user_collect
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="musicId != null">music_id = #{musicId},</if>
<if test="collectId != null">collect_id = #{collectId},</if>
<if test="collectName != null">collect_name = #{collectName},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>

View File

@@ -58,4 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<delete id="deleteUserHistoryByMusicId">
delete from user_history where user_history.music_id in
<foreach item="id" collection="musicIds" open="(" separator="," close=")">
#{id}
</foreach>
and user_id=#{userId}
</delete>
</mapper>