Browse Source

预览下载自增开发

anderx 3 years ago
parent
commit
2199cbb3e0

+ 16 - 0
src/main/java/com/goafanti/RD/controller/RDContorller.java

@@ -90,6 +90,22 @@ public class RDContorller extends BaseApiController {
         return res;
     }
 
+
+
+    @RequestMapping(value = "/addBrowse",method = RequestMethod.POST)
+    public Result addBrowse(Long id){
+        Result res =new Result();
+        res.setData(rdService.updateBrowseOrDownload(id,0));
+        return res;
+    }
+
+    @RequestMapping(value = "/addDownload",method = RequestMethod.POST)
+    public Result addDownload(Long id){
+        Result res =new Result();
+        res.setData(rdService.updateBrowseOrDownload(id,1));
+        return res;
+    }
+
     @RequestMapping(value = "/details",method = RequestMethod.GET)
     public Result details(Long id){
         Result res =new Result();

+ 8 - 0
src/main/java/com/goafanti/RD/service/RDService.java

@@ -29,4 +29,12 @@ public interface RDService {
     boolean checkRdNo(String rdNo, Long id);
 
     int update(InputRdDetails in);
+
+    /**
+     *
+     * @param id 编号
+     * @param type  0为浏览 1为新增
+     * @return
+     */
+    int updateBrowseOrDownload(Long id, Integer type);
 }

+ 6 - 2
src/main/java/com/goafanti/RD/service/impl/RDServiceImpl.java

@@ -35,8 +35,7 @@ import java.util.*;
 public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RDService {
     @Autowired
     private RdDetailsMapper rdDetailsMapper;
-    @Autowired
-    private AdminMapper adminMapper;
+
 
 
 
@@ -54,6 +53,11 @@ public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RD
     }
 
     @Override
+    public int updateBrowseOrDownload(Long id, Integer type) {
+        return rdDetailsMapper.updateBrowseOrDownload(id,type);
+    }
+
+    @Override
     public boolean checkRdNo(String rdNo, Long id) {
         int i = rdDetailsMapper.checkRdNo(rdNo,id);
         if (i>0)return true;

+ 2 - 0
src/main/java/com/goafanti/common/dao/RdDetailsMapper.java

@@ -25,4 +25,6 @@ public interface RdDetailsMapper {
     int checkRdNo(@Param("rdNo") String rdNo,@Param("id")  Long id);
 
     void insertBatch(List<InputExcelRdDetails> list);
+
+    int updateBrowseOrDownload(@Param("id")Long id, @Param("type")Integer type);
 }

+ 13 - 2
src/main/java/com/goafanti/common/mapper/RdDetailsMapper.xml

@@ -340,8 +340,19 @@
       #{item.openTime,jdbcType=TIMESTAMP}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.aid,jdbcType=VARCHAR}
       )
     </foreach>
-
-
   </insert>
 
+  <update id="updateBrowseOrDownload">
+    update rd_details
+    <set>
+      <if test="type==0">
+        browse_count = browse_count+1
+      </if>
+      <if test="type==1">
+        download_count = download_count+1
+      </if>
+      where id = #{id,jdbcType=BIGINT}
+    </set>
+  </update>
+
 </mapper>