浏览代码

统计,查询修改

hau 2 年之前
父节点
当前提交
9f1f7288b1

+ 3 - 1
src/main/java/com/caimei365/commodity/mapper/StatisticsTypeMapper.java

@@ -5,6 +5,8 @@ import com.caimei365.commodity.model.po.StatisticsTypePo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
+
 /**
  * @创建人 hzg
  * @创建时间 2022/8/30
@@ -16,5 +18,5 @@ public interface StatisticsTypeMapper {
     /**
      * 修改类型数量
      */
-    int updataTypeNumber(@Param("typeId") Integer typeId);
+    int updataTypeNumber(@Param("typeId") Integer typeId, @Param("clickTime")Date clickTime);
 }

+ 5 - 4
src/main/java/com/caimei365/commodity/model/po/StatisticsTypePo.java

@@ -3,6 +3,7 @@ package com.caimei365.commodity.model.po;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @创建人 hzg
@@ -15,12 +16,12 @@ public class StatisticsTypePo implements Serializable {
      * 主键statisticsId
      */
     private Integer statisticsId;
-    /**
-     * 类型统计数
-     */
-    private Integer typeNumber;
     /**
      * 类型
      */
     private Integer typeId;
+    /**
+     * 点击时间
+     */
+    private Date clickTime;
 }

+ 3 - 1
src/main/java/com/caimei365/commodity/service/impl/StatisticsTypeServiceImpl.java

@@ -6,6 +6,8 @@ import com.caimei365.commodity.service.StatisticsTypeService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
  * @创建人 hzg
@@ -23,7 +25,7 @@ public class StatisticsTypeServiceImpl implements StatisticsTypeService {
      */
     @Override
     public ResponseJson alterTypeNumber(Integer typeId) {
-        int i = typeMapper.updataTypeNumber(typeId);
+        int i = typeMapper.updataTypeNumber(typeId,new Date());
         return ResponseJson.success(i);
     }
 }

+ 1 - 0
src/main/resources/mapper/PageMapper.xml

@@ -977,6 +977,7 @@
             </if>
         </where>
         order by p.sortIndex desc,newshowTime desc
+        limit 20
     </select>
 
     <select id="getNewFloor" resultType="com.caimei365.commodity.model.vo.ProductItemVo">

+ 1 - 1
src/main/resources/mapper/StatisticsTypeMapper.xml

@@ -2,6 +2,6 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.commodity.mapper.StatisticsTypeMapper">
     <update id="updataTypeNumber" parameterType="com.caimei365.commodity.model.po.StatisticsTypePo">
-        update cm_statistics_type set typeNumber=typeNumber+1 where typeId = #{typeId}
+        insert into cm_statistics_type(typeId,clickTime) values (#{typeId},#{clickTime})
     </update>
 </mapper>