lidongdong
2022-09-23 afb088b35b01ceab763081810a6e964c23d0cef8
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.dg.core.controller;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dg.core.ResultData;
import com.dg.core.annotation.Authorization;
import com.dg.core.annotation.CurrentUser;
import com.dg.core.db.gen.entity.ReplyTemplateEntity;
import com.dg.core.db.gen.entity.SysUser;
import com.dg.core.service.IReplyTemplateService;
import com.dg.core.util.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@Api(tags = {"回复模板接口"})
@RestController
@RequestMapping("/reply")
public class ReplyTemplateController extends BaseController
{
 
    @Autowired
    IReplyTemplateService iReplyTemplateService;
 
    /**
     * 获取模板列表
     * @return
     */
    @ApiOperation("获取模板列表")
    @GetMapping("/getlist")
    public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum,
                                          @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                          @RequestParam(value = "Name",required = false) String Name)
    {
        Page<ReplyTemplateEntity> pageParam = new Page<>(pageNum,pageSize);
        List<ReplyTemplateEntity> list = iReplyTemplateService.selectConfigList(pageParam,pageSize,Name);
        int num=iReplyTemplateService.countNum(Name);
        return getDataTable(list,num);
    }
 
    /**
     * 获取详情
     * @param Id
     * @return
     */
    @ApiOperation("获取详情")
    @GetMapping("/getdata")
    public ResultData selectConfigData(@RequestParam(value = "Id",required = false) String Id)
    {
        if(StringUtils.isEmpty(Id))
        {
            return ResultData.error("Id不能为空");
        }
        return ResultData.success(iReplyTemplateService.selectConfigData(Id));
    }
 
    /**
     * 新增模板
     * @param entity
     * @return
     */
    @ApiOperation("新增模板")
    @PostMapping("/add")
    @Authorization
    public ResultData insertConfig(@RequestBody ReplyTemplateEntity entity,@CurrentUser SysUser sysUser)
    {
        if(entity==null)
        {
            return ResultData.error("参数不能为空");
        }
 
        if(StringUtils.isEmpty(entity.getName()))
        {
            return ResultData.error("模板名称不能为空");
        }
 
        entity.setId(null);
        entity.setDepartmentId(sysUser.getDepartmentId());
        entity.setCreateUserId(sysUser.getUserId()+"");
 
        return toAjax(iReplyTemplateService.insertConfig(entity));
    }
 
    /**
     * 更新模板
     * @param entity
     * @return
     */
    @ApiOperation("更新模板")
    @PostMapping("/update")
    public ResultData updateConfig(@RequestBody ReplyTemplateEntity entity)
    {
        if(entity==null)
        {
            return ResultData.error("参数不能为空");
        }
 
        if(StringUtils.isEmpty(entity.getName()))
        {
            return ResultData.error("模板名称不能为空");
        }
        return toAjax(iReplyTemplateService.updateConfig(entity));
    }
 
    /**
     * 删除模板
     * @param Id
     * @return
     */
    @ApiOperation("删除模板")
    @DeleteMapping("/delete")
    public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id)
    {
        return toAjax(iReplyTemplateService.deleteConfigById(Id));
    }
 
 
    /**
     * 复制模板
     * @param Id
     * @return
     */
    @ApiOperation("复制模板")
    @PostMapping("/copy")
    public ResultData copy(@RequestParam(value = "Id",required = false) String Id)
    {
        if(StringUtils.isEmpty(Id))
        {
            return ResultData.error("Id不能为空");
        }
 
        ReplyTemplateEntity entity=iReplyTemplateService.selectConfigData(Id);
 
        if(entity==null)
        {
            return ResultData.error("模板不存在!");
        }
        entity.setId(null);
        return toAjax(iReplyTemplateService.insertConfig(entity));
    }
 
 
}