Commit 92f03e22 authored by LeMinhChien-06's avatar LeMinhChien-06

200

parent aa41380b
Pipeline #5847 failed with stages
/mvnw text eol=lf
*.cmd text eol=crlf
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.3.2
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
}
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>nextads-service-be</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>nextads-service-be</name>
<description>nextads-service-be</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<!-- Jackson for JSON processing -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- Lombok for reducing boilerplate -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- &lt;!&ndash; Redis&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; Redis&ndash;&gt;-->
<!-- Swagger -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.6</version>
</dependency>
<!-- Swagger -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.example.nextadsservicebe;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class NextadsServiceBeApplication {
public static void main(String[] args) {
SpringApplication.run(NextadsServiceBeApplication.class, args);
}
}
package com.example.nextadsservicebe.auth;
public class AdminGuard {
}
package com.example.nextadsservicebe.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PageResponse<T> {
private int pageIndex;
private int pageSize;
private int totalPages;
private int totalItems;
private T items;
public PageResponse(int pageIndex, int pageSize, int totalItems, T items) {
this.pageIndex = pageIndex;
this.pageSize = pageSize;
this.totalPages = (int) Math.ceil((double) totalItems / pageSize);
this.totalItems = totalItems;
this.items = items;
}
}
package com.example.nextadsservicebe.config;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.util.List;
@Configuration
public class AppConfig {
private static final String[] CORS_ALLOWED_ORIGINS = {
"http://localhost:3000",
// "http://example.com"
};
private static final String[] CORS_ALLOWED_METHODS = {
"GET", "PUT", "POST", "DELETE", "UPDATE", "OPTIONS"
};
private static final String[] CORS_ALLOWED_HEADERS = {
"X-Requested-With", "X-HTTP-Method-Override",
"Content-Type", "Accept", "Observe", "Authorization",
"X-Lang", "Access-Control-Allow-Origin", "X-Channel"
};
@Bean
public FilterRegistrationBean<CorsFilter> corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.setAllowedOrigins(List.of(CORS_ALLOWED_ORIGINS)); // domain
config.setAllowedMethods(List.of(CORS_ALLOWED_METHODS)); // Các phương thức được phép
config.setAllowedHeaders(List.of(CORS_ALLOWED_HEADERS)); // Các header được phép
source.registerCorsConfiguration("/**", config); // Áp dụng CORS cho tất cả các endpoint
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE); // có thể set = 0
return bean;
}
}
package com.example.nextadsservicebe.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class StaticResourceConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/uploads/**")
.addResourceLocations("file:uploads/");
}
}
package com.example.nextadsservicebe.config;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
//@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI(@Value("${open.api.title}") String title,
@Value("${open.api.version}") String version,
@Value("${open.api.description}") String description,
@Value("${open.api.serverUrl}") String serverUrl,
@Value("${open.api.serverName}") String serverName
) {
return new OpenAPI().info(new Info().title(title)
.version(version)
.description(description)
.license(new License().name("Develop by XTEL").url("https://xtel.vn")))
.servers(List.of(new Server().url(serverUrl).description(serverName)));
// .components(
// new Components()
// .addSecuritySchemes(
// "bearerAuth",
// new SecurityScheme()
// .type(SecurityScheme.Type.HTTP)
// .scheme("bearer")
// .bearerFormat("JWT")))
// .security(List.of(new SecurityRequirement().addList("bearerAuth")));
}
@Bean
public GroupedOpenApi groupedOpenApi() {
return GroupedOpenApi.builder()
.group("api-service")
.packagesToScan("com.example.nextadsservicebe.controller")
// .pathsToMatch("api/**")
.build();
}
}
package com.example.nextadsservicebe.config.log;
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.StreamUtils;
import java.io.*;
public class CachedBodyHttpServletRequest extends HttpServletRequestWrapper {
private final byte[] cachedBody;
public CachedBodyHttpServletRequest(HttpServletRequest request) throws IOException {
super(request);
InputStream requestInputStream = request.getInputStream();
this.cachedBody = StreamUtils.copyToByteArray(requestInputStream);
}
@Override
public ServletInputStream getInputStream() throws IOException {
return new CachedBodyServletInputStream(cachedBody);
}
@Override
public BufferedReader getReader() throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(cachedBody);
return new BufferedReader(new InputStreamReader(byteArrayInputStream));
}
public byte[] getCachedBody() {
return cachedBody;
}
private static class CachedBodyServletInputStream extends ServletInputStream {
private final ByteArrayInputStream inputStream;
public CachedBodyServletInputStream(byte[] cachedBody) {
this.inputStream = new ByteArrayInputStream(cachedBody);
}
@Override
public int read() throws IOException {
return inputStream.read();
}
@Override
public boolean isFinished() {
return inputStream.available() == 0;
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setReadListener(jakarta.servlet.ReadListener readListener) {
throw new UnsupportedOperationException();
}
}
}
\ No newline at end of file
package com.example.nextadsservicebe.config.log;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
//@Slf4j
public class RequestLoggingFilter implements jakarta.servlet.Filter {
private static final Logger log = LoggerFactory.getLogger(RequestLoggingFilter.class);
private static final String RESET = "\u001B[0m";
private static final String BLUE = "\u001B[34m";
private static final String GREEN = "\u001B[32m";
private static final String TRACE_ID = "traceId";
private final ObjectMapper objectMapper;
private final Set<String> sensitiveFields = new HashSet<>(Arrays.asList("password", "token"));
public RequestLoggingFilter(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String traceId = UUID.randomUUID().toString();
MDC.put(TRACE_ID, traceId);
CachedBodyHttpServletRequest cachedRequest = new CachedBodyHttpServletRequest(httpRequest);
ResponseBodyCaptureWrapper responseWrapper = new ResponseBodyCaptureWrapper(httpResponse);
long startTime = System.currentTimeMillis();
try {
logRequest(cachedRequest);
chain.doFilter(cachedRequest, responseWrapper);
} finally {
long duration = System.currentTimeMillis() - startTime;
logResponse(cachedRequest, responseWrapper, duration);
MDC.clear();
}
}
private void logRequest(CachedBodyHttpServletRequest request) throws IOException {
String queryString = request.getQueryString() == null ? "" : "?" + request.getQueryString();
String url = request.getRequestURL().toString() + queryString;
String method = request.getMethod();
String contentType = request.getContentType();
Map<String, String> headers = getHeaders(request);
Map<String, String> params = getRequestParams(request);
String body = new String(request.getCachedBody(), StandardCharsets.UTF_8);
String maskedBody = maskSensitiveData(body, contentType);
log.info(GREEN + "REQ: traceId={}, method={}, url={}, headers={}, params={}, body={}" + RESET,
MDC.get(TRACE_ID), method, url, headers, params, maskedBody);
}
private void logResponse(HttpServletRequest request, ResponseBodyCaptureWrapper response, long duration) {
String responseBody = new String(response.getCapturedBody(), StandardCharsets.UTF_8);
String maskedResponseBody = maskSensitiveData(responseBody, response.getContentType());
log.info(BLUE + "RES: traceId={}, method={}, url={}, status={}, body={}, duration={}ms" + RESET,
MDC.get(TRACE_ID), request.getMethod(), request.getRequestURL(), response.getStatus(),
maskedResponseBody, duration);
}
private Map<String, String> getHeaders(HttpServletRequest request) {
Map<String, String> headers = new HashMap<>();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
headers.put(headerName, maskSensitiveHeader(headerName, headerValue));
}
return headers;
}
private String maskSensitiveHeader(String headerName, String headerValue) {
if (headerName.toLowerCase().contains("authorization")) {
return "********";
}
return headerValue;
}
private Map<String, String> getRequestParams(HttpServletRequest request) {
Map<String, String> params = new HashMap<>();
Enumeration<String> paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String paramName = paramNames.nextElement();
String paramValue = request.getParameter(paramName);
params.put(paramName, maskSensitiveParam(paramName, paramValue));
}
return params;
}
private String maskSensitiveParam(String paramName, String paramValue) {
if (sensitiveFields.contains(paramName.toLowerCase())) {
return "********";
}
return paramValue;
}
private String maskSensitiveData(String body, String contentType) {
if (contentType != null && contentType.startsWith(MediaType.APPLICATION_JSON_VALUE)) {
try {
JsonNode jsonNode = objectMapper.readTree(body);
maskSensitiveJsonFields(jsonNode);
return objectMapper.writeValueAsString(jsonNode);
} catch (IOException e) {
log.warn("Failed to parse JSON body for masking", e);
return "{\"error\": \"Failed to parse JSON body\"}";
}
}
return body;
}
private void maskSensitiveJsonFields(JsonNode jsonNode) {
if (jsonNode.isObject()) {
ObjectNode objectNode = (ObjectNode) jsonNode;
objectNode.fields().forEachRemaining(entry -> {
String fieldName = entry.getKey();
JsonNode fieldValue = entry.getValue();
if (sensitiveFields.contains(fieldName.toLowerCase())) {
objectNode.put(fieldName, "********");
} else if (fieldValue.isObject() || fieldValue.isArray()) {
maskSensitiveJsonFields(fieldValue);
}
});
} else if (jsonNode.isArray()) {
jsonNode.forEach(this::maskSensitiveJsonFields);
}
}
}
\ No newline at end of file
package com.example.nextadsservicebe.config.log;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.WriteListener;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;
import java.io.*;
public class ResponseBodyCaptureWrapper extends HttpServletResponseWrapper {
private final ByteArrayOutputStream capturedBody = new ByteArrayOutputStream();
private PrintWriter writer;
public ResponseBodyCaptureWrapper(HttpServletResponse response) {
super(response);
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
return new CachedBodyServletOutputStream(capturedBody);
}
@Override
public PrintWriter getWriter() throws IOException {
if (writer == null) {
writer = new PrintWriter(new OutputStreamWriter(capturedBody, getCharacterEncoding()));
}
return writer;
}
public byte[] getCapturedBody() {
if (writer != null) {
writer.flush();
}
return capturedBody.toByteArray();
}
private static class CachedBodyServletOutputStream extends ServletOutputStream {
private final ByteArrayOutputStream outputStream;
public CachedBodyServletOutputStream(ByteArrayOutputStream outputStream) {
this.outputStream = outputStream;
}
@Override
public void write(int b) throws IOException {
outputStream.write(b);
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setWriteListener(WriteListener writeListener) {
throw new UnsupportedOperationException();
}
}
}
package com.example.nextadsservicebe.controller;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/a")
public class a {
@Operation(summary = "Get user by ID", description = "Returns user details")
@GetMapping
public String b() {
return "chien";
}
}
package com.example.nextadsservicebe.dto.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ResponseData<T> {
private final int status;
private final String message;
@JsonInclude(JsonInclude.Include.NON_NULL)
private T data;
/**
* Response data for the API to retrieve data successfully. For GET, POST only
*
* @param status
* @param message
* @param data
*/
public ResponseData(int status, String message, T data) {
this.status = status;
this.message = message;
this.data = data;
}
/**
* Response data when the API executes successfully or getting error. For PUT, PATCH, DELETE
*
* @param status
* @param message
*/
public ResponseData(int status, String message) {
this.status = status;
this.message = message;
}
}
package com.example.nextadsservicebe.dto.response;
public class ResponseError extends ResponseData {
public ResponseError(int status, String message) {
super(status, message);
}
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@Table(name = "achievements")
public class Achievements {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "homePageId", nullable = false)
private Integer homePageId;
@Column(nullable = false)
private Integer count;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "achievements", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<AchievementsTranslate> achievementsTranslate;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "achievements_translate")
public class AchievementsTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String title;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY, optional = false) // optional = false: bắt buộc phải có Achievement
@JoinColumn(name = "achievementsId", nullable = false)
private Achievements achievements;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "benefit")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Benefit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "homePageId", nullable = false)
private Integer homePageId;
@Column(name = "image", nullable = false)
private String image;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "benefit", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<BenefitTranslate> benefitTranslate;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "benefit_translate")
public class BenefitTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "lang_code")
private String langCode;
@Column(name = "description")
private String description;
@Column(name = "title")
private String title;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "benefitId", nullable = false)
private Benefit benefit;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "campaign")
public class Campaign {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "date_from", nullable = false)
private LocalDateTime dateFrom;
@Column(name = "date_to", nullable = false)
private LocalDateTime dateTo;
@Column(name = "address", nullable = false)
private String address;
@Column(name = "config_file", nullable = false)
private String configFile;
@Column(name = "qrcode", nullable = false)
private String qrcode;
@Column(name = "link", nullable = false)
private String link;
@Column(name = "join_person", nullable = false)
private Integer joinPerson;
@Column(name = "turn_play", nullable = false)
private Integer turnPlay;
@Column(name = "turn_played", nullable = false)
private Integer turnPlayed;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameCode", referencedColumnName = "code")
private Game game;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "customerId", nullable = false)
private Customer customer;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "case_study")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CaseStudy {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String slug;
private String image;
@Column(name = "date_from", nullable = false)
private LocalDateTime dateFrom;
@Column(name = "date_to", nullable = false)
private LocalDateTime dateTo;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "caseStudy", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<CaseStudyTranslate> caseStudyTranslates;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "customerId", nullable = false)
private Customer customer;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "case_study_translate")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CaseStudyTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long Id;
private String name;
private String content;
@Column(name = "lang_code")
private String lang_code;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "caseStudyId", nullable = false)
private CaseStudy caseStudy;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.contact.Status;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
@Entity
@Table(name = "contact")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Contact {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String fullName;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String email;
@Column(name = "type_code", nullable = false)
private String typeCode;
@Column(name = "company_name", nullable = false)
private String companyName;
@Column(name = "gameId", nullable = true)
private Long gameId;
@Column(name = "updated_by", nullable = true)
private Integer updatedBy;
@Column(nullable = false)
private String message;
@Enumerated(EnumType.ORDINAL)
private Status status;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "updated_by", referencedColumnName = "id", insertable = false, updatable = false)
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameId", referencedColumnName = "id", insertable = false, updatable = false)
private Game game;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "content_mail")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ContentMail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String title;
private String content;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "settingMailId", nullable = false)
private SettingMail settingMail;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.IsActive;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "customer")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String code;
private String name;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String email;
@Column(nullable = false)
private String image;
@Column(nullable = false)
private String address;
@Column(nullable = false)
private String password;
@Column(name = "company_name", nullable = false)
private String companyName;
@Column(name = "number_turns", nullable = false)
private Long numberTurns; // so luot quay
@Column(name = "reset_token", nullable = false)
private String resetToken;
@Column(name = "expires_time")
private LocalDateTime expiresTime;
@Enumerated(EnumType.ORDINAL)
private IsActive isActive;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Campaign> campaigns;
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<CaseStudy> caseStudies;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "galaxy")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Galaxy {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private Integer homePageId;
@Column(nullable = false)
private String image;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "galaxy", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<GalaxyTranslate> galaxyTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "galaxy_translate")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GalaxyTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
private String description;
@Column(name = "lang_code")
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "galaxyId", nullable = false)
private Galaxy galaxy;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "game")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Game {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NaturalId // Hibernate hiểu đây là một khóa tự nhiên
@Column(unique = true, nullable = false)
private String code;
@Column(nullable = false)
private String slug;
@Column(nullable = false)
private Integer rate;
@Column(nullable = false)
private Integer vote;
@Column(nullable = false)
private Integer price;
@Column(nullable = false)
private String iframe;
@Column(nullable = false)
private String thumbnail;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "is_hot", nullable = false)
private Integer isHot;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameTranslate> gameTranslate;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Contact> contact;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Campaign> campaign;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameHasType> gameHasTypes;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameHasCategory> gameHasCategories;
@OneToMany(mappedBy = "game", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameHasPlatform> gameHasPlatforms;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "updated_by", referencedColumnName = "id", insertable = false, updatable = false)
private User user;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_category")
public class GameCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String slug;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "gameCategory", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameCategoryTranslate> gameCategoryTranslates;
@OneToMany(mappedBy = "gameCategory", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameHasCategory> gameHasCategories;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_category_translate")
public class GameCategoryTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "title", nullable = false)
private String title;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameCategoryId")
private GameCategory gameCategory;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_has_category")
public class GameHasCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameId", nullable = false)
private Game game;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameCategoryId", nullable = false)
private GameCategory gameCategory;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_has_platform")
public class GameHasPlatform {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "game_id", nullable = false)
private Game game;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "platform_id", nullable = false)
private Platform platform;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_has_type")
public class GameHasType {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "game_id", nullable = false)
private Game game;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "game_type_id", nullable = false)
private GameType gameType;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.IsHost;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "game_package")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GamePackage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String image;
private Integer price;
@Enumerated(EnumType.ORDINAL)
private IsHost isHost;
@Column(nullable = false)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "gamePackage", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<GamePackageTranslate> gamePackageTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "game_package_translate")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GamePackageTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String content;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String description;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gamePackageId", nullable = false)
private GamePackage gamePackage;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_translate")
public class GameTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String content;
@Column(nullable = false)
private String description;
@Column(name = "lang_code", nullable = false)
private String langCode;
@Column(name = "meta_keyword", nullable = false)
private String metaKeyword;
@Column(name = "meta_description", nullable = false)
private String metaDescription;
@Column(name = "meta_title", nullable = false)
private String metaTitle;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameId")
private Game game;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_type")
public class GameType {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String slug;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "gameType", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameTypeTranslate> gameTypeTranslates;
@OneToMany(mappedBy = "gameType", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<GameHasType> gameHasTypes;
}
\ No newline at end of file
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "game_type_translate")
public class GameTypeTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String title;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gameTypeId")
private GameType gameType;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "general")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class General {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String favicon;
@Column(nullable = false)
private String logo;
@Column(nullable = false)
private String email;
@Column(nullable = false)
private String link;
@Column(nullable = false)
private String map;
@Column(name = "add_header", nullable = false)
private String addHeader;
@Column(name = "add_body", nullable = false)
private String addBody;
@Column(name = "src_analytics", nullable = false)
private String srcAnalytics;
@Column(name = "inner_analytics", nullable = false)
private String innerAnalytics;
@Column(name = "business_license", nullable = false)
private String businessLicense;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "general", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<GeneralTranslate> generalTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "general_translate")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GeneralTranslate {
@Id
private Integer id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String address;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "generalId", nullable = false)
private General general;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "home_page")
public class HomePage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String slug;
@Column(nullable = false)
private String image;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "homePage", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<HomePageTranslate> homePageTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "home_page_translate")
public class HomePageTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String description;
@Column(nullable = false)
private String slogun;
@Column(name = "meta_title", nullable = false)
private String metaTitle;
@Column(name = "lang_code", nullable = false)
private String langCode;
@Column(name = "meta_keyword", nullable = false)
private String metaKeyword;
@Column(name = "meta_description", nullable = false)
private String metaDescription;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "homePageId", nullable = false)
private HomePage homePage;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.IsHost;
import com.example.nextadsservicebe.enums.Status;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "news")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class News {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String slug;
@Column(nullable = false)
private String image;
@Column(nullable = false)
private Status status;
@Enumerated(EnumType.ORDINAL)
@Column(name = "is_hot", nullable = false)
private IsHost isHot;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "news", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JsonIgnore
private List<NewsTranslate> newsTranslate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "updated_by", referencedColumnName = "id", insertable = false, updatable = false)
private User user;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "news_translate")
public class NewsTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String content;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String description;
@Column(name = "meta_title", nullable = false)
private String metaTitle;
@Column(name = "meta_description", nullable = false)
private String metaDescription;
@Column(name = "meta_keyword", nullable = false)
private String metaKeyword;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "newsId", referencedColumnName = "id", nullable = false)
private News news;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "order")
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String code;
@Column(nullable = false)
private String type;
@Column(nullable = false)
private Integer amount;
@Column(nullable = false)
private String status;
@Column(nullable = false)
private String paymentGate;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn
private TurnPackage turnPackage;
@OneToOne(mappedBy = "order",cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Transaction transaction;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "partner")
public class Partner {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String image;
private Integer status;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "payment_gate")
public class PaymentGate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String code;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String image;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "permission")
public class Permission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String code;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String slug;
private Integer status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
// permission cha
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "parent_id", nullable = false)
private Permission parent;
// permission con
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Permission> children;
@OneToMany(mappedBy = "permission", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<RoleHasPermission> roleHasPermissions;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "platform")
public class Platform {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "platform", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<GameHasPlatform> gameHasPlatforms;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "policy")
public class Policy {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "policy_translate")
public class PolicyTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String content;
@Column(name = "meta_title", nullable = false)
private String metaTitle;
@Column(name = "lang_code", nullable = false)
private String langCode;
@Column(name = "meta_keyword", nullable = false)
private String metaKeyword;
@Column(name = "meta_description", nullable = false)
private String metaDescription;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "policyId", nullable = false)
private Policy policy;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "role")
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String code;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private Integer status;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<RoleHasPermission> roleHasPermissions;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "role_has_permission")
public class RoleHasPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role_id", nullable = false)
private Role role;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "permission_id", nullable = false)
private Permission permission;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "role_log")
public class RoleLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String action;
@Column(nullable = false)
private String description;
@Column(nullable = false)
private Integer createdBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Entity
@Table(name = "setting_mail")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SettingMail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String host;
private Integer port;
private Integer secure;
private String user;
private String pass;
private String address;
@OneToMany(mappedBy = "settingMail", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<ContentMail> contentMails;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "slider")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Slider {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String slug;
private String image;
private Integer position;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "slider", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<SliderTranslate> sliderTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Table(name = "slider_translate")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SliderTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
@Column(name = "lang_code", nullable = false)
private String langCode;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "sliderId", nullable = false)
private Slider slider;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "transaction")
public class Transaction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private LocalDateTime payDate;
@Column(nullable = false)
private Integer transactionNo;
@Column(nullable = false)
private String transactionStatus;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private TransactionDetail transactionDetail;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "orderCode", referencedColumnName = "code")
private Order order;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "customerId")
private Customer customer;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "transaction_detail")
public class TransactionDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String bankCode;
@Column(nullable = false)
private Integer price;
@Column(nullable = false)
private String bankTranNo;
@Column(nullable = false)
private String cardType;
@Column(nullable = false)
private String orderInfo;
@Column(nullable = false)
private String responseCode;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "transactionId", nullable = false)
private Transaction transaction;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "turn_balance")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class TurnBalance {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Integer number_turns;
private String perHash;
private String hash;
private String type;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
}
package com.example.nextadsservicebe.entity;
import com.example.nextadsservicebe.enums.IsHost;
import com.example.nextadsservicebe.enums.Status;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "turn_package")
public class TurnPackage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String slug;
@Enumerated(EnumType.ORDINAL)
private Status status;
@Enumerated(EnumType.ORDINAL)
private IsHost isHost;
@Column(nullable = false)
private Integer price;
@Column(nullable = false)
private Integer amount;
@Column(nullable = false)
private String image;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@OneToMany(mappedBy = "turnPackage", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<TurnPackageTranslate> turnPackageTranslates;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import javax.print.attribute.standard.MediaSize;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "turn_package_translate")
public class TurnPackageTranslate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String content;
@Column(nullable = false)
private String description;
@Column(nullable = false)
private String lang_code;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "turnPackageId", nullable = false)
private TurnPackage turnPackage;
}
package com.example.nextadsservicebe.entity;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;
import java.util.List;
@Entity
@Table(name = "user")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false)
private String name;
@Column(nullable = true)
private String email;
@Column(nullable = false)
private String username;
@Column(nullable = false)
private String password;
@Column(nullable = true)
private String phone;
@Column(nullable = true)
private String image;
@Column(nullable = false) // Default value là 0
private Integer status;
@Column(name = "role_id", nullable = true) // Liên kết với cột role_id
private Integer roleId;
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
@Column(name = "created_by", nullable = false)
private Integer createdBy;
@Column(name = "updated_by", nullable = false)
private Integer updatedBy;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<News> news;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Game> game;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Contact> contact;
}
\ No newline at end of file
package com.example.nextadsservicebe.enums;
public enum IsActive {
AUTHENTICATION, NOT_AUTHENTICATED
}
package com.example.nextadsservicebe.enums;
public enum IsHost {
HOT, NOT_HOST
}
package com.example.nextadsservicebe.enums;
public enum Status {
ACTIVE, LOCK
}
package com.example.nextadsservicebe.enums.contact;
public enum Status {
CONTACTED, NOT_CONTACTED
}
package com.example.nextadsservicebe.exception;
import lombok.*;
import java.util.Date;
import java.util.Map;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ErrorResponse {
private Date timestamp;
private int status;
private String path;
private String error;
private String message;
private Map<String, String> details;
}
package com.example.nextadsservicebe.exception;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler({MethodArgumentNotValidException.class, jakarta.validation.ConstraintViolationException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<ErrorResponse> handleValidationException(Exception e, WebRequest request) {
log.error("Validation error occurred: {}", e.getMessage(), e);
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setTimestamp(new Date());
errorResponse.setStatus(HttpStatus.BAD_REQUEST.value());
errorResponse.setPath(request.getDescription(false).replace("uri=", ""));
Map<String, String> errorDetails = new HashMap<>();
if (e instanceof MethodArgumentNotValidException) {
MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
errorResponse.setError("Payload Invalid");
ex.getBindingResult().getAllErrors().forEach((error) -> {
if (error instanceof FieldError) {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
errorDetails.put(fieldName, errorMessage);
} else {
errorDetails.put("global", errorResponse.getError());
}
});
errorResponse.setMessage("Validation failed for request body");
} else if (e instanceof ConstraintViolationException) {
ConstraintViolationException ex = (ConstraintViolationException) e;
errorResponse.setError("PathVariable Invalid");
for (ConstraintViolation<?> violation : ex.getConstraintViolations()) {
String fieldName = violation.getPropertyPath().toString();
String errorMessage = violation.getMessage();
errorDetails.put(fieldName, errorMessage);
}
errorResponse.setMessage("Validation failed for path variables or query params");
}
errorResponse.setDetails(errorDetails);
return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
}
}
package com.example.nextadsservicebe.exception;
public class ResourceNotFoundException extends RuntimeException {
public ResourceNotFoundException(String message) {
super(message);
}
public ResourceNotFoundException(String message, Throwable cause) {
super(message, cause);
}
}
spring.application.name=nextads-service-be
# Cau hinh DataSource
########-- MAIN -- #########
#spring.datasource.url=jdbc:mysql://103.147.35.60:3306/nextadsv2?useSSL=false&serverTimezone=UTC
#spring.datasource.username=nextadsv2
#spring.datasource.password=nextadsv2@123
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
########-- MAIN -- #########
########-- TEST -- #########
spring.datasource.url=jdbc:mysql://localhost/nextadsv2_test?useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=12345678
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
########-- TEST -- #########
# Cau hinh JPA/Hibernate
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
#TRACE < DEBUG < INFO < WARN < ERROR < OFF
# Logging
logging.level.root=INFO
logging.level.com.example.nextadsservicebe=INFO
logging.level.org.springframework=WARN
logging.level.org.hibernate=WARN
# upload file
#spring.servlet.multipart.max-file-size=50MB
#spring.servlet.multipart.max-request-size=50MB
#spring.http.multipart.max-file-size=50MB
#spring.http.multipart.max-request-size=50MB
#spring.servlet.multipart.enabled=true
open:
api:
title: NextADS V2 Api Documents
version: 1.0
description: NextADS V2 Documents description
serverUrl: http://localhost:8080
serverName: server
springdoc:
api-docs:
path: /v3/api-docs
enabled: true
swagger-ui:
path: /swagger-ui.html
operations-sorter: alpha
csrf:
enabled: true
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %highlight(%-5level) %logger{36} [%X{traceId}] - %msg%n
</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/application.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/application.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} traceId:%X{traceId} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
package com.example.nextadsservicebe;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NextadsServiceBeApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment