Parcourir la source

分类查询拍品接口

linhui.li il y a 1 semaine
Parent
commit
7efe7e5ed7

+ 1 - 1
auc/src/main/resources/application.yml

@@ -19,7 +19,7 @@ swagger:
   # 是否开启swagger
   enabled: true
   # 请求前缀
-  pathMapping: /
+  pathMapping: /auc/
 
 # 日志配置
 logging:

+ 11 - 3
bid/src/main/java/cn/hobbystocks/auc/web/LotController.java

@@ -28,17 +28,25 @@ public class LotController extends BaseController {
     @ApiOperation("热门拍品")
     public AjaxResult hotLot(@RequestBody Lot lot){
         if (lot.getPageSize()==null)
-            lot.setPageSize(20);
+            lot.setPageSize(20);//默认20条数据
         startPage(lot);
         //查询正在竞价中的拍品,按开始时间排序
         // todo 按计算的热度值排序;
         List<Lot> lots = lotService.selectBiddingLotList();
-
-
         return AjaxResult.success(lots);
     }
 
     /**
      * 根据分类查询拍品
      */
+    @PostMapping("/list/search")
+    @ApiOperation("资产-珍品搜索查询")
+    public AjaxResult searchLotList(@RequestBody Lot lot){
+        /*
+         * 查询拍品,关键字模糊匹配拍品名称
+         */
+        startPage(lot);
+        List<Lot> lots = lotService.queryLotByCategory(lot);
+        return AjaxResult.success(lots);
+    }
 }

+ 1 - 0
bid/src/main/resources/logback-spring.xml

@@ -41,6 +41,7 @@
 
     <!-- Spring日志级别控制  -->
     <logger name="org.springframework" level="warn" />
+<!--    <logger name="cn.hobbystocks.auc.mapper" level="debug"/>-->
     <!--系统操作日志-->
     <root level="info">
         <if condition='p("logging.console.enabled").equals("true")'>

+ 9 - 0
lot/src/main/java/cn/hobbystocks/auc/domain/Lot.java

@@ -9,11 +9,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import cn.hobbystocks.auc.common.core.domain.BaseEntity;
+import com.fasterxml.jackson.databind.JsonNode;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 import nonapi.io.github.classgraph.json.Id;
+import org.apache.ibatis.type.Alias;
 
 import javax.validation.constraints.NotBlank;
 
@@ -24,6 +26,7 @@ import javax.validation.constraints.NotBlank;
 @NoArgsConstructor
 @TableName("lot")
 @ApiModel("拍品")
+@Alias("lot")
 public class Lot extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -193,4 +196,10 @@ public class Lot extends BaseEntity
     private BigDecimal serviceTariff;
     @ApiModelProperty("中拍支付时限(小时)")
     private Integer payTimeLimit;
+    @ApiModelProperty("拍品分类:如资产类、收藏类")
+    private String category;
+    @ApiModelProperty("拍品子分类")
+    private String subCategory;
+    @ApiModelProperty("拍品属性json")
+    private JsonNode properties;
 }

+ 2 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java

@@ -58,4 +58,6 @@ public interface LotMapper extends BaseMapper<Lot> {
 
     List<Lot> selectBiddingLotList();
 
+    List<Lot> queryLotListByCategory(Lot lot);
+
 }

+ 63 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/handler/JsonNodeTypeHandler.java

@@ -0,0 +1,63 @@
+package cn.hobbystocks.auc.mapper.handler;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@MappedTypes(JsonNode.class)
+public class JsonNodeTypeHandler extends BaseTypeHandler<JsonNode> {
+
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
+    @Override
+    public void setNonNullParameter(PreparedStatement ps, int i, JsonNode parameter, JdbcType jdbcType)
+            throws SQLException {
+        ps.setString(i, parameter.toString());
+    }
+
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, String columnName) throws SQLException {
+        String json = rs.getString(columnName);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+        String json = rs.getString(columnIndex);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public JsonNode getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+        String json = cs.getString(columnIndex);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+}

+ 2 - 0
lot/src/main/java/cn/hobbystocks/auc/service/ILotService.java

@@ -114,4 +114,6 @@ public interface ILotService extends IService<Lot> {
     void calculatorAndUpdateLotHot();
 
     List<Lot> selectBiddingLotList();
+
+    List<Lot> queryLotByCategory(Lot lot);
 }

+ 5 - 0
lot/src/main/java/cn/hobbystocks/auc/service/impl/LotServiceImpl.java

@@ -636,4 +636,9 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
 
         return getBaseMapper().selectBiddingLotList();
     }
+
+    @Override
+    public List<Lot> queryLotByCategory(Lot lot) {
+        return baseMapper.queryLotListByCategory(lot);
+    }
 }

+ 41 - 5
lot/src/main/resources/mapper/LotMapper.xml

@@ -28,7 +28,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="dealAccountId"    column="deal_account_id"    />
         <result property="dealAccount"    column="deal_account"    />
         <result property="paid"    column="paid"    />
-
         <result property="bidCount"    column="bid_count"    />
         <result property="bidPersionCount"    column="bid_persion_count"    />
         <result property="delFlag"    column="del_flag"    />
@@ -49,11 +48,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="deposit" column="deposit"/>
         <result property="serviceTariff" column="service_tariff"/>
         <result property="payTimeLimit" column="pay_time_limit"/>
+        <result property="category" column="category"/>
+        <result property="subCategory" column="sub_category"/>
+        <result property="properties" column="properties" jdbcType="OTHER" typeHandler="cn.hobbystocks.auc.mapper.handler.JsonNodeTypeHandler"/>
     </resultMap>
 
     <sql id="selectLotVo">
         select id, goods_id, auction_id, name, num, unit, imgs, detail, pub_status, pub_time, status, start_time, end_time, real_end_time, rule_type, rule_content, last_price, last_price_time, deal_price, deal_time, deal_account_id, deal_account, paid,  bid_count, bid_persion_count, del_flag, create_by, create_time, update_by, update_time, sort,
-        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit
+        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit,category,sub_category,properties
          from lot
     </sql>
 
@@ -144,6 +146,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deposit !=null ">deposit,</if>
             <if test="serviceTariff !=null ">service_tariff,</if>
             <if test="payTimeLimit!=null">pay_limit_time,</if>
+            <if test="category!=null and category!=''">category,</if>
+            <if test="subCategory!=null and subCategory!=''">sub_category,</if>
+            <if test="properties!=null">properties,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -169,7 +174,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dealAccountId != null">#{dealAccountId},</if>
             <if test="dealAccount != null">#{dealAccount},</if>
             <if test="paid != null">#{paid},</if>
-
             <if test="bidCount != null">#{bidCount},</if>
             <if test="bidPersionCount != null">#{bidPersionCount},</if>
             <if test="delFlag != null">#{delFlag},</if>
@@ -190,6 +194,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deposit !=null ">#{deposit},</if>
             <if test="serviceTariff !=null ">#{serviceTariff},</if>
             <if test="payTimeLimit!=null">#{payTimeLimit},</if>
+            <if test="category!=null and category!=''">#{category},</if>
+            <if test="subCategory!=null and subCategory!=''">#{subCategory}</if>
+            <if test="properties!=null">#{properties,jdbcType=OTHER,typeHandler=cn.hobbystocks.auc.mapper.handler.JsonNodeTypeHandler}</if>
          </trim>
     </insert>
 
@@ -468,13 +475,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="selectBiddingLotList" resultMap="LotResult">
         select id, goods_id, auction_id, name, num, unit, imgs, detail, pub_status, pub_time, status, start_time, end_time, real_end_time, rule_type, rule_content, last_price, last_price_time, deal_price, deal_time, deal_account_id, deal_account, paid,  bid_count, bid_persion_count, del_flag, create_by, create_time, update_by, update_time, sort,
-        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit
+        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit,category,subCategory,properties
         from
         lot
         where
         status in ('Waiting','Starting','Bidding') and del_flag &lt;&gt; 1 and pub_status = 1
-        and start_time is not null and end_time is not null
         order by start_time
     </select>
 
+    <select id="queryLotListByCategory" resultMap="LotResult" parameterType="lot">
+        select id, goods_id, auction_id, name, num, unit, imgs, detail, pub_status, pub_time, status, start_time, end_time, real_end_time, rule_type, rule_content, last_price, last_price_time, deal_price, deal_time, deal_account_id, deal_account, paid,  bid_count, bid_persion_count, del_flag, create_by, create_time, update_by, update_time, sort,
+        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit,category,sub_category,properties
+        from
+        lot
+        <where>
+            del_flag &lt;&gt; 1 and pub_status = 1
+            <if test="category!=null and category!=''">
+                and category=#{category}
+            </if>
+            <if test="subCategory!=null and subCategory!=''">
+                and sub_category=#{subCategory}
+            </if>
+            <if test="searchValue!=null and searchValue!=''">
+                and name like concat('%',#{searchValue},'%')
+            </if>
+            <if test="status==1">
+                and status in ('Starting','Bidding')
+            </if>
+            <if test="status==2">
+                and status ='Waiting'
+            </if>
+            <if test="status==3">
+                and status ='Sold'
+            </if>
+            <if test="status==4">
+                and now()+ interval '1 hour'>end_time and status in ('Starting','Bidding')
+            </if>
+        </where>
+    </select>
 </mapper>