| Line 28... |
Line 28... |
| 28 |
TagRepository tagRepository;
|
28 |
TagRepository tagRepository;
|
| 29 |
|
29 |
|
| 30 |
@Autowired
|
30 |
@Autowired
|
| 31 |
ResponseSender<?> responseSender;
|
31 |
ResponseSender<?> responseSender;
|
| 32 |
|
32 |
|
| 33 |
@RequestMapping(value = "/tag", method = RequestMethod.POST)
|
33 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG, method = RequestMethod.POST)
|
| 34 |
public ResponseEntity<?> createTag(HttpServletRequest request, @RequestBody CreateTagRequest createTagRequest) {
|
34 |
public ResponseEntity<?> createTag(HttpServletRequest request, @RequestBody CreateTagRequest createTagRequest) {
|
| 35 |
Tag tag = new Tag();
|
35 |
Tag tag = new Tag();
|
| 36 |
tag.setActive(true);
|
36 |
tag.setActive(true);
|
| 37 |
tag.setDescription(createTagRequest.getDescription());
|
37 |
tag.setDescription(createTagRequest.getDescription());
|
| 38 |
tag.setLabel(createTagRequest.getLabel());
|
38 |
tag.setLabel(createTagRequest.getLabel());
|
| Line 42... |
Line 42... |
| 42 |
tag.setCreatedBy(1);
|
42 |
tag.setCreatedBy(1);
|
| 43 |
tagRepository.persist(tag);
|
43 |
tagRepository.persist(tag);
|
| 44 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1000"));
|
44 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1000"));
|
| 45 |
}
|
45 |
}
|
| 46 |
|
46 |
|
| 47 |
@RequestMapping(value = "/tag/id", method = RequestMethod.GET)
|
47 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ID, method = RequestMethod.GET)
|
| 48 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
48 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
| 49 |
try{
|
49 |
try{
|
| 50 |
return responseSender.ok(tagRepository.selectById(id));
|
50 |
return responseSender.ok(tagRepository.selectById(id));
|
| 51 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
51 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 52 |
return responseSender.badRequest(profitMandiBusinessException);
|
52 |
return responseSender.badRequest(profitMandiBusinessException);
|
| 53 |
}
|
53 |
}
|
| 54 |
}
|
54 |
}
|
| 55 |
|
55 |
|
| 56 |
@RequestMapping(value = "/tag/all", method = RequestMethod.GET)
|
56 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ALL, method = RequestMethod.GET)
|
| 57 |
public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {
|
57 |
public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {
|
| 58 |
return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));
|
58 |
return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));
|
| 59 |
}
|
59 |
}
|
| 60 |
|
60 |
|
| - |
|
61 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ACTIVE, method = RequestMethod.PUT)
|
| - |
|
62 |
public ResponseEntity<?> setActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
| - |
|
63 |
try {
|
| - |
|
64 |
tagRepository.updateActiveById(id, true);
|
| - |
|
65 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| - |
|
66 |
return responseSender.badRequest(profitMandiBusinessException);
|
| - |
|
67 |
}
|
| - |
|
68 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1001"));
|
| - |
|
69 |
}
|
| - |
|
70 |
|
| - |
|
71 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_INACTIVE, method = RequestMethod.PUT)
|
| - |
|
72 |
public ResponseEntity<?> setInActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
| - |
|
73 |
try {
|
| - |
|
74 |
tagRepository.updateActiveById(id, false);
|
| - |
|
75 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| - |
|
76 |
return responseSender.badRequest(profitMandiBusinessException);
|
| - |
|
77 |
}
|
| - |
|
78 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1002"));
|
| - |
|
79 |
}
|
| - |
|
80 |
|
| 61 |
}
|
81 |
}
|