liujie
2026-01-05 553c738f567f2a3e40a1be56a88778e667c1dc96
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
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.dto.THtmlConfigDTO;
import com.ruoyi.system.model.THtmlConfig;
import com.ruoyi.system.service.THtmlConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 富文本内容管理 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-11-06
 */
@RestController
@RequestMapping("/t-html-config")
@Api(tags = "(嘉视达)基础信息管理-协议管理")
public class THtmlConfigController {
 
    private final THtmlConfigService htmlConfigService;
    @Autowired
    public THtmlConfigController(THtmlConfigService htmlConfigService) {
        this.htmlConfigService = htmlConfigService;
    }
    /**
     * 修改系统配置-协议管理
     */
    @Log(title = "系统配置-协议管理-修改", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改系统配置-协议管理管理")
    @PostMapping(value = "/update")
    public R<Boolean> update(@Validated @RequestBody THtmlConfig dto) {
        THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.<THtmlConfig>lambdaQuery().eq(THtmlConfig::getConfigType, dto.getConfigType())
                .last("LIMIT 1"));
        sysConfig.setContent(dto.getContent());
        return R.ok(htmlConfigService.updateById(sysConfig));
    }
 
    /**
     * 修改系统配置-协议管理
     */
    @Log(title = "系统配置-协议管理-批量修改", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "批量修改系统配置-协议管理管理")
    @PostMapping(value = "/updateBatch")
    public R<Boolean> updateBatch(@RequestBody THtmlConfigDTO dto) {
        List<THtmlConfig> htmlConfigs = dto.getHtmlConfigs();
        List<Integer> types = htmlConfigs.stream().map(THtmlConfig::getConfigType).collect(Collectors.toList());
        List<THtmlConfig> sysConfigs = htmlConfigService.list(Wrappers.<THtmlConfig>lambdaQuery().in(THtmlConfig::getConfigType, types));
        for (THtmlConfig sysConfig : sysConfigs) {
            List<THtmlConfig> htmlConfigList = htmlConfigs.stream().filter(htmlConfig -> htmlConfig.getConfigType().equals(sysConfig.getConfigType())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(htmlConfigList)) {
                sysConfig.setContent(htmlConfigList.get(0).getContent());
            }
        }
        htmlConfigService.updateBatchById(sysConfigs);
        return R.ok();
    }
 
    /**
     * 查看系统配置-协议管理详情
     */
    @ApiOperation(value = "查看系统配置-协议管理详情",notes = "配置类型 类型 1=用户注册隐私协议,2=大礼包购买协议,3=实物商品购买协议,4=关于我们  5=积分规则,6=金币兑换图文说明,7=普通商品模块展示配置  8实物商品展示   9启动页")
    @GetMapping(value = "/getDetailById")
    public R<THtmlConfig> getDetailById(@RequestParam Integer configType) {
        THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.<THtmlConfig>lambdaQuery().eq(THtmlConfig::getConfigType, configType)
                .last("LIMIT 1"));
        return R.ok(sysConfig);
    }
 
    /**
     * 查看系统配置-协议管理详情
     */
    @ApiOperation(value = "查看系统配置-协议管理列表",notes = "配置类型 类型 1=用户注册隐私协议,2=大礼包购买协议,3=实物商品购买协议,4=关于我们  5=积分规则,6=金币兑换图文说明,7=普通商品模块展示配置  8实物商品展示")
    @GetMapping(value = "/list")
    public R<List<THtmlConfig>> list() {
        List<THtmlConfig> sysConfigs = htmlConfigService.list();
        return R.ok(sysConfigs);
    }
 
}