Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b6f8da6c2 | |||
| 9b2d90d290 | |||
| d40c586299 | |||
| 66df4488c0 | |||
| a3470a3b7a | |||
| a320b6cd16 |
@@ -4,7 +4,7 @@ services:
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
- "host.docker.internal:host-gateway"
|
||||
environment:
|
||||
KAFKA_NODE_ID: 1
|
||||
KAFKA_PROCESS_ROLES: broker,controller
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
||||
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
|
||||
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
||||
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
||||
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
|
||||
kafdrop:
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
- kafka
|
||||
network_mode: host
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
- "host.docker.internal:host-gateway"
|
||||
command: sh -c "sleep 5 && exec ./start-app"
|
||||
environment:
|
||||
KAFKA_BROKERCONNECT: 'localhost:9092'
|
||||
KAFKA_BROKERCONNECT: "localhost:9092"
|
||||
|
||||
@@ -11,5 +11,5 @@ services:
|
||||
- ../..:/workspaces:cached
|
||||
network_mode: host
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
command: sleep infinity
|
||||
- "host.docker.internal:host-gateway"
|
||||
command: sleep infinity
|
||||
|
||||
@@ -5,9 +5,9 @@ services:
|
||||
- POSTGRES_PASSWORD=password
|
||||
network_mode: host
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
- "host.docker.internal:host-gateway"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
postgres_data:
|
||||
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
@@ -19,15 +19,15 @@ jobs:
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
distribution: "temurin"
|
||||
java-version: "25"
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.demonkernel.io.vn
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.ACCESS_TOKEN }}
|
||||
password: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
|
||||
- name: Commit & Push Changes
|
||||
env:
|
||||
MY_PAT_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
MY_PAT_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git config --global user.name "gitea-actions"
|
||||
@@ -82,4 +82,4 @@ jobs:
|
||||
git commit -m "chore: release [ci skip]"
|
||||
|
||||
git push origin HEAD:${{ github.ref_name }}
|
||||
fi
|
||||
fi
|
||||
|
||||
+2
-1
@@ -45,4 +45,5 @@ nb-configuration.xml
|
||||
.certs/
|
||||
|
||||
# NodeJS
|
||||
/node_modules
|
||||
/node_modules
|
||||
/.pnpm-store
|
||||
@@ -0,0 +1,13 @@
|
||||
# [1.0.0-dev.7](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.0.0-dev.6...v1.0.0-dev.7) (2026-03-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* better image push ([66df448](https://git.demonkernel.io.vn/FoodSurf/backend/commit/66df4488c0fd9b9bda1df72877d7ab6c4a075d84))
|
||||
|
||||
# [1.0.0-dev.6](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.0.0-dev.5...v1.0.0-dev.6) (2026-03-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* test ([a320b6c](https://git.demonkernel.io.vn/FoodSurf/backend/commit/a320b6cd162be6f09381698ee1551e7575c33c1c))
|
||||
+16
-7
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>account-service</artifactId>
|
||||
@@ -10,9 +14,11 @@
|
||||
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<project.reporting.outputEncoding
|
||||
>UTF-8</project.reporting.outputEncoding>
|
||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||
<quarkus.platform.group-id
|
||||
>io.quarkus.platform</quarkus.platform.group-id>
|
||||
<quarkus.platform.version>3.32.4</quarkus.platform.version>
|
||||
<skipITs>true</skipITs>
|
||||
<surefire-plugin.version>3.5.4</surefire-plugin.version>
|
||||
@@ -102,7 +108,8 @@
|
||||
<configuration>
|
||||
<argLine>@{argLine}</argLine>
|
||||
<systemPropertyVariables>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<java.util.logging.manager
|
||||
>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<maven.home>${maven.home}</maven.home>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
@@ -121,8 +128,10 @@
|
||||
<configuration>
|
||||
<argLine>@{argLine}</argLine>
|
||||
<systemPropertyVariables>
|
||||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<native.image.path
|
||||
>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||
<java.util.logging.manager
|
||||
>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<maven.home>${maven.home}</maven.home>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
|
||||
@@ -2,46 +2,46 @@ package com.drinkool;
|
||||
|
||||
import com.drinkool.dtos.*;
|
||||
import com.drinkool.models.Customer;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.*;
|
||||
|
||||
@Path("/api")
|
||||
public class RestAPI {
|
||||
@POST
|
||||
@Path("/signup")
|
||||
@Transactional
|
||||
public Response signup(Signup input) {
|
||||
Customer newCustomer = new Customer();
|
||||
|
||||
newCustomer.signup(input.name, input.phone, input.password);
|
||||
@POST
|
||||
@Path("/signup")
|
||||
@Transactional
|
||||
public Response signup(Signup input) {
|
||||
Customer newCustomer = new Customer();
|
||||
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
newCustomer.signup(input.name, input.phone, input.password);
|
||||
|
||||
@POST
|
||||
@Path("/quickSignup")
|
||||
@Transactional
|
||||
public Response quickSignup(QuickSignup input) {
|
||||
Customer newCustomer = new Customer();
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
|
||||
newCustomer.signup(input.phone);
|
||||
@POST
|
||||
@Path("/quickSignup")
|
||||
@Transactional
|
||||
public Response quickSignup(QuickSignup input) {
|
||||
Customer newCustomer = new Customer();
|
||||
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
newCustomer.signup(input.phone);
|
||||
|
||||
@POST
|
||||
@Path("/login")
|
||||
public Response login(Login input) {
|
||||
Customer customer = Customer.find("phone", input.phone).firstResult();
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
|
||||
if (customer == null)
|
||||
throw new BadRequestException("InvalidPhoneNumber");
|
||||
@POST
|
||||
@Path("/login")
|
||||
public Response login(Login input) {
|
||||
Customer customer = Customer.find("phone", input.phone).firstResult();
|
||||
|
||||
if (!customer.login(input.password))
|
||||
throw new BadRequestException("InvalidPassword");
|
||||
if (customer == null) throw new BadRequestException("InvalidPhoneNumber");
|
||||
|
||||
return Response.accepted().build();
|
||||
}
|
||||
if (!customer.login(input.password)) throw new BadRequestException(
|
||||
"InvalidPassword"
|
||||
);
|
||||
|
||||
return Response.accepted().build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.drinkool.dtos;
|
||||
|
||||
public class Login {
|
||||
public String phone;
|
||||
public String password;
|
||||
|
||||
public String phone;
|
||||
public String password;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.drinkool.dtos;
|
||||
|
||||
public class QuickSignup {
|
||||
public String phone;
|
||||
|
||||
public String phone;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.drinkool.dtos;
|
||||
|
||||
public class Signup {
|
||||
public String name;
|
||||
public String phone;
|
||||
public String password;
|
||||
|
||||
public String name;
|
||||
public String phone;
|
||||
public String password;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,4 @@ import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "customer")
|
||||
public class Customer extends User {
|
||||
|
||||
}
|
||||
public class Customer extends User {}
|
||||
|
||||
@@ -1,56 +1,54 @@
|
||||
package com.drinkool.models;
|
||||
|
||||
import com.drinkool.utils.PhoneValidator;
|
||||
import com.password4j.Password;
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.transaction.*;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.drinkool.utils.PhoneValidator;
|
||||
import com.password4j.Password;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "users")
|
||||
public abstract class User extends PanacheEntity {
|
||||
@Column(nullable = false)
|
||||
public String name;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String phone;
|
||||
@Column(nullable = false)
|
||||
public String name;
|
||||
|
||||
@Column(nullable = false, length = 1024)
|
||||
public String hashedPassword;
|
||||
@Column(nullable = false)
|
||||
public String phone;
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
@Column(nullable = false, length = 1024)
|
||||
public String hashedPassword;
|
||||
|
||||
@Transactional
|
||||
public void signup(String phone) {
|
||||
this.signup(phone, phone, UUID.randomUUID().toString().substring(0, 32));
|
||||
}
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void signup(String name, String phone, String rawPassword) {
|
||||
this.name = name;
|
||||
@Transactional
|
||||
public void signup(String phone) {
|
||||
this.signup(phone, phone, UUID.randomUUID().toString().substring(0, 32));
|
||||
}
|
||||
|
||||
if (!PhoneValidator.isValidInternationalPhone(phone)) {
|
||||
throw new BadRequestException("InvalidPhoneNumber");
|
||||
} else {
|
||||
this.phone = phone;
|
||||
}
|
||||
@Transactional
|
||||
public void signup(String name, String phone, String rawPassword) {
|
||||
this.name = name;
|
||||
|
||||
this.hashedPassword = Password.hash(rawPassword).withArgon2().getResult();
|
||||
if (!PhoneValidator.isValidInternationalPhone(phone)) {
|
||||
throw new BadRequestException("InvalidPhoneNumber");
|
||||
} else {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
this.persist();
|
||||
}
|
||||
this.hashedPassword = Password.hash(rawPassword).withArgon2().getResult();
|
||||
|
||||
public boolean login(String rawPassword) {
|
||||
if (this.hashedPassword == null)
|
||||
return false;
|
||||
this.persist();
|
||||
}
|
||||
|
||||
return Password.check(rawPassword, this.hashedPassword).withArgon2();
|
||||
}
|
||||
}
|
||||
public boolean login(String rawPassword) {
|
||||
if (this.hashedPassword == null) return false;
|
||||
|
||||
return Password.check(rawPassword, this.hashedPassword).withArgon2();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,17 @@ import com.google.i18n.phonenumbers.*;
|
||||
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
|
||||
|
||||
public class PhoneValidator {
|
||||
private static final PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
|
||||
|
||||
public static boolean isValidInternationalPhone(String phone) {
|
||||
try {
|
||||
PhoneNumber numberProto = phoneUtil.parse(phone, "VN");
|
||||
private static final PhoneNumberUtil phoneUtil =
|
||||
PhoneNumberUtil.getInstance();
|
||||
|
||||
return phoneUtil.isValidNumber(numberProto);
|
||||
} catch (NumberParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isValidInternationalPhone(String phone) {
|
||||
try {
|
||||
PhoneNumber numberProto = phoneUtil.parse(phone, "VN");
|
||||
|
||||
return phoneUtil.isValidNumber(numberProto);
|
||||
} catch (NumberParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ quarkus.hibernate-orm.database.generation=update
|
||||
|
||||
# URL của Gitea Registry (thường là gitea.yourdomain.com)
|
||||
quarkus.container-image.registry=git.demonkernel.io.vn
|
||||
quarkus.container-image.group=foodsurf/backend
|
||||
quarkus.container-image.name=auth-service
|
||||
quarkus.container-image.group=foodsurf
|
||||
quarkus.container-image.name=account-service
|
||||
quarkus.container-image.push=true
|
||||
quarkus.container-image.build=true
|
||||
quarkus.container-image.builder=docker
|
||||
quarkus.container-image.builder=docker
|
||||
quarkus.container-image.tag=latest
|
||||
@@ -4,5 +4,5 @@ import io.quarkus.test.junit.QuarkusIntegrationTest;
|
||||
|
||||
@QuarkusIntegrationTest
|
||||
class GreetingResourceIT extends GreetingResourceTest {
|
||||
// Execute the same tests but in packaged mode.
|
||||
// Execute the same tests but in packaged mode.
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package com.drinkool;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@QuarkusTest
|
||||
class GreetingResourceTest {
|
||||
@Test
|
||||
void testHelloEndpoint() {
|
||||
given()
|
||||
.when().get("/hello")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(is("Hello from Quarkus REST"));
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
void testHelloEndpoint() {
|
||||
given()
|
||||
.when()
|
||||
.get("/hello")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(is("Hello from Quarkus REST"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.0.0-dev.7</version>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
@@ -27,4 +29,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user