Subversion Repositories SmartDukaan

Rev

Rev 22193 | Rev 22198 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22193 Rev 22196
Line 3... Line 3...
3
import javax.servlet.http.HttpServletRequest;
3
import javax.servlet.http.HttpServletRequest;
4
 
4
 
5
import org.slf4j.Logger;
5
import org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
6
import org.slf4j.LoggerFactory;
7
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.beans.factory.annotation.Autowired;
-
 
8
import org.springframework.http.HttpHeaders;
-
 
9
import org.springframework.http.HttpStatus;
-
 
10
import org.springframework.http.MediaType;
-
 
11
import org.springframework.http.ResponseEntity;
8
import org.springframework.stereotype.Controller;
12
import org.springframework.stereotype.Controller;
9
import org.springframework.ui.Model;
13
import org.springframework.ui.Model;
10
import org.springframework.web.bind.annotation.PathVariable;
14
import org.springframework.web.bind.annotation.PathVariable;
11
import org.springframework.web.bind.annotation.RequestMapping;
15
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestMethod;
16
import org.springframework.web.bind.annotation.RequestMethod;
13
 
17
 
14
import com.spice.profitmandi.dao.model.FofoForm;
18
import com.spice.profitmandi.dao.model.FofoForm;
15
import com.spice.profitmandi.dao.repository.dtr.Mongo;
19
import com.spice.profitmandi.dao.repository.dtr.Mongo;
16
 
20
 
-
 
21
import in.shop2020.dtrapi.utils.FofoDocumentsGenerator;
-
 
22
 
17
@Controller
23
@Controller
18
public class FofoController {
24
public class FofoController {
19
	
25
	
20
	private static final Logger LOGGER = LoggerFactory.getLogger(FofoController.class);
26
	private static final Logger LOGGER = LoggerFactory.getLogger(FofoController.class);
21
	
27
	
22
 
28
 
23
	@Autowired
29
	@Autowired
24
	Mongo mongoClient;
30
	Mongo mongoClient;
25
	
31
	
-
 
32
	@Autowired
-
 
33
	FofoDocumentsGenerator generator;
-
 
34
	
26
	
35
	
27
	@RequestMapping(value = "/fofo", method = RequestMethod.GET)
36
	@RequestMapping(value = "/fofo", method = RequestMethod.GET)
28
	public String getAll(HttpServletRequest request, Model model) throws Exception{
37
	public String getAll(HttpServletRequest request, Model model) throws Exception{
29
		model.addAttribute("fofoForms", mongoClient.getFofoForms(0, 50));
38
		model.addAttribute("fofoForms", mongoClient.getFofoForms(0, 50));
30
		return "fofo-index";
39
		return "fofo-index";
31
	}
40
	}
32
	
41
	
-
 
42
	@RequestMapping(value = "/fofo/{fofoId}/file-display", method = RequestMethod.GET)
-
 
43
	public ResponseEntity<byte[]> displayDocs(HttpServletRequest request, @PathVariable(name = "fofoId") int fofoId) throws Exception{
-
 
44
		HttpHeaders headers = new HttpHeaders();
-
 
45
	    headers.setContentType(MediaType.parseMediaType("application/pdf"));
-
 
46
	    String filename = "output.pdf";
-
 
47
	    headers.setContentDispositionFormData(filename, filename);
-
 
48
	    headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
-
 
49
	    byte[] contents = generator.getDocumentStream(fofoId);
-
 
50
		ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(contents, headers, HttpStatus.OK);
-
 
51
	    return response;
-
 
52
	}
-
 
53
	
33
	@RequestMapping(value = "/fofo/{fofoId}/edit", method = RequestMethod.GET)
54
	@RequestMapping(value = "/fofo/{fofoId}/edit", method = RequestMethod.GET)
34
	public String editFofoForm(HttpServletRequest request, @PathVariable(name = "fofoId") int fofoId, Model model) throws Exception{
55
	public String editFofoForm(HttpServletRequest request, @PathVariable(name = "fofoId") int fofoId, Model model) throws Exception{
35
		FofoForm ff = mongoClient.getFofoForm(fofoId);
56
		FofoForm ff = mongoClient.getFofoForm(fofoId);
36
		model.addAttribute("fofoForm", mongoClient.getFofoFormJsonStringByFofoId(fofoId));
57
		model.addAttribute("fofoForm", mongoClient.getFofoFormJsonStringByFofoId(fofoId));
37
		model.addAttribute("email", ff.getRegisteredEmail1());
58
		model.addAttribute("email", ff.getRegisteredEmail1());