|
@@ -0,0 +1,212 @@
|
|
|
|
+package com.ruoyi.generator.controller;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
+import com.ruoyi.common.core.text.Convert;
|
|
|
|
+import com.ruoyi.common.exception.user.ProjectException;
|
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
+import com.ruoyi.common.utils.ServletUtils;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityArticleImages;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityFeedbackImages;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityFeedbackUser;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityReportUser;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityFeedbackUserMapper;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityReportUserMapper;
|
|
|
|
+import com.ruoyi.generator.service.ICommunityFeedbackUserService;
|
|
|
|
+import com.ruoyi.generator.service.ICommunityReportUserService;
|
|
|
|
+import com.ruoyi.generator.vo.CommunityArticleVo;
|
|
|
|
+import com.ruoyi.generator.vo.CommunityFeedbackUserVo;
|
|
|
|
+import com.ruoyi.generator.vo.CommunityImagesVo;
|
|
|
|
+import com.ruoyi.generator.vo.CommunityReportUserVo;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.net.HttpURLConnection;
|
|
|
|
+import java.net.URL;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 社区用户反馈
|
|
|
|
+ *
|
|
|
|
+ * @author fangQing
|
|
|
|
+ * @date 2025/6/13 10:39
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+@Api(tags = "社区用户反馈")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/community/feedback")
|
|
|
|
+public class CommunityFeedbackController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommunityFeedbackUserService communityFeedbackUserService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommunityFeedbackUserMapper communityFeedbackUserMapper;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户反馈
|
|
|
|
+ * @param communityFeedbackUser
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("用户反馈")
|
|
|
|
+ @PostMapping("/feedbackTypes")
|
|
|
|
+ public AjaxResult feedbackTypes(@RequestBody CommunityFeedbackUser communityFeedbackUser) {
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(communityFeedbackUser.getType())) {
|
|
|
|
+ return AjaxResult.error("请填写反馈类型!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(communityFeedbackUser.getUserFeedback())) {
|
|
|
|
+ return AjaxResult.error("请填写反馈内容!");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ communityFeedbackUserService.insertCommunityFeedbacktUser(communityFeedbackUser);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("反馈成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 管理员反馈
|
|
|
|
+ * @param communityFeedbackUser
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("管理员反馈")
|
|
|
|
+ @PostMapping("/punishTypes")
|
|
|
|
+ public AjaxResult punishTypes(@RequestBody CommunityFeedbackUser communityFeedbackUser) {
|
|
|
|
+ if (Objects.isNull(communityFeedbackUser.getId())) {
|
|
|
|
+ return AjaxResult.error("请填写回执ID!");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(communityFeedbackUser.getPunishFeedback())) {
|
|
|
|
+ return AjaxResult.error("请管理员填写反馈内容!");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ communityFeedbackUserService.updateCommunityFeedbacktUser(communityFeedbackUser);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("反馈成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询反馈
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("查询反馈")
|
|
|
|
+ @GetMapping("/feedbackUsers")
|
|
|
|
+ public AjaxResult feedbackUsers(Long id, Long type, String userId) {
|
|
|
|
+ int total = 0;
|
|
|
|
+ List<CommunityFeedbackUserVo> communityFeedbackUserVos = null;
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
|
+ int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
|
+ int offset = (pageNum - 1) * pageSize;
|
|
|
|
+ int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
|
|
|
|
+
|
|
|
|
+ communityFeedbackUserVos = communityFeedbackUserMapper.selectFeedbackUserVo(offset, pageSize, searchType, id, type, userId);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<CommunityFeedbackUserVo> feedbackVos_copy = new ArrayList<>(communityFeedbackUserVos);
|
|
|
|
+
|
|
|
|
+ for (CommunityFeedbackUserVo feedbackVo : feedbackVos_copy) {
|
|
|
|
+
|
|
|
|
+ //获取用户传的图片
|
|
|
|
+ List<Map<String, Object>> userImageList = feedbackVo.getUserImages();
|
|
|
|
+
|
|
|
|
+ //创建视屏数组
|
|
|
|
+ List<CommunityFeedbackImages> videoList = new ArrayList<>();
|
|
|
|
+ CommunityFeedbackImages userVideos = null;
|
|
|
|
+ List<Map<String, Object>> userImageList_copy = new ArrayList<>(userImageList);
|
|
|
|
+ for (Map<String, Object> image : userImageList_copy) {
|
|
|
|
+ String imageUrl = image.get("imageUrl").toString();
|
|
|
|
+ //判断是否是视频
|
|
|
|
+ boolean isVideo = isVideoFile(imageUrl);
|
|
|
|
+ if (isVideo) {
|
|
|
|
+ userImageList.remove(image);
|
|
|
|
+ userVideos = JSONObject.parseObject(JSONObject.toJSONString(image), CommunityFeedbackImages.class);
|
|
|
|
+ //BeanUtils.copyProperties(image, videos);
|
|
|
|
+ videoList.add(userVideos);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ feedbackVo.setUserVideoList(videoList);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //获取管理员传的图片
|
|
|
|
+ List<Map<String, Object>> punishImageList = feedbackVo.getPunishImages();
|
|
|
|
+
|
|
|
|
+ //创建视屏数组
|
|
|
|
+ List<CommunityFeedbackImages> punishVideoList = new ArrayList<>();
|
|
|
|
+ CommunityFeedbackImages punishVideos = null;
|
|
|
|
+ List<Map<String, Object>> punishImageList_copy = new ArrayList<>(punishImageList);
|
|
|
|
+ for (Map<String, Object> image : punishImageList_copy) {
|
|
|
|
+ String imageUrl = image.get("imageUrl").toString();
|
|
|
|
+ //判断是否是视频
|
|
|
|
+ boolean isVideo = isVideoFile(imageUrl);
|
|
|
|
+ if (isVideo) {
|
|
|
|
+ punishImageList.remove(image);
|
|
|
|
+ punishVideos = JSONObject.parseObject(JSONObject.toJSONString(image), CommunityFeedbackImages.class);
|
|
|
|
+ //BeanUtils.copyProperties(image, videos);
|
|
|
|
+ punishVideoList.add(punishVideos);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ feedbackVo.setPunishVideoList(punishVideoList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+
|
|
|
|
+ total = communityReportUserMapper.selectList(new QueryWrapper<CommunityReportUser>()
|
|
|
|
+ .and((wrapper) -> {
|
|
|
|
+ wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
|
+ })).size();
|
|
|
|
+*/
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(communityFeedbackUserVos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断是否是视频文件
|
|
|
|
+ *
|
|
|
|
+ * @param fileUrl 文件地址
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ public static boolean isVideoFile(String fileUrl) {
|
|
|
|
+ try {
|
|
|
|
+ // 打开 HTTP 连接
|
|
|
|
+ URL url = new URL(fileUrl);
|
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
|
+
|
|
|
|
+ // 获取文件类型
|
|
|
|
+ String mimeType = connection.getContentType();
|
|
|
|
+
|
|
|
|
+ // 判断是否为视频类型
|
|
|
|
+ return mimeType != null && mimeType.startsWith("video");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|