# 服务默认

# 概述

平台会抽取常用功能放至基础类中,平台提供常用稳定的方法,便于开发过程中直接调用。

# Repository 默认提供方法

代码生成器会自动生成基础操作代码,提供默认的方法,方法提供如下

序号 方法 描述 是否集成 备注
1 List<Entity> findAll() 集成
2 List<Entity> findAll(Sort sort) 集成
3 List<Entity> findAllById(Iterable<ID> ids) 集成
4 <S extends Entity> List<S> saveAll(Iterable<S> entities) 集成
5 void flush() 集成
6 <S extends Entity> S saveAndFlush(S entity) 集成
7 void deleteInBatch(Iterable<Entity> entities) 集成
8 void deleteAllInBatch() 集成
9 Entity getOne(ID id) 集成
10 <S extends Entity> List<S> findAll(Example<S> example) 集成
11 <S extends Entity> List<S> findAll(Example<S> example, Sort sort) 集成
12 Page<Entity> findAll(Pageable pageable) 集成
13 <S extends Entity> S save(S entity) 集成
14 Optional<Entity> findById(ID id) 集成
15 boolean existsById(ID id) 集成
16 long count() 集成
17 void deleteById(ID id) 集成
18 void delete(Entity entity) 集成
19 void deleteAll(Iterable<? extends Entity> entities) 集成
20 void deleteAll() 集成
21 <S extends Entity> Optional<S> findOne(Example<S> example) 集成
22 <S extends Entity> Page<S> findAll(Example<S> example, Pageable pageable) 集成
23 <S extends Entity> long count(Example<S> example) 集成
24 <S extends Entity> boolean exists(Example<S> example) 集成
25 Optional<Entity> findOne(Specification<Entity> spec) 集成
26 List<Entity> findAll(Specification<Entity> spec) 集成
27 Page<Entity> findAll(Specification<Entity> spec, Pageable pageable) 集成
28 List<Entity> findAll(Specification<Entity> spec, Sort sort) 集成
29 long count(Specification<Entity> spec) 集成 .

# Service 默认提供方法

代码生成器会自动生成基础操作代码,提供默认的方法,方法提供如下

序号 方法 描述 是否集成 备注
1 List<Entity> findAll() 集成
2 List<Entity> findAll(Sort sort) 集成
3 List<Entity> findAllById(Iterable<ID> ids) 集成
4 <S extends Entity> List<S> saveAll(Iterable<S> entities) 集成
5 void flush() 集成
6 <S extends Entity> S saveAndFlush(S entity) 集成
7 void deleteInBatch(Iterable<Entity> entities) 集成
8 void deleteAllInBatch() 集成
9 Entity getOne(ID id) 集成
10 <S extends Entity> List<S> findAll(Example<S> example) 集成
11 <S extends Entity> List<S> findAll(Example<S> example, Sort sort) 集成
12 Page<Entity> findAll(Pageable pageable) 集成
13 <S extends Entity> S save(S entity) 集成
14 Optional<Entity> findById(ID id) 集成
15 boolean existsById(ID id) 集成
16 long count() 集成
17 void deleteById(ID id) 集成
18 void delete(Entity entity) 集成
19 void deleteAll(Iterable<? extends Entity> entities) 集成
20 void deleteAll() 集成
21 <S extends Entity> Optional<S> findOne(Example<S> example) 集成
22 <S extends Entity> Page<S> findAll(Example<S> example, Pageable pageable) 集成
23 <S extends Entity> long count(Example<S> example) 集成
24 <S extends Entity> boolean exists(Example<S> example) 集成
25 Optional<Entity> findOne(Specification<Entity> spec) 集成
26 List<Entity> findAll(Specification<Entity> spec) 集成
27 Page<Entity> findAll(Specification<Entity> spec, Pageable pageable) 集成
28 List<Entity> findAll(Specification<Entity> spec, Sort sort) 集成
29 long count(Specification<Entity> spec) 集成 .

# Controller 默认提供方法

序号 方法 描述 是否集成 备注
1 @GetMapping("findAll")
public List<E> findAll()
集成
2 @PostMapping("findAllBySort")
public List<E> findAll(@RequestBody Sort sort)
集成
3 @PostMapping("findAllById")
public List<E> findAllById(@RequestBody Iterable<String> ids)
集成
4 @PostMapping("saveAll")
public List<E> saveall(@RequestBody Iterable<E> entities)
集成
5 @PostMapping("saveAndFlush")
public E saveAndFlush(@RequestBody E entity)
集成
6 @PostMapping("deleteInBatch")
public void deleteInBatch(@RequestBody Iterable<E> entities)
集成
7 @GetMapping("deleteAllInBatch")
public void deleteAllInBatch()
集成
8 @GetMapping("getOne")
public E getOne(String id)
集成
9 @PostMapping("findAllByPageable")
public RestPage<E> findAll(Pageable pageable)
集成
10 @PostMapping("save")
public E save(E entity)
集成
11 @GetMapping("findById")
public Optional<E> findById(String id)
集成
12 @GetMapping("existsById")
public boolean existsById(String id)
集成
13 @GetMapping("count")
public long count()
集成
14 @GetMapping("deleteById")
public void deleteById(String id)
集成
15 @PostMapping("delete")
public void delete(@RequestBody E entity)
集成
16 @PostMapping("deleteAllByIterable")
public void deleteAll(@RequestBody Iterable<E> entities)
集成
17 @PostMapping("deleteAll")
public void deleteAll()
集成
18 @PostMapping("findOneByWrapper")
public Optional<E> findOne(@RequestBody RestWrapper restWrapper)
集成
19 @PostMapping("findAllByWrapper")
public List<E> findAll(@RequestBody RestWrapper restWrapper)
集成
20 @PostMapping("findAllByWrapperAndPageable")
public RestPage<E> findAllByWrapperAndPageable(@RequestBody RestWrapper restWrapper)
集成 .