| 21749 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
| 21541 |
ashik.ali |
2 |
|
| 21749 |
ashik.ali |
3 |
import javax.servlet.http.HttpServletRequest;
|
| 21541 |
ashik.ali |
4 |
|
| 21749 |
ashik.ali |
5 |
|
|
|
6 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
7 |
import org.springframework.http.ResponseEntity;
|
| 21541 |
ashik.ali |
8 |
import org.springframework.stereotype.Controller;
|
| 21749 |
ashik.ali |
9 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
10 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21541 |
ashik.ali |
11 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
12 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21749 |
ashik.ali |
13 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21541 |
ashik.ali |
14 |
|
| 21749 |
ashik.ali |
15 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
|
|
16 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
17 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
18 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
|
|
19 |
import com.spice.profitmandi.dao.entity.fofo.Tag;
|
|
|
20 |
import com.spice.profitmandi.dao.repository.fofo.TagRepository;
|
| 21760 |
ashik.ali |
21 |
import com.spice.profitmandi.web.request.CreatePinCodeTagRequest;
|
| 21541 |
ashik.ali |
22 |
|
|
|
23 |
@Controller
|
| 21749 |
ashik.ali |
24 |
@Transactional
|
|
|
25 |
public class TagController {
|
| 21541 |
ashik.ali |
26 |
|
| 21749 |
ashik.ali |
27 |
@Autowired
|
|
|
28 |
TagRepository tagRepository;
|
|
|
29 |
|
|
|
30 |
@Autowired
|
|
|
31 |
ResponseSender<?> responseSender;
|
|
|
32 |
|
| 21541 |
ashik.ali |
33 |
|
| 21755 |
ashik.ali |
34 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ID, method = RequestMethod.GET)
|
| 21749 |
ashik.ali |
35 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
|
|
36 |
try{
|
|
|
37 |
return responseSender.ok(tagRepository.selectById(id));
|
|
|
38 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
39 |
return responseSender.badRequest(profitMandiBusinessException);
|
|
|
40 |
}
|
| 21541 |
ashik.ali |
41 |
}
|
| 21749 |
ashik.ali |
42 |
|
| 21755 |
ashik.ali |
43 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ALL, method = RequestMethod.GET)
|
| 21749 |
ashik.ali |
44 |
public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {
|
|
|
45 |
return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));
|
|
|
46 |
}
|
|
|
47 |
|
| 21755 |
ashik.ali |
48 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ACTIVE, method = RequestMethod.PUT)
|
|
|
49 |
public ResponseEntity<?> setActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
|
|
50 |
try {
|
|
|
51 |
tagRepository.updateActiveById(id, true);
|
|
|
52 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
53 |
return responseSender.badRequest(profitMandiBusinessException);
|
|
|
54 |
}
|
|
|
55 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1001"));
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_INACTIVE, method = RequestMethod.PUT)
|
|
|
59 |
public ResponseEntity<?> setInActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
|
|
60 |
try {
|
|
|
61 |
tagRepository.updateActiveById(id, false);
|
|
|
62 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
63 |
return responseSender.badRequest(profitMandiBusinessException);
|
|
|
64 |
}
|
|
|
65 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1002"));
|
|
|
66 |
}
|
|
|
67 |
|
| 21541 |
ashik.ali |
68 |
}
|