@@ -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){
+ res.setData(rdService.updateBrowseOrDownload(id,1));
@RequestMapping(value = "/details",method = RequestMethod.GET)
public Result details(Long id){
Result res =new Result();
@@ -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);
@@ -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;
@@ -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);
@@ -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
+ where id = #{id,jdbcType=BIGINT}
+ </set>
+ </update>
</mapper>