home chao 5 年 前
コミット
0b3a88c0b2

+ 25 - 0
caimei-search/pom.xml

@@ -0,0 +1,25 @@
+<?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">
+    <parent>
+        <artifactId>caimei-modules-soa</artifactId>
+        <groupId>com.caimei.module</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>caimei-search</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+</project>

+ 11 - 0
caimei-search/src/main/java/com/caimei/module/dao/SearchMapper.java

@@ -0,0 +1,11 @@
+package com.caimei.module.dao;
+
+import com.caimei.module.entity.CmMallOrganizeProducts;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface SearchMapper {
+    List<CmMallOrganizeProducts> searchProduct(Integer organizeID, String searchWord);
+}

+ 107 - 0
caimei-search/src/main/java/com/caimei/module/entity/CmMallOrganizeProducts.java

@@ -0,0 +1,107 @@
+package com.caimei.module.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * cm_mall_organize_products
+ * @author
+ */
+@Data
+public class CmMallOrganizeProducts implements Serializable {
+    private Integer id;
+
+    /**
+     * 对应cm_mall_products_classify商品分类表id
+     */
+    private Integer classifyID;
+
+    /**
+     * 组织ID,具体对应cm_mall_organize表ID
+     */
+    private Integer organizeID;
+
+    /**
+     * 商品ID,具体对应product表
+     */
+    private Integer productID;
+
+    /**
+     * 市场价
+     */
+    private BigDecimal normalPrice;
+
+    /**
+     * 成本价
+     */
+    private BigDecimal costPrice;
+
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    private String ladderPriceFlag;
+
+    /**
+     * 售价(此起售价适用于非阶梯价格)
+     */
+    private BigDecimal retailPrice;
+
+    /**
+     * 最小起订量(此起订量适用于非阶梯价格)
+     */
+    private Integer minBuyNumber;
+
+    /**
+     * [对应表cm_mall_page_modules模块一]:是否是星范优惠:0不是优惠,1优惠商品
+     */
+    private String preferredProduct;
+
+    /**
+     * [对应表cm_mall_page_modules模块二]:是否是星范精品:0不是精品,1星范精品商品
+     */
+    private String preferentialProduct;
+
+    /**
+     * [对应表cm_mall_page_modules模块三]:是否是常用商品:0不是常用,1常用商品
+     */
+    private String commonlyProduct;
+
+    /**
+     * 商品状态,1已上架,2已下架
+     */
+    private String validFlag;
+
+    /**
+     * 模块一(优惠排序)排序默认为空,排序优先级1最高,空最后
+     */
+    private Integer preferredProductSort;
+
+    /**
+     * 模块二(精品排序)排序默认为空,排序优先级1最高,空最后
+     */
+    private Integer preferentialProductSort;
+
+    /**
+     * 模块三(常用排序)排序默认为空,排序优先级1最高,空最后
+     */
+    private Integer commonlyProductSort;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     *  0 有效  其它无效
+     */
+    private String delFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 15 - 0
caimei-search/src/main/java/com/caimei/module/service/SearchService.java

@@ -0,0 +1,15 @@
+package com.caimei.module.service;
+
+import com.caimei.module.entity.CmMallOrganizeProducts;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/2/27
+ */
+public interface SearchService {
+    List<CmMallOrganizeProducts> searchProduct(Integer organizeID, String searchWord);
+}

+ 26 - 0
caimei-search/src/main/java/com/caimei/module/service/impl/SearchServiceImpl.java

@@ -0,0 +1,26 @@
+package com.caimei.module.service.impl;
+
+import com.caimei.module.dao.SearchMapper;
+import com.caimei.module.entity.CmMallOrganizeProducts;
+import com.caimei.module.service.SearchService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/2/27
+ */
+@Service
+public class SearchServiceImpl implements SearchService {
+    @Resource
+    private SearchMapper searchMapper;
+    @Override
+    public List<CmMallOrganizeProducts> searchProduct(Integer organizeID, String searchWord) {
+        List<CmMallOrganizeProducts> productsList = searchMapper.searchProduct(organizeID, searchWord);
+        return productsList;
+    }
+}

+ 7 - 0
caimei-search/src/main/resources/application.yml

@@ -0,0 +1,7 @@
+
+#整合mybatis
+mybatis:
+  #加载Mybatis映射文件
+  mapper-locations: classpath:mapper/*Mapper.xml
+  #pojo别名扫描包
+  type-aliases-package: com.caimei.module.entity

+ 48 - 0
caimei-search/src/main/resources/mapper/SearchMapper.xml

@@ -0,0 +1,48 @@
+<?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.caimei.module.dao.SearchMapper">
+  <resultMap id="BaseResultMap" type="com.caimei.module.entity.CmMallOrganizeProducts">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="classifyID" jdbcType="INTEGER" property="classifyID" />
+    <result column="organizeID" jdbcType="INTEGER" property="organizeID" />
+    <result column="productID" jdbcType="INTEGER" property="productID" />
+    <result column="normalPrice" jdbcType="DECIMAL" property="normalPrice" />
+    <result column="costPrice" jdbcType="DECIMAL" property="costPrice" />
+    <result column="ladderPriceFlag" jdbcType="CHAR" property="ladderPriceFlag" />
+    <result column="retailPrice" jdbcType="DECIMAL" property="retailPrice" />
+    <result column="minBuyNumber" jdbcType="INTEGER" property="minBuyNumber" />
+    <result column="preferredProduct" jdbcType="CHAR" property="preferredProduct" />
+    <result column="preferentialProduct" jdbcType="CHAR" property="preferentialProduct" />
+    <result column="commonlyProduct" jdbcType="CHAR" property="commonlyProduct" />
+    <result column="validFlag" jdbcType="CHAR" property="validFlag" />
+    <result column="preferredProductSort" jdbcType="INTEGER" property="preferredProductSort" />
+    <result column="preferentialProductSort" jdbcType="INTEGER" property="preferentialProductSort" />
+    <result column="commonlyProductSort" jdbcType="INTEGER" property="commonlyProductSort" />
+    <result column="addTime" jdbcType="TIMESTAMP" property="addTime" />
+    <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="delFlag" jdbcType="CHAR" property="delFlag" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, classifyID, organizeID, productID, normalPrice, costPrice, ladderPriceFlag, retailPrice,
+    minBuyNumber, preferredProduct, preferentialProduct, commonlyProduct, validFlag,
+    preferredProductSort, preferentialProductSort, commonlyProductSort, addTime, updateTime,
+    delFlag
+  </sql>
+  <select id="searchProduct" resultType="com.caimei.module.entity.CmMallOrganizeProducts">
+    SELECT
+      cmop.*,
+      p.mainImage,
+      p.name,
+      p.unit
+    FROM
+      cm_mall_organize_products cmop
+        LEFT JOIN product p ON cmop.productID = p.productID
+    WHERE
+      cmop.organizeID = 1
+      AND cmop.validFlag = '1'
+      AND cmop.delFlag = '0'
+      AND p.name LIKE CONCAT('%', #{searchWord}, '%')
+      AND p.productID IS NOT NULL
+  </select>
+
+</mapper>

+ 68 - 0
pom.xml

@@ -0,0 +1,68 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>pom</packaging>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.4.RELEASE</version>
+        <relativePath/>
+    </parent>
+    <groupId>com.caimei.module</groupId>
+    <artifactId>caimei-modules-soa</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>caimei-modules-soa</name>
+    <description>面向服务的组件模块集合,每个子模块一个独立服务。</description>
+    <modules>
+        <module>caimei-search</module>
+    </modules>
+    <properties>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
+
+        <module.latest.version>1.0.0-SNAPSHOT</module.latest.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- spring-cloud-parent -->
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>Hoxton.RELEASE</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.0.0</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>