xiaoyong931011
2022-07-07 472f283b4da53a68dddb2ade8a32f646cc475f9f
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
package com.xcong.farmer.cms.modules.system.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.TemplateListDto;
import com.xcong.farmer.cms.modules.system.entity.CmsTemplateEntity;
import com.xcong.farmer.cms.modules.system.service.ICmsTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.validation.Valid;
 
/**
 * @author wzy
 * @date 2022-07-04
 **/
@RestController
@RequestMapping(value = "/api/template")
@Api(value = "CmsTemplateController", tags = "模板接口类")
public class CmsTemplateController {
 
    @Autowired
    private ICmsTemplateService cmsTemplateService;
 
    @ApiOperation(value = "上传模板", notes = "上传模板接口")
    @PostMapping(value = "/uploadTemplate")
    public Result uploadTemplate(MultipartFile file) {
        cmsTemplateService.updateTemplate(file);
        return Result.ok("上传成功");
    }
 
    @ApiOperation(value = "模板列表", notes = "模板列表接口")
    @PostMapping(value = "/list")
    public Result list(@RequestBody @Valid TemplateListDto templateListDto) {
        return Result.ok(cmsTemplateService.findInPage(templateListDto));
    }
 
    @ApiOperation(value = "删除模板", notes = "删除模板")
    @PostMapping(value = "/delete/{id}")
    public Result delete(@PathVariable("id") Long id) {
        cmsTemplateService.delete(id);
        return Result.ok("删除成功");
    }
 
    @ApiOperation(value = "模板下拉列表", notes = "模板下拉列表接口")
    @GetMapping(value = "/dropdownList")
    public Result dropdownList() {
        return cmsTemplateService.dropdownList();
    }
 
    @ApiOperation(value = "查看模板", notes = "查看模板")
    @GetMapping(value = "/viewTemplateInfo/{id}")
    public Result viewTemplateInfo(@PathVariable(value = "id") Long id) {
        return cmsTemplateService.viewTemplateInfo(id);
    }
}