| Line 37... |
Line 37... |
| 37 |
import org.apache.logging.log4j.LogManager;
|
37 |
import org.apache.logging.log4j.LogManager;
|
| 38 |
import org.apache.logging.log4j.Logger;
|
38 |
import org.apache.logging.log4j.Logger;
|
| 39 |
import org.json.JSONArray;
|
39 |
import org.json.JSONArray;
|
| 40 |
import org.json.JSONObject;
|
40 |
import org.json.JSONObject;
|
| 41 |
import org.springframework.beans.factory.annotation.Autowired;
|
41 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 42 |
import org.springframework.http.HttpStatus;
|
- |
|
| 43 |
import org.springframework.http.ResponseEntity;
|
42 |
import org.springframework.http.ResponseEntity;
|
| 44 |
import org.springframework.stereotype.Controller;
|
43 |
import org.springframework.stereotype.Controller;
|
| 45 |
import org.springframework.transaction.annotation.Transactional;
|
44 |
import org.springframework.transaction.annotation.Transactional;
|
| 46 |
import org.springframework.ui.Model;
|
45 |
import org.springframework.ui.Model;
|
| 47 |
import org.springframework.web.bind.annotation.*;
|
46 |
import org.springframework.web.bind.annotation.*;
|
| Line 122... |
Line 121... |
| 122 |
String imageString = getMediaPrefix(items.get(0).getItemDescriptionNoColor() + " " + description) + "-"
|
121 |
String imageString = getMediaPrefix(items.get(0).getItemDescriptionNoColor() + " " + description) + "-"
|
| 123 |
+ LocalDateTime.now().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30));
|
122 |
+ LocalDateTime.now().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30));
|
| 124 |
return imageString + "." + extension;
|
123 |
return imageString + "." + extension;
|
| 125 |
}
|
124 |
}
|
| 126 |
|
125 |
|
| 127 |
/* @PostMapping(value = "/content/upload")
|
126 |
@PostMapping(value = "/content/upload")
|
| 128 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
127 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
| 129 |
throws Exception {
|
128 |
throws Exception {
|
| 130 |
List<ContentPojo> contentPojos = readFile(file);
|
129 |
List<ContentPojo> contentPojos = readFile(file);
|
| - |
|
130 |
if (contentPojos.size() < 1) {
|
| - |
|
131 |
throw new RuntimeException("please check your file first ...may be content are wrong");
|
| - |
|
132 |
}
|
| 131 |
for (ContentPojo contentPojo : contentPojos) {
|
133 |
for (ContentPojo contentPojo : contentPojos) {
|
| 132 |
mongoClient.persistEntity(contentPojo);
|
134 |
mongoClient.persistEntity(contentPojo);
|
| 133 |
}
|
135 |
}
|
| 134 |
//List<SuperCatalog> superCatalog = superCatalogRepository.selectAll();
|
136 |
//List<SuperCatalog> superCatalog = superCatalogRepository.selectAll();
|
| 135 |
|
137 |
|
| 136 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
138 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 137 |
return "response";
|
139 |
return "response";
|
| 138 |
}*/
|
- |
|
| 139 |
|
- |
|
| 140 |
@PostMapping(value = "/content/upload")
|
- |
|
| 141 |
public ResponseEntity<?> uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
- |
|
| 142 |
throws Exception {
|
- |
|
| 143 |
|
- |
|
| 144 |
try {
|
- |
|
| 145 |
List<ContentPojo> contentPojos = readFile(file);
|
- |
|
| 146 |
|
- |
|
| 147 |
LOGGER.info("ContentPojo {}", contentPojos);
|
- |
|
| 148 |
|
- |
|
| 149 |
for (ContentPojo contentPojo : contentPojos) {
|
- |
|
| 150 |
mongoClient.persistEntity(contentPojo);
|
- |
|
| 151 |
}
|
- |
|
| 152 |
|
- |
|
| 153 |
return ResponseEntity.ok(
|
- |
|
| 154 |
mvcResponseSender.createResponseString(true)
|
- |
|
| 155 |
);
|
- |
|
| 156 |
|
- |
|
| 157 |
} catch (Exception e) {
|
- |
|
| 158 |
e.printStackTrace();
|
- |
|
| 159 |
return ResponseEntity
|
- |
|
| 160 |
.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
- |
|
| 161 |
.body(mvcResponseSender.createResponseString(false));
|
- |
|
| 162 |
}
|
- |
|
| 163 |
}
|
140 |
}
|
| 164 |
|
141 |
|
| 165 |
|
- |
|
| 166 |
@Autowired
|
142 |
@Autowired
|
| 167 |
ItemLoaderService itemLoaderService;
|
143 |
ItemLoaderService itemLoaderService;
|
| 168 |
@PostMapping(value = "/catalog/upload")
|
144 |
@PostMapping(value = "/catalog/upload")
|
| 169 |
public String uploadCatalog(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
145 |
public String uploadCatalog(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
| 170 |
throws Exception {
|
146 |
throws Exception {
|