Skip to content

Commit 7b36284

Browse files
Catalog
1 parent 2cd2ff8 commit 7b36284

File tree

41 files changed

+1550
-943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1550
-943
lines changed

sm-core-model/src/main/java/com/salesmanager/core/model/catalog/catalog/CatalogEntry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.salesmanager.core.model.catalog.catalog;
22

3+
import javax.persistence.Column;
34
import javax.persistence.Embedded;
45
import javax.persistence.Entity;
56
import javax.persistence.EntityListeners;
@@ -59,6 +60,11 @@ public class CatalogEntry extends SalesManagerEntity<Long, CatalogEntry> impleme
5960
@ManyToOne
6061
@JoinColumn(name = "CATALOG_ID", nullable = false)
6162
private Catalog catalog;
63+
64+
@Column(name = "VISIBLE")
65+
private boolean visible;
66+
67+
6268

6369
public Product getProduct() {
6470
return product;
@@ -105,4 +111,12 @@ public void setAuditSection(AuditSection audit) {
105111

106112
}
107113

114+
public boolean isVisible() {
115+
return visible;
116+
}
117+
118+
public void setVisible(boolean visible) {
119+
this.visible = visible;
120+
}
121+
108122
}

sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/catalog/CatalogRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ public interface CatalogRepository extends JpaRepository<Catalog, Long> {
1313

1414
@Query("select c from Catalog c join fetch c.merchantStore cm where c.code=?1 and cm.id = ?2")
1515
Catalog findByCode(String code, Integer merchantId);
16+
17+
@Query("SELECT COUNT(c) > 0 FROM Catalog c WHERE c.code = ?1")
18+
boolean existsByCode(String code);
1619

1720
}

sm-core/src/main/java/com/salesmanager/core/business/repositories/catalog/product/relationship/ProductRelationshipRepositoryImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public List<ProductRelationship> getByType(MerchantStore store, String type, Lan
9191
qs.append("left join fetch pap.descriptions papd ");
9292

9393
qs.append("where pr.code=:code ");
94-
qs.append("and rp.available=:available ");
94+
//qs.append("and rp.available=:available ");
9595
qs.append("and pr.store.id=:storeId ");
9696
qs.append("and rpd.language.id=:langId");
9797

@@ -103,7 +103,7 @@ public List<ProductRelationship> getByType(MerchantStore store, String type, Lan
103103
q.setParameter("code", type);
104104
q.setParameter("langId", language.getId());
105105
q.setParameter("storeId", store.getId());
106-
q.setParameter("available", true);
106+
//q.setParameter("available", true);
107107

108108

109109

sm-core/src/main/java/com/salesmanager/core/business/repositories/content/ContentRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public interface ContentRepository extends JpaRepository<Content, Long>, Conten
2323
@Query("select c from Content c left join fetch c.descriptions cd join fetch c.merchantStore cm where c.contentType in (?1) and cm.id = ?2 order by c.sortOrder asc")
2424
List<Content> findByTypes(List<ContentType> contentTypes, Integer storeId);
2525

26+
2627
@Query("select c from Content c left join fetch c.descriptions cd join fetch c.merchantStore cm where c.code = ?1 and cm.id = ?2")
2728
Content findByCode(String code, Integer storeId);
2829

sm-core/src/main/java/com/salesmanager/core/business/repositories/merchant/PageableMerchantRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public interface PageableMerchantRepository extends PagingAndSortingRepository<M
1717
Page<MerchantStore> listByStore(String code, Pageable pageable);
1818

1919

20-
@Query(value = "select distinct m from MerchantStore m left join fetch m.parent mp left join fetch m.country mc left join fetch m.currency mc left join fetch m.zone mz left join fetch m.defaultLanguage md left join fetch m.languages mls",
21-
countQuery = "select count(distinct m) from MerchantStore m join m.parent")
20+
@Query(value = "select distinct m from MerchantStore m left join fetch m.parent mp left join fetch m.country mc left join fetch m.currency mc left join fetch m.zone mz left join fetch m.defaultLanguage md left join fetch m.languages mls where (?1 is null or m.storename like %?1%)",
21+
countQuery = "select count(distinct m) from MerchantStore m join m.parent where (?1 is null or m.storename like %?1%)")
2222
Page<MerchantStore> listAll(String storeName, Pageable pageable);
2323

2424

sm-core/src/main/java/com/salesmanager/core/business/services/catalog/catalog/CatalogEntryService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
public interface CatalogEntryService extends SalesManagerEntityService<Long, CatalogEntry> {
1313

1414

15-
CatalogEntry add (CatalogEntry entry, Catalog catalog) throws ServiceException;
15+
void add (CatalogEntry entry, Catalog catalog) throws ServiceException;
1616

17-
void remove (Long entryId, Catalog catalog) throws ServiceException;
17+
void remove (CatalogEntry catalogEntry) throws ServiceException;
1818

1919
Page<CatalogEntry> list(Catalog catalog, MerchantStore store, Language language, String name, int page, int count) throws ServiceException;
2020

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
package com.salesmanager.core.business.services.catalog.catalog;
22

3-
import java.util.List;
4-
53
import javax.inject.Inject;
64

5+
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.data.domain.Page;
7+
import org.springframework.data.domain.PageRequest;
8+
import org.springframework.data.domain.Pageable;
89
import org.springframework.stereotype.Service;
910

1011
import com.salesmanager.core.business.exception.ServiceException;
1112
import com.salesmanager.core.business.repositories.catalog.catalog.CatalogEntryRepository;
13+
import com.salesmanager.core.business.repositories.catalog.catalog.PageableCatalogEntryRepository;
1214
import com.salesmanager.core.business.services.common.generic.SalesManagerEntityServiceImpl;
1315
import com.salesmanager.core.model.catalog.catalog.Catalog;
1416
import com.salesmanager.core.model.catalog.catalog.CatalogEntry;
1517
import com.salesmanager.core.model.merchant.MerchantStore;
1618
import com.salesmanager.core.model.reference.language.Language;
1719

1820
@Service("catalogEntryService")
19-
public class CatalogEntryServiceImpl
20-
extends SalesManagerEntityServiceImpl<Long, CatalogEntry>
21+
public class CatalogEntryServiceImpl extends SalesManagerEntityServiceImpl<Long, CatalogEntry>
2122
implements CatalogEntryService {
23+
24+
@Autowired
25+
private PageableCatalogEntryRepository pageableCatalogEntryRepository;
2226

2327
private CatalogEntryRepository catalogEntryRepository;
2428

@@ -29,70 +33,25 @@ public CatalogEntryServiceImpl(CatalogEntryRepository repository) {
2933
}
3034

3135
@Override
32-
public void save(CatalogEntry entity) throws ServiceException {
33-
// TODO Auto-generated method stub
34-
36+
public void add(CatalogEntry entry, Catalog catalog) throws ServiceException {
37+
entry.setCatalog(catalog);
38+
catalogEntryRepository.save(entry);
3539
}
3640

37-
@Override
38-
public void update(CatalogEntry entity) throws ServiceException {
39-
// TODO Auto-generated method stub
40-
41-
}
42-
43-
@Override
44-
public void create(CatalogEntry entity) throws ServiceException {
45-
// TODO Auto-generated method stub
46-
47-
}
48-
49-
@Override
50-
public void delete(CatalogEntry entity) throws ServiceException {
51-
// TODO Auto-generated method stub
52-
53-
}
54-
55-
@Override
56-
public CatalogEntry getById(Long id) {
57-
// TODO Auto-generated method stub
58-
return null;
59-
}
6041

6142
@Override
62-
public List<CatalogEntry> list() {
63-
// TODO Auto-generated method stub
64-
return null;
65-
}
66-
67-
@Override
68-
public Long count() {
69-
// TODO Auto-generated method stub
70-
return null;
71-
}
72-
73-
@Override
74-
public void flush() {
75-
// TODO Auto-generated method stub
76-
77-
}
43+
public Page<CatalogEntry> list(Catalog catalog, MerchantStore store, Language language, String name, int page,
44+
int count) throws ServiceException {
45+
Pageable pageRequest = new PageRequest(page, count);
46+
return pageableCatalogEntryRepository.listByCatalog(catalog.getId(), store.getId(), language.getId(), name, pageRequest);
7847

79-
@Override
80-
public CatalogEntry add(CatalogEntry entry, Catalog catalog) throws ServiceException {
81-
// TODO Auto-generated method stub
82-
return null;
8348
}
8449

8550
@Override
86-
public void remove(Long entryId, Catalog catalog) throws ServiceException {
87-
// TODO Auto-generated method stub
88-
51+
public void remove(CatalogEntry catalogEntry) throws ServiceException {
52+
catalogEntryRepository.delete(catalogEntry);
53+
8954
}
9055

91-
@Override
92-
public Page<CatalogEntry> list(Catalog catalog, MerchantStore store, Language language, String name, int page,
93-
int count) throws ServiceException {
94-
// TODO Auto-generated method stub
95-
return null;
96-
}
9756

9857
}

sm-core/src/main/java/com/salesmanager/core/business/services/catalog/catalog/CatalogService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public interface CatalogService extends SalesManagerEntityService<Long, Catalog>
3535
* Delete a Catalog and related objects
3636
*/
3737
void delete(Catalog catalog) throws ServiceException;
38+
39+
boolean existByCode(String code);
3840

3941
}

sm-core/src/main/java/com/salesmanager/core/business/services/catalog/catalog/CatalogServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,11 @@ public Catalog getByCode(String code, MerchantStore store) {
6363
return catalogRepository.findByCode(code, store.getId());
6464
}
6565

66+
@Override
67+
public boolean existByCode(String code) {
68+
return catalogRepository.existsByCode(code);
69+
}
70+
71+
72+
6673
}

sm-core/src/main/java/com/salesmanager/core/business/services/content/ContentService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ void saveOrUpdate( Content content )
4545

4646
Content getByCode( String code, MerchantStore store, Language language )
4747
throws ServiceException;
48+
49+
Content getById( Long id, MerchantStore store, Language language )
50+
throws ServiceException;
4851

4952
/**
5053
* Method responsible for storing content file for given Store.Files for given merchant store will be stored in

sm-core/src/main/java/com/salesmanager/core/business/services/content/ContentServiceImpl.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ public List<ContentDescription> listNameByType(List<ContentType> contentType, Me
8686
@Override
8787
public List<Content> listByType(List<ContentType> contentType, MerchantStore store)
8888
throws ServiceException {
89-
/*
90-
* List<String> contentTypes = new ArrayList<String>(); for (int i = 0; i < contentType.size();
91-
* i++) { contentTypes.add(contentType.get(i).name()); }
92-
*/
89+
9390

9491
return contentRepository.findByTypes(contentType, store.getId());
9592
}
@@ -404,6 +401,20 @@ public List<Content> getByCodeLike(ContentType type, String codeLike, MerchantSt
404401
language.getId());
405402
}
406403

404+
@Override
405+
public Content getById(Long id, MerchantStore store, Language language) throws ServiceException {
406+
407+
Content content = contentRepository.findOne(id);
408+
409+
if(content != null) {
410+
if(content.getMerchantStore().getId().intValue() != store.getId().intValue()) {
411+
return null;
412+
}
413+
}
414+
415+
return content;
416+
}
417+
407418

408419

409420
}

sm-core/src/main/java/com/salesmanager/core/business/services/merchant/MerchantStoreServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public Page<MerchantStore> listAll(Optional<String> storeName, int page, int cou
8888
}
8989
Pageable pageRequest = new PageRequest(page, count);
9090
return pageableMerchantRepository.listAll(store, pageRequest);
91+
9192
}
9293

9394

sm-shop-model/src/main/java/com/salesmanager/shop/model/catalog/catalog/CetalogEntryEntity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ public class CetalogEntryEntity extends Entity {
99
*/
1010
private static final long serialVersionUID = 1L;
1111
private String catalog;
12+
private boolean visible;
1213
public String getCatalog() {
1314
return catalog;
1415
}
1516
public void setCatalog(String catalog) {
1617
this.catalog = catalog;
1718
}
19+
public boolean isVisible() {
20+
return visible;
21+
}
22+
public void setVisible(boolean visible) {
23+
this.visible = visible;
24+
}
1825

1926
}

sm-shop-model/src/main/java/com/salesmanager/shop/model/catalog/catalog/PersistableCatalogEntry.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.salesmanager.shop.model.catalog.catalog;
22

3-
import com.salesmanager.shop.model.catalog.NamedEntity;
4-
5-
public class PersistableCatalogEntry extends NamedEntity {
3+
public class PersistableCatalogEntry extends CetalogEntryEntity {
64

75
/**
86
*
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.salesmanager.shop.model.catalog.catalog;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import com.salesmanager.shop.model.entity.ReadableList;
7+
8+
public class ReadableCatalogList extends ReadableList {
9+
10+
/**
11+
*
12+
*/
13+
private static final long serialVersionUID = 1L;
14+
private List<ReadableCatalog> catalogs = new ArrayList<ReadableCatalog>();
15+
public List<ReadableCatalog> getCatalogs() {
16+
return catalogs;
17+
}
18+
public void setCatalogs(List<ReadableCatalog> catalogs) {
19+
this.catalogs = catalogs;
20+
}
21+
22+
}

sm-shop-model/src/main/java/com/salesmanager/shop/model/content/ReadableContentDescription.java renamed to sm-shop-model/src/main/java/com/salesmanager/shop/model/content/ContentDescriptionEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.salesmanager.shop.model.catalog.NamedEntity;
44

5-
public class ReadableContentDescription extends NamedEntity {
5+
public class ContentDescriptionEntity extends NamedEntity {
66

77
/**
88
*
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.salesmanager.shop.model.content;
2+
3+
import com.salesmanager.core.model.content.ContentType;
4+
import com.salesmanager.shop.model.entity.Entity;
5+
6+
public class ContentEntity extends Entity {
7+
8+
private static final long serialVersionUID = 1L;
9+
private String code;
10+
private String contentType = ContentType.BOX.name();
11+
private boolean isDisplayedInMenu;
12+
private boolean visible;
13+
public String getCode() {
14+
return code;
15+
}
16+
public void setCode(String code) {
17+
this.code = code;
18+
}
19+
public String getContentType() {
20+
return contentType;
21+
}
22+
public void setContentType(String contentType) {
23+
this.contentType = contentType;
24+
}
25+
public boolean isDisplayedInMenu() {
26+
return isDisplayedInMenu;
27+
}
28+
public void setDisplayedInMenu(boolean isDisplayedInMenu) {
29+
this.isDisplayedInMenu = isDisplayedInMenu;
30+
}
31+
public boolean isVisible() {
32+
return visible;
33+
}
34+
public void setVisible(boolean visible) {
35+
this.visible = visible;
36+
}
37+
public static long getSerialversionuid() {
38+
return serialVersionUID;
39+
}
40+
41+
}

0 commit comments

Comments
 (0)