doum
7 小时以前 bd33d9649906e88271725a7d450b0c49afd54df5
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
package ${package.Controller};
 
import ${package.Base}.core.annotation.excel.ExcelExporter;
import ${package.Base}.core.annotation.pr.PreventRepeat;
 
import ${package.Base}.core.model.ApiResponse;
import ${package.Base}.core.model.PageData;
import ${package.Base}.core.model.PageWrap;
import ${package.Entity}.${entityName};
import ${package.Base}.core.utils.Utils;
import ${package.Service}.${entityName}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
 
import  ${package.Base}.api.BaseController;
/**
 * ${tableComment}Controller定义
 * @author doumee
 * @date ${nowDate}
 */
@Api(tags = "tableName接口")
@RestController
@RequestMapping("/business/${entityNameLower}")
public class ${entityName}Controller extends BaseController {
 
    @Autowired
    private ${entityName}Service ${entityNameLower}Service;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("business:${entityNameLowerFull}:create")
    public ApiResponse create(@RequestBody ${entityName} ${entityNameLower}) {
        return ApiResponse.success(${entityNameLower}Service.create(${entityNameLower}));
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:${entityNameLowerFull}:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        ${entityNameLower}Service.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:${entityNameLowerFull}:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        ${entityNameLower}Service.deleteByIdInBatch(this.getIdList(ids));
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:${entityNameLowerFull}:update")
    public ApiResponse updateById(@RequestBody ${entityName} ${entityNameLower}) {
        ${entityNameLower}Service.updateById(${entityNameLower});
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("business:${entityNameLowerFull}:query")
    public ApiResponse<PageData<${entityName}>> findPage (@RequestBody PageWrap<${entityName}> pageWrap) {
        return ApiResponse.success(${entityNameLower}Service.findPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:${entityNameLowerFull}:exportExcel")
    public void exportExcel (@RequestBody PageWrap<${entityName}> pageWrap, HttpServletResponse response) {
        ExcelExporter.build(${entityName}.class).export(${entityNameLower}Service.findPage(pageWrap).getRecords(), "月台_作业操作历史表", response);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:${entityNameLowerFull}:query")
    public ApiResponse findById(@PathVariable Integer id) {
        return ApiResponse.success(${entityNameLower}Service.findById(id));
    }
}