TestController.java
3.77 KB
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
package com.infoloop.tianting.controller;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.constant.PathVariableResourceConstants;
import com.infoloop.tianting.model.common.CreatedResult;
import com.infoloop.tianting.model.common.PageResult;
import com.infoloop.tianting.model.dto.TestExampleDbDTO;
import com.infoloop.tianting.model.vo.TestExampleDbVO;
import com.infoloop.tianting.service.TestService;
import com.tianting.infoloop.grpc.exampleservice.SingleTestExampleDbRpcResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
@Api(tags = "示例")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TestController {
private final TestService testService;
@ApiOperation(value = "分页查询")
@PostMapping("/testexampledbs/page")
@ResponseStatus(HttpStatus.OK)
public PageResult<TestExampleDbVO> queryPage(@Valid @RequestBody TestExampleDbDTO.QueryPage queryPage) {
return testService.queryPage(queryPage);
}
@ApiOperation(value = "查询所有")
@PostMapping("/testexampledbs/queryall")
@ResponseStatus(HttpStatus.OK)
public List<TestExampleDbVO> queryAll() {
return testService.queryAll();
}
@ApiOperation(value = "新增")
@PutMapping("/testexampledb")
@ResponseStatus(HttpStatus.CREATED)
public CreatedResult<TestExampleDbVO> createTestExampleDb(@Valid @RequestBody TestExampleDbDTO.CreateTestExampleDb createTestExampleDb) {
return testService.createTestExampleDb(createTestExampleDb);
}
@ApiOperation(value = "修改")
@PatchMapping("/testexampledb/{testExampleDbId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateTestExampleDb(@ApiIgnore @RequestAttribute(PathVariableResourceConstants.INJECTED_TEST_EXAMPLE_DB) final SingleTestExampleDbRpcResponse testExampleDbRpcResponse,
@Valid @RequestBody TestExampleDbDTO.UpdateTestExampleDb updateTestExampleDb) {
testService.updateTestExampleDb(testExampleDbRpcResponse, updateTestExampleDb);
}
@ApiOperation(value = "删除")
@DeleteMapping("/testexampledb/{testExampleDbId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteTestExampleDb(@ApiIgnore @RequestAttribute(PathVariableResourceConstants.INJECTED_TEST_EXAMPLE_DB)final SingleTestExampleDbRpcResponse testExampleDbRpcResponse) {
testService.deleteTestExampleDb(testExampleDbRpcResponse);
}
@ApiOperation(value = "详情")
@GetMapping("/testexampledb/{testExampleDbId}")
@ResponseStatus(HttpStatus.OK)
public TestExampleDbVO getTestExampleDb(@ApiIgnore @RequestAttribute(PathVariableResourceConstants.INJECTED_TEST_EXAMPLE_DB)final SingleTestExampleDbRpcResponse testExampleDbRpcResponse) {
return testService.getTestExampleDb(testExampleDbRpcResponse);
}
}