WePosterFontController.java
3.08 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.web.controller.common.CommonController;
import com.linkwechat.wecom.domain.WePosterFont;
import com.linkwechat.wecom.service.IWePosterFontService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @author ws
*/
@RestController
@RequestMapping(value = "wecom/posterFont/")
@Api(description = "海报字体")
public class WePosterFontController extends BaseController {
@Resource
private IWePosterFontService wePosterFontService;
@PostMapping(value = "posterFont")
@ApiOperation("创建海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult insertPosterFont(@RequestBody WePosterFont posterFont){
posterFont.setId(SnowFlakeUtil.nextId());
posterFont.setDelFlag(0);
posterFont.setMediaType(MediaType.POSTER_FONT.getType());
wePosterFontService.save(posterFont);
return AjaxResult.success("创建成功");
}
@PutMapping(value = "posterFont")
@ApiOperation("修改海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult updatePosterFont(@RequestBody WePosterFont posterFont){
if(posterFont.getId() == null){
return AjaxResult.error("id为空");
}
posterFont.setMediaType(null);
wePosterFontService.saveOrUpdate(posterFont);
return AjaxResult.success("修改成功");
}
@GetMapping(value = "posterFontList")
@ApiOperation("列表查询海报字体")
public AjaxResult selectPosterFontList(){
List<WePosterFont> fontList = wePosterFontService.lambdaQuery()
.eq(WePosterFont::getDelFlag,0)
.orderByDesc(WePosterFont::getOrder)
.orderByDesc(WePosterFont::getCreateTime)
.list();
return AjaxResult.success(fontList);
}
@GetMapping(value = "posterFontPage")
@ApiOperation("分页查询海报字体")
public AjaxResult selectPosterFontPage(){
startPage();
List<WePosterFont> fontList = wePosterFontService.lambdaQuery()
.eq(WePosterFont::getDelFlag,0)
.orderByDesc(WePosterFont::getOrder)
.orderByDesc(WePosterFont::getCreateTime)
.list();
return AjaxResult.success(getDataTable(fontList));
}
@DeleteMapping(value = "posterFont/{id}")
@ApiOperation("删除海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult deletePosterFont(@PathVariable Long id){
wePosterFontService.lambdaUpdate().set(WePosterFont::getDelFlag,1).eq(WePosterFont::getId,id);
return AjaxResult.success("删除成功");
}
}