我使用 Spring Boot 并通过多个模块进行设计。下面是我的项目结构:
模块商店核心:包名称:com.baotrung.core.business 我设计了一些子包:模型,存储库,服务
行长:
<modelVersion>4.0.0</modelVersion>
<artifactId>shop-core</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- shop-core-model !-->
<dependency>
<groupId>com.baotrung</groupId>
<artifactId>shop-core-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
类别服务
public interface CategoryService {
List<Object> countProductsByCategories(MerchantStore store, List<Long> categoryIds);
List<Category> listByStoreAndParent(MerchantStore store, Category category);
PersistableCategory saveCategories(MerchantStore store, PersistableCategory persistableCategory);
Category findById(Long id);
List<ReadableCategory> findCategories(MerchantStore store, int dept, Language language,List<String> filters);
}
类别 服务实施
@Service
public class CategoryServiceImpl implements CategoryService {
@Autowired
private CategoriesRepository categoryRepository;
@Autowired
private LanguageRepository languageRepository;
@Autowired
private Mapper<Category,ReadableCategory> categoryReadableCategoryMapper;
//some method
@存储库
public interface CategoriesRepository extends CrudRepository<Category, Long>, CategoryRepositoryCustom {
}
public interface CategoryRepositoryCustom {
List<Object> countProductsByCategories(MerchantStore store, List<Long> categoryIds);
List<Category> listByStoreAndParent(MerchantStore store, Category category);
}
@Repository
public class CategoryRepositoryCustomImpl implements CategoryRepositoryCustom {
// some method impl
}
开满天机
ABOUTYOU
相关分类