| 28300 |
tejbeer |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import javax.servlet.http.HttpServletRequest;
|
|
|
7 |
|
|
|
8 |
import org.apache.logging.log4j.LogManager;
|
|
|
9 |
import org.apache.logging.log4j.Logger;
|
|
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
11 |
import org.springframework.stereotype.Controller;
|
|
|
12 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
13 |
import org.springframework.ui.Model;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
17 |
|
|
|
18 |
import com.spice.profitmandi.dao.entity.warehouse.Supplier;
|
|
|
19 |
|
|
|
20 |
import com.spice.profitmandi.dao.repository.warehouse.SupplierRepository;
|
|
|
21 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
|
|
22 |
|
|
|
23 |
@Controller
|
|
|
24 |
@Transactional(rollbackFor = Throwable.class)
|
|
|
25 |
public class SupplierController {
|
|
|
26 |
|
|
|
27 |
@Autowired
|
|
|
28 |
private SupplierRepository supplierRepository;
|
|
|
29 |
|
|
|
30 |
@Autowired
|
|
|
31 |
private MVCResponseSender mvcResponseSender;
|
|
|
32 |
|
|
|
33 |
private static final Logger LOGGER = LogManager.getLogger(SellerController.class);
|
|
|
34 |
|
|
|
35 |
@RequestMapping(value = "/getAllSupplier", method = RequestMethod.GET)
|
|
|
36 |
public String getShowSupplier(HttpServletRequest request,Model model)
|
|
|
37 |
throws Exception {
|
|
|
38 |
|
|
|
39 |
List<Supplier> supplierAcvtives =supplierRepository.selectByStatus(true);
|
|
|
40 |
|
|
|
41 |
model.addAttribute("suppliers", supplierAcvtives);
|
|
|
42 |
|
|
|
43 |
LOGGER.info("supplierAcvtives"+supplierAcvtives);
|
|
|
44 |
|
|
|
45 |
return "supplier";
|
|
|
46 |
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
@RequestMapping(value = "/getAllInActiveSupplier", method = RequestMethod.GET)
|
|
|
51 |
public String getShowInActiveSupplier(HttpServletRequest request,Model model)
|
|
|
52 |
throws Exception {
|
|
|
53 |
|
|
|
54 |
List<Supplier> supplierInactives =supplierRepository.selectByStatus(false);
|
|
|
55 |
|
|
|
56 |
model.addAttribute("supplierInactives", supplierInactives);
|
|
|
57 |
|
|
|
58 |
LOGGER.info("supplierInactives"+supplierInactives);
|
|
|
59 |
|
|
|
60 |
return "supplier-in-active";
|
|
|
61 |
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
@RequestMapping(value = "/setStatusInActive", method = RequestMethod.POST)
|
|
|
69 |
public String setInActiveSupplier(HttpServletRequest request,
|
|
|
70 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model)
|
|
|
71 |
throws Exception {
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
Supplier supplier=supplierRepository.selectById(id);
|
|
|
75 |
|
|
|
76 |
supplier.setStatus(false);
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
80 |
|
|
|
81 |
return "response";
|
|
|
82 |
}
|
|
|
83 |
@RequestMapping(value = "/setStatusActive", method = RequestMethod.POST)
|
|
|
84 |
public String setActiveSupplier(HttpServletRequest request,
|
|
|
85 |
@RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model)
|
|
|
86 |
throws Exception {
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
Supplier supplier=supplierRepository.selectById(id);
|
|
|
90 |
|
|
|
91 |
supplier.setStatus(true);
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
95 |
|
|
|
96 |
return "response";
|
|
|
97 |
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
}
|