admin.controller.java.ftl 3.0 KB
Newer Older
F
fengyw 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
package ${cfg.packagePrefix}.${cfg.packageName!}.service.admin;

import ${cfg.packagePrefix}.common.core.base.Page;
import ${cfg.packagePrefix}.common.core.base.Result;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.biz.Admin${entity}Biz;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.req.Admin${entity}EditReq;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.req.Admin${entity}PageReq;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.req.Admin${entity}SaveReq;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.resp.Admin${entity}PageResp;
import ${cfg.packagePrefix}.${cfg.packageName!}.service.admin.resp.Admin${entity}ViewResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
F
fengyw 已提交
21 22 23 24
* ADMIN-${table.comment!}
*
* @author ${author}
*/
F
fengyw 已提交
25 26 27 28 29 30
@Api(tags = "ADMIN-${table.comment!}")
@RestController
@RequiredArgsConstructor
@RequestMapping("/${cfg.packageName}/admin/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.name ?replace("_","/")}</#if>")
public class Admin${table.entityName}Controller {

F
fengyw 已提交
31 32
@NotNull
private final Admin${entity}Biz biz;
F
fengyw 已提交
33

F
fengyw 已提交
34 35 36 37 38 39
@ApiOperation(value = "${table.comment!}分页", notes = "${table.comment!}分页")
@PostMapping(value = "/page")
public Result
<Page<#noparse>
<</#noparse>Admin${entity}PageResp<#noparse>></#noparse>> page(@RequestBody Admin${entity}PageReq req) {
    return biz.page(req);
F
fengyw 已提交
40 41 42 43
    }

    @ApiOperation(value = "${table.comment!}添加", notes = "${table.comment!}添加")
    @PostMapping(value = "/save")
F
fengyw 已提交
44 45
    public Result
    <String> save(@RequestBody @Valid Admin${entity}SaveReq req) {
F
fengyw 已提交
46
        return biz.save(req);
F
fengyw 已提交
47
        }
F
fengyw 已提交
48

F
fengyw 已提交
49 50 51 52 53 54 55
        @ApiOperation(value = "${table.comment!}查看", notes = "${table.comment!}查看")
        @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
        @GetMapping(value = "/view")
        public Result
        <Admin${entity}ViewResp> view(@RequestParam Long id) {
            return biz.view(id);
            }
F
fengyw 已提交
56

F
fengyw 已提交
57 58 59 60 61 62
            @ApiOperation(value = "${table.comment!}修改", notes = "${table.comment!}修改")
            @PutMapping(value = "/edit")
            public Result
            <String> edit(@RequestBody @Valid Admin${entity}EditReq req) {
                return biz.edit(req);
                }
F
fengyw 已提交
63

F
fengyw 已提交
64 65 66 67 68 69 70 71
                @ApiOperation(value = "${table.comment!}删除", notes = "${table.comment!}删除")
                @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
                @DeleteMapping(value = "/delete")
                public Result
                <String> delete(@RequestParam Long id) {
                    return biz.delete(id);
                    }
                    }