Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43041c31ef | ||
|
|
69c577001c | ||
|
|
c2fb4bbfe7 | ||
|
|
8680a2a33d |
+37
-1
@@ -14,10 +14,15 @@ import java.util.stream.Collectors;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -36,7 +41,7 @@ import com.realnet.FileUpload.Services.FileuploadService;
|
|||||||
import com.realnet.FileUpload.Services.UploadedFileService;
|
import com.realnet.FileUpload.Services.UploadedFileService;
|
||||||
|
|
||||||
@RequestMapping(value = "/FileUpload")
|
@RequestMapping(value = "/FileUpload")
|
||||||
//@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
@RestController
|
@RestController
|
||||||
public class UploadeddocsController {
|
public class UploadeddocsController {
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -125,6 +130,37 @@ public class UploadeddocsController {
|
|||||||
return get;
|
return get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/files/{filename:.+}")
|
||||||
|
public ResponseEntity<Resource> getFile(@PathVariable String filename) {
|
||||||
|
try {
|
||||||
|
Path filePath = Paths.get(projectPath, "Resources", "Files", filename).normalize();
|
||||||
|
File file = filePath.toFile();
|
||||||
|
if (!file.exists()) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
Resource resource = new UrlResource(filePath.toUri());
|
||||||
|
String contentType = Files.probeContentType(filePath);
|
||||||
|
if (contentType == null) {
|
||||||
|
contentType = "application/octet-stream";
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.parseMediaType(contentType))
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + resource.getFilename() + "\"")
|
||||||
|
.body(resource);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/view/{id}")
|
||||||
|
public ResponseEntity<Resource> getFileById(@PathVariable Integer id) {
|
||||||
|
Uploadeddocs doc = Service.getdetailsbyId(id);
|
||||||
|
if (doc == null || doc.getUploadedfile_name() == null) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
return getFile(doc.getUploadedfile_name());
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcTemplate jdbcTemplate;
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
|||||||
@@ -7,33 +7,52 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
import com.realnet.logging.NoLogging;
|
import com.realnet.logging.NoLogging;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
// @Bean
|
|
||||||
// public HibernateJpaSessionFactoryBean sessionFactory() {
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("[MM/dd/yyyy][yyyy-MM-dd][dd/MM/yyyy]");
|
||||||
// return new HibernateJpaSessionFactoryBean();
|
private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("[yyyy-MM-dd'T'HH:mm:ss][yyyy-MM-dd HH:mm:ss][MM/dd/yyyy HH:mm:ss]");
|
||||||
// }
|
|
||||||
|
|
||||||
@NoLogging
|
@NoLogging
|
||||||
@Bean
|
@Bean
|
||||||
public ModelMapper modelMapper() {
|
public ModelMapper modelMapper() {
|
||||||
return new ModelMapper();
|
return new ModelMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObjectMapper configureMapper(ObjectMapper mapper) {
|
||||||
|
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||||
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
|
||||||
|
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||||
|
javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DATE_FORMAT));
|
||||||
|
javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("MM/dd/yyyy")));
|
||||||
|
|
||||||
|
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DATE_TIME_FORMAT));
|
||||||
|
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
|
||||||
|
mapper.registerModule(javaTimeModule);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
|
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = configureMapper(new ObjectMapper());
|
||||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
return new MappingJackson2HttpMessageConverter(mapper);
|
||||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(mapper);
|
|
||||||
return converter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper objectMapper() {
|
public ObjectMapper objectMapper() {
|
||||||
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
|
return configureMapper(new ObjectMapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
web.ignoring().antMatchers("/", "/resources/**", "/static/**", "/public/**", "/webui/**", "/h2-console/**",
|
web.ignoring().antMatchers("/", "/resources/**", "/static/**", "/public/**", "/webui/**", "/h2-console/**",
|
||||||
"/configuration/**", "/swagger-ui/**", "/swagger-resources/**", "/webjars/**", "/api-docs",
|
"/configuration/**", "/swagger-ui/**", "/swagger-resources/**", "/webjars/**", "/api-docs",
|
||||||
"/api-docs/**", "/v2/api-docs/**", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/**/*.png",
|
"/api-docs/**", "/v2/api-docs/**", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/**/*.png",
|
||||||
"/**/*.jpg", "/**/*.gif", "/**/*.svg", "/**/*.ico", "/**/*.ttf", "/**/*.woff", "/**/*.otf");
|
"/**/*.jpg", "/**/*.gif", "/**/*.svg", "/**/*.ico", "/**/*.ttf", "/**/*.woff", "/**/*.otf", "/FileUpload/files/**", "/FileUpload/view/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
// }
|
// }
|
||||||
@@ -125,7 +125,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
// Add CORS Filter //http.cors().and().csrf().disable().
|
// Add CORS Filter //http.cors().and().csrf().disable().
|
||||||
.addFilterBefore(new CorsFilter(), ChannelProcessingFilter.class)
|
.addFilterBefore(new CorsFilter(), ChannelProcessingFilter.class)
|
||||||
// adding backend/token for single container by Azmat 27-08
|
// adding backend/token for single container by Azmat 27-08
|
||||||
.authorizeRequests(requests -> requests.antMatchers("/token/**", "/backend/token/**", "/**/backend/token/**").permitAll().antMatchers("/log2/**")
|
.authorizeRequests(requests -> requests.antMatchers("/token/**", "/backend/token/**", "/**/backend/token/**", "/FileUpload/files/**", "/FileUpload/view/**").permitAll().antMatchers("/log2/**")
|
||||||
.permitAll().antMatchers("/api/**").permitAll()
|
.permitAll().antMatchers("/api/**").permitAll()
|
||||||
// .antMatchers("/SqlworkbenchSqlcont/**").hasRole("ADMIN")
|
// .antMatchers("/SqlworkbenchSqlcont/**").hasRole("ADMIN")
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
|
|||||||
@@ -5,14 +5,7 @@ import java.util.List;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.realnet.io8ref.Xyz.Entity.Xyz;
|
import com.realnet.io8ref.Xyz.Entity.Xyz;
|
||||||
import com.realnet.io8ref.Xyz.Services.XyzService;
|
import com.realnet.io8ref.Xyz.Services.XyzService;
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
package com.realnet.io8ref.Xyz.Entity;
|
package com.realnet.io8ref.Xyz.Entity;
|
||||||
import lombok.*;
|
|
||||||
import javax.persistence.*;
|
import lombok.*;
|
||||||
import java.time.LocalDate;
|
import javax.persistence.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
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.LocalDateDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@@ -13,17 +23,6 @@ package com.realnet.io8ref.Xyz.Entity;
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String name;
|
/* {{FORM_FIELDS}} */
|
||||||
private String description;
|
|
||||||
private String email;
|
|
||||||
private Double price;
|
|
||||||
private Long quantity;
|
|
||||||
private LocalDate dob;
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
private Boolean active;
|
|
||||||
private String status;
|
|
||||||
private String tags;
|
|
||||||
private String photo;
|
|
||||||
private Long categoryId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user