pig
↥ ↥ ↥ Follow for updates An RBAC permission management system based on Spring Cloud 2025, Spring Boot 4, and OAuth2.
Top Related Projects
Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于Spring Boot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
🔥 官方推荐 🔥 RuoYi-Vue 全新 Pro 版本,优化重构所有功能。基于 Spring Boot + MyBatis Plus + Vue & Element 实现的后台管理系统 + 微信小程序,支持 RBAC 动态权限、数据权限、SaaS 多租户、Flowable 工作流、三方登录、支付、短信、商城、CRM、ERP、MES、IM、AI 大模型、IoT 物联网等功能。你的 ⭐️ Star ⭐️,是作者生发的动力!
eladmin jpa 版本:项目基于 Spring Boot 2.7.18、 Jpa、 Spring Security、Redis、Vue的前后端分离的后台管理系统,项目采用分模块开发方式, 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前后端代码,支持动态路由
Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。 包含了基础的RBAC权限管理、授权认证、网关管理、服务治理、审计日志等系统管理基础应用。 定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。 让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。 目标是建立一套金融级、高安全性的微服务解决方案。
【低代码v2.0,一句话即可生 成整个系统】企业级AI低代码平台,一键生成前后端代码甚至整个系统。 AI Skills 一句话画流程、设计表单、生成报表、大屏。内置 AI应用平台涵盖:AI聊天、知识库、流程编排、MCP插件等,兼容主流大模型。引领AI低代码「Skills 生成 → 在线配置 → 代码生成 → 手工合并->AI修改」开发模式,解决 Java 项目 90% 重复工作,提高效率又不失灵活。
Quick Overview
The pig-mesh/pig repository is a lightweight, fast, and flexible web framework for building modern web applications in Go. It provides a simple and intuitive API for handling HTTP requests, routing, middleware, and more, making it a great choice for developers looking to build scalable and efficient web applications.
Pros
- Simplicity: Pig is designed to be easy to use and understand, with a clean and concise API that makes it easy to get started.
- Performance: Pig is built on top of the high-performance
net/httppackage, and is optimized for speed and efficiency. - Flexibility: Pig is highly customizable and can be easily extended with middleware and other plugins.
- Scalability: Pig is designed to be scalable and can handle high-traffic web applications with ease.
Cons
- Limited Documentation: While the Pig project has a good amount of documentation, it may not be as comprehensive as some other web frameworks.
- Smaller Community: Pig has a smaller community compared to some of the more popular Go web frameworks, which may make it harder to find support and resources.
- Fewer Features: Pig is a relatively lightweight framework, which means it may not have as many built-in features as some of the more feature-rich web frameworks.
- Lack of Widespread Adoption: Pig is not as widely used as some of the more popular Go web frameworks, which may make it harder to find developers who are familiar with the project.
Code Examples
Here are a few examples of how to use Pig in your Go web applications:
- Basic HTTP Handler:
package main
import (
"fmt"
"net/http"
"github.com/pig-mesh/pig"
)
func main() {
r := pig.New()
r.Get("/", func(c *pig.Context) error {
_, err := fmt.Fprintf(c.Writer, "Hello, World!")
return err
})
http.ListenAndServe(":8080", r)
}
- Routing and Parameters:
package main
import (
"fmt"
"net/http"
"github.com/pig-mesh/pig"
)
func main() {
r := pig.New()
r.Get("/users/:id", func(c *pig.Context) error {
id := c.Param("id")
_, err := fmt.Fprintf(c.Writer, "User ID: %s", id)
return err
})
http.ListenAndServe(":8080", r)
}
- Middleware:
package main
import (
"fmt"
"net/http"
"github.com/pig-mesh/pig"
)
func main() {
r := pig.New()
r.Use(func(next pig.HandlerFunc) pig.HandlerFunc {
return func(c *pig.Context) error {
fmt.Println("Before request")
err := next(c)
fmt.Println("After request")
return err
}
})
r.Get("/", func(c *pig.Context) error {
_, err := fmt.Fprintf(c.Writer, "Hello, World!")
return err
})
http.ListenAndServe(":8080", r)
}
Getting Started
To get started with Pig, you can follow these steps:
- Install Go on your system if you haven't already.
- Create a new Go module for your project:
go mod init your-project
- Install the Pig package:
go get github.com/pig-mesh/pig
- Create a new file (e.g.,
main.go) and add the following code:
package main
import (
"fmt"
"net/http"
"github.com/pig-mesh/pig"
)
func main() {
r := pig.New()
r.Get("/", func(c *pig.Context) error {
_, err := fmt.Fprintf(c.Writer, "Hello, Worl
Competitor Comparisons
Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
Pros of spring-cloud-alibaba
- More comprehensive ecosystem with a wider range of components for microservices
- Stronger community support and regular updates from Alibaba
- Better integration with Alibaba Cloud services
Cons of spring-cloud-alibaba
- Steeper learning curve due to its extensive feature set
- Potentially heavier resource consumption for smaller projects
- Some components may be more tailored for Alibaba Cloud, limiting flexibility
Code Comparison
spring-cloud-alibaba:
@SpringBootApplication
@EnableDiscoveryClient
public class ProviderApplication {
public static void main(String[] args) {
SpringApplication.run(ProviderApplication.class, args);
}
}
pig:
@SpringBootApplication
@EnablePigFeignClients
@EnablePigResourceServer
public class PigAdminApplication {
public static void main(String[] args) {
SpringApplication.run(PigAdminApplication.class, args);
}
}
Both projects use Spring Boot annotations, but spring-cloud-alibaba focuses on service discovery, while pig includes custom annotations for Feign clients and resource server configuration.
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于Spring Boot+MyBatis实现,采用Docker容器化部署。 前台商城系统 包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Pros of mall
- More comprehensive e-commerce solution with front-end and back-end components
- Extensive documentation and learning resources for developers
- Larger community and more frequent updates
Cons of mall
- Steeper learning curve due to its complexity
- May be overkill for smaller projects or simpler e-commerce needs
- Potentially higher resource requirements for deployment
Code Comparison
mall (Java):
@ApiOperation("Add product to cart")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public CommonResult add(@RequestBody OmsCartItem cartItem) {
int count = cartItemService.add(cartItem);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
pig (Java):
@Inner(false)
@GetMapping("/info/{username}")
public R<UserInfo> info(@PathVariable String username) {
SysUser user = sysUserService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username));
if (user == null) {
return R.failed(String.format("用户信息为空 %s", username));
}
return R.ok(sysUserService.getUserInfo(user));
}
Both projects use Spring Boot and similar annotation-based approaches, but mall focuses on e-commerce functionality while pig emphasizes microservices and security features.
🔥 官方推荐 🔥 RuoYi-Vue 全新 Pro 版本,优化重构所有功能。基于 Spring Boot + MyBatis Plus + Vue & Element 实现的后台管理 系统 + 微信小程序,支持 RBAC 动态权限、数据权限、SaaS 多租户、Flowable 工作流、三方登录、支付、短信、商城、CRM、ERP、MES、IM、AI 大模型、IoT 物联网等功能。你的 ⭐️ Star ⭐️,是作者生发的动力!
Pros of ruoyi-vue-pro
- More comprehensive documentation and tutorials
- Larger community and more frequent updates
- Extensive integration with popular third-party services
Cons of ruoyi-vue-pro
- Steeper learning curve due to its extensive features
- Potentially heavier resource consumption
- May be overly complex for smaller projects
Code Comparison
ruoyi-vue-pro:
@PreAuthorize("@ss.hasPermission('system:user:list')")
@GetMapping("/page")
public CommonResult<PageResult<UserPageItemRespVO>> getUserPage(@Valid UserPageReqVO reqVO) {
PageResult<AdminUserDO> pageResult = userService.getUserPage(reqVO);
return success(UserConvert.INSTANCE.convertPage(pageResult));
}
pig:
@GetMapping("/page")
public R getUserPage(Page page, UserDTO userDTO) {
return R.ok(userService.getUserWithRolePage(page, userDTO));
}
The ruoyi-vue-pro example shows more detailed permission handling and request validation, while pig's code is more concise but may require additional security measures elsewhere in the application.
eladmin jpa 版本:项目基于 Spring Boot 2.7.18、 Jpa、 Spring Security、Redis、Vue的前后端分离的后台管理系统,项目采用分模块开发方式 , 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前后端代码,支持动态路由
Pros of eladmin
- More comprehensive documentation and detailed user guide
- Extensive built-in components and modules for rapid development
- Active community with frequent updates and bug fixes
Cons of eladmin
- Steeper learning curve due to its extensive feature set
- Potentially heavier resource usage for smaller projects
- Less flexibility for customization compared to Pig's modular approach
Code Comparison
eladmin (Entity class example):
@Entity
@Data
@Table(name="sys_user")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String username;
private String email;
}
Pig (Entity class example):
@Data
@TableName("sys_user")
public class SysUser implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private Long userId;
private String username;
private String email;
}
Both projects use similar annotations for entity classes, but Pig uses MyBatis-Plus annotations while eladmin uses JPA annotations. eladmin's approach may be more familiar to developers with a Spring Data background, while Pig's approach aligns with MyBatis-Plus conventions.
Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。 包含了基础的RBAC权限管理、 授权认证、网关管理、服务治理、审计日志等系统管理基础应用。 定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。 让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。 目标是建立一套金融级、高安全性的微服务解决方案。
Pros of SpringCloud
- More comprehensive microservices architecture demonstration
- Includes detailed documentation and diagrams for system design
- Implements a wider range of Spring Cloud components
Cons of SpringCloud
- Less frequent updates and maintenance compared to Pig
- May be more complex for beginners to understand and implement
- Lacks some modern features and integrations present in Pig
Code Comparison
SpringCloud (auth-server module):
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private UserDetailsService userDetailsService;
Pig (auth module):
@Configuration
@EnableAuthorizationServer
@RequiredArgsConstructor
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
private final DataSource dataSource;
private final PigUserDetailsService pigUserDetailsService;
Both projects use Spring Cloud for microservices architecture, but Pig demonstrates a more modern approach with Lombok annotations and constructor injection. SpringCloud provides a more traditional setup, which may be easier for developers familiar with older Spring versions. Pig also includes additional security features and integrations with tools like Swagger and MyBatis-Plus, making it more feature-rich for enterprise applications.
【低代码v2.0,一句话即可生成整个系统】企业级AI低代码平台,一键生成前后端代码甚至整个系统。 AI Skills 一句话画流程、设计表单、生成报表、大屏。内置 AI应用平台涵盖:AI聊天、知识库、流程编排、MCP插件等,兼容主流大模型。引领AI低代码「Skills 生成 → 在线配置 → 代码生成 → 手工合并->AI修改」开发模式,解决 Java 项目 90% 重复工作,提高效率又不失灵活。
Pros of JeecgBoot
- More comprehensive documentation and tutorials
- Stronger focus on low-code development and code generation
- Larger community and more frequent updates
Cons of JeecgBoot
- Steeper learning curve due to more complex architecture
- Potentially slower performance in some scenarios
- Less emphasis on microservices architecture
Code Comparison
JeecgBoot:
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {
@GetMapping("/hello")
public Result<String> hello() {
return Result.OK("Hello JeecgBoot!");
}
}
Pig:
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {
@GetMapping("/hello")
public R<String> hello() {
return R.ok("Hello Pig!");
}
}
Both projects use similar Spring Boot annotations and controller structures. JeecgBoot uses a custom Result class, while Pig uses R for wrapping responses. Pig also utilizes Lombok's @RequiredArgsConstructor for dependency injection, whereas JeecgBoot uses @Slf4j for logging.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ç³»ç»è¯´æ
- Pig æ¯åºäº Spring CloudãSpring BootãOAuth2 ç RBAC ä¼ä¸çº§å¿«éå¼åå¹³å°ï¼åæ¶æ¯æå¾®æå¡æ¶æåå使¶æã
- 认è¯ä¸å¿åºäº Spring Authorization Server è½å°ç产级 OAuth2 å®è·µï¼æ¯æææç ãå¯ç ãå·æ°ä»¤çç常è§ç»å½ä¸ææåºæ¯ã
- å½å弿ºçæ¬ä¿ç认è¯ãç½å ³ãç¨æ·æéãçæ§ã代ç çæå宿¶ä»»å¡çæ ¸å¿è½åï¼ç§»é¤äºåä¸çä¸çå¤ç§æ·ãæ°æ®æéãå¨æè·¯ç±ãæµç¨ãæ¯ä»ãå ¬ä¼å·ãæ¥è¡¨åç§»å¨ç«¯æå¡çæ©å±æ¨¡åã
- æä¾ Docker Compose æ¬å°ç¼æï¼æ¯æå¿«éå¯å¨ MySQLãRedisãNacos åä¸å¡æå¡ã
ä½¿ç¨ææ¡£
PIG æä¾äºå®æ´çé¨ç½²ä¸å¼åææ¡£ï¼wiki.pig4cloud.comï¼æ¶µçå¼åç¯å¢é ç½®ãæå¡ç«¯å¯å¨ãå端è¿è¡ãå¾®æå¡é¨ç½²ååä½é¨ç½²çå ³é®æ¥éª¤ã
å ¶ä»äº§å
å¿«éå¼å§
åºç¡ç¯å¢
- JDK 17+
- Maven 3.9+
- Docker å Docker Compose
- Node.js 20.19.0+ï¼è¿è¡
pig-uiå端æ¶éè¦ï¼
å¾®æå¡æ¨¡å¼
å¨é¡¹ç®æ ¹ç®å½æ§è¡å®æ´ç¼è¯ï¼åæå»ºå¹¶å¯å¨æ¬å°æå¡æ ï¼
mvn clean install -T 4 -Pcloud
docker compose build && docker compose up
æå¡å¯å¨åï¼é»è®¤éè¿ç½å
³ç«¯å£ 9999 访é®å端æ¥å£ï¼Nacos æ§å¶å°ç«¯å£ä¸º 8848ã
å使¨¡å¼
å使¨¡å¼éè¿ boot profile å¯ç¨ pig-boot 模åï¼
mvn clean install -T 4 -Pboot
docker compose -f docker-compose-boot.yml build && docker compose -f docker-compose-boot.yml up
å使å¡é»è®¤çå¬ 9999 端å£ã
æ ¸å¿ä¾èµ
| ä¾èµ | çæ¬ |
|---|---|
| Pig | 4.1.0 |
| JDK | 17+ |
| Spring Boot | 4.0.6 |
| Spring Cloud | 2025.1.2 |
| Spring Cloud Alibaba | 2025.1.0.0 |
| Spring Security OAuth2 Authorization Server | 7.0.5 |
| MyBatis Plus | 3.5.16 |
| Nacos Client | 3.1.2 |
| Druid | 1.2.28 |
| Vue | 3.5.34 |
| Element Plus | 2.13.7 |
| Vite | 5.4.21 |
模å说æ
pig-ui -- https://github.com/pig-mesh/pig-ui
pig
âââ pig-register -- Nacos Server [8848/9848/18080]
âââ pig-gateway -- Spring Cloud Gateway ç½å
³ [9999]
âââ pig-auth -- æææå¡ [3000]
âââ pig-upms -- éç¨ç¨æ·æéç®¡çæ¨¡å
â âââ pig-upms-api -- éç¨ç¨æ·æé管çå
Œ
± API
â âââ pig-upms-biz -- éç¨ç¨æ·æéä¸å¡æå¡ [4000]
âââ pig-common -- ç³»ç»å
Œ
±æ¨¡å
â âââ pig-common-bom -- å
¨å±ä¾èµçæ¬ç®¡ç
â âââ pig-common-core -- å
Œ
±å·¥å
·ç±»æ ¸å¿å
â âââ pig-common-data -- MyBatis Plus ä¸ç¼åæ©å±
â âââ pig-common-datasource -- å¨ææ°æ®æºå°è£
â âââ pig-common-log -- æ¥å¿æå¡
â âââ pig-common-oss -- æä»¶ä¸ä¼ å·¥å
·ç±»
â âââ pig-common-security -- å®å
¨å·¥å
·ç±»
â âââ pig-common-sentinel -- Sentinel ä¸å¼å¸¸å¤çå°è£
â âââ pig-common-swagger -- æ¥å£ææ¡£å°è£
â âââ pig-common-feign -- OpenFeign æ©å±å°è£
â âââ pig-common-excel -- Excel 导å
¥å¯¼åºå°è£
â âââ pig-common-xss -- XSS å®å
¨å°è£
âââ pig-visual -- å¯è§åæ¯ææå¡
â âââ pig-monitor -- æå¡çæ§ [5001]
â âââ pig-codegen -- å¾å½¢å代ç çæ [5002]
â âââ pig-quartz -- 宿¶ä»»å¡ç®¡çå° [5007]
âââ pig-boot -- å使¨¡å¼å¯å¨å¨ [9999]ï¼éè¿ `-Pboot` å¯ç¨
é 置说æ
- å¾®æå¡æ¨¡å¼ä½¿ç¨
cloudprofileï¼é»è®¤æ¿æ´»devç¯å¢é ç½®ã - å使¨¡å¼ä½¿ç¨
bootprofileï¼pig-boot模ååªå¨è¯¥ profile ä¸åä¸æå»ºã - ç½å
³è·¯ç±ç±
pig-gateway/src/main/resources/application.ymlå Nacos é 置维æ¤ï¼ä¸åä¾èµå¨æè·¯ç±è¡¨ã - é»è®¤æ°æ®åºèæ¬ä½äº
db/ï¼ä¸å¡è¡¨åå§åå°pigï¼Nacos é ç½®åå§åå°pig_configã - å
åå·²ç»ä¸ä¸º
com.pig4cloud.pigã
弿ºå ±å»º
弿ºåè®®
Pig 弿ºè½¯ä»¶éµå¾ª Apache 2.0 åè®®ï¼å 许åä¸ä½¿ç¨ï¼ä½å¡å¿ ä¿çç±»ä½è ãCopyright ä¿¡æ¯ã
å ¶ä»è¯´æ
- æ¬¢è¿æäº¤ PRï¼è¯·åºäºå½åå¼å忝æäº¤ã
- æ¬¢è¿æäº¤ Issueï¼è¯·åæ¸ æ¥é®é¢ç°è±¡ãå¼åç¯å¢åå¤ç°æ¥éª¤ã
- ä»£ç æ ¼å¼éµå¾ª Spring Java Formatï¼æäº¤åå¯å¨é¡¹ç®æ ¹ç®å½è¿è¡ï¼
mvn spring-javaformat:apply
Top Related Projects
Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于Spring Boot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
🔥 官方推荐 🔥 RuoYi-Vue 全新 Pro 版本,优化重构所有功能。基于 Spring Boot + MyBatis Plus + Vue & Element 实现的后台管理系统 + 微信小程序,支持 RBAC 动态权限、数据权限、SaaS 多租户、Flowable 工作流、三方登录、支付、短信、商城、CRM、ERP、MES、IM、AI 大模型、IoT 物联网等功能。你的 ⭐️ Star ⭐️,是作者生发的动力!
eladmin jpa 版本:项目基于 Spring Boot 2.7.18、 Jpa、 Spring Security、Redis、Vue的前后端分离的后台管理系统,项目采用分模块开发方式, 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前后端代码,支持动态路由
Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。 包含了基础的RBAC权限管理、授权认证、网关管理、服务治理、审计日志等系统管理基础应用。 定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。 让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。 目标是建立一套金融级、高安全性的微服务解决方案。
【低代码v2.0,一句话即可生成整个系统】企业级AI低代码平台,一键生成前后端代码甚至整个系统。 AI Skills 一句话画流程、设计表单、生成报表、大屏。内置 AI应用平台涵盖:AI聊天、知识库、流程编排、MCP插件等,兼容主流大模型。引领AI低代码「Skills 生成 → 在线配置 → 代码生成 → 手工合并->AI修改」开发模式,解决 Java 项目 90% 重复工作,提高效率又不失灵活。
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot