Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/longhaoteng/service-sdk
Treasure chest - 常用基础类和服务底层类
https://github.com/longhaoteng/service-sdk
sdk service springboot starter
Last synced: about 1 month ago
JSON representation
Treasure chest - 常用基础类和服务底层类
- Host: GitHub
- URL: https://github.com/longhaoteng/service-sdk
- Owner: longhaoteng
- License: apache-2.0
- Created: 2019-05-29T06:43:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T02:47:28.000Z (over 5 years ago)
- Last Synced: 2024-10-13T13:22:36.834Z (3 months ago)
- Topics: sdk, service, springboot, starter
- Language: Java
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Latest release](https://img.shields.io/github/release/longhaoteng/service-sdk.svg)](https://github.com/longhaoteng/service-sdk/releases/latest)
[![License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/longhaoteng/service-sdk/blob/master/LICENSE)# SERVICE-SDK
整合一些常用基础类和服务底层类,提升开发效率和规范代码结构
## Maven [![Latest release](https://img.shields.io/badge/dynamic/json.svg?color=lightgrey&label=latest&query=tag_name&url=https://api.github.com/repos/longhaoteng/service-sdk/releases/latest)](https://github.com/longhaoteng/service-sdk/releases/latest)
```XML
com.github.longhaoteng
service-sdk
latest```
## 示例
- 对象序列化
```java
// java bean
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "test")
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
public class Test extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String password;
@CreatedDate
private LocalDateTime createDatetime;
@LastModifiedDate
private LocalDateTime updateDatetime;
@Transactional
public Test create() {
TestRepository repository = getBean(TestRepository.class);
return repository.save(this);
}
@Transactional
public void update(String name, String password) {
this.name = name;
this.password = password;
TestRepository repository = getBean(TestRepository.class);
repository.save(this);
}
@Transactional
public void delete() {
TestRepository repository = getBean(TestRepository.class);
repository.delete(this);
}
}
// 对象操作 在service中数据序列化操作变成了简单的对象操作
test.create();
test.update(name,password);
test.delete();
```
- 对象深度拷贝(这里使用的是dozer),浅拷贝可使用spring的BeanUtils.copyProperties(),效率更高
```java
Test test = repository.findOne(id).orElse(null);
TestVO testVo = TestVO.builder().build();
testVo = BeanConverter.map(test, TestVO.class);
// 列表同理
BeanConverter.map(List sourceList, Class targetClass);
```## 加入项目
欢迎添砖加瓦