some minor changes

parent 184f79bf
...@@ -35,6 +35,17 @@ public class AdminResourceController { ...@@ -35,6 +35,17 @@ public class AdminResourceController {
if (resource.isPresent()){ if (resource.isPresent()){
Resource r = resource.get(); Resource r = resource.get();
r.setApproved(true); r.setApproved(true);
r.setHide(false);
resourceRepository.save(r);
}
}
@GetMapping("/archive/{id}")
public void archiveResource(@PathVariable("id") String idResource){
Optional<Resource> resource = resourceRepository.findById(idResource);
if (resource.isPresent()){
Resource r = resource.get();
r.setApproved(false);
r.setHide(true);
resourceRepository.save(r); resourceRepository.save(r);
} }
} }
......
package ipm.ipmworks.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Comment {
private String text;
private String commenterEmail;
}
package ipm.ipmworks.model; package ipm.ipmworks.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -29,7 +38,8 @@ public class Resource { ...@@ -29,7 +38,8 @@ public class Resource {
private String contactPhone; private String contactPhone;
private String contactAddress; private String contactAddress;
private List<String> links = new ArrayList<String>(); private List<Link> links = new ArrayList<Link>();
private String youtube;
private List<Map> files = new ArrayList(); private List<Map> files = new ArrayList();
private String project; private String project;
private String projectWeb; private String projectWeb;
...@@ -42,9 +52,9 @@ public class Resource { ...@@ -42,9 +52,9 @@ public class Resource {
private User approvedBy; private User approvedBy;
private List<Pest> pests = new ArrayList<Pest>(); private List<Pest> pests = new ArrayList<Pest>();
private List<Crop> crops = new ArrayList<Crop>(); private List<Crop> crops = new ArrayList<Crop>();
private List<User> likes = new ArrayList<User>(); private LocalDateTime creationDate;
private Date creationDate;
private boolean approved; private boolean approved;
private boolean canEdit; private boolean canEdit;
private boolean external; private boolean external;
private boolean hide;
} }
package ipm.ipmworks.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class EmailService {
@Autowired
private JavaMailSender javaMailSender;
public void sendEmail(String receiver, String subject, String body) {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(receiver);
msg.setSubject(subject);
msg.setText(body);
javaMailSender.send(msg);
}
}
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