Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
526 changes: 526 additions & 0 deletions .github/workflows/maven.yml

Large diffs are not rendered by default.

174 changes: 174 additions & 0 deletions .github/workflows/pr-label-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: PR Label Management

on:
pull_request:
types: [opened, reopened, synchronize]
pull_request_review:
types: [submitted]

jobs:
manage-labels:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Add Review label on PR creation
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Add Review label to the PR
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['Review']
});

console.log(`Added Review label to PR #${context.payload.pull_request.number}`);

// Extract related issue numbers from PR title and body
const prText = `${context.payload.pull_request.title} ${context.payload.pull_request.body || ''}`;
const issuePattern = /#(\d+)/g;
const relatedIssues = new Set();
let match;

while ((match = issuePattern.exec(prText)) !== null) {
relatedIssues.add(match[1]);
}

// Also check commit messages for issue references
const commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});

for (const commit of commits.data) {
const commitMessage = commit.commit.message;
while ((match = issuePattern.exec(commitMessage)) !== null) {
relatedIssues.add(match[1]);
}
}

// Add Review label to all related issues
for (const issueNumber of relatedIssues) {
try {
// Check if issue exists
await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber)
});

// Add Review label to the issue
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber),
labels: ['Review']
});

console.log(`Added Review label to related issue #${issueNumber}`);
} catch (error) {
console.log(`Error processing issue #${issueNumber}: ${error.message}`);
}
}

- name: Handle PR approval
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;

// Remove Review label and add Verified label to the PR
try {
// First try to remove the Review label
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'Review'
});
console.log(`Removed Review label from PR #${prNumber}`);
} catch (error) {
console.log(`Note: Review label might not exist on PR #${prNumber}: ${error.message}`);
}

// Add Verified label to the PR
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['Verified']
});
console.log(`Added Verified label to PR #${prNumber}`);

// Extract related issue numbers from PR title and body
const prText = `${context.payload.pull_request.title} ${context.payload.pull_request.body || ''}`;
const issuePattern = /#(\d+)/g;
const relatedIssues = new Set();
let match;

while ((match = issuePattern.exec(prText)) !== null) {
relatedIssues.add(match[1]);
}

// Also check commit messages for issue references
const commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});

for (const commit of commits.data) {
const commitMessage = commit.commit.message;
while ((match = issuePattern.exec(commitMessage)) !== null) {
relatedIssues.add(match[1]);
}
}

// Update labels on all related issues
for (const issueNumber of relatedIssues) {
try {
// Check if issue exists
await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber)
});

// Try to remove Review label from the issue
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber),
name: 'Review'
});
console.log(`Removed Review label from related issue #${issueNumber}`);
} catch (error) {
console.log(`Note: Review label might not exist on issue #${issueNumber}: ${error.message}`);
}

// Add Verified label to the issue
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber),
labels: ['Verified']
});
console.log(`Added Verified label to related issue #${issueNumber}`);
} catch (error) {
console.log(`Error processing issue #${issueNumber}: ${error.message}`);
}
}
6 changes: 6 additions & 0 deletions ts-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<!-- Hibernate Validator - Bean Validation provider -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.5.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
Expand Down
10 changes: 5 additions & 5 deletions ts-common/src/main/java/edu/fudan/common/entity/Contacts.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public boolean equals(Object obj) {
return false;
}
Contacts other = (Contacts) obj;
return name.equals(other.getName())
&& accountId .equals( other.getAccountId() )
&& documentNumber.equals(other.getDocumentNumber())
&& phoneNumber.equals(other.getPhoneNumber())
&& documentType == other.getDocumentType();
return name.equals(other.name)
&& accountId .equals( other.accountId )
&& documentNumber.equals(other.documentNumber)
&& phoneNumber.equals(other.phoneNumber)
&& documentType == other.documentType;
}

@Override
Expand Down
36 changes: 34 additions & 2 deletions ts-common/src/main/java/edu/fudan/common/entity/Food.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
package edu.fudan.common.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class Food implements Serializable{

private String foodName;
private double price;
public Food(){
//Default Constructor

// Getters and Setters
public String getFoodName() {
return foodName;
}

public void setFoodName(String foodName) {
this.foodName = foodName;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Food food = (Food) o;
return Double.compare(food.price, price) == 0 &&
Objects.equals(foodName, food.foodName);
}

@Override
public int hashCode() {
return Objects.hash(foodName, price);
}
}
70 changes: 67 additions & 3 deletions ts-common/src/main/java/edu/fudan/common/entity/FoodOrder.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package edu.fudan.common.entity;

import lombok.Data;

import java.util.UUID;

/**
* @author fdse
*/
@Data
public class FoodOrder {

private String id;
Expand All @@ -31,4 +28,71 @@ public FoodOrder(){
//Default Constructor
}

public FoodOrder(String id, String orderId, int foodType, String stationName,
String storeName, String foodName, double price) {
this.id = id;
this.orderId = orderId;
this.foodType = foodType;
this.stationName = stationName;
this.storeName = storeName;
this.foodName = foodName;
this.price = price;
}

// Getters and Setters
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getOrderId() {
return orderId;
}

public void setOrderId(String orderId) {
this.orderId = orderId;
}

public int getFoodType() {
return foodType;
}

public void setFoodType(int foodType) {
this.foodType = foodType;
}

public String getStationName() {
return stationName;
}

public void setStationName(String stationName) {
this.stationName = stationName;
}

public String getStoreName() {
return storeName;
}

public void setStoreName(String storeName) {
this.storeName = storeName;
}

public String getFoodName() {
return foodName;
}

public void setFoodName(String foodName) {
this.foodName = foodName;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}
}
Loading