package ${basePackage}.module.${modulePackage}.controller;

import ${basePackage}.common.domain.PageResultDTO;
import ${basePackage}.common.domain.ResponseDTO;
import ${basePackage}.module.${modulePackage}.domain.dto.${moduleClass}DTO;
import ${basePackage}.module.${modulePackage}.domain.dto.${moduleClass}QueryDTO;
import ${basePackage}.module.${modulePackage}.service.${moduleClass}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * [ ${tableDesc} ]
 *
 * @author ${author}
 * @version 1.0
 * @company ${company}
 * @copyright (c) 2019 ${company}Inc. All rights reserved.
 * @date ${date}
 * @since JDK1.8
 */
@RestController
@Api(tags = {"${tableDesc}"})
public class ${moduleClass}Controller {

    @Autowired
    private ${moduleClass}Service ${moduleVar}Service;

    @ApiOperation(value = "分页查询${tableDesc}",notes = "@author ${author}")
    @PostMapping("/${moduleVar}/page/query")
    public ResponseDTO<PageResultDTO<${moduleClass}DTO>> queryByPage(@RequestBody ${moduleClass}QueryDTO queryDTO) {
        return ${moduleVar}Service.queryByPage(queryDTO);
    }

    @ApiOperation(value = "添加${tableDesc}",notes = "@author ${author}")
    @PostMapping("/${moduleVar}/add")
    public ResponseDTO<String> add(@RequestBody @Valid ${moduleClass}DTO addTO){
        return ${moduleVar}Service.add(addTO);
    }

    @ApiOperation(value="修改${tableDesc}",notes = "@author ${author}")
    @PostMapping("/${moduleVar}/update")
    public ResponseDTO<String> update(@RequestBody @Valid ${moduleClass}DTO updateDTO){
        return ${moduleVar}Service.update(updateDTO);
    }


    @ApiOperation(value="删除${tableDesc}",notes = "@author ${author}")
    @GetMapping("/${moduleVar}/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return ${moduleVar}Service.delete(id);
    }


    @ApiOperation(value="详情${tableDesc}",notes = "@author ${author}")
    @GetMapping("/${moduleVar}/detail/{id}")
    public ResponseDTO<${moduleClass}DTO> detail(@PathVariable("id") Long id){
        return ${moduleVar}Service.detail(id);
    }
}
