package ${packageName};

#foreach ($importClass in $importPackageList)
$importClass
#end
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.common.domain.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;

/**
 * ${basic.description} Controller
 *
 * @Author ${basic.backendAuthor}
 * @Date ${basic.backendDate}
 * @Copyright ${basic.copyright}
 */

@RestController
@Api(tags = "")
public class ${name.upperCamel}Controller {

    @Autowired
    private ${name.upperCamel}Service ${name.lowerCamel}Service;

    @ApiOperation("分页查询 @author ${basic.backendAuthor}")
    @PostMapping("/${name.lowerCamel}/queryPage")
    public ResponseDTO<PageResult<${name.upperCamel}VO>> queryPage(@RequestBody @Valid ${name.upperCamel}QueryForm queryForm) {
        return ResponseDTO.ok(${name.lowerCamel}Service.queryPage(queryForm));
    }

#if($insertAndUpdate.isSupportInsertAndUpdate)
    @ApiOperation("添加 @author ${basic.backendAuthor}")
    @PostMapping("/${name.lowerCamel}/add")
    public ResponseDTO<String> add(@RequestBody @Valid ${name.upperCamel}AddForm addForm) {
        return ${name.lowerCamel}Service.add(addForm);
    }

    @ApiOperation("更新 @author ${basic.backendAuthor}")
    @PostMapping("/${name.lowerCamel}/update")
    public ResponseDTO<String> update(@RequestBody @Valid ${name.upperCamel}UpdateForm updateForm) {
        return ${name.lowerCamel}Service.update(updateForm);
    }
#end

#if($deleteInfo.isSupportDelete)
    #if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
    @ApiOperation("批量删除 @author ${basic.backendAuthor}")
    @PostMapping("/${name.lowerCamel}/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<${primaryKeyJavaType}> idList) {
        return ${name.lowerCamel}Service.batchDelete(idList);
    }
    #end

    #if($deleteInfo.deleteEnum == "Single" || $deleteInfo.deleteEnum == "SingleAndBatch")
    @ApiOperation("单个删除 @author ${basic.backendAuthor}")
    @GetMapping("/${name.lowerCamel}/delete/{${name.lowerCamel}Id}")
    public ResponseDTO<String> batchDelete(@PathVariable ${primaryKeyJavaType} ${primaryKeyFieldName}) {
        return ${name.lowerCamel}Service.delete(${name.lowerCamel}Id);
    }
    #end
#end
}
