diff --git a/README.md b/README.md index 5a65bc6..97964aa 100644 --- a/README.md +++ b/README.md @@ -186,4 +186,12 @@ graph TB style K fill:#6cf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 style L fill:#f6c,stroke:#333,stroke-width:2px style M fill:#6fc,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 -``` \ No newline at end of file +```## PD-463 +## PD-464 +## PD-465 +## PD-466 +## PD-467 +## PD-468 +## PD-469 +## PD-470 +## PD-471 diff --git a/my-chart/templates/redis_db-deployment.yaml b/my-chart/templates/redis_db-deployment.yaml index c5c3f45..5f49599 100644 --- a/my-chart/templates/redis_db-deployment.yaml +++ b/my-chart/templates/redis_db-deployment.yaml @@ -54,4 +54,5 @@ spec: ports: - containerPort: 6379 resources: {{- toYaml .Values.redisDatabaseDeployment.redisDatabaseContainer.resources - | nindent 10 }} \ No newline at end of file + | nindent 10 }} + diff --git a/src/main/java/net/codejava/AppController.java b/src/main/java/net/codejava/AppController.java index 20461cc..be87a2d 100755 --- a/src/main/java/net/codejava/AppController.java +++ b/src/main/java/net/codejava/AppController.java @@ -207,5 +207,12 @@ public void exportToCSV(HttpServletResponse response) throws IOException { writer.newLine(); } writer.flush(); -} + } + + @RequestMapping("/high-quantity-items") + public String getHighQuantityItems(@RequestParam int threshold, Model model) { + List highQuantityItems = dao.getItemsWithHighestQuantity(threshold); + model.addAttribute("highQuantityItems", highQuantityItems); + return "high_quantity_items"; // This should be the name of your view file + } } diff --git a/src/main/java/net/codejava/EnableWebSecurity.java b/src/main/java/net/codejava/EnableWebSecurity.java index b09b2b8..58d673a 100644 --- a/src/main/java/net/codejava/EnableWebSecurity.java +++ b/src/main/java/net/codejava/EnableWebSecurity.java @@ -1,5 +1,6 @@ package net.codejava; public @interface EnableWebSecurity { - -} + String message() default "Web security enabled"; + int securityLevel() default 1; +} \ No newline at end of file diff --git a/src/main/java/net/codejava/Role.java b/src/main/java/net/codejava/Role.java new file mode 100644 index 0000000..f552ca0 --- /dev/null +++ b/src/main/java/net/codejava/Role.java @@ -0,0 +1,13 @@ +package net.codejava; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Role { + @Id + private Long id; + private String roleName; + + // getters and setters +} \ No newline at end of file diff --git a/src/main/java/net/codejava/RoleRepository.java b/src/main/java/net/codejava/RoleRepository.java new file mode 100644 index 0000000..faaaf21 --- /dev/null +++ b/src/main/java/net/codejava/RoleRepository.java @@ -0,0 +1,8 @@ +package net.codejava; + +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + +public interface RoleRepository extends JpaRepository { + List findByRoleName(String roleName); +} \ No newline at end of file diff --git a/src/main/java/net/codejava/Sale.java b/src/main/java/net/codejava/Sale.java index 7560878..cf5c1ba 100755 --- a/src/main/java/net/codejava/Sale.java +++ b/src/main/java/net/codejava/Sale.java @@ -83,4 +83,19 @@ public void setEditing(boolean isEditing) { public String toString() { return "Sale [serial_number=" + serialNumber + ", item=" + item + ", quantity=" + quantity + ", amount=" + amount + ", date=" + date + "]"; } + + public float calculateTotalAmount(float pricePerItem) { + return this.quantity * pricePerItem; + } + + public boolean isRecentSale(int days) { + Date now = new Date(); + long millisInADay = 24 * 60 * 60 * 1000; + return (now.getTime() - this.date.getTime()) / millisInADay <= days; + } + + public void updateSale(int quantity, float amount) { + this.quantity = quantity; + this.amount = amount; + } } \ No newline at end of file diff --git a/src/main/java/net/codejava/SalesDAO.java b/src/main/java/net/codejava/SalesDAO.java index 24e1541..4e9e645 100755 --- a/src/main/java/net/codejava/SalesDAO.java +++ b/src/main/java/net/codejava/SalesDAO.java @@ -124,4 +124,10 @@ public List listAll() { List listSale = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(Sale.class)); return listSale; } + + public List getItemsWithHighestQuantity(int threshold) { + String sql = "SELECT * FROM sales WHERE quantity >= ?"; + List listSale = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(Sale.class), threshold); + return listSale; + } } diff --git a/src/main/java/net/codejava/SalesManager.java b/src/main/java/net/codejava/SalesManager.java index 92d1016..3031602 100755 --- a/src/main/java/net/codejava/SalesManager.java +++ b/src/main/java/net/codejava/SalesManager.java @@ -6,10 +6,17 @@ @SpringBootApplication public class SalesManager { - /** - * @param args - */ public static void main(String[] args) { SpringApplication.run(SalesManager.class, args); } -} + + // A simple static method to print a greeting + public static void printGreeting() { + System.out.println("Hello, welcome to Sales Manager!"); + } + + // A simple static method to calculate the sum of two numbers + public static int sum(int a, int b) { + return a + b; + } +} \ No newline at end of file diff --git a/src/main/java/net/codejava/SessionConfig.java b/src/main/java/net/codejava/SessionConfig.java index 4ad5a38..b6aba40 100644 --- a/src/main/java/net/codejava/SessionConfig.java +++ b/src/main/java/net/codejava/SessionConfig.java @@ -1,10 +1,28 @@ package net.codejava; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.session.data.redis.config.ConfigureRedisAction; import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; @Configuration @EnableRedisHttpSession public class SessionConfig { - // This class is intentionally left blank. + + // Override Redis configuration action + @Bean + public static ConfigureRedisAction configureRedisAction() { + return ConfigureRedisAction.NO_OP; + } + + // Customize Redis template + @Bean + public RedisTemplate sessionRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + // Add any custom configuration here + return template; + } } \ No newline at end of file diff --git a/src/main/java/net/codejava/UserDetailsServiceImpl.java b/src/main/java/net/codejava/UserDetailsServiceImpl.java index 4766bea..7e402cf 100644 --- a/src/main/java/net/codejava/UserDetailsServiceImpl.java +++ b/src/main/java/net/codejava/UserDetailsServiceImpl.java @@ -17,7 +17,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { private static final Logger logger = LoggerFactory.getLogger(UserDetailsServiceImpl.class); @Autowired - private UserRepository userRepository; + private RoleRepository userRepository; @Autowired private PasswordEncoder passwordEncoder; diff --git a/src/main/java/net/codejava/UserRepository.java b/src/main/java/net/codejava/UserRepository.java deleted file mode 100644 index 09fd5b0..0000000 --- a/src/main/java/net/codejava/UserRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.codejava; - -import org.springframework.data.jpa.repository.JpaRepository; - -public interface UserRepository extends JpaRepository { - User findByUsername(String username); -} \ No newline at end of file diff --git a/src/main/resources/db/changelog/changelog_version-3.3.xml b/src/main/resources/db/changelog/changelog_version-3.3.xml index 3406fd2..f390386 100755 --- a/src/main/resources/db/changelog/changelog_version-3.3.xml +++ b/src/main/resources/db/changelog/changelog_version-3.3.xml @@ -59,4 +59,26 @@ + + + + + + + + + + + + + + + + + + name = 'ROLE_USER' + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 9dfc0f8..c6d41c9 100755 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -94,6 +94,35 @@

Inventory Records

Clear + + + + +
+
+ + + +
+
+
+

High Quantity Items

+ + + + + + + + + + + + + + + +
Serial NumberItem NameQuantityAmount
serial NumberItem NameQuantityAmount