service sdk

treasure chest

License

License

GroupId

GroupId

com.github.longhaoteng
ArtifactId

ArtifactId

service-sdk
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

service sdk
treasure chest
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/service-sdk
Source Code Management

Source Code Management

https://github.com/longhaoteng/service-sdk.git

Download service-sdk

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.longhaoteng/service-sdk/ -->
<dependency>
    <groupId>com.github.longhaoteng</groupId>
    <artifactId>service-sdk</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.longhaoteng/service-sdk/
implementation 'com.github.longhaoteng:service-sdk:0.0.1'
// https://jarcasting.com/artifacts/com.github.longhaoteng/service-sdk/
implementation ("com.github.longhaoteng:service-sdk:0.0.1")
'com.github.longhaoteng:service-sdk:jar:0.0.1'
<dependency org="com.github.longhaoteng" name="service-sdk" rev="0.0.1">
  <artifact name="service-sdk" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.longhaoteng', module='service-sdk', version='0.0.1')
)
libraryDependencies += "com.github.longhaoteng" % "service-sdk" % "0.0.1"
[com.github.longhaoteng/service-sdk "0.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar 2.1.5.RELEASE
com.github.dozermapper : dozer-spring-boot-starter jar 6.4.1

Project Modules

There are no modules declared in this project.

Latest release License

SERVICE-SDK

整合一些常用基础类和服务底层类,提升开发效率和规范代码结构

Maven Latest release

<dependency>
    <groupId>com.github.longhaoteng</groupId>
    <artifactId>service-sdk</artifactId>
    <version>latest</version>
</dependency>

示例

  • 对象序列化

    // 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(),效率更高

    Test test = repository.findOne(id).orElse(null);
    TestVO testVo = TestVO.builder().build();
    testVo = BeanConverter.map(test, TestVO.class);
    // 列表同理
    BeanConverter.map(List<S> sourceList, Class<T> targetClass);

加入项目

欢迎添砖加瓦

Versions

Version
0.0.1