From 0c51a577db337520452022d9d6a22b720ef858d4 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 31 十二月 2024 14:13:01 +0800
Subject: [PATCH] 全部代码、数据库提交

---
 xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java |   52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java
index c2c8221..629e084 100644
--- a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java
+++ b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java
@@ -5,18 +5,18 @@
 import com.xinquan.common.core.utils.page.PageDTO;
 import com.xinquan.system.domain.ContentSetting;
 import com.xinquan.system.domain.VipSetting;
+import com.xinquan.system.domain.dto.AggrementOtherDto;
 import com.xinquan.system.service.ContentSettingService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * <p>
@@ -43,32 +43,54 @@
     public R<String> getCourseList(@RequestParam(value = "contentType", required = true) int contentType) {
         ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, contentType).one();
         if (one!=null){
+
             return R.ok(one.getContent());
         }else{
             return R.ok();
-
         }
     }
     @PostMapping("/saveOrupdateContent")
     @ApiOperation(value = "保存修改富文本内容",tags = "管理后台-富文本规则说明")
-    @ApiImplicitParams({
-            @ApiImplicitParam(value = "内容类型 1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值规则说明", name = "type", required = true, dataType = "int"),
-            @ApiImplicitParam(value = "富文本内容", name = "content", required = true, dataType = "String"),
-    })
-    public R saveOrupdateContent(Integer type,String content) {
-        ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, type).one();
+
+    public R saveOrupdateContent(@RequestBody AggrementOtherDto dto) {
+        ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, dto.getType()).one();
+        if (dto.getType() == 7){
+            dto.setContent("<img src="+"\""+dto.getContent()+"\">"+"</img>");
+        }
         if (one!=null){
-            one.setContent(content);
+            one.setContent(dto.getContent());
             contentSettingService.updateById(one);
         }else{
             ContentSetting contentSetting = new ContentSetting();
-            contentSetting.setContentType(type);
-            contentSetting.setContent(content);
+            contentSetting.setContentType(dto.getType());
+            contentSetting.setContent(dto.getContent());
             contentSetting.setCreateTime(LocalDateTime.now());
             contentSettingService.save(contentSetting);
         }
 
         return R.ok();
     }
+
+    public static void main(String[] args) {
+        // 示例 HTML 字符串
+        String htmlString = "<img src=\"https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/17313899095390cf6c36b6172b7143579920e0dfb816a_0fd6cbede59403085e39fa106a528eb8f0a734f32528a68832340f7d68939d33.png\"></img>";
+
+        // 定义正则表达式来提取 src 属性的值
+        String regex = "<img[^>]+src=\"([^\"]+)\"";
+
+        // 编译正则表达式
+        Pattern pattern = Pattern.compile(regex);
+
+        // 创建 Matcher 对象
+        Matcher matcher = pattern.matcher(htmlString);
+
+        // 查找匹配项并输出 src 属性值
+        if (matcher.find()) {
+            String imgSrc = matcher.group(1);  // 获取 src 属性值
+            System.out.println("Extracted image source: " + imgSrc);
+        } else {
+            System.out.println("No image source found.");
+        }
+    }
 }
 

--
Gitblit v1.7.1