luodangjia
2024-08-24 4fe0ca21f984b38e24df69be4443c30341ee8efb
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
package com.ruoyi.other.controller;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.other.api.domain.THtml;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.service.THtmlService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-08-06
 */
@RestController
@RequestMapping("/t-html")
public class THtmlController {
    @Resource
    private THtmlService htmlService;
 
 
 
    @ApiOperation(tags = {"后台-内容设置-协议服务"},value = "新增修改")
    @PostMapping(value = "/saveOrUpdate")
    public AjaxResult saveOrUpdate(@RequestBody THtml tHtml) {
        THtml one = htmlService.lambdaQuery().eq(THtml::getType, tHtml.getType()).one();
        if(one!=null){
            one.setContent(tHtml.getContent());
            htmlService.updateById(one);
        }else {
            htmlService.save(tHtml);
        }
    return AjaxResult.success();
    }
 
    @ApiOperation(tags = {"后台-内容设置-协议服务"},value = "查询")
    @GetMapping(value = "/selectByType/{type}")
    public AjaxResult selectByType(@PathVariable Integer type) {
        THtml one = htmlService.lambdaQuery().eq(THtml::getType, type).last("limit 1").one();
        return AjaxResult.success(one);
    }
 
}