Changed folder structure
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.faf223.expensetrackerfaf.controller;
|
||||
|
||||
import com.faf223.expensetrackerfaf.model.BasicEntity;
|
||||
import com.faf223.expensetrackerfaf.repository.BasicRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/getData")
|
||||
public class BasicController {
|
||||
private final BasicRepository basicRepository;
|
||||
|
||||
@Autowired
|
||||
public BasicController(BasicRepository basicRepository) {
|
||||
this.basicRepository = basicRepository;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public List<BasicEntity> listDepartments() {
|
||||
return basicRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.faf223.expensetrackerfaf.controllers;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
class GetHelloWorld {
|
||||
|
||||
@GetMapping("/")
|
||||
public String helloWorld() {
|
||||
return "Hello, World!";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.faf223.expensetrackerfaf.custom;
|
||||
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
|
||||
public class UppercaseStrategy implements PhysicalNamingStrategy {
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalCatalogName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
|
||||
return identifier; // No modification for catalog name
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalSchemaName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
|
||||
return identifier; // No modification for schema name
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
|
||||
String tableName = name.getText();
|
||||
return new Identifier(tableName, name.isQuoted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalSequenceName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
|
||||
return identifier; // No modification for sequence name
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalColumnName(Identifier identifier, JdbcEnvironment jdbcEnvironment) {
|
||||
return identifier; // No modification for column name
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalTypeName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
|
||||
return PhysicalNamingStrategy.super.toPhysicalTypeName(logicalName, jdbcEnvironment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.faf223.expensetrackerfaf.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "Department", schema = "HumanResources")
|
||||
public class BasicEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "DepartmentID")
|
||||
private Short departmentId;
|
||||
|
||||
@Column(name = "GroupName", nullable = false, length = 50)
|
||||
private String groupName;
|
||||
|
||||
@Column(name = "ModifiedDate", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date modifiedDate;
|
||||
|
||||
@Column(name = "Name", nullable = false, length = 50)
|
||||
private String name;
|
||||
|
||||
public Short getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
public Date getModifiedDate() {
|
||||
return modifiedDate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.faf223.expensetrackerfaf.repository;
|
||||
|
||||
import com.faf223.expensetrackerfaf.model.BasicEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface BasicRepository extends JpaRepository<BasicEntity, Short> {
|
||||
// You can define custom query methods here if needed
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.faf223.expensetrackerfaf.service;
|
||||
|
||||
import com.faf223.expensetrackerfaf.model.BasicEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BasicService {
|
||||
List<BasicEntity> getAllData();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.faf223.expensetrackerfaf.service;
|
||||
|
||||
import com.faf223.expensetrackerfaf.model.BasicEntity;
|
||||
import com.faf223.expensetrackerfaf.repository.BasicRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BasicServiceImpl implements BasicService {
|
||||
private final BasicRepository basicRepository;
|
||||
|
||||
@Autowired
|
||||
public BasicServiceImpl(BasicRepository basicRepository) {
|
||||
this.basicRepository = basicRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BasicEntity> getAllData() {
|
||||
return basicRepository.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user