登陆放开
This commit is contained in:
@@ -44,36 +44,39 @@ public class FileController extends BaseController {
|
||||
// 获取文件字节
|
||||
if (objectName.equals("musicFile")) {
|
||||
LoginUser userInfo = SecurityUtils.getLoginUser();
|
||||
if (userInfo == null){
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
return;
|
||||
}
|
||||
SysUser sysUser = userInfo.getUser();
|
||||
if (sysUser == null) {
|
||||
// if (userInfo == null){
|
||||
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
// response.setContentType("application/json;charset=UTF-8");
|
||||
// response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
// return;
|
||||
// }
|
||||
// SysUser sysUser = userInfo.getUser();
|
||||
//if (sysUser == null) {
|
||||
// if (StrUtil.isBlank(musicId)) {
|
||||
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
// response.setContentType("application/json;charset=UTF-8");
|
||||
// response.getWriter().write("{\"code\":400,\"msg\":\"音乐ID不能为空\"}");
|
||||
// return;
|
||||
// }
|
||||
ShopUser shopUser = userInfo.getShopUser();
|
||||
if (shopUser == null) {
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
return;
|
||||
}else{
|
||||
// 检查会员时间
|
||||
if (!MusicUtil.getShopIsVip(shopUser)) {
|
||||
if (shopUser.getVip() == 1){
|
||||
// 会员已过期修改为非会员
|
||||
shopUser.setVip(2L);
|
||||
shopUserMapper.updateShopUser(shopUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
//MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
|
||||
|
||||
//ShopUser shopUser = userInfo.getShopUser();
|
||||
// if (shopUser == null) {
|
||||
// response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// response.setContentType("application/json;charset=UTF-8");
|
||||
// response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
// return;
|
||||
// }else{
|
||||
// // 检查会员时间
|
||||
// if (!MusicUtil.getShopIsVip(shopUser)) {
|
||||
// if (shopUser.getVip() == 1){
|
||||
// // 会员已过期修改为非会员
|
||||
// shopUser.setVip(2L);
|
||||
// shopUserMapper.updateShopUser(shopUser);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//shopUser = shopUserMapper.selectShopUserByUserId(userId);
|
||||
// MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
//
|
||||
@@ -93,7 +96,7 @@ public class FileController extends BaseController {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// 设置响应头
|
||||
|
||||
@@ -114,9 +114,7 @@ public class MusicController extends BaseController {
|
||||
@RequestMapping("/getMusicInfo/{musicId}")
|
||||
public AjaxResult getMusicInfo(@PathVariable String musicId){
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
if (userId == null){
|
||||
return AjaxResult.error(401,"用户未登录或用户ID为空");
|
||||
}
|
||||
if (userId != null){
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(userId, musicId);
|
||||
if (musicInfo != null){
|
||||
// 增加历史
|
||||
@@ -125,6 +123,11 @@ public class MusicController extends BaseController {
|
||||
}else {
|
||||
return new AjaxResult(HttpStatus.USER_VIP_EXPIRE, "请开通会员");
|
||||
}
|
||||
}else {
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(null, musicId);
|
||||
return AjaxResult.success(musicInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 新增用户混音
|
||||
|
||||
@@ -145,7 +145,8 @@ public class SecurityConfig
|
||||
"/client/index/getCategory","/client/index/re/bind/music","/client/index/re/music",
|
||||
"/client/version/getLastVersion","/client/search/list","/client/music/find","/client" +
|
||||
"/index/getCategory","/client/index/cate/music/**","/client/consult/list",
|
||||
"/client/index/re/music/**","/client/share/list").permitAll()
|
||||
"/client/index/re/music/**","/client/share/list","/file/download/**",
|
||||
"/client/music/getMusicInfo/**","/client/music/getPrevMusicId","/client/music/getNextMusicId").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.stream.Collectors;
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Service
|
||||
public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
{
|
||||
public class MusicInfoServiceImpl implements IMusicInfoService {
|
||||
@Autowired
|
||||
private MusicInfoMapper musicInfoMapper;
|
||||
@Autowired
|
||||
@@ -38,8 +37,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询音乐信息
|
||||
*
|
||||
@@ -47,8 +44,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 音乐信息
|
||||
*/
|
||||
@Override
|
||||
public MusicInfo selectMusicInfoById(String id)
|
||||
{
|
||||
public MusicInfo selectMusicInfoById(String id) {
|
||||
return musicInfoMapper.selectMusicInfoById(id);
|
||||
}
|
||||
|
||||
@@ -59,8 +55,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 音乐信息
|
||||
*/
|
||||
@Override
|
||||
public List<MusicInfo> selectMusicInfoList(MusicInfo musicInfo)
|
||||
{
|
||||
public List<MusicInfo> selectMusicInfoList(MusicInfo musicInfo) {
|
||||
return musicInfoMapper.selectMusicInfoList(musicInfo);
|
||||
}
|
||||
|
||||
@@ -71,8 +66,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMusicInfo(MusicInfo musicInfo)
|
||||
{
|
||||
public int insertMusicInfo(MusicInfo musicInfo) {
|
||||
|
||||
musicInfo.setCreateTime(DateUtils.getNowDate());
|
||||
musicInfo.setMusicId(IdUtil.getSnowflakeNextId());
|
||||
@@ -89,8 +83,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMusicInfo(MusicInfo musicInfo)
|
||||
{
|
||||
public int updateMusicInfo(MusicInfo musicInfo) {
|
||||
musicInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return musicInfoMapper.updateMusicInfo(musicInfo);
|
||||
}
|
||||
@@ -102,8 +95,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicInfoByIds(String[] ids)
|
||||
{
|
||||
public int deleteMusicInfoByIds(String[] ids) {
|
||||
return musicInfoMapper.deleteMusicInfoByIds(ids);
|
||||
}
|
||||
|
||||
@@ -114,8 +106,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicInfoById(String id)
|
||||
{
|
||||
public int deleteMusicInfoById(String id) {
|
||||
return musicInfoMapper.deleteMusicInfoById(id);
|
||||
}
|
||||
|
||||
@@ -180,7 +171,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (userId != null) {
|
||||
// 查询是否是用户喜欢
|
||||
UserLikeMusic userLikeMusic = userLikeMusicMapper.selectUserLikeMusicAndUserId(userId, musicId);
|
||||
if (userLikeMusic != null) {
|
||||
@@ -192,6 +183,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
musicInfo.setCollect(true);
|
||||
musicInfo.setUserCollect(userCollect);
|
||||
}
|
||||
}
|
||||
// 判断是否是是混音
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())) {
|
||||
// 查询混音相关信息
|
||||
@@ -284,7 +276,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
public String getPrevMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId, String reId, String currentMusicId) {
|
||||
List<MusicInfo> musicList = null;
|
||||
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
if (userId != null) {
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
@@ -315,13 +307,16 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
}
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
|
||||
// 如果列表为空,返回null
|
||||
if (musicList == null || musicList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// 根据播放模式获取上一首音乐ID
|
||||
if (playMode == 1) { // 顺序播放
|
||||
// 按照ID排序列表
|
||||
@@ -331,8 +326,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
return idA.compareTo(idB);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 如果没有当前音乐ID,返回列表中的最后一首
|
||||
if (currentMusicId == null || currentMusicId.isEmpty()) {
|
||||
return musicList.get(musicList.size() - 1).getMusicId().toString();
|
||||
@@ -381,6 +374,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
public String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId, String reId, String currentMusicId) {
|
||||
List<MusicInfo> musicList = null;
|
||||
|
||||
if (userId != null) {
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
@@ -412,6 +406,9 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
}
|
||||
|
||||
// 如果列表为空,返回null
|
||||
if (musicList == null || musicList.isEmpty()) {
|
||||
@@ -468,7 +465,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询喜欢的音乐数量
|
||||
*
|
||||
@@ -500,7 +496,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public List<MusicInfo> findLikeSearch(String search) {
|
||||
|
||||
|
||||
// 根据作者名称或音乐名称模糊搜索音乐
|
||||
List<MusicInfo> musicList = musicInfoMapper.selectMusicInfoBySearch(search);
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
orderInfo.setOrderName(request.getOrderName());
|
||||
orderInfo.setUserId(loginUser.getUserId());
|
||||
Product product = productMapper.selectProductByPageType(request.getPackageType());
|
||||
orderInfo.setAmount(new BigDecimal("0.01"));
|
||||
|
||||
orderInfo.setAmount(product.getCurrentPrice());
|
||||
orderInfo.setPayType(request.getPayType());
|
||||
orderInfo.setPackageType(request.getPackageType());
|
||||
orderInfo.setDeviceType(request.getDeviceType());
|
||||
|
||||
Reference in New Issue
Block a user