Subversion Repositories SmartDukaan

Rev

Rev 23227 | Rev 23300 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23227 Rev 23273
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.util.Date;
3
import java.util.Date;
-
 
4
import java.util.List;
4
import java.util.Set;
5
import java.util.Set;
5
 
6
 
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletRequest;
7
 
8
 
8
import org.slf4j.Logger;
9
import org.slf4j.Logger;
Line 31... Line 32...
31
import com.spice.profitmandi.dao.entity.dtr.RetailerBrand;
32
import com.spice.profitmandi.dao.entity.dtr.RetailerBrand;
32
import com.spice.profitmandi.dao.entity.dtr.RetailerRegisteredAddress;
33
import com.spice.profitmandi.dao.entity.dtr.RetailerRegisteredAddress;
33
import com.spice.profitmandi.dao.entity.dtr.Shop;
34
import com.spice.profitmandi.dao.entity.dtr.Shop;
34
import com.spice.profitmandi.dao.entity.dtr.ShopAddress;
35
import com.spice.profitmandi.dao.entity.dtr.ShopAddress;
35
import com.spice.profitmandi.dao.entity.dtr.User;
36
import com.spice.profitmandi.dao.entity.dtr.User;
36
import com.spice.profitmandi.dao.entity.dtr.UserAccounts;
37
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
37
import com.spice.profitmandi.dao.entity.dtr.UserRole;
38
import com.spice.profitmandi.dao.entity.dtr.UserRole;
38
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
39
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
39
import com.spice.profitmandi.dao.entity.fofo.FofoStoreSequenceGeneration;
40
import com.spice.profitmandi.dao.entity.fofo.FofoStoreSequenceGeneration;
40
import com.spice.profitmandi.dao.entity.user.Address;
41
import com.spice.profitmandi.dao.entity.user.Address;
41
import com.spice.profitmandi.dao.entity.user.Cart;
42
import com.spice.profitmandi.dao.entity.user.Cart;
Line 271... Line 272...
271
			ShopAddress shopAddress = new ShopAddress();
272
			ShopAddress shopAddress = new ShopAddress();
272
			shopAddress.setShopId(shop.getId());
273
			shopAddress.setShopId(shop.getId());
273
			shopAddress.setAddressId(addressShop.getId());
274
			shopAddress.setAddressId(addressShop.getId());
274
			shopAddressRepository.persist(shopAddress);
275
			shopAddressRepository.persist(shopAddress);
275
		}
276
		}
276
		UserAccounts ua = new UserAccounts();
277
		UserAccount ua = new UserAccount();
277
		ua.setAccount_key(String.valueOf(saholicUser.getId()));
278
		ua.setAccountKey(saholicUser.getId());
278
		ua.setUser_id(user.getId());
279
		ua.setUserId(user.getId());
279
		ua.setAccount_type(AccountType.saholic);
280
		ua.setType(AccountType.saholic);
280
		userAccountRepository.persist(ua);
281
		userAccountRepository.persist(ua);
281
 
282
 
282
		UserAccounts ua2 = new UserAccounts();
283
		UserAccount ua2 = new UserAccount();
283
		ua2.setAccount_key(String.valueOf(saholicUser.getActiveCartId()));
284
		ua2.setAccountKey(saholicUser.getActiveCartId());
284
		ua2.setUser_id(user.getId());
285
		ua2.setUserId(user.getId());
285
		ua2.setAccount_type(AccountType.cartId);
286
		ua2.setType(AccountType.cartId);
286
		userAccountRepository.persist(ua2);
287
		userAccountRepository.persist(ua2);
287
		
288
		
288
		UserRole ur = new UserRole();
289
		UserRole ur = new UserRole();
289
		ur.setRoleType(RoleType.RETAILER);
290
		ur.setRoleType(RoleType.RETAILER);
290
		ur.setUserId(user.getId());
291
		ur.setUserId(user.getId());
Line 388... Line 389...
388
	public ResponseEntity<?> createFofoStore(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DISTRICT_NAME) String districtName) throws ProfitMandiBusinessException, Exception{
389
	public ResponseEntity<?> createFofoStore(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.DISTRICT_NAME) String districtName) throws ProfitMandiBusinessException, Exception{
389
		UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
390
		UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
390
		LOGGER.info("requestAttribute [userInfo={}]", userInfo);
391
		LOGGER.info("requestAttribute [userInfo={}]", userInfo);
391
		User user = userRepository.selectById(userInfo.getUserId());
392
		User user = userRepository.selectById(userInfo.getUserId());
392
		// = userAccountRepository.selectRetailerIdByUserId(user.getId());
393
		// = userAccountRepository.selectRetailerIdByUserId(user.getId());
393
		UserAccounts userAccounts = userAccountRepository.selectSaholicByUserId(user.getId());
394
		UserAccount userAccounts = userAccountRepository.selectSaholicByUserId(user.getId());
394
		Retailer retailer = retailerRepository.selectById(Integer.parseInt(userAccounts.getAccount_key()));
395
		Retailer retailer = retailerRepository.selectById(userAccounts.getAccountKey());
395
		try{
396
		try{
396
			userRoleRepository.selectByUserIdAndRoleType(user.getId(), RoleType.FOFO);
397
			userRoleRepository.selectByUserIdAndRoleType(user.getId(), RoleType.FOFO);
397
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
398
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
398
			throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, user.getId(), "USR_1013");
399
			throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, user.getId(), "USR_1013");
399
		}
400
		}
Line 545... Line 546...
545
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_REMOVE, method=RequestMethod.DELETE)
546
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_REMOVE, method=RequestMethod.DELETE)
546
	public ResponseEntity<?> removeBrand(HttpServletRequest request, @RequestParam(name = "brandId") int brandId, @RequestParam(name = "retailerId") int retailerId) throws ProfitMandiBusinessException{
547
	public ResponseEntity<?> removeBrand(HttpServletRequest request, @RequestParam(name = "brandId") int brandId, @RequestParam(name = "retailerId") int retailerId) throws ProfitMandiBusinessException{
547
		LOGGER.info("requested url : "+request.getRequestURL().toString());
548
		LOGGER.info("requested url : "+request.getRequestURL().toString());
548
		brandRepository.selectById(brandId);
549
		brandRepository.selectById(brandId);
549
		retailerRepository.selectById(retailerId);
550
		retailerRepository.selectById(retailerId);
550
		retailerBrandRepository.deleteByRetailerAndBrandId(retailerId, brandId);
551
		retailerBrandRepository.deleteByRetailerIdBrandId(retailerId, brandId);
551
		return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
552
		return responseSender.ok(ResponseCodeHolder.getMessage("API_OK_1001"));
552
		
553
		
553
	}
554
	}
554
	
555
	
555
	
556
	
Line 575... Line 576...
575
	}
576
	}
576
	
577
	
577
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ALL, method=RequestMethod.GET)
578
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_ADDRESS_ALL, method=RequestMethod.GET)
578
	public ResponseEntity<?> getAllAddresses(HttpServletRequest request, @RequestParam(name = "id") int id){
579
	public ResponseEntity<?> getAllAddresses(HttpServletRequest request, @RequestParam(name = "id") int id){
579
		LOGGER.info("requested url : "+request.getRequestURL().toString());
580
		LOGGER.info("requested url : "+request.getRequestURL().toString());
580
		return responseSender.ok(retailerAddressRepository.selectAddressesByRetailerId(id));
581
		List<Integer> addressIds = retailerAddressRepository.selectAddressIdsByRetailerId(id);
-
 
582
		return responseSender.ok(addressRepository.selectByIds(addressIds));
581
	}
583
	}
582
	
584
	
583
	
585
	
584
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ALL, method=RequestMethod.GET)
586
	@RequestMapping(value = ProfitMandiConstants.URL_RETAILER_BRAND_ALL, method=RequestMethod.GET)
585
	public ResponseEntity<?> getAllBrads(HttpServletRequest request, @RequestParam(name = "id") int id){
587
	public ResponseEntity<?> getAllBrads(HttpServletRequest request, @RequestParam(name = "id") int id){