{
+
+}
diff --git a/src/main/java/io/github/talelin/latticy/model/CategoryDO.java b/src/main/java/io/github/talelin/latticy/model/CategoryDO.java
new file mode 100644
index 0000000000000000000000000000000000000000..23d825c9ccb88cb30cf49bf7a7226801ffddc9bf
--- /dev/null
+++ b/src/main/java/io/github/talelin/latticy/model/CategoryDO.java
@@ -0,0 +1,60 @@
+package io.github.talelin.latticy.model;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.github.talelin.latticy.dto.category.CategoryDTO;
+import io.github.talelin.latticy.dto.category.UpdateCategoryDTO;
+import io.github.talelin.latticy.dto.warehouse.WarehouseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.beans.BeanUtils;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 品类
+ * ClassName CategoryDO
+ * Description
+ * Create by zcy
+ * Date 2022-06-09
+ */
+@Data
+@TableName("wms_category")
+@EqualsAndHashCode(callSuper = true)
+public class CategoryDO extends BaseModel implements Serializable {
+
+
+ private static final long serialVersionUID = 4886045618174102463L;
+
+ /**
+ * 父ID
+ */
+ private Integer parentId;
+
+ /**
+ * 品类名称
+ */
+ private String categoryName;
+
+ /**
+ * 品类英文名称
+ */
+ private String categoryEnglishName;
+
+ /**
+ * 等级
+ */
+ private Integer level;
+
+ public CategoryDO(CategoryDTO dto) {
+ BeanUtils.copyProperties(dto, this);
+ }
+
+ public CategoryDO(Integer id, UpdateCategoryDTO dto) {
+ BeanUtils.copyProperties(dto, this);
+ this.setId(id);
+ }
+
+ public CategoryDO() {
+ }
+}
diff --git a/src/main/java/io/github/talelin/latticy/service/CategoryService.java b/src/main/java/io/github/talelin/latticy/service/CategoryService.java
new file mode 100644
index 0000000000000000000000000000000000000000..987c3203c74c5a705123cecc81203ea4fd431c11
--- /dev/null
+++ b/src/main/java/io/github/talelin/latticy/service/CategoryService.java
@@ -0,0 +1,62 @@
+package io.github.talelin.latticy.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.github.talelin.latticy.dto.category.CategoryDTO;
+import io.github.talelin.latticy.dto.category.CategoryPageDTO;
+import io.github.talelin.latticy.dto.category.UpdateCategoryDTO;
+import io.github.talelin.latticy.model.CategoryDO;
+
+import java.util.List;
+
+/**
+ * 品类管理
+ *
+ * ClassName CategoryService
+ * Description
+ * Create by zcy
+ * Date 2022-06-09
+ */
+public interface CategoryService extends IService {
+
+
+ /**
+ * 新增品类
+ *
+ * @param categoryDTO
+ */
+ void createCategory(CategoryDTO categoryDTO);
+
+
+ /**
+ * 修改品类
+ *
+ * @param id
+ * @param updateCategoryDTO
+ */
+ void updateCategory(Integer id, UpdateCategoryDTO updateCategoryDTO);
+
+
+ /**
+ * 删除品类
+ *
+ * @param id
+ */
+ void deleteCategory(Integer id);
+
+ /**
+ * 分页查询
+ *
+ * @param categoryPageDTO
+ * @return
+ */
+ IPage getCategoryPage(CategoryPageDTO categoryPageDTO);
+
+
+ /**
+ * 查询树形结构
+ *
+ * @return
+ */
+ List getCategoryTree();
+}
diff --git a/src/main/java/io/github/talelin/latticy/service/impl/CategoryServiceImpl.java b/src/main/java/io/github/talelin/latticy/service/impl/CategoryServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..106b98c8a0b8066d94510e7f847e5c7f8898d64b
--- /dev/null
+++ b/src/main/java/io/github/talelin/latticy/service/impl/CategoryServiceImpl.java
@@ -0,0 +1,86 @@
+package io.github.talelin.latticy.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.lang.Assert;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.github.talelin.latticy.common.mybatis.Page;
+import io.github.talelin.latticy.dto.category.CategoryDTO;
+import io.github.talelin.latticy.dto.category.CategoryPageDTO;
+import io.github.talelin.latticy.dto.category.UpdateCategoryDTO;
+import io.github.talelin.latticy.mapper.CategoryMapper;
+import io.github.talelin.latticy.model.CategoryDO;
+import io.github.talelin.latticy.service.CategoryService;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * ClassName CategoryServiceImpl
+ * Description
+ * Create by zcy
+ * Date 2022-06-09
+ */
+@Service
+public class CategoryServiceImpl extends ServiceImpl implements CategoryService {
+
+ @Override
+ public void createCategory(CategoryDTO categoryDTO) {
+ CategoryDO categoryDO = new CategoryDO(categoryDTO);
+ Assert.isTrue(this.baseMapper.insert(categoryDO) > 0, "18503");
+ }
+
+ @Override
+ public void updateCategory(Integer id, UpdateCategoryDTO updateCategoryDTO) {
+ CategoryDO categoryDO = new CategoryDO(id, updateCategoryDTO);
+ Assert.isTrue(this.baseMapper.updateById(categoryDO) > 0, "18504");
+ }
+
+ @Override
+ public void deleteCategory(Integer id) {
+ Assert.isTrue(this.baseMapper.deleteById(id) > 0, "18505");
+ }
+
+ @Override
+ public IPage getCategoryPage(CategoryPageDTO categoryPageDTO) {
+ return this.baseMapper.selectPage(new Page<>(categoryPageDTO.getPage(), categoryPageDTO.getCount()), new LambdaQueryWrapper().like(StrUtil.isNotEmpty(categoryPageDTO.getSearch()), CategoryDO::getCategoryName, categoryPageDTO.getSearch()).like(StrUtil.isNotEmpty(categoryPageDTO.getSearch()), CategoryDO::getCategoryEnglishName, categoryPageDTO.getSearch()));
+ }
+
+ @Override
+ public List getCategoryTree() {
+ List categoryDOList = this.baseMapper.selectList(new LambdaQueryWrapper<>());
+ //判断是否有数据
+ if (CollUtil.isEmpty(categoryDOList)) {
+ return new ArrayList<>();
+ }
+ List firstColumn = categoryDOList.stream().filter(c -> c.getParentId() == 0).map(CategoryDTO::new).collect(Collectors.toList());
+ List lastColumn = categoryDOList.stream().filter(c -> c.getParentId() != 0).map(CategoryDTO::new).collect(Collectors.toList());
+
+ return firstColumn.stream().filter((category) -> category.getParentId() == 0).map((category) -> {
+ category.setChildren(getChildren(category, lastColumn));
+ return category;
+ }).collect(Collectors.toList());
+ }
+
+ /**
+ * 递归查找所有菜单的子菜单
+ *
+ * @param root
+ * @param all
+ * @return
+ */
+ private List getChildren(CategoryDTO root, List all) {
+ return all.stream().filter(categoryEntity -> {
+ return categoryEntity.getParentId().equals(root.getId());
+ }).map(category -> {
+ //查询子品类
+ category.setChildren(getChildren(category, all));
+ return category;
+ }).collect(Collectors.toList());
+ }
+}
diff --git a/src/main/resources/ValidationMessages.properties b/src/main/resources/ValidationMessages.properties
index 9f5a75a22509ebbf00f4de8dae80df19e1fd3e84..39b73cb7137d852ab3cd24770c1ab1eef5709729 100644
--- a/src/main/resources/ValidationMessages.properties
+++ b/src/main/resources/ValidationMessages.properties
@@ -67,4 +67,10 @@ warearea.length=\u5206\u533A\u540D\u957F\u5EA6\u5FC5\u987B\u57282~10\u4E4B\u95F4
# \u5E93\u4F4D\u5F02\u5E38\u4FE1\u606F
location.not-blank=\u5E93\u4F4D\u540D\u4E0D\u53EF\u4E3A\u7A7A
-location.length=\u5E93\u4F4D\u540D\u957F\u5EA6\u5FC5\u987B\u57282~10\u4E4B\u95F4
\ No newline at end of file
+location.length=\u5E93\u4F4D\u540D\u957F\u5EA6\u5FC5\u987B\u57282~10\u4E4B\u95F4
+
+category.category-name=品类名称不可为空
+category.category-english-name=品类英文名称不可为空
+category.parent-id=上级ID不可为空
+category.level=等级不可为空
+category.id=品类ID不可为空
\ No newline at end of file
diff --git a/src/main/resources/code-message.properties b/src/main/resources/code-message.properties
index c427613c27e19a945463ef505242bb8802b4582a..fb223bb0530c3fa2556cf9ddb33d9a70a1a37122 100644
--- a/src/main/resources/code-message.properties
+++ b/src/main/resources/code-message.properties
@@ -78,3 +78,6 @@ code-message[18401]=\u5206\u533A\u4E0D\u5B58\u5728
code-message[18402]=\u5206\u533A\u5DF2\u4F7F\u7528\uFF0C\u4E0D\u80FD\u88AB\u5220\u9664
code-message[18501]=\u5E93\u4F4D\u540D\u79F0\u5DF2\u88AB\u5360\u7528
code-message[18502]=\u5E93\u4F4D\u4E0D\u5B58\u5728
+code-message[18503]=新增品类失败
+code-message[18504]=修改品类失败
+code-message[18505]=删除品类失败
\ No newline at end of file
diff --git a/src/main/resources/mapper/CategoryMapper.xml b/src/main/resources/mapper/CategoryMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..db39de07ab9928440213dcfaa763fb4400970991
--- /dev/null
+++ b/src/main/resources/mapper/CategoryMapper.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+