无关风月
2025-01-22 99367ea1c11a68b420936e7f7db5fa7367da4f44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.xinquan.system.controller;
 
 
import com.xinquan.common.core.domain.R;
import com.xinquan.common.core.utils.page.PageDTO;
import com.xinquan.common.log.annotation.Log;
import com.xinquan.common.log.enums.BusinessType;
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.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>
 * 内容设置表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-08-21
 */
@RestController
@RequestMapping("/system/content-setting")
public class ContentSettingController {
    @Resource
    private ContentSettingService contentSettingService;
    /**
     * 获取协议
     *
     */
    @PostMapping("/getCoursePageList")
    @ApiOperation(value = "获取内容、协议1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值说明",tags = "富文本规则说明")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "内容类型 1=用户协议 2=隐私协议 3=关于心泉 4= 新手冥想指南 5=课程/冥想音频购买协议 6=能量规则说明 7等级经验值说明", name = "contentType", required = true, dataType = "int"),
    })
    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 = "管理后台-富文本规则说明")
    @Log(title = "【富文本规则说明】修改富文本内容", businessType = BusinessType.UPDATE)
 
    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(dto.getContent());
            contentSettingService.updateById(one);
        }else{
            ContentSetting contentSetting = new ContentSetting();
            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.");
        }
    }
}