新增 批量添加目录下书签数量 数量可以自定义

This commit is contained in:
WangHao 2020-08-30 17:35:01 +08:00
parent fd61ceda4c
commit 102b94e4d1
7 changed files with 62 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import com.ruoyi.bookmark.service.ISqBookmarkService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.junit.Test;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
@ -155,6 +156,19 @@ public class SqMenuController extends BaseController
}
}
// /**
// * 批量更新书签的数量
// */
//
// @RequestMapping("/bookmarkcount")
// public void bookmarkcount()
// {
//
// Long[] menuIds={1L,2L,3L};
//
// sqMenuService.updateCountAdd(menuIds,5);
// logger.info("执行完毕");
// }
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.web.test.controller;
import com.ruoyi.bookmark.mapper.SqMenuMapper;
import com.ruoyi.bookmark.service.impl.SqMenuServiceImpl;
import com.ruoyi.web.controller.yunbookmark.SqBookmarkController;
import org.assertj.core.api.Assertions;
import org.junit.Before;
@ -24,6 +26,8 @@ public class SqBookmarkTest extends BaseSpringBootTest{
@Autowired
private SqBookmarkController sqBookmarkController;
@Autowired
private SqMenuMapper sqMenuMapper;
private MockMvc mockMvc;
@ -32,14 +36,23 @@ public class SqBookmarkTest extends BaseSpringBootTest{
mockMvc = MockMvcBuilders.standaloneSetup(sqBookmarkController).build();
logger.info("setup().........");
}
// @Test
// public void demo() throws Exception {
// MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/bookmark/bookmark/2"))
// .andExpect(MockMvcResultMatchers.status().isOk())
// .andDo(MockMvcResultHandlers.print())
// .andReturn();
//
// logger.info(mvcResult.getResponse().getContentAsString());
//
// }
@Test
public void demo() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/bookmark/bookmark/2"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcResultHandlers.print())
.andReturn();
Long[] menuIds={1L,4L,6L};
sqMenuMapper.updateCountAdd(menuIds,5);
logger.info("执行完毕");
logger.info(mvcResult.getResponse().getContentAsString());
}
}

View File

@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/dqsj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/dqsj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root
password: root
# 从库数据源

View File

@ -77,7 +77,7 @@ public interface SqMenuMapper extends MyMapper<SqMenu>
* @param menuIds
* @return 结果
*/
public int updateCountReduce(Long[] menuIds);
public int updateCountReduce(@Param("menuIds")Long[] menuIds,@Param("icount")int icount);
/**
* 批量添加目录下书签数量 +1
@ -85,7 +85,7 @@ public interface SqMenuMapper extends MyMapper<SqMenu>
* @param menuIds +1
* @return 结果
*/
public int updateCountAdd(Long[] menuIds);
public int updateCountAdd(@Param("menuIds")Long[] menuIds,@Param("icount")int icount);
}

View File

@ -13,20 +13,20 @@ public interface ISqMenuService
{
/**
* 批量减少目录下书签数量 -1
* 批量减少目录下书签数量
*
* @param menuIds
* @return 结果
*/
public int updateCountReduce(Long[] menuIds);
public int updateCountReduce(Long[] menuIds,int icount);
/**
* 批量添加目录下书签数量 +1
* 批量添加目录下书签数量
*
* @param menuIds +1
* @param menuIds
* @return 结果
*/
public int updateCountAdd(Long[] menuIds);
public int updateCountAdd(Long[] menuIds,int icount);
/**
* @auther: Wang
* @date: 2020/08/16 20:04

View File

@ -108,24 +108,24 @@ public class SqMenuServiceImpl implements ISqMenuService
/**
* 批量减少目录下书签数量 -1
* 批量减少目录下书签数量
*
* @param menuIds
* @return 结果
*/
@Override
public int updateCountReduce(Long[] menuIds){
return sqMenuMapper.updateCountReduce(menuIds);
public int updateCountReduce(Long[] menuIds,int icount){
return sqMenuMapper.updateCountReduce(menuIds,icount);
}
/**
* 批量添加目录下书签数量 +1
* 批量添加目录下书签数量
*
* @param menuIds +1
* @param menuIds
* @return 结果
*/
@Override
public int updateCountAdd(Long[] menuIds){
return sqMenuMapper.updateCountAdd(menuIds);
public int updateCountAdd(Long[] menuIds,int icount){
return sqMenuMapper.updateCountAdd(menuIds,icount);
}
}

View File

@ -92,18 +92,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="updateCountReduce" parameterType="String">
<foreach item="menuId" collection="array" separator=";" >
update sq_menu set bookmark_count=bookmark_count-1 where menu_id = #{menuId}
<update id="updateCountReduce" >
<foreach item="menuId" collection="menuIds" separator=";" >
update sq_menu set bookmark_count=bookmark_count - #{icount} where menu_id = #{menuId}
</foreach>
</delete>
</update>
<delete id="updateCountAdd" parameterType="String">
<foreach item="menuId" collection="array" separator=";" >
update sq_menu set bookmark_count=bookmark_count+1 where menu_id = #{menuId}
<update id="updateCountAdd" >
<foreach item="menuId" collection="menuIds" separator=";" >
update sq_menu set bookmark_count = bookmark_count + #{icount} where menu_id = #{menuId}
</foreach>
</delete>
</update>
</mapper>