Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4ccf7a8
Object User
Jawarians Jan 2, 2025
0ef9327
Simple gallery model, controller, service and repo
muame-amr Jan 3, 2025
f1f0aef
changes to model and service of WebsiteImage module
heyjude992241 Jan 12, 2025
b312f9f
Object User
Jawarians Jan 13, 2025
d1499c9
Merge remote-tracking branch 'origin/Gallery-Ame' into User-Arif
Jawarians Jan 13, 2025
6ab3781
Object User
Jawarians Jan 13, 2025
5839a3e
Object User
Jawarians Jan 13, 2025
fc9a4ac
Product
aidilqushairi Jan 14, 2025
e9dab8d
Completed
ghost7elite Jan 14, 2025
e803b29
Merge remote-tracking branch 'origin/products-aidil' into User-Arif
Jawarians Jan 14, 2025
1db5d9d
Merge remote-tracking branch 'origin/Text-Johan' into User-Arif
Jawarians Jan 14, 2025
c1020c2
Merge remote-tracking branch 'origin/Image-Hafizudden' into Gallery-Ame
muame-amr Jan 14, 2025
b01f64f
Merge remote-tracking branch 'origin/Text-Johan' into Gallery-Ame
muame-amr Jan 14, 2025
3479118
Merge remote-tracking branch 'origin/products-aidil' into Gallery-Ame
muame-amr Jan 14, 2025
bbfef9f
Merge remote-tracking branch 'origin/User-Arif' into Gallery-Ame
muame-amr Jan 14, 2025
3010d22
Merge remote-tracking branch 'origin/Image-Hafizudden' into User-Arif
Jawarians Jan 14, 2025
784ae4b
Object User
Jawarians Jan 14, 2025
a678424
Logout Button
Jawarians Jan 15, 2025
fb472a3
BackEnd:
muame-amr Jan 15, 2025
ce52916
Modify gitignore
muame-amr Jan 15, 2025
5f2e258
Merge branch 'User-Arif' into Gallery-Ame
muame-amr Jan 15, 2025
ac26822
Logout Button
muame-amr Jan 15, 2025
e757446
Update All
Jawarians Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
db
/db
./db

ccsd/pom.xml
ccsd/src/main/resources/application.properties
ccsd/src/main/resources/profpic.png
dashboard/debug.log
dashboard/package-lock.json
dashboard/package.json
dashboard/yarn.lock
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/java-ccsd.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 38 additions & 3 deletions ccsd/src/main/java/com/example/ccsd/CcsdApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
package com.example.ccsd;

import com.example.ccsd.Users.Users;
import com.example.ccsd.Users.UsersRepository;
import com.example.ccsd.Users.UsersService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;

@SpringBootApplication
public class CcsdApplication {

public static void main(String[] args) {
SpringApplication.run(CcsdApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(CcsdApplication.class, args);
}

@Bean
public CommandLineRunner runner(UsersService usersService, UsersRepository usersRepository) {
return args -> {

String imagePath = "src/main/resources/profpic.png";
byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath));
Users adminUser = new Users(
imageBytes,
"10-11-2010",
"admin",
"admin",
"KL, MY",
"+601110111012",
"Doe",
"John",
"passwd",
"john.doe@admin.my"
);

Optional<Users> userExist = usersRepository.findByEmail("john.doe@admin.my");
if (userExist.isEmpty()) {
usersService.addUser(adminUser);
}
};
}

}
125 changes: 125 additions & 0 deletions ccsd/src/main/java/com/example/ccsd/Gallery/Gallery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.example.ccsd.Gallery;


import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;


@Document(collection = "Gallery")
public class Gallery {

private String title;
private String postSlug;
private String postShortDescription;
private String tag;
private String place;
private String date;
private String status;
private String image;
private String content;

public Gallery() {
}

public Gallery(String title, String postSlug, String postShortDescription, String tag, String place, String date, String status, String image, String content) {
this.title = title;
this.postSlug = postSlug;
this.postShortDescription = postShortDescription;
this.tag = tag;
this.place = place;
this.date = date;
this.status = status;
this.image = image;
this.content = content;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getPostSlug() {
return postSlug;
}

public void setPostSlug(String postSlug) {
this.postSlug = postSlug;
}

public String getPostShortDescription() {
return postShortDescription;
}

public void setPostShortDescription(String postShortDescription) {
this.postShortDescription = postShortDescription;
}

public String getTag() {
return tag;
}

public void setTag(String tag) {
this.tag = tag;
}

public String getPlace() {
return place;
}

public void setPlace(String place) {
this.place = place;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getImage() {
return image;
}

public void setImage(String image) {
this.image = image;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

@Override
public String toString() {
return "Gallery{" +
"title='" + title + '\'' +
", postSlug='" + postSlug + '\'' +
", postShortDescription='" + postShortDescription + '\'' +
", tag='" + tag + '\'' +
", place='" + place + '\'' +
", date='" + date + '\'' +
", status='" + status + '\'' +
", image='" + image + '\'' +
", content='" + content + '\'' +
'}';
}
}


Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.example.ccsd.Gallery;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
Expand All @@ -25,33 +22,25 @@
@RestController
@RequestMapping("/api/Gallery")

public class galleryController {
public class GalleryController {

@Autowired
private galleryService GalleryService;
private com.example.ccsd.Gallery.GalleryService GalleryService;

@GetMapping
public List<gallery> getAllGallerys() {
List<gallery> galleryList = GalleryService.getAllGallerys();


return galleryList.stream()
.map(gallery -> {
// Add Base64 encoded image to each
gallery.setImage64String(gallery.getImageAsBase64());
return gallery;
})
.collect(Collectors.toList());
public ResponseEntity<List<Gallery>> getAllGallerys() {
List<Gallery> galleryList = GalleryService.getAllGallerys();
return ResponseEntity.ok(galleryList);
}

@GetMapping("/{id}")
public ResponseEntity<gallery> getGalleryById(@PathVariable String id) {
public ResponseEntity<Object> getGalleryById(@PathVariable String id) {
return GalleryService.getGalleryById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}

@PostMapping
@PostMapping
public ResponseEntity<Map<String, Object>> addGallery(
@RequestParam("title") String title,
@RequestParam("postSlug") String postSlug,
Expand All @@ -64,30 +53,31 @@ public ResponseEntity<Map<String, Object>> addGallery(
@RequestParam("image") MultipartFile image) throws IOException {

byte[] imageBytes = image.getBytes();
String base64String = Base64.getEncoder().encodeToString(imageBytes);

gallery Gallery = new gallery();
Gallery Gallery = new Gallery();
Gallery.setTitle(title);
Gallery.setPostSlug(postSlug);
Gallery.setpostShortDescription(postShortDescription);
Gallery.setPostShortDescription(postShortDescription);
Gallery.setTag(tag);
Gallery.setPlace(place);
Gallery.setDate(date);
Gallery.setStatus(status);
Gallery.setimage(imageBytes);
Gallery.setContent(content);
gallery savedGallery = GalleryService.addGallery(Gallery);
Gallery.setImage(base64String);
Gallery.setContent(content);

Gallery savedGallery = GalleryService.addGallery(Gallery);

Map<String, Object> response = new HashMap<>();
response.put("success", true);
response.put("product", savedGallery);

return ResponseEntity.ok(response);
}

@PutMapping("/{id}")
public ResponseEntity<gallery> updategallery(@PathVariable String id, @RequestBody gallery GalleryDetails) {
gallery updatedgallery = GalleryService.updategallery(id, GalleryDetails);
public ResponseEntity<Gallery> updategallery(@PathVariable String id, @RequestBody Gallery GalleryDetails) {
Gallery updatedgallery = GalleryService.updateGallery(id, GalleryDetails);
if (updatedgallery != null) {
return ResponseEntity.ok(updatedgallery);
}
Expand All @@ -96,8 +86,7 @@ public ResponseEntity<gallery> updategallery(@PathVariable String id, @RequestBo

@DeleteMapping("/{id}")
public ResponseEntity<Void> deletegallery(@PathVariable String id) {
GalleryService.deletegallery(id);
GalleryService.deleteGallery(id);
return ResponseEntity.noContent().build();
}

}
Loading