diff --git a/README.md b/README.md index 50311bf74f..0edb89d9eb 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Shopizer (for java 1.8 +) ------------------- -[![last_version](https://img.shields.io/badge/last_version-v2.12.0-blue.svg?style=flat)](https://github.com/shopizer-ecommerce/shopizer/tree/2.12.0) +[![last_version](https://img.shields.io/badge/last_version-v2.13.0-blue.svg?style=flat)](https://github.com/shopizer-ecommerce/shopizer/tree/2.13.0) [![Official site](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=official%20site)](http://www.shopizer.com/) [![Docker Pulls](https://img.shields.io/docker/pulls/shopizerecomm/shopizer.svg)](https://hub.docker.com/r/shopizerecomm/shopizer) [![stackoverflow](https://img.shields.io/badge/shopizer-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/shopizer) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 50a0506487..6eecda7da2 100755 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,4 @@ -Release changes in version 2.12.0 +Release changes in version 2.13.0 Spring boot 2.2.6.RELEASE diff --git a/pom.xml b/pom.xml index 1a9aac3df4..606bc75046 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 pom shopizer @@ -44,7 +44,7 @@ / - 2.12.0 + 2.13.0 2.11.1 2.11.0 diff --git a/sm-core-model/pom.xml b/sm-core-model/pom.xml index a5336ae43d..9e06165bfd 100755 --- a/sm-core-model/pom.xml +++ b/sm-core-model/pom.xml @@ -7,7 +7,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 sm-core-model diff --git a/sm-core-modules/pom.xml b/sm-core-modules/pom.xml index 2eb624fda1..a326bf56d2 100755 --- a/sm-core-modules/pom.xml +++ b/sm-core-modules/pom.xml @@ -7,7 +7,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 sm-core-modules diff --git a/sm-core/pom.xml b/sm-core/pom.xml index 70a82c464c..170c56a056 100755 --- a/sm-core/pom.xml +++ b/sm-core/pom.xml @@ -7,7 +7,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 sm-core diff --git a/sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/product/type/PageableProductTypeRepository.java b/sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/product/type/PageableProductTypeRepository.java index 267a212c73..94e9d8425e 100644 --- a/sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/product/type/PageableProductTypeRepository.java +++ b/sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/product/type/PageableProductTypeRepository.java @@ -2,12 +2,16 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import com.salesmanager.core.model.catalog.product.type.ProductType; public interface PageableProductTypeRepository extends PagingAndSortingRepository { - //Page listByStore(Integer storeId, Pageable pageable); + + @Query(value = "select distinct p from ProductType p left join fetch p.descriptions pd left join fetch p.merchantStore pm where pm.id=?1", + countQuery = "select count(c) from ProductType p left join p.merchantStore pm where pm.id = ?1") + Page listByStore(Integer storeId, Pageable pageable); } diff --git a/sm-core/src/main/java/com/salesmanager/core/business/repositories/user/PageableUserRepository.java b/sm-core/src/main/java/com/salesmanager/core/business/repositories/user/PageableUserRepository.java index 96b01384bb..8a8ddc1f1e 100644 --- a/sm-core/src/main/java/com/salesmanager/core/business/repositories/user/PageableUserRepository.java +++ b/sm-core/src/main/java/com/salesmanager/core/business/repositories/user/PageableUserRepository.java @@ -16,11 +16,11 @@ public interface PageableUserRepository extends PagingAndSortingRepository listByStore(String store, String email, Pageable pageable); @Query(value = "select distinct u from User as u left join fetch u.groups ug left join fetch ug.permissions ugp left join fetch u.defaultLanguage ud join fetch u.merchantStore um where (?1 is null or u.adminEmail like %?1%)", - countQuery = "select count(distinct u) from User as u join u.merchantStore um where (?1 is null or u.adminEmail like %?1%)") + countQuery = "select count(distinct u) from User as u join u.groups ug join ug.permissions ugp join u.merchantStore um where (?1 is null or u.adminEmail like %?1%)") Page listAll(String email, Pageable pageable); @Query(value = "select distinct u from User as u left join fetch u.groups ug left join fetch ug.permissions ugp left join fetch u.defaultLanguage ud join fetch u.merchantStore um where um.id in ?1 and (?2 is null or u.adminEmail like %?2%)", - countQuery = "select count(distinct u) from User as u join u.merchantStore um where um.id in ?1 and (?2 is null or u.adminEmail like %?2%)") + countQuery = "select count(distinct u) from User as u join u.groups ug join ug.permissions ugp join u.merchantStore um where um.id in ?1 and (?2 is null or u.adminEmail like %?2%)") Page listByStoreIds(List stores, String email, Pageable pageable); diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserService.java b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserService.java index 8cca5bac05..5e5736d6f2 100755 --- a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserService.java +++ b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserService.java @@ -20,6 +20,8 @@ public interface UserService extends SalesManagerEntityService { User getByUserName(String userName, String storeCode) throws ServiceException; List listUser() throws ServiceException; + + User getById(Long id, MerchantStore store); /** * Create or update a User diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceImpl.java index 2057257c5c..8152f60f08 100755 --- a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceImpl.java +++ b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceImpl.java @@ -4,6 +4,7 @@ import javax.inject.Inject; import org.apache.commons.lang3.StringUtils; +import org.jsoup.helper.Validate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -20,112 +21,108 @@ import com.salesmanager.core.model.user.User; import com.salesmanager.core.model.user.UserCriteria; +public class UserServiceImpl extends SalesManagerEntityServiceImpl implements UserService { + private UserRepository userRepository; -public class UserServiceImpl extends SalesManagerEntityServiceImpl - implements UserService { + @Autowired + private MerchantStoreService merchantStoreService; + @Autowired + private PageableUserRepository pageableUserRepository; - private UserRepository userRepository; - - @Autowired - private MerchantStoreService merchantStoreService; - - @Autowired - private PageableUserRepository pageableUserRepository; - - @Inject - public UserServiceImpl(UserRepository userRepository) { - super(userRepository); - this.userRepository = userRepository; - - } - - - @Override - public User getByUserName(String userName) throws ServiceException { - return userRepository.findByUserName(userName); - } - + @Inject + public UserServiceImpl(UserRepository userRepository) { + super(userRepository); + this.userRepository = userRepository; + } - @Override - public void delete(User user) throws ServiceException { - User u = this.getById(user.getId()); - super.delete(u); + @Override + public User getByUserName(String userName) throws ServiceException { + return userRepository.findByUserName(userName); + } - } + @Override + public void delete(User user) throws ServiceException { + User u = this.getById(user.getId()); + super.delete(u); - @Override - public List listUser() throws ServiceException { - try { - return userRepository.findAll(); - } catch (Exception e) { - throw new ServiceException(e); - } - } + } - @Override - public List listByStore(MerchantStore store) throws ServiceException { - try { - return userRepository.findByStore(store.getId()); - } catch (Exception e) { - throw new ServiceException(e); - } - } + @Override + public List listUser() throws ServiceException { + try { + return userRepository.findAll(); + } catch (Exception e) { + throw new ServiceException(e); + } + } + @Override + public List listByStore(MerchantStore store) throws ServiceException { + try { + return userRepository.findByStore(store.getId()); + } catch (Exception e) { + throw new ServiceException(e); + } + } - @Override - public void saveOrUpdate(User user) throws ServiceException { - userRepository.save(user); - } + @Override + public void saveOrUpdate(User user) throws ServiceException { + userRepository.save(user); + } + @Override + public User findByStore(Long userId, String storeCode) throws ServiceException { - @Override - public User findByStore(Long userId, String storeCode) throws ServiceException { - - - User user = userRepository.findOne(userId); - - //store must be in lineage - boolean isFound = merchantStoreService.isStoreInGroup(storeCode); - - if(isFound) - return user; + User user = userRepository.findOne(userId); - return null; - - } + // store must be in lineage + boolean isFound = merchantStoreService.isStoreInGroup(storeCode); + if (isFound) + return user; - @Override - public GenericEntityList listByCriteria(Criteria criteria) throws ServiceException { - return userRepository.listByCriteria(criteria); - } + return null; + } - @Override - public User getByUserName(String userName, String storeCode) throws ServiceException { - return userRepository.findByUserName(userName, storeCode); - } + @Override + public GenericEntityList listByCriteria(Criteria criteria) throws ServiceException { + return userRepository.listByCriteria(criteria); + } + @Override + public User getByUserName(String userName, String storeCode) throws ServiceException { + return userRepository.findByUserName(userName, storeCode); + } -@Override -public Page listByCriteria(UserCriteria criteria, int page, int count) throws ServiceException { - - Pageable pageRequest = PageRequest.of(page, count); - Page users = null; - if(criteria.getStoreIds() != null) {//search within a predefined list of stores - users = pageableUserRepository.listByStoreIds(criteria.getStoreIds(), criteria.getAdminEmail(), pageRequest); - } else if(StringUtils.isBlank(criteria.getStoreCode())) {//search for a specific store - users = pageableUserRepository.listAll(criteria.getAdminEmail(), pageRequest); - } else if(criteria.getStoreIds() != null) {//full search - users = pageableUserRepository.listByStore(criteria.getStoreCode(), criteria.getAdminEmail(), pageRequest); + @Override + public Page listByCriteria(UserCriteria criteria, int page, int count) throws ServiceException { + + Pageable pageRequest = PageRequest.of(page, count); + Page users = null; + if (criteria.getStoreIds() != null) {// search within a predefined list + // of stores + users = pageableUserRepository.listByStoreIds(criteria.getStoreIds(), criteria.getAdminEmail(), + pageRequest); + } else if (StringUtils.isBlank(criteria.getStoreCode())) {// search for + // a + // specific + // store + users = pageableUserRepository.listAll(criteria.getAdminEmail(), pageRequest); + } else if (criteria.getStoreIds() != null) {// full search + users = pageableUserRepository.listByStore(criteria.getStoreCode(), criteria.getAdminEmail(), pageRequest); + } + + return users; } - - - return users; -} + @Override + public User getById(Long id, MerchantStore store) { + Validate.notNull(store, "MerchantStore cannot be null"); + return userRepository.findByUserId(id, store.getCode()); + } } diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceLDAPImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceLDAPImpl.java index c041b1aa00..2d6c66dc88 100755 --- a/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceLDAPImpl.java +++ b/sm-core/src/main/java/com/salesmanager/core/business/services/user/UserServiceLDAPImpl.java @@ -114,4 +114,10 @@ public Page listByCriteria(UserCriteria criteria, int page, int count) thr // TODO Auto-generated method stub return null; } + + @Override + public User getById(Long id, MerchantStore store) { + // TODO Auto-generated method stub + return null; + } } diff --git a/sm-shop-model/pom.xml b/sm-shop-model/pom.xml index cf7841e12d..69f1f73b65 100755 --- a/sm-shop-model/pom.xml +++ b/sm-shop-model/pom.xml @@ -5,7 +5,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 sm-shop-model diff --git a/sm-shop-model/src/main/java/com/salesmanager/shop/model/catalog/product/type/ReadableProductTypeList.java b/sm-shop-model/src/main/java/com/salesmanager/shop/model/catalog/product/type/ReadableProductTypeList.java new file mode 100644 index 0000000000..7341668a84 --- /dev/null +++ b/sm-shop-model/src/main/java/com/salesmanager/shop/model/catalog/product/type/ReadableProductTypeList.java @@ -0,0 +1,25 @@ +package com.salesmanager.shop.model.catalog.product.type; + +import java.util.ArrayList; +import java.util.List; + +import com.salesmanager.shop.model.entity.ReadableList; + +public class ReadableProductTypeList extends ReadableList { + + /** + * + */ + private static final long serialVersionUID = 1L; + + List list = new ArrayList(); + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + +} diff --git a/sm-shop-model/src/main/java/com/salesmanager/shop/model/shoppingcart/ReadableShoppingCart.java b/sm-shop-model/src/main/java/com/salesmanager/shop/model/shoppingcart/ReadableShoppingCart.java index 81d9f7b4e4..9fd169c1ab 100755 --- a/sm-shop-model/src/main/java/com/salesmanager/shop/model/shoppingcart/ReadableShoppingCart.java +++ b/sm-shop-model/src/main/java/com/salesmanager/shop/model/shoppingcart/ReadableShoppingCart.java @@ -26,6 +26,7 @@ public class ReadableShoppingCart extends ShoppingCartEntity { private BigDecimal total; private String displayTotal; private int quantity; + private Long order; List products = new ArrayList(); List totals; @@ -140,5 +141,17 @@ public void setQuantity(int quantity) { + public Long getOrder() { + return order; + } + + + + public void setOrder(Long order) { + this.order = order; + } + + + } diff --git a/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/product/facade/ProductTypeFacade.java b/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/product/facade/ProductTypeFacade.java index 162426b5eb..6c117c769e 100644 --- a/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/product/facade/ProductTypeFacade.java +++ b/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/product/facade/ProductTypeFacade.java @@ -1,15 +1,14 @@ package com.salesmanager.shop.store.controller.product.facade; -import java.util.List; - import com.salesmanager.core.model.merchant.MerchantStore; import com.salesmanager.core.model.reference.language.Language; import com.salesmanager.shop.model.catalog.product.type.PersistableProductType; import com.salesmanager.shop.model.catalog.product.type.ReadableProductType; +import com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeList; public interface ProductTypeFacade { - List getByMerchant(MerchantStore store, Language language); + ReadableProductTypeList getByMerchant(MerchantStore store, Language language, int count, int page); ReadableProductType get(MerchantStore store, String code, Language language); diff --git a/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacade.java b/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacade.java index b3941a3906..7ac8fe0ff1 100755 --- a/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacade.java +++ b/sm-shop-model/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacade.java @@ -31,11 +31,11 @@ public interface UserFacade { /** * Find user by id * @param id - * @param storeCode + * @param merchant * @param lang * @return */ - ReadableUser findById(Long id, String storeCode, Language lang); + ReadableUser findById(Long id, MerchantStore store, Language lang); /** * Creates a User diff --git a/sm-shop/files/store/DownlaodRepository.dat b/sm-shop/files/store/DownlaodRepository.dat index 36e41b152c..7918ccc5f0 100644 Binary files a/sm-shop/files/store/DownlaodRepository.dat and b/sm-shop/files/store/DownlaodRepository.dat differ diff --git a/sm-shop/pom.xml b/sm-shop/pom.xml index 28f1f7cdaf..e3f2a93a01 100755 --- a/sm-shop/pom.xml +++ b/sm-shop/pom.xml @@ -8,7 +8,7 @@ com.shopizer shopizer - 2.12.0 + 2.13.0 sm-shop @@ -64,10 +64,6 @@ spring-boot-starter-actuator - - - com.google.guava guava diff --git a/sm-shop/src/main/java/com/salesmanager/shop/populator/shoppingCart/ReadableShoppingCartPopulator.java b/sm-shop/src/main/java/com/salesmanager/shop/populator/shoppingCart/ReadableShoppingCartPopulator.java index 140d45e47d..a22d4f464d 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/populator/shoppingCart/ReadableShoppingCartPopulator.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/populator/shoppingCart/ReadableShoppingCartPopulator.java @@ -200,6 +200,10 @@ public ReadableShoppingCart populate(ShoppingCart source, ReadableShoppingCart t target.setQuantity(cartQuantity); target.setId(source.getId()); + if(source.getOrderId() != null) { + target.setOrder(source.getOrderId()); + } + } catch(Exception e) { throw new ConversionException(e); diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductTypeApi.java b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductTypeApi.java index cd612dc07f..8f0842cf13 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductTypeApi.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/product/ProductTypeApi.java @@ -7,10 +7,12 @@ import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.salesmanager.core.model.merchant.MerchantStore; import com.salesmanager.core.model.reference.language.Language; import com.salesmanager.shop.model.catalog.product.type.ReadableProductType; +import com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeList; import com.salesmanager.shop.store.controller.product.facade.ProductTypeFacade; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -46,11 +48,15 @@ public class ProductTypeApi { @ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en")}) - public List getTypes( + public ReadableProductTypeList getTypes( + @RequestParam(name="count", defaultValue="10") int count, + @RequestParam(name="page", defaultValue="0") int page, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) { + + return productTypeFacade.getByMerchant(merchantStore, language, count, page); - return productTypeFacade.getByMerchant(merchantStore, language); + } diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/user/UserApi.java b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/user/UserApi.java index d5b6f263d7..6c3244ae21 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/user/UserApi.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/api/v1/user/UserApi.java @@ -4,7 +4,6 @@ import java.security.Principal; import java.util.Arrays; -import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -30,8 +29,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import com.google.common.collect.ImmutableMap; -import com.salesmanager.core.model.common.Criteria; import com.salesmanager.core.model.merchant.MerchantStore; import com.salesmanager.core.model.reference.language.Language; import com.salesmanager.core.model.user.UserCriteria; @@ -43,11 +40,8 @@ import com.salesmanager.shop.model.user.ReadableUserList; import com.salesmanager.shop.model.user.UserPassword; import com.salesmanager.shop.store.api.exception.ResourceNotFoundException; -import com.salesmanager.shop.store.api.exception.RestApiException; import com.salesmanager.shop.store.api.exception.UnauthorizedException; -import com.salesmanager.shop.store.controller.store.facade.StoreFacade; import com.salesmanager.shop.store.controller.user.facade.UserFacade; -import com.salesmanager.shop.utils.ServiceRequestCriteriaBuilderUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -99,7 +93,7 @@ public ReadableUser get(@ApiIgnore MerchantStore merchantStore, @ApiIgnore Langu // only admin and superadmin allowed userFacade.authorizedGroup(authenticatedUser, Stream.of(Constants.GROUP_SUPERADMIN, Constants.GROUP_ADMIN, Constants.GROUP_ADMIN_RETAIL).collect(Collectors.toList())); - return userFacade.findById(id, merchantStore.getCode(), language); + return userFacade.findById(id, merchantStore, language); } /** @@ -142,8 +136,6 @@ public ReadableUser create( } @ResponseStatus(HttpStatus.OK) - // @PutMapping(value = {"/private/{store}/user/{id}","/private/user/{id}"}, - // produces = MediaType.APPLICATION_JSON_VALUE) @PutMapping(value = { "/private/user/{id}" }, produces = MediaType.APPLICATION_JSON_VALUE) @ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") }) @@ -200,10 +192,6 @@ public ReadableUserList list( criteria.setStoreCode(merchantStore.getCode()); - if (userFacade.userInRoles(authenticatedUser, Arrays.asList(Constants.GROUP_SUPERADMIN))) { - criteria.setStoreCode(null); - } - if (!userFacade.userInRoles(authenticatedUser, Arrays.asList(Constants.GROUP_SUPERADMIN))) { if (!userFacade.authorizedStore(authenticatedUser, merchantStore.getCode())) { throw new UnauthorizedException("Operation unauthorized for user [" + authenticatedUser @@ -212,7 +200,6 @@ public ReadableUserList list( } userFacade.authorizedGroup(authenticatedUser, Stream.of(Constants.GROUP_SUPERADMIN, Constants.GROUP_ADMIN, Constants.GROUP_ADMIN_RETAIL).collect(Collectors.toList())); - return userFacade.listByCriteria(criteria, page, count, language); } diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/shoppingCart/facade/ShoppingCartFacadeImpl.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/shoppingCart/facade/ShoppingCartFacadeImpl.java index 35ae6d8ed6..90a4016eb7 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/shoppingCart/facade/ShoppingCartFacadeImpl.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/shoppingCart/facade/ShoppingCartFacadeImpl.java @@ -426,7 +426,7 @@ public ShoppingCartData getShoppingCartData(final Customer customer, final Merch } //if cart has been completed return null - if(cart.getOrderId() != null) { + if(cart.getOrderId() != null && cart.getOrderId().longValue() > 0) { return null; } diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacadeImpl.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacadeImpl.java index 6a3d6af297..026e57565a 100755 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacadeImpl.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/user/facade/UserFacadeImpl.java @@ -385,16 +385,6 @@ public ReadableUser update(Long id, String authenticatedUser, String storeCode, } - @Override - public ReadableUser findById(Long id, String storeCode, Language lang) { - User user = getByUserId(id); - if (user == null) { - throw new ResourceNotFoundException("User [" + id + "] not found"); - } - - - return convertUserToReadableUser(lang, user); - } @Override public void changePassword(Long userId, String authenticatedUser, UserPassword changePassword) { @@ -638,5 +628,19 @@ public boolean authorizeStore(MerchantStore store, String path) { return true; } + @Override + public ReadableUser findById(Long id, MerchantStore store, Language lang) { + Validate.notNull(store, "MerchantStore cannot be null"); + + User user = userService.getById(id, store); + if (user == null) { + throw new ResourceNotFoundException("User [" + id + "] not found"); + } + + + return convertUserToReadableUser(lang, user); + + } + } diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/facade/product/ProductTypeFacadeImpl.java b/sm-shop/src/main/java/com/salesmanager/shop/store/facade/product/ProductTypeFacadeImpl.java index edd34caa23..9a7481e943 100644 --- a/sm-shop/src/main/java/com/salesmanager/shop/store/facade/product/ProductTypeFacadeImpl.java +++ b/sm-shop/src/main/java/com/salesmanager/shop/store/facade/product/ProductTypeFacadeImpl.java @@ -1,18 +1,20 @@ package com.salesmanager.shop.store.facade.product; -import java.util.ArrayList; -import java.util.List; - import org.jsoup.helper.Validate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import com.salesmanager.core.business.exception.ServiceException; + +import com.salesmanager.core.business.repositories.catalog.product.type.PageableProductTypeRepository; import com.salesmanager.core.business.services.catalog.product.type.ProductTypeService; import com.salesmanager.core.model.catalog.product.type.ProductType; import com.salesmanager.core.model.merchant.MerchantStore; import com.salesmanager.core.model.reference.language.Language; import com.salesmanager.shop.model.catalog.product.type.PersistableProductType; import com.salesmanager.shop.model.catalog.product.type.ReadableProductType; +import com.salesmanager.shop.model.catalog.product.type.ReadableProductTypeList; import com.salesmanager.shop.store.api.exception.ServiceRuntimeException; import com.salesmanager.shop.store.controller.product.facade.ProductTypeFacade; @@ -21,13 +23,27 @@ public class ProductTypeFacadeImpl implements ProductTypeFacade { @Autowired private ProductTypeService productTypeService; + + @Autowired + private PageableProductTypeRepository pageableProductTypeRepository; @Override - public List getByMerchant(MerchantStore store, Language language) { + public ReadableProductTypeList getByMerchant(MerchantStore store, Language language, int count, int page) { Validate.notNull(store, "MerchantStore cannot be null"); + ReadableProductTypeList returnList = new ReadableProductTypeList(); try { + + + Pageable pageRequest = PageRequest.of(page, count); + Page types = pageableProductTypeRepository.listByStore(store.getId(), pageRequest); + + if(types != null) { + //returnList.setList(types.); + } + + /* List productTypes = productTypeService.getByMerchant(store.getCode(), language); List readableTypes = new ArrayList(); for (ProductType type : productTypes) { @@ -38,10 +54,13 @@ public List getByMerchant(MerchantStore store, Language lan readableTypes.add(readableType); } return readableTypes; - } catch (ServiceException e) { + */ + } catch (Exception e) { throw new ServiceRuntimeException( "An exception occured while getting product types for merchant[ " + store.getCode() + "]"); } + + return null; } @Override diff --git a/sm-shop/src/main/webapp/resources/js/shop-minicart.js b/sm-shop/src/main/webapp/resources/js/shop-minicart.js index 56ee3086f7..f61ea369a6 100755 --- a/sm-shop/src/main/webapp/resources/js/shop-minicart.js +++ b/sm-shop/src/main/webapp/resources/js/shop-minicart.js @@ -9,7 +9,7 @@ function initMiniCart() { var cartCode = getCartCode(); - //log('Check for cart code ' + cartCode); + console.log(' Cart code ' + cartCode); if(cartCode!=null) { miniCart(cartCode); } else { @@ -251,8 +251,7 @@ function miniCart(cartCode){ }, success: function(miniCart) { - log('Success ' + miniCart.code); - + //log('Success ' + JSON.stringify(miniCart)); cleanupMiniCart(); miniCartSummary(miniCart); fullCart(miniCart);