| Line 31... |
Line 31... |
| 31 |
import com.spice.profitmandi.dao.repository.catalog.PinCodeTagRepository;
|
31 |
import com.spice.profitmandi.dao.repository.catalog.PinCodeTagRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.catalog.RetailerTagRepository;
|
32 |
import com.spice.profitmandi.dao.repository.catalog.RetailerTagRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.catalog.TagRepository;
|
33 |
import com.spice.profitmandi.dao.repository.catalog.TagRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
35 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
- |
|
| 37 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
36 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 38 |
import com.spice.profitmandi.web.request.CreateTagRequest;
|
37 |
import com.spice.profitmandi.web.request.CreateTagRequest;
|
| 39 |
|
38 |
|
| 40 |
@Controller
|
39 |
@Controller
|
| 41 |
@Transactional(rollbackFor=Throwable.class)
|
40 |
@Transactional(rollbackFor=Throwable.class)
|
| 42 |
public class TagController {
|
41 |
public class TagController {
|
| 43 |
|
42 |
|
| 44 |
@Autowired
|
43 |
@Autowired
|
| 45 |
TagRepository tagRepository;
|
44 |
private TagRepository tagRepository;
|
| 46 |
|
45 |
|
| 47 |
@Autowired
|
46 |
@Autowired
|
| 48 |
PinCodeTagRepository pinCodeTagRepository;
|
47 |
private PinCodeTagRepository pinCodeTagRepository;
|
| 49 |
|
48 |
|
| 50 |
@Autowired
|
49 |
@Autowired
|
| 51 |
RetailerRepository retailerRepository;
|
50 |
private RetailerRepository retailerRepository;
|
| 52 |
|
51 |
|
| 53 |
@Autowired
|
52 |
@Autowired
|
| 54 |
UserAccountRepository userAccountRepoitory;
|
53 |
private UserAccountRepository userAccountRepoitory;
|
| 55 |
|
- |
|
| 56 |
|
54 |
|
| 57 |
@Autowired
|
55 |
@Autowired
|
| 58 |
UserRoleRepository userRoleRepository;
|
56 |
private UserRoleRepository userRoleRepository;
|
| 59 |
|
57 |
|
| 60 |
|
- |
|
| 61 |
@Autowired
|
58 |
@Autowired
|
| 62 |
UserRepository userRepoitory;
|
59 |
private RetailerTagRepository fofoTagRepository;
|
| 63 |
|
60 |
|
| 64 |
@Autowired
|
61 |
@Autowired
|
| 65 |
RetailerTagRepository fofoTagRepository;
|
- |
|
| 66 |
|
- |
|
| 67 |
@Autowired
|
- |
|
| 68 |
ResponseSender<?> responseSender;
|
62 |
private ResponseSender<?> responseSender;
|
| 69 |
|
63 |
|
| 70 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG, method = RequestMethod.POST)
|
64 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG, method = RequestMethod.POST)
|
| 71 |
public ResponseEntity<?> createPinCodeTag(HttpServletRequest request, @RequestBody CreateTagRequest createTagRequest) throws Throwable {
|
65 |
public ResponseEntity<?> createPinCodeTag(HttpServletRequest request, @RequestBody CreateTagRequest createTagRequest) throws Throwable {
|
| 72 |
Set<String> invalidPinCodes = new HashSet<>();
|
66 |
Set<String> invalidPinCodes = new HashSet<>();
|
| 73 |
for(String pinCode : createTagRequest.getPinCodes()){
|
67 |
for(String pinCode : createTagRequest.getPinCodes()){
|
| Line 135... |
Line 129... |
| 135 |
}
|
129 |
}
|
| 136 |
return responseSender.ok(ResponseCodeHolder.getMessage("PNCDTG_OK_1000"));
|
130 |
return responseSender.ok(ResponseCodeHolder.getMessage("PNCDTG_OK_1000"));
|
| 137 |
}
|
131 |
}
|
| 138 |
|
132 |
|
| 139 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ID, method = RequestMethod.GET)
|
133 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ID, method = RequestMethod.GET)
|
| 140 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
134 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) throws ProfitMandiBusinessException {
|
| 141 |
try{
|
- |
|
| 142 |
return responseSender.ok(tagRepository.selectById(id));
|
135 |
return responseSender.ok(tagRepository.selectById(id));
|
| 143 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
- |
|
| 144 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 145 |
}
|
- |
|
| 146 |
}
|
136 |
}
|
| 147 |
|
137 |
|
| 148 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ALL, method = RequestMethod.GET)
|
138 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ALL, method = RequestMethod.GET)
|
| 149 |
public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {
|
139 |
public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {
|
| 150 |
return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));
|
140 |
return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));
|
| 151 |
}
|
141 |
}
|
| 152 |
|
142 |
|
| 153 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ACTIVE, method = RequestMethod.PUT)
|
143 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_ACTIVE, method = RequestMethod.PUT)
|
| 154 |
public ResponseEntity<?> setActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
144 |
public ResponseEntity<?> setActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) throws ProfitMandiBusinessException{
|
| 155 |
try {
|
- |
|
| 156 |
tagRepository.updateActiveById(id, true);
|
145 |
tagRepository.updateActiveById(id, true);
|
| 157 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 158 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 159 |
}
|
- |
|
| 160 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1001"));
|
146 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1001"));
|
| 161 |
}
|
147 |
}
|
| 162 |
|
148 |
|
| 163 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_INACTIVE, method = RequestMethod.PUT)
|
149 |
@RequestMapping(value = ProfitMandiConstants.URL_TAG_INACTIVE, method = RequestMethod.PUT)
|
| 164 |
public ResponseEntity<?> setInActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {
|
150 |
public ResponseEntity<?> setInActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) throws ProfitMandiBusinessException{
|
| 165 |
try {
|
- |
|
| 166 |
tagRepository.updateActiveById(id, false);
|
151 |
tagRepository.updateActiveById(id, false);
|
| 167 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 168 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 169 |
}
|
- |
|
| 170 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1002"));
|
152 |
return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1002"));
|
| 171 |
}
|
153 |
}
|
| 172 |
|
154 |
|
| 173 |
}
|
155 |
}
|