feat: implement cover image upload with canvas compression and db storage in RIT-EMS-main
This commit is contained in:
@@ -43,8 +43,16 @@ public class AdminController {
|
||||
if (user.getRole() == null || user.getRole().trim().isEmpty()) {
|
||||
user.setRole("FACULTY");
|
||||
}
|
||||
if (user.getDepartment() == null || user.getDepartment().trim().isEmpty()) {
|
||||
user.setDepartment("H&S Dept");
|
||||
|
||||
String role = user.getRole();
|
||||
if ("HOD".equals(role) || "FACULTY".equals(role)) {
|
||||
if (user.getDepartment() == null || user.getDepartment().trim().isEmpty()) {
|
||||
user.setDepartment("H&S Dept");
|
||||
} else {
|
||||
user.setDepartment(user.getDepartment().trim());
|
||||
}
|
||||
} else {
|
||||
user.setDepartment("");
|
||||
}
|
||||
|
||||
if (userRepository.findByEmail(user.getEmail()).isPresent()) {
|
||||
@@ -61,7 +69,14 @@ public class AdminController {
|
||||
user.setFullName(userDetails.getFullName());
|
||||
user.setEmail(userDetails.getEmail());
|
||||
user.setRole(userDetails.getRole());
|
||||
user.setDepartment(userDetails.getDepartment());
|
||||
|
||||
String role = user.getRole();
|
||||
if ("HOD".equals(role) || "FACULTY".equals(role)) {
|
||||
user.setDepartment(userDetails.getDepartment() != null ? userDetails.getDepartment().trim() : "");
|
||||
} else {
|
||||
user.setDepartment("");
|
||||
}
|
||||
|
||||
user.setClubCoordinator(userDetails.isClubCoordinator());
|
||||
user.setPlacementStaff(userDetails.isPlacementStaff());
|
||||
user.setClassIncharge(userDetails.isClassIncharge());
|
||||
|
||||
@@ -76,6 +76,9 @@ public class EventController {
|
||||
if (payload.containsKey("isPublicEvent")) {
|
||||
event.setPublicEvent((boolean) payload.get("isPublicEvent"));
|
||||
}
|
||||
if (payload.containsKey("image")) {
|
||||
event.setImage(payload.get("image") != null ? payload.get("image").toString() : null);
|
||||
}
|
||||
|
||||
// Workflow Logic
|
||||
if ("PRINCIPAL".equals(proposer.getRole())) {
|
||||
@@ -202,6 +205,9 @@ public class EventController {
|
||||
if (payload.containsKey("requirements")) {
|
||||
event.setRequirements((List<String>) payload.get("requirements"));
|
||||
}
|
||||
if (payload.containsKey("image")) {
|
||||
event.setImage(payload.get("image") != null ? payload.get("image").toString() : null);
|
||||
}
|
||||
|
||||
if (payload.get("proposer") != null) {
|
||||
try {
|
||||
@@ -350,6 +356,9 @@ public class EventController {
|
||||
|
||||
if (payload.containsKey("centreName")) event.setCentreName(payload.get("centreName").toString());
|
||||
if (payload.containsKey("isPublicEvent")) event.setPublicEvent((boolean) payload.get("isPublicEvent"));
|
||||
if (payload.containsKey("image")) {
|
||||
event.setImage(payload.get("image") != null ? payload.get("image").toString() : null);
|
||||
}
|
||||
if (payload.containsKey("status") && isAdmin) {
|
||||
event.setStatus(payload.get("status").toString());
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ public class Event extends BaseEntity {
|
||||
@Column(columnDefinition = "boolean default false")
|
||||
private boolean isPublicEvent;
|
||||
|
||||
@Column(columnDefinition = "LONGTEXT")
|
||||
private String image;
|
||||
|
||||
@jakarta.persistence.Transient
|
||||
private String conflictMessage;
|
||||
|
||||
@@ -169,6 +172,14 @@ public class Event extends BaseEntity {
|
||||
isPublicEvent = publicEvent;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
// Manual Builder
|
||||
public static EventBuilder builder() {
|
||||
return new EventBuilder();
|
||||
@@ -198,6 +209,7 @@ public class Event extends BaseEntity {
|
||||
public EventBuilder sponsors(List<String> sponsors) { event.setSponsors(sponsors); return this; }
|
||||
public EventBuilder proposer(User proposer) { event.setProposer(proposer); return this; }
|
||||
public EventBuilder groupRequestId(String groupRequestId) { event.setGroupRequestId(groupRequestId); return this; }
|
||||
public EventBuilder image(String image) { event.setImage(image); return this; }
|
||||
|
||||
public Event build() {
|
||||
return event;
|
||||
|
||||
Reference in New Issue
Block a user