1 Star 5 Fork 0

冰羽 / Alpha-Framework

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

冰羽 / Alpha-Framework

点击前往 项目地址

若感觉有用,麻烦请 ☞ star 🚀 一下

简介

​ 基于Jpa封装(也可以看作是Jpa-Plus😹),方便CRUD,减少重复制造轮子,可作为Jpa相关项目的基础框架使用;定义了Mvc加构的基础父类,以及实现了多种主键生成策略;在示例项目(Alpha-Framework-Sample)中可以看到适配的数据库类型以及具体的使用。框架版本对应当前使用的「Spring Boot」版本。

​ 详细的使用方法请参照 Wiki

版本

alpha-framework.version:2.0.0.1.RELEASE

项目依赖

<dependency>
  <groupId>cn.com.zhaoweiping</groupId>
  <artifactId>Alpha-Framework</artifactId>
  <version>${alpha-framework.version}</version>
</dependency>

注意:${alpha-framework.version}版本 为准

功能

具体使用参见Wiki 功能实现

语义化查询

具体使用参见Wiki 语义化查询

开发示例

Alpha-Framework-Sample

注意:提供的示例中主要以H2数据库对应的最新。

注意:快速开发可使用代码生成器 Alpha-Framework-Generator

Entity

import cn.com.zhaoweiping.framework.entity.IEntity;
import cn.com.zhaoweiping.framework.strategy.pk.uuid.UUIDIdentifierGenerator;
import io.swagger.annotations.ApiModel;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "T_BOOK")
@ApiModel(value = "书籍", description = "书籍")
public class Book implements IEntity {

  /** 主键ID {@link cn.com.zhaoweiping.framework.strategy.pk} 主键生成策略 */
  @Id
  @GeneratedValue(generator = UUIDIdentifierGenerator.NAME)
  @GenericGenerator(
      name = UUIDIdentifierGenerator.NAME,
      strategy = UUIDIdentifierGenerator.STRATEGY)
  @Column(name = "ID_", length = 64)
  private String id;

  // ...

}

目前支持的主键生成策略有两种,以String和long类型的方式出现;

若使用String类型的UUID主键,推荐字段长度设为64;若使用long类型的雪花算法主键,推荐字段长度设为32;

防止字段为数据库列关键字,可以在后面追加_

Repository

import cn.com.zhaoweiping.framework.repository.IRepository;
import cn.com.zhaoweiping.sample.h2.entity.Book;
import org.springframework.stereotype.Repository;

@Repository
public interface BookRepository extends IRepository<Book, String> {}

Service

import cn.com.zhaoweiping.framework.service.IService;
import cn.com.zhaoweiping.sample.h2.entity.Book;

public interface BookService extends IService<Book, String> {}

ServiceImpl

import cn.com.zhaoweiping.framework.service.AbstractService;
import cn.com.zhaoweiping.sample.h2.entity.Book;
import cn.com.zhaoweiping.sample.h2.repository.BookRepository;
import cn.com.zhaoweiping.sample.h2.service.BookService;
import org.springframework.stereotype.Service;

@Service
public class BookServiceImpl extends AbstractService<Book, String, BookRepository>
    implements BookService {}

Controller

import cn.com.zhaoweiping.framework.controller.AbstractController;
import cn.com.zhaoweiping.sample.h2.entity.Book;
import cn.com.zhaoweiping.sample.h2.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/")
public class BookController extends AbstractController<Book> {

  @Autowired private BookService bookService;
}
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>

在Controller的开发中需要提前加入Mvc相关的Jar;

然后再Controller中进行Service的注入,以及Api其他相关的开发即可。

Comments ( 0 )

Sign in for post a comment

About

基于Jpa封装(也可以看作是Jpa-Plus😹),方便CRUD,减少重复制造轮子,可作为Jpa相关项目的基础框架使用;定义了Mvc加构的基础父类,以及实现了多种主键生成策略;在示例项目(Alpha-Framework-Sample)中可以看到适配的数据库类型以及具体的使用。 spread retract
Cancel

Releases

No release

Gitee Metrics

Contributors

All

Activities

load more
can not load any more
Java
1
https://gitee.com/zhaoweiping/alpha-framework.git
git@gitee.com:zhaoweiping/alpha-framework.git
zhaoweiping
alpha-framework
Alpha-Framework
master

Search