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.model.TOtherConfig; import com.ruoyi.system.service.THtmlConfigService; import com.ruoyi.system.service.TOtherConfigService; 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; /** *

* 富文本内容管理 前端控制器 *

* * @author xiaochen * @since 2025-11-06 */ @RestController @RequestMapping("/t-html-config") @Api(tags = "(青都)基础信息管理-协议管理") public class THtmlConfigController { private final THtmlConfigService htmlConfigService; private final TOtherConfigService otherConfigService; @Autowired public THtmlConfigController(THtmlConfigService htmlConfigService, TOtherConfigService otherConfigService) { this.htmlConfigService = htmlConfigService; this.otherConfigService = otherConfigService; } /** * 修改系统配置-协议管理 */ @Log(title = "系统配置-协议管理-修改", businessType = BusinessType.UPDATE) @ApiOperation(value = "修改系统配置-协议管理管理") @PostMapping(value = "/update") public R update(@Validated @RequestBody THtmlConfig dto) { THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.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 updateBatch(@RequestBody THtmlConfigDTO dto) { List htmlConfigs = dto.getHtmlConfigs(); List types = htmlConfigs.stream().map(THtmlConfig::getConfigType).collect(Collectors.toList()); List sysConfigs = htmlConfigService.list(Wrappers.lambdaQuery().in(THtmlConfig::getConfigType, types)); for (THtmlConfig sysConfig : sysConfigs) { List 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=用户注册隐私协议 9=启动页") @GetMapping(value = "/getDetailById") public R getDetailById(@RequestParam Integer configType) { THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.lambdaQuery().eq(THtmlConfig::getConfigType, configType) .last("LIMIT 1")); return R.ok(sysConfig); } /** * 查看系统配置-协议管理详情 */ @ApiOperation(value = "查看系统配置-协议管理列表",notes = "配置类型 类型 1=用户注册隐私协议") @GetMapping(value = "/list") public R> list() { List sysConfigs = htmlConfigService.list(); return R.ok(sysConfigs); } @ApiOperation(value = "查看系统配置-基础信息管理",notes = "基础信息管理") @GetMapping(value = "/baseInfo") public R baseInfo() { TOtherConfig otherConfig = otherConfigService.getById(1); return R.ok(otherConfig); } @ApiOperation(value = "修改系统配置-基础信息管理",notes = "基础信息管理") @GetMapping(value = "/updateBaseInfo") @Log(title = "系统配置-基础信息管理-修改", businessType = BusinessType.UPDATE) public R updateBaseInfo(TOtherConfig config) { otherConfigService.updateById(config); return R.ok(); } }