Rev 21755 | Rev 21763 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.ResponseCodeHolder;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.web.util.ResponseSender;import com.spice.profitmandi.dao.entity.fofo.Tag;import com.spice.profitmandi.dao.repository.fofo.TagRepository;import com.spice.profitmandi.web.request.CreatePinCodeTagRequest;@Controller@Transactionalpublic class TagController {@AutowiredTagRepository tagRepository;@AutowiredResponseSender<?> responseSender;@RequestMapping(value = ProfitMandiConstants.URL_TAG_ID, method = RequestMethod.GET)public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {try{return responseSender.ok(tagRepository.selectById(id));}catch(ProfitMandiBusinessException profitMandiBusinessException){return responseSender.badRequest(profitMandiBusinessException);}}@RequestMapping(value = ProfitMandiConstants.URL_TAG_ALL, method = RequestMethod.GET)public ResponseEntity<?> getAll(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber, @RequestParam(name = ProfitMandiConstants.PAGE_SIZE) int pageSize) {return responseSender.ok(tagRepository.selectAll(pageNumber, pageSize));}@RequestMapping(value = ProfitMandiConstants.URL_TAG_ACTIVE, method = RequestMethod.PUT)public ResponseEntity<?> setActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {try {tagRepository.updateActiveById(id, true);} catch (ProfitMandiBusinessException profitMandiBusinessException) {return responseSender.badRequest(profitMandiBusinessException);}return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1001"));}@RequestMapping(value = ProfitMandiConstants.URL_TAG_INACTIVE, method = RequestMethod.PUT)public ResponseEntity<?> setInActive(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ID) int id) {try {tagRepository.updateActiveById(id, false);} catch (ProfitMandiBusinessException profitMandiBusinessException) {return responseSender.badRequest(profitMandiBusinessException);}return responseSender.ok(ResponseCodeHolder.getMessage("TG_OK_1002"));}}