|
@@ -0,0 +1,53 @@
|
|
|
+package com.fjhx.admin.service.product.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.admin.entity.product.dto.ProductClassifyDto;
|
|
|
+import com.fjhx.admin.entity.product.po.ProductClassify;
|
|
|
+import com.fjhx.admin.mapper.product.ProductClassifyMapper;
|
|
|
+import com.fjhx.admin.service.product.ProductClassifyService;
|
|
|
+import com.ruoyi.common.utils.TreeUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 产品分类 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author zlj
|
|
|
+ * @since 2023-03-15
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ProductClassifyServiceImpl extends ServiceImpl<ProductClassifyMapper, ProductClassify> implements ProductClassifyService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> tree(ProductClassify productClassify) {
|
|
|
+ // 分类名称
|
|
|
+ String name = productClassify.getName();
|
|
|
+
|
|
|
+ List<ProductClassify> list = lambdaQuery()
|
|
|
+ .select(ProductClassify::getId, ProductClassify::getName, ProductClassify::getParentId)
|
|
|
+ .like(ObjectUtil.isNotEmpty(name), ProductClassify::getName, name)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ // 构建树形
|
|
|
+ return TreeUtil.buildTree("name", list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void add(ProductClassifyDto productClassifyDto) {
|
|
|
+ this.save(productClassifyDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void edit(ProductClassifyDto productClassifyDto) {
|
|
|
+ this.updateById(productClassifyDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|