24282 2 years ago
parent
commit
b58194e507

+ 20 - 0
admin/pom.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.example</groupId>
+        <artifactId>test</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>admin</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+</project>

+ 1 - 1
src/main/java/com/fjhx/winfaster/WinfasterApplication.java → admin/src/main/java/com/fjhx/admin/WinfasterApplication.java

@@ -1,4 +1,4 @@
-package com.fjhx.winfaster;
+package com.fjhx.admin;
 
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.SpringApplication;

File diff suppressed because it is too large
+ 0 - 0
admin/src/main/java/com/fjhx/admin/a-json/ProductClassifyApi.json


+ 66 - 0
admin/src/main/java/com/fjhx/admin/controller/product/ProductClassifyController.java

@@ -0,0 +1,66 @@
+package com.fjhx.admin.controller.product;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fjhx.admin.entity.product.dto.ProductClassifyDto;
+import com.fjhx.admin.entity.product.po.ProductClassify;
+import com.fjhx.admin.service.product.ProductClassifyService;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 产品分类 前端控制器
+ * </p>
+ *
+ * @author zlj
+ * @since 2023-03-15
+ */
+@RestController
+@RequestMapping("/productClassify")
+public class ProductClassifyController {
+
+    @Autowired
+    private ProductClassifyService productClassifyService;
+
+    /**
+     * 产品分类树形
+     */
+    @PostMapping("/tree")
+    public List<JSONObject> tree(@RequestBody ProductClassify productClassify) {
+        List<JSONObject> tree = productClassifyService.tree(productClassify);
+        return tree;
+    }
+
+
+    /**
+     * 产品分类新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody ProductClassifyDto productClassifyDto) {
+        productClassifyService.add(productClassifyDto);
+    }
+
+    /**
+     * 产品分类编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody ProductClassifyDto productClassifyDto) {
+        productClassifyService.edit(productClassifyDto);
+    }
+
+    /**
+     * 产品分类删除
+     */
+    @PostMapping("/delete")
+    public void delete(@RequestBody BaseSelectDto dto) {
+        productClassifyService.delete(dto.getId());
+    }
+
+}

+ 17 - 0
admin/src/main/java/com/fjhx/admin/entity/product/dto/ProductClassifyDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.admin.entity.product.dto;
+
+import com.fjhx.admin.entity.product.po.ProductClassify;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 产品分类新增编辑入参实体
+ *
+ * @author zlj
+ * @since 2023-03-15
+ */
+@Getter
+@Setter
+public class ProductClassifyDto extends ProductClassify {
+
+}

+ 36 - 0
admin/src/main/java/com/fjhx/admin/entity/product/po/ProductClassify.java

@@ -0,0 +1,36 @@
+package com.fjhx.admin.entity.product.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 产品分类
+ * </p>
+ *
+ * @author zlj
+ * @since 2023-03-15
+ */
+@Getter
+@Setter
+@TableName("product_classify")
+public class ProductClassify extends BasePo {
+
+    /**
+     * 父级分类id
+     */
+    private Long parentId;
+
+    /**
+     * 父级分类id集合,用,拼接
+     */
+    private String parentIdSet;
+
+    /**
+     * 分类名称
+     */
+    private String name;
+
+}

+ 17 - 0
admin/src/main/java/com/fjhx/admin/mapper/product/ProductClassifyMapper.java

@@ -0,0 +1,17 @@
+package com.fjhx.admin.mapper.product;
+
+import com.fjhx.admin.entity.product.po.ProductClassify;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+
+/**
+ * <p>
+ * 产品分类 Mapper 接口
+ * </p>
+ *
+ * @author zlj
+ * @since 2023-03-15
+ */
+public interface ProductClassifyMapper extends BaseMapper<ProductClassify> {
+
+}

+ 42 - 0
admin/src/main/java/com/fjhx/admin/service/product/ProductClassifyService.java

@@ -0,0 +1,42 @@
+package com.fjhx.admin.service.product;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fjhx.admin.entity.product.dto.ProductClassifyDto;
+import com.fjhx.admin.entity.product.po.ProductClassify;
+import com.ruoyi.common.core.service.BaseService;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 产品分类 服务类
+ * </p>
+ *
+ * @author zlj
+ * @since 2023-03-15
+ */
+public interface ProductClassifyService extends BaseService<ProductClassify> {
+
+    /**
+     * 产品分类树形
+     */
+    List<JSONObject> tree(ProductClassify productClassify);
+
+    /**
+     * 产品分类新增
+     */
+    void add(ProductClassifyDto productClassifyDto);
+
+    /**
+     * 产品分类编辑
+     */
+    void edit(ProductClassifyDto productClassifyDto);
+
+    /**
+     * 产品分类删除
+     */
+    void delete(Long id);
+
+
+}

+ 53 - 0
admin/src/main/java/com/fjhx/admin/service/product/impl/ProductClassifyServiceImpl.java

@@ -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);
+    }
+
+}

+ 0 - 0
src/main/resources/application-dev.yml → admin/src/main/resources/application-dev.yml


+ 0 - 0
src/main/resources/application-prod.yml → admin/src/main/resources/application-prod.yml


+ 0 - 0
src/main/resources/application-test.yml → admin/src/main/resources/application-test.yml


+ 0 - 0
src/main/resources/application.yml → admin/src/main/resources/application.yml


+ 5 - 0
admin/src/main/resources/product/ProductClassifyMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.admin.mapper.product.ProductClassifyMapper">
+
+</mapper>

+ 11 - 0
pom.xml

@@ -7,6 +7,10 @@
     <groupId>org.example</groupId>
     <artifactId>test</artifactId>
     <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <modules>
+        <module>admin</module>
+    </modules>
 
     <properties>
         <maven.compiler.source>8</maven.compiler.source>
@@ -28,6 +32,13 @@
             <version>1.0.0</version>
         </dependency>
 
+<!--        <dependency>-->
+<!--            <groupId>com.fly</groupId>-->
+<!--            <artifactId>fly-generator</artifactId>-->
+<!--            <version>1.0.hx</version>-->
+<!--            <scope>test</scope>-->
+<!--        </dependency>-->
+
     </dependencies>
 
     <build>

Some files were not shown because too many files changed in this diff