完善功能
This commit is contained in:
@@ -8,12 +8,10 @@ import com.ruoyi.common.core.domain.entity.BannerInfo;
|
|||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.config.AliConfig;
|
|
||||||
import com.ruoyi.system.service.IBannerInfoService;
|
import com.ruoyi.system.service.IBannerInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -66,24 +64,9 @@ public class BackIndexController extends BaseController {
|
|||||||
//@PreAuthorize("@ss.hasPermi('system:info:add')")
|
//@PreAuthorize("@ss.hasPermi('system:info:add')")
|
||||||
//@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
//@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public AjaxResult add(
|
public AjaxResult add(@RequestBody BannerInfo bannerInfo) {
|
||||||
@RequestParam("name") String name,
|
|
||||||
@RequestParam("sort") int sort,
|
|
||||||
@RequestParam("jumpUrl") String jumpUrl,
|
|
||||||
@RequestParam("file") MultipartFile file
|
|
||||||
) {
|
|
||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
return toAjax(bannerInfoService.insertBannerInfo(bannerInfo));
|
||||||
// 保存文件逻辑
|
|
||||||
// String url = fileService.save(file);
|
|
||||||
// bannerInfo.setImageUrl(url);
|
|
||||||
}
|
|
||||||
// 2. 保存bannerInfo
|
|
||||||
BannerInfo bannerInfo = new BannerInfo();
|
|
||||||
bannerInfo.setSort(sort);
|
|
||||||
bannerInfo.setJumpUrl(jumpUrl);
|
|
||||||
bannerInfo.setName(name);
|
|
||||||
return toAjax(bannerInfoService.insertBannerInfo(bannerInfo,file));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -84,12 +84,11 @@ public class CategoryInfoController extends BaseController
|
|||||||
// @PreAuthorize("@ss.hasPermi('system:info:add')")
|
// @PreAuthorize("@ss.hasPermi('system:info:add')")
|
||||||
// @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
// @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestParam("file") MultipartFile file,
|
public AjaxResult add(@RequestBody CategoryInfo categoryInfo) throws IOException {
|
||||||
@RequestParam("name") String name) throws IOException {
|
// String imgAddr = AliConfig.ossUp("config/", file.getOriginalFilename(), file.getInputStream());
|
||||||
String imgAddr = AliConfig.ossUp("config/", file.getOriginalFilename(), file.getInputStream());
|
// CategoryInfo categoryInfo = new CategoryInfo();
|
||||||
CategoryInfo categoryInfo = new CategoryInfo();
|
// categoryInfo.setBackImg(imgAddr);
|
||||||
categoryInfo.setBackImg(imgAddr);
|
// categoryInfo.setName(name);
|
||||||
categoryInfo.setName(name);
|
|
||||||
return toAjax(categoryInfoService.insertCategoryInfo(categoryInfo));
|
return toAjax(categoryInfoService.insertCategoryInfo(categoryInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,103 @@
|
|||||||
package com.ruoyi.web.controller.back;
|
package com.ruoyi.web.controller.back;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
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.common.core.domain.entity.MusicInfo;
|
||||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.utils.MusicUtil;
|
import com.ruoyi.common.utils.MusicUtil;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.config.AliConfig;
|
import com.ruoyi.system.config.AliConfig;
|
||||||
import com.ruoyi.system.mapper.MusicInfoMapper;
|
import com.ruoyi.system.mapper.MusicInfoMapper;
|
||||||
import com.ruoyi.system.mapper.ShopUserMapper;
|
import com.ruoyi.system.mapper.ShopUserMapper;
|
||||||
import com.ruoyi.system.service.ShopUserService;
|
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@RequestMapping("/file")
|
@RequestMapping("/file")
|
||||||
@RestController
|
@RestController
|
||||||
public class FileController {
|
public class FileController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopUserMapper shopUserMapper;
|
private ShopUserMapper shopUserMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private SysUserPostMapper sysUserPostMapper;
|
||||||
|
@Autowired
|
||||||
private MusicInfoMapper musicInfoMapper;
|
private MusicInfoMapper musicInfoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载OSS文件
|
* 下载OSS文件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/download/{objectName}")
|
@GetMapping("/download/{objectName}/{fileName}")
|
||||||
public void downloadOssFile(@PathVariable String objectName, HttpServletResponse response) {
|
public void downloadOssFile(@RequestParam(value = "musicId",required = false) String musicId, @PathVariable("objectName") String objectName, @PathVariable("fileName") String fileName, HttpServletResponse response) {
|
||||||
try {
|
try {
|
||||||
String ossPath = objectName.split("file/download")[1];
|
String ossPath = objectName + "/" + fileName;
|
||||||
|
// 检查用户登录状态
|
||||||
|
|
||||||
// 获取文件字节
|
// 获取文件字节
|
||||||
if (objectName.equals("musicFile")) {
|
if (objectName.equals("musicFile")) {
|
||||||
//TODO:// 获取是否是vip 音乐,检查用户登录状态
|
LoginUser userInfo = SecurityUtils.getLoginUser();
|
||||||
Long userId = SecurityUtils.getUserId();
|
SysUser sysUser = userInfo.getUser();
|
||||||
ShopUser shopUser = shopUserMapper.selectShopUserByUserId(userId);
|
if (sysUser == null) {
|
||||||
MusicInfo musicInfo = musicInfoMapper.selectByPath(objectName);
|
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;
|
||||||
|
}
|
||||||
|
//shopUser = shopUserMapper.selectShopUserByUserId(userId);
|
||||||
|
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||||
|
|
||||||
|
if (musicInfo == null) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
|
response.getWriter().write("{\"code\":404,\"msg\":\"音乐信息不存在\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (musicInfo.getVip() != null && musicInfo.getVip() == 1) {
|
if (musicInfo.getVip() != null && musicInfo.getVip() == 1) {
|
||||||
// 判断用户vip
|
// 判断用户vip
|
||||||
if (!MusicUtil.getShopIsVip(shopUser)) {
|
if (!MusicUtil.getShopIsVip(shopUser)) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||||
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
|
response.getWriter().write("{\"code\":403,\"msg\":\"该音乐为VIP专享,请升级VIP后下载\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileName = ossPath.substring(objectName.lastIndexOf("/") + 1);
|
}
|
||||||
|
|
||||||
byte[] data = AliConfig.ossDown(ossPath);
|
byte[] data = AliConfig.ossDown(ossPath);
|
||||||
|
if (data == null || data.length == 0) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
|
response.getWriter().write("{\"code\":404,\"msg\":\"文件不存在或下载失败\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置响应头,支持中文文件名
|
// 设置响应头,支持中文文件名
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
|
||||||
assert data != null;
|
|
||||||
response.getOutputStream().write(data);
|
response.getOutputStream().write(data);
|
||||||
response.getOutputStream().flush();
|
response.getOutputStream().flush();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
|
e.printStackTrace();
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
response.setContentType("application/json;charset=UTF-8");
|
response.setContentType("application/json;charset=UTF-8");
|
||||||
response.getWriter().write("{\"msg\":\"下载失败: " + e.getMessage() + "\"}");
|
response.getWriter().write("{\"code\":500,\"msg\":\"下载失败: " + e.getMessage() + "\"}");
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log;
|
|||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||||
|
import com.ruoyi.common.core.domain.entity.MusicMaxReq;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicScene;
|
import com.ruoyi.common.core.domain.entity.MusicScene;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicSceneRelate;
|
import com.ruoyi.common.core.domain.entity.MusicSceneRelate;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
@@ -151,11 +152,21 @@ public class MusicInfoController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/add/mixMusic")
|
@RequestMapping("/add/mixMusic")
|
||||||
public AjaxResult addMixMusicInfo(@RequestBody Map<String,String> param){
|
public AjaxResult addMixMusicInfo(@RequestBody MusicMaxReq param){
|
||||||
MusicInfo newMusic = musicInfoService.addMixMusicInfo(param);
|
MusicInfo newMusic = musicInfoService.addMixMusicInfo(param);
|
||||||
if (newMusic != null){
|
if (newMusic != null){
|
||||||
return AjaxResult.success(newMusic);
|
return AjaxResult.success(newMusic);
|
||||||
}
|
}
|
||||||
return AjaxResult.error("混音错误");
|
return AjaxResult.error("混音错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 编辑混音歌曲
|
||||||
|
@RequestMapping("/edit/mixMusic")
|
||||||
|
public AjaxResult editMixMusicInfo(@RequestBody MusicMaxReq param){
|
||||||
|
MusicInfo newMusic = musicInfoService.editMixMusicInfo(param);
|
||||||
|
if (newMusic != null){
|
||||||
|
return AjaxResult.success(newMusic);
|
||||||
|
}
|
||||||
|
return AjaxResult.error("混音错误");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package com.ruoyi.web.controller.back;
|
|||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||||
import com.ruoyi.common.core.domain.entity.RecommendInfo;
|
import com.ruoyi.common.core.domain.entity.RecommendInfo;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.system.service.IMusicInfoService;
|
||||||
import com.ruoyi.system.service.IRecommendInfoService;
|
import com.ruoyi.system.service.IRecommendInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -27,6 +29,8 @@ public class RecommendInfoController extends BaseController
|
|||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRecommendInfoService recommendInfoService;
|
private IRecommendInfoService recommendInfoService;
|
||||||
|
@Autowired
|
||||||
|
private IMusicInfoService musicInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询推荐列表
|
* 查询推荐列表
|
||||||
@@ -105,4 +109,13 @@ public class RecommendInfoController extends BaseController
|
|||||||
}
|
}
|
||||||
return AjaxResult.error();
|
return AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据推荐获取分类音乐
|
||||||
|
@GetMapping("/music/{reId}")
|
||||||
|
public TableDataInfo geReIdMusic(@PathVariable String reId){
|
||||||
|
startPage();
|
||||||
|
List<MusicInfo> list = musicInfoService.selectMusicInfoByReId(reId);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public class UploadOSSController extends BaseController {
|
|||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
if (file != null && !file.isEmpty()) {
|
||||||
// 保存文件逻辑
|
// 保存文件逻辑
|
||||||
return AjaxResult.error("文件不能为空");
|
return AjaxResult.success("请求成功",AliConfig.ossUp("musicFile/", file.getOriginalFilename(), file.getInputStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success(AliConfig.ossUp("musicFile/" , file.getOriginalFilename(), file.getInputStream()));
|
return AjaxResult.error("文件不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,11 +38,11 @@ public class UploadOSSController extends BaseController {
|
|||||||
) throws IOException {
|
) throws IOException {
|
||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
if (file != null && !file.isEmpty()) {
|
||||||
|
return AjaxResult.success("请求成功",AliConfig.ossUp("musicImg/", file.getOriginalFilename(), file.getInputStream()));
|
||||||
|
}
|
||||||
// 保存文件逻辑
|
// 保存文件逻辑
|
||||||
return AjaxResult.error("文件不能为空");
|
return AjaxResult.error("文件不能为空");
|
||||||
}
|
}
|
||||||
return AjaxResult.success(AliConfig.ossUp("musicImg/" , file.getOriginalFilename(), file.getInputStream()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/config/file")
|
@PostMapping("/config/file")
|
||||||
public AjaxResult addConfigFile(
|
public AjaxResult addConfigFile(
|
||||||
@@ -51,9 +51,9 @@ public class UploadOSSController extends BaseController {
|
|||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
if (file != null && !file.isEmpty()) {
|
||||||
// 保存文件逻辑
|
// 保存文件逻辑
|
||||||
return AjaxResult.error("文件不能为空");
|
return AjaxResult.success("请求成功",AliConfig.ossUp("config/", file.getOriginalFilename(), file.getInputStream()));
|
||||||
}
|
}
|
||||||
return AjaxResult.success(AliConfig.ossUp("config/" , file.getOriginalFilename(), file.getInputStream()));
|
return AjaxResult.error("文件不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||||
|
import com.ruoyi.common.core.domain.entity.MusicMaxReq;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicScene;
|
import com.ruoyi.common.core.domain.entity.MusicScene;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
@@ -97,7 +98,7 @@ public class MusicController extends BaseController {
|
|||||||
|
|
||||||
// 新增用户混音
|
// 新增用户混音
|
||||||
@RequestMapping("/add/mixMusic")
|
@RequestMapping("/add/mixMusic")
|
||||||
public AjaxResult addMixMusicInfo(@RequestBody Map<String,String> param){
|
public AjaxResult addMixMusicInfo(@RequestBody MusicMaxReq param){
|
||||||
MusicInfo newMusic = musicService.addMixMusicInfo(param);
|
MusicInfo newMusic = musicService.addMixMusicInfo(param);
|
||||||
if (newMusic != null){
|
if (newMusic != null){
|
||||||
return AjaxResult.success(newMusic);
|
return AjaxResult.success(newMusic);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ruoyi:
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
server:
|
server:
|
||||||
# 服务器的HTTP端口,默认为8080
|
# 服务器的HTTP端口,默认为8080
|
||||||
port: 8080
|
port: 8081
|
||||||
servlet:
|
servlet:
|
||||||
# 应用的访问路径
|
# 应用的访问路径
|
||||||
context-path: /
|
context-path: /
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class MusicMaxReq extends MusicInfo{
|
||||||
|
|
||||||
|
private String sceneIds;
|
||||||
|
|
||||||
|
private String sceneJson;
|
||||||
|
|
||||||
|
private String sourceMusicId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -42,6 +42,9 @@ public class RecommendInfo extends BaseEntity
|
|||||||
@Excel(name = "描述")
|
@Excel(name = "描述")
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
private String backImg;
|
||||||
|
|
||||||
private List<MusicInfo> musics;
|
private List<MusicInfo> musics;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ public class LoginUser implements UserDetails
|
|||||||
|
|
||||||
public Long getUserId()
|
public Long getUserId()
|
||||||
{
|
{
|
||||||
if (userId != null){
|
if (user != null){
|
||||||
return userId;
|
return user.getUserId();
|
||||||
}else if(shopUser != null){
|
}else if(shopUser != null){
|
||||||
return shopUser.getUserId();
|
return shopUser.getUserId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class SecurityUtils
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class SecurityConfig
|
|||||||
/**
|
/**
|
||||||
* 身份验证实现
|
* 身份验证实现
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean("authenticationManager")
|
||||||
@Primary
|
@Primary
|
||||||
public AuthenticationManager authenticationManager()
|
public AuthenticationManager authenticationManager()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class SysLoginService
|
|||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@Qualifier("authenticationManager")
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -67,4 +67,5 @@ public interface CategoryInfoMapper
|
|||||||
int bindMusic(@Param("categoryId") String categoryId,@Param("ids") String[] ids);
|
int bindMusic(@Param("categoryId") String categoryId,@Param("ids") String[] ids);
|
||||||
|
|
||||||
|
|
||||||
|
int deleteCategoryInfoBycategoryId(String categoryId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,4 +89,6 @@ public interface MusicInfoMapper
|
|||||||
List<MusicInfo> selectRecommendMusicByReId(String reId);
|
List<MusicInfo> selectRecommendMusicByReId(String reId);
|
||||||
|
|
||||||
MusicInfo selectByPath(String path);
|
MusicInfo selectByPath(String path);
|
||||||
|
|
||||||
|
List<MusicInfo> selectMusicInfoByReId(String reId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public interface MusicSceneRelateMapper
|
|||||||
int insertMusicSceneRelate(MusicSceneRelate musicSceneRelate);
|
int insertMusicSceneRelate(MusicSceneRelate musicSceneRelate);
|
||||||
|
|
||||||
MusicSceneRelate selectByMusicId(String musicId);
|
MusicSceneRelate selectByMusicId(String musicId);
|
||||||
|
|
||||||
|
int deleteByMusicId(Long musicId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,6 @@ public interface RecommendInfoMapper
|
|||||||
|
|
||||||
|
|
||||||
List<RecommendInfo> selectMusicRecommend();
|
List<RecommendInfo> selectMusicRecommend();
|
||||||
|
|
||||||
|
int deleteRecommendInfoByReId(String reId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.system.domain.SysUserPost;
|
import com.ruoyi.system.domain.SysUserPost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,4 +43,6 @@ public interface SysUserPostMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int batchUserPost(List<SysUserPost> userPostList);
|
public int batchUserPost(List<SysUserPost> userPostList);
|
||||||
|
|
||||||
|
SysUser selectShopUserByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public interface IBannerInfoService
|
|||||||
* @param bannerInfo 【请填写功能名称】
|
* @param bannerInfo 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertBannerInfo(BannerInfo bannerInfo, MultipartFile file);
|
public int insertBannerInfo(BannerInfo bannerInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
import com.ruoyi.common.core.domain.entity.CategoryInfo;
|
||||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||||
|
import com.ruoyi.common.core.domain.entity.MusicMaxReq;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -81,5 +82,9 @@ public interface IMusicInfoService
|
|||||||
|
|
||||||
MusicInfo getMusicInfo(Long userId, String musicId);
|
MusicInfo getMusicInfo(Long userId, String musicId);
|
||||||
|
|
||||||
MusicInfo addMixMusicInfo(Map<String, String> param);
|
MusicInfo addMixMusicInfo(MusicMaxReq param);
|
||||||
|
|
||||||
|
MusicInfo editMixMusicInfo(MusicMaxReq param);
|
||||||
|
|
||||||
|
List<MusicInfo> selectMusicInfoByReId(String reId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,14 +55,7 @@ public class BannerInfoServiceImpl implements IBannerInfoService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertBannerInfo(BannerInfo bannerInfo, MultipartFile file){
|
public int insertBannerInfo(BannerInfo bannerInfo){
|
||||||
bannerInfo.setCreateTime(DateUtils.getNowDate());
|
|
||||||
try {
|
|
||||||
String addr = AliConfig.ossUp("config/" , file.getOriginalFilename(), file.getInputStream());
|
|
||||||
bannerInfo.setBannerAddr(addr);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
//上传文件
|
//上传文件
|
||||||
return bannerInfoMapper.insertBannerInfo(bannerInfo);
|
return bannerInfoMapper.insertBannerInfo(bannerInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ public class CategoryInfoServiceImpl implements ICategoryInfoService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int bindMusic(String categoryId,String[] ids) {
|
public int bindMusic(String categoryId,String[] ids) {
|
||||||
|
// 先删除再绑定
|
||||||
|
categoryInfoMapper.deleteCategoryInfoBycategoryId(categoryId);
|
||||||
return categoryInfoMapper.bindMusic(categoryId,ids);
|
return categoryInfoMapper.bindMusic(categoryId,ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,20 +202,21 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MusicInfo addMixMusicInfo(Map<String, String> param) {
|
public MusicInfo addMixMusicInfo(MusicMaxReq param) {
|
||||||
//TODO:
|
//TODO:
|
||||||
// Long userId = SecurityUtils.getUserId();
|
// Long userId = SecurityUtils.getUserId();
|
||||||
Long userId = 10000L;
|
Long userId = 10000L;
|
||||||
String musicId = param.get("musicId");
|
String musicId = String.valueOf(param.getMusicId());
|
||||||
String sceneIds = param.get("sceneIds");
|
String sceneIds = param.getSceneIds();
|
||||||
String sceneJson = param.get("sceneJson");
|
String sceneJson = param.getSceneJson();
|
||||||
// 新增混音音乐标签
|
// 新增混音音乐标签
|
||||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||||
if (musicInfo != null){
|
if (musicInfo != null){
|
||||||
long newMusicId = IdUtil.getSnowflakeNextId();
|
long newMusicId = IdUtil.getSnowflakeNextId();
|
||||||
musicInfo.setMusicId(newMusicId);
|
param.setMusicId(newMusicId);
|
||||||
musicInfo.setMusicType(MusicType.MIXING.getMusicType());
|
param.setMusicType(MusicType.MIXING.getMusicType());
|
||||||
musicInfoMapper.insertMusicInfo(musicInfo);
|
param.setMusicAddr(musicInfo.getMusicAddr());
|
||||||
|
musicInfoMapper.insertMusicInfo(param);
|
||||||
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
||||||
musicSceneRelate.setMusicId(String.valueOf(newMusicId));
|
musicSceneRelate.setMusicId(String.valueOf(newMusicId));
|
||||||
musicSceneRelate.setSceneIds(sceneIds);
|
musicSceneRelate.setSceneIds(sceneIds);
|
||||||
@@ -228,6 +229,37 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MusicInfo editMixMusicInfo(MusicMaxReq param) {
|
||||||
|
Long userId = 10000L;
|
||||||
|
Long musicId = param.getMusicId();
|
||||||
|
String sceneIds = param.getSceneIds();
|
||||||
|
String sceneJson = param.getSceneJson();
|
||||||
|
String sourceMusicId = param.getSourceMusicId();
|
||||||
|
// 查询混音音乐
|
||||||
|
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(String.valueOf(musicId));
|
||||||
|
if (musicInfo != null){
|
||||||
|
// 先删除在新增
|
||||||
|
relateMapper.deleteByMusicId(musicId);
|
||||||
|
//musicSceneMapper.selectMusicSceneById()
|
||||||
|
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
||||||
|
musicInfoMapper.updateMusicInfo(param);
|
||||||
|
musicSceneRelate.setMusicId(String.valueOf(musicId));
|
||||||
|
musicSceneRelate.setSceneIds(sceneIds);
|
||||||
|
musicSceneRelate.setUserId(userId);
|
||||||
|
musicSceneRelate.setSceneInfo(sceneJson);
|
||||||
|
musicSceneRelate.setSourceMusicId(sourceMusicId);
|
||||||
|
relateMapper.insertMusicSceneRelate(musicSceneRelate);
|
||||||
|
return musicInfo;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MusicInfo> selectMusicInfoByReId(String reId) {
|
||||||
|
return musicInfoMapper.selectMusicInfoByReId(reId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: 待完善
|
//TODO: 待完善
|
||||||
public Map<String, String> getMixMusicInfo(String musicId){
|
public Map<String, String> getMixMusicInfo(String musicId){
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ public class RecommendInfoServiceImpl implements IRecommendInfoService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int bindMusic(String reId, String[] musicIds) {
|
public int bindMusic(String reId, String[] musicIds) {
|
||||||
|
recommendInfoMapper.deleteRecommendInfoByReId(reId);
|
||||||
return recommendInfoMapper.bindMusic(reId,musicIds);
|
return recommendInfoMapper.bindMusic(reId,musicIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<if test="sort != null "> and sort = #{sort}</if>
|
<if test="sort != null "> and sort = #{sort}</if>
|
||||||
<if test="jumpUrl != null and jumpUrl != ''"> and jump_url = #{jumpUrl}</if>
|
<if test="jumpUrl != null and jumpUrl != ''"> and jump_url = #{jumpUrl}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectBannerInfoById" parameterType="String" resultMap="BannerInfoResult">
|
<select id="selectBannerInfoById" parameterType="String" resultMap="BannerInfoResult">
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="creator != null and creator != ''"> and creator = #{creator}</if>
|
<if test="creator != null and creator != ''"> and creator = #{creator}</if>
|
||||||
<if test="modify != null and modify != ''"> and modify = #{modify}</if>
|
<if test="modify != null and modify != ''"> and modify = #{modify}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCategoryInfoById" parameterType="String" resultMap="CategoryInfoResult">
|
<select id="selectCategoryInfoById" parameterType="String" resultMap="CategoryInfoResult">
|
||||||
@@ -65,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||||
<if test="name != null">name = #{name},</if>
|
<if test="name != null">name = #{name},</if>
|
||||||
|
<if test="backImg != null">back_img =#{backImg},</if>
|
||||||
<if test="isDel != null">is_del = #{isDel},</if>
|
<if test="isDel != null">is_del = #{isDel},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
@@ -97,4 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteCategoryInfoBycategoryId">
|
||||||
|
DELETE FROM music_category where category_id =#{categoryId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -182,4 +182,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectByPath" resultMap="MusicInfoResult">
|
<select id="selectByPath" resultMap="MusicInfoResult">
|
||||||
<include refid="selectMusicInfoVo" /> where music_addr=#{path} and is_del=0
|
<include refid="selectMusicInfoVo" /> where music_addr=#{path} and is_del=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMusicInfoByReId" resultMap="MusicInfoResult">
|
||||||
|
SELECT * FROM music_recommend mr left join music_info mi on mi.music_id=mr.music_id WHERE mi.is_del=0 and mr.recommend_id =#{reId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -24,4 +24,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectByMusicId" resultMap="MusicSceneRelateResult">
|
<select id="selectByMusicId" resultMap="MusicSceneRelateResult">
|
||||||
select * from music_scene_relate where music_id = #{musicId}
|
select * from music_scene_relate where music_id = #{musicId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteByMusicId">
|
||||||
|
delete from music_scene_relate where music_id=#{musicId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="isDel" column="is_del" />
|
<result property="isDel" column="is_del" />
|
||||||
<result property="desc" column="desc" />
|
<result property="desc" column="desc" />
|
||||||
|
<result property="backImg" column="back_img" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRecommendInfoVo">
|
<sql id="selectRecommendInfoVo">
|
||||||
select id, name, creator, modify, create_time, update_time, is_del, `desc` from recommend_info
|
select id, name, creator, modify, create_time, update_time, is_del,back_img, `desc` from recommend_info
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectRecommendInfoList" parameterType="RecommendInfo" resultMap="RecommendInfoResult">
|
<select id="selectRecommendInfoList" parameterType="RecommendInfo" resultMap="RecommendInfoResult">
|
||||||
@@ -28,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="isDel != null "> and is_del = #{isDel}</if>
|
<if test="isDel != null "> and is_del = #{isDel}</if>
|
||||||
<if test="desc != null and desc != ''"> and `desc` = #{desc}</if>
|
<if test="desc != null and desc != ''"> and `desc` = #{desc}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRecommendInfoById" parameterType="Long" resultMap="RecommendInfoResult">
|
<select id="selectRecommendInfoById" parameterType="Long" resultMap="RecommendInfoResult">
|
||||||
@@ -45,7 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="isDel != null">is_del,</if>
|
<if test="isDel != null">is_del,</if>
|
||||||
<if test="desc != null">desc,</if>
|
<if test="desc != null">`desc`,</if>
|
||||||
|
<if test="backImg != null">back_img,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">#{id},</if>
|
<if test="id != null">#{id},</if>
|
||||||
@@ -56,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
<if test="isDel != null">#{isDel},</if>
|
<if test="isDel != null">#{isDel},</if>
|
||||||
<if test="desc != null">#{desc},</if>
|
<if test="desc != null">#{desc},</if>
|
||||||
|
<if test="backImg != null">#{backImg}</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -69,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="isDel != null">is_del = #{isDel},</if>
|
<if test="isDel != null">is_del = #{isDel},</if>
|
||||||
<if test="desc != null">desc = #{desc},</if>
|
<if test="desc != null">desc = #{desc},</if>
|
||||||
|
<if test="backImg != null">back_img = #{backImg},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
@@ -94,4 +99,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectMusicRecommend" resultMap="RecommendInfoResult">
|
<select id="selectMusicRecommend" resultMap="RecommendInfoResult">
|
||||||
SELECT ri.* FROM music_recommend mr LEFT JOIN recommend_info ri on mr.recommend_id = ri.id and ri.is_del=0
|
SELECT ri.* FROM music_recommend mr LEFT JOIN recommend_info ri on mr.recommend_id = ri.id and ri.is_del=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteRecommendInfoByReId">
|
||||||
|
DELETE FROM music_recommend where recommend_id=#{reId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -31,4 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectShopUserByUserId" resultType="com.ruoyi.common.core.domain.entity.SysUser">
|
||||||
|
select * from sys_user where user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<where>
|
<where>
|
||||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTagById" parameterType="String" resultMap="TagResult">
|
<select id="selectTagById" parameterType="String" resultMap="TagResult">
|
||||||
|
|||||||
Reference in New Issue
Block a user