huliguo
2 天以前 5d7b65670282a4fad015e37d567cfa171b162052
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
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<Void> startPageAdd(@RequestBody StartPageSetDto startPageSetDto){
        //先删除启动页的数据
        List<SystemConfig> 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<StartPageSetDto> 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);
    }
 
}