package com.ruoyi.web.controller.errand; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.core.domain.R; import com.ruoyi.errand.constant.SystemConfigTypeConstant; import com.ruoyi.errand.domain.SystemConfig; import com.ruoyi.errand.object.dto.app.StartPageSetDto; import com.ruoyi.errand.service.SystemConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @Validated @RestController @RequestMapping(value = "/app/systemConfig") @Api(value = "系统配置", tags = "系统配置操作控制器") @Slf4j public class SystemConfigController { @Autowired private SystemConfigService systemConfigService; @PostMapping("/startPage/add") @PreAuthorize("@ss.hasPermi('system:agreement:list')") @ApiOperation(value = "协议管理-启动页配置", tags = {"管理后台-系统管理"}) public R startPageAdd(@RequestBody StartPageSetDto startPageSetDto){ //先删除启动页的数据 List list = systemConfigService.lambdaQuery().eq(SystemConfig::getType, SystemConfigTypeConstant.START_PAGE).list(); systemConfigService.removeBatchByIds(list); SystemConfig systemConfig = new SystemConfig(); systemConfig.setType(SystemConfigTypeConstant.START_PAGE); systemConfig.setContent(JSON.toJSONString(startPageSetDto)); systemConfigService.save(systemConfig); return R.ok(); } @GetMapping("/index/start") @ApiOperation(value = "启动页-详情", tags = {"app用户端-启动页","管理后台-启动页配置"}) public R indexStart(){ SystemConfig one = systemConfigService.lambdaQuery().eq(SystemConfig::getType, SystemConfigTypeConstant.START_PAGE).one(); if (one==null){ return R.ok(); } StartPageSetDto indexConfigSetDto = JSONObject.parseObject(one.getContent(), StartPageSetDto.class); return R.ok(indexConfigSetDto); } }