-
Notifications
You must be signed in to change notification settings - Fork 0
BaseController
a simple abstract implementation of REST controller that support CRUD operations, and which you can use in your application
@PostMapping
public ResponseEntity<BaseDTO> create(@Valid @RequestBody S s)
s is the object of request model
return ResponseEntity<BaseDTO < R>> that R the view model you must add to controller
this method save data to DataBase that you must implement in repository layer
@PutMapping
public ResponseEntity<BaseDTO> update(@Valid @RequestBody S s, @Valid @RequestParam I id)
s is the object of request model
id is your IncrementalId of DataBase
ResponseEntity<BaseDTO < R>> that R the view model you must add to controller
apiNote this method save data to DataBase that you must implement in repository layer
@DeleteMapping
public ResponseEntity<BaseDTO> deleteById(@Valid @RequestParam I id)
id is your IncrementalId of DataBase
ResponseEntity<BaseDTO < Boolean>> is the true or false result in BaseDTO pattern
used for delete an entity from data base
@GetMapping
public ResponseEntity<BaseDTO> findByID(@Valid @RequestParam I id)
id is your IncrementalId of DataBase
ResponseEntity<BaseDTO < R>> that R the view model you must add to controller
this method used for get object from Identify number of data base
@GetMapping(value = "/all")
public ResponseEntity<BaseDTO<List>> findAll()
@return ResponseEntity<BaseDTO < List < R>>> that R the view model you must add to controller
used for getAll data from data base , you must know that the cost of this method is high and you can used findListByPagination Or findByPagination for fetch data
@GetMapping(value = "/all/pagination")
public ResponseEntity<BaseDTO<PageDTO<List>>> findListByPagination(@Valid @RequestParam Integer page, @RequestParam Integer pageSize)
page is the number of page you need to fetch
pageSize is the sizable page of data
ResponseEntity<BaseDTO < PageDTO < List < R>>>> this methode return PageDTO that is all data in it
@PostMapping(value = "/all/pagination")
public ResponseEntity<BaseDTO<PageDTO<List>>> findListByPagination(@Valid @RequestParam Integer page, @RequestParam Integer pageSize, @RequestBody String orders)
page is the number of page you need to fetch
pageSize is the sizable page of data
orders is the list of fields and your direction such as Asc and Desc for Sorting
return ResponseEntity<BaseDTO < PageDTO < List < R>>>> this methode return PageDTO that is all data in it
@GetMapping(value = "/all/pagination/detail")
public ResponseEntity<BaseDTO<PageDTO<List>>> findByPagination(@Valid @RequestParam Integer page, @RequestParam Integer pageSize)
page is the number of page you need to fetch
pageSize is the sizable page of data
return ResponseEntity<BaseDTO < PageDTO < List < R>>>> this methode return PageDTO that is all data in it
@PostMapping(value = "/all/pagination/detail")
public ResponseEntity<BaseDTO<PageDTO<List>>> findByPagination(@Valid @RequestParam Integer page, @RequestParam Integer pageSize, @RequestBody String orders)
page is the number of page you need to fetch
pageSize is the sizable page of data
orders is the list of fields and your direction such as Asc and Desc for Sorting
return ResponseEntity<BaseDTO < PageDTO < List < R>>>> this methode return PageDTO that is all data in it
@GetMapping(value = "/exists/ById")
public ResponseEntity<BaseDTO> existsById(@Valid @RequestParam I id)
id is your IncrementalId of DataBase
return the Boolean of result
@GetMapping(value = "/count")
public ResponseEntity<BaseDTO> count()
return the number of objects
apiNote this controller used for the count of data
@RestController
@RequestMapping(value = "/rest/integration/v1/affair")
@Api(value = "Integration", protocols = "HTTP")
@SwaggerDefinition(tags = {@Tag(name = "Integration", description = "سرویس مدیریت اطلاعات")})
@RequiredArgsConstructor
public class AffairController extends BaseController<Affair, AffairReqVM, AffairResVM, Long> {
}