增加信息反馈
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package com.ruoyi.web.controller.back;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.UserFeedback;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.IUserFeedbackService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户反馈Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/back/feedback")
|
||||
public class UserFeedbackController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IUserFeedbackService userFeedbackService;
|
||||
|
||||
/**
|
||||
* 查询用户反馈列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(UserFeedback userFeedback)
|
||||
{
|
||||
startPage();
|
||||
List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户反馈列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:export')")
|
||||
@Log(title = "用户反馈", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, UserFeedback userFeedback)
|
||||
{
|
||||
List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
|
||||
ExcelUtil<UserFeedback> util = new ExcelUtil<>(UserFeedback.class);
|
||||
util.exportExcel(response, list, "用户反馈数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户反馈详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(userFeedbackService.selectUserFeedbackById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户反馈
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:add')")
|
||||
@Log(title = "用户反馈", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody UserFeedback userFeedback)
|
||||
{
|
||||
return toAjax(userFeedbackService.insertUserFeedback(userFeedback));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户反馈
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:edit')")
|
||||
@Log(title = "用户反馈", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody UserFeedback userFeedback)
|
||||
{
|
||||
return toAjax(userFeedbackService.updateUserFeedback(userFeedback));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户反馈
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:feedback:remove')")
|
||||
@Log(title = "用户反馈", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(userFeedbackService.deleteUserFeedbackByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.web.controller.client;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.UserFeedback;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.IUserFeedbackService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 用户反馈Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/client/feedback")
|
||||
public class ClientFeedbackController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IUserFeedbackService userFeedbackService;
|
||||
|
||||
/**
|
||||
* 提交用户反馈
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
public AjaxResult submit(@RequestBody UserFeedback userFeedback, HttpServletRequest request)
|
||||
{
|
||||
// 验证必填字段
|
||||
if (StringUtils.isEmpty(userFeedback.getFeedbackContent())) {
|
||||
return AjaxResult.error("反馈内容不能为空");
|
||||
}
|
||||
|
||||
// 设置ID
|
||||
userFeedback.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
|
||||
// 设置IP地址
|
||||
userFeedback.setIpAddress(IpUtils.getIpAddr(request));
|
||||
|
||||
// 设置用户浏览器信息
|
||||
userFeedback.setUserAgent(request.getHeader("User-Agent"));
|
||||
|
||||
// 设置状态,如果未提供则默认为pending
|
||||
if (StringUtils.isEmpty(userFeedback.getStatus())) {
|
||||
userFeedback.setStatus("pending");
|
||||
} else {
|
||||
// 验证状态值是否合法
|
||||
String status = userFeedback.getStatus();
|
||||
if (!status.equals("pending") && !status.equals("processing") &&
|
||||
!status.equals("resolved") && !status.equals("closed")) {
|
||||
return AjaxResult.error("状态值无效,必须是 pending、processing、resolved 或 closed");
|
||||
}
|
||||
}
|
||||
|
||||
// 设置创建时间和更新时间
|
||||
Date now = new Date();
|
||||
userFeedback.setCreatedAt(now);
|
||||
userFeedback.setUpdatedAt(now);
|
||||
|
||||
return toAjax(userFeedbackService.insertUserFeedback(userFeedback));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户反馈详情
|
||||
*/
|
||||
@GetMapping("/detail/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return AjaxResult.success(userFeedbackService.selectUserFeedbackById(id));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -73,10 +74,10 @@ public class MusicController extends BaseController {
|
||||
int count = musicService.findLikeNumsByUserId(userId);
|
||||
// 获取一张音乐图片
|
||||
String imgUrl = musicService.findLikeMusicImageByUserId(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("count", count);
|
||||
ajax.put("imgUrl", imgUrl);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
// 删除我喜欢的音乐 cancel/like
|
||||
|
||||
@@ -14,7 +14,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户播放历史Controller
|
||||
@@ -118,10 +120,10 @@ public class UserHistoryController extends BaseController
|
||||
// 获取一张音乐图片
|
||||
String imgUrl = userHistoryService.findHistoryMusicImageByUserId(userId);
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("count", count);
|
||||
ajax.put("imgUrl", imgUrl);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user