完善>>編輯目录菜单,自动修改对应的上下级目录,书签数量统计
This commit is contained in:
parent
d62720f5a7
commit
0696de196b
@ -5,7 +5,9 @@ import java.util.List;
|
|||||||
import com.ruoyi.bookmark.service.ISqBookmarkService;
|
import com.ruoyi.bookmark.service.ISqBookmarkService;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||||
|
import org.apache.velocity.runtime.directive.Foreach;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -119,12 +121,34 @@ public class SqMenuController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody SqMenu sqMenu)
|
public AjaxResult edit(@RequestBody SqMenu sqMenu)
|
||||||
{
|
{
|
||||||
|
//查询当前目录的 所有下级目录ID
|
||||||
|
Long[] downMenuid = sqMenuService.selectBymenuidsubordinateid(sqMenu.getMenuId());
|
||||||
|
|
||||||
|
//自身menuId >> 所有下级目录的书签数量
|
||||||
|
int bookmarkCount =sqBookmarkService.selectByMenuIdCount(sqMenu.getMenuId());
|
||||||
|
for (Long menuId:downMenuid){
|
||||||
|
SqMenu menu=new SqMenu();
|
||||||
|
menu.setMenuId(menuId);
|
||||||
|
List<SqMenu> menulist= sqMenuService.selectSqMenuList(menu);
|
||||||
|
bookmarkCount +=menulist.get(0).getBookmarkCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================修改前,减少上级所有目录的书签统计数量===================
|
||||||
|
//查询书签修改前的所有上级
|
||||||
|
Long[] parentMenuidlist = sqMenuService.selectBymenuidParentid(sqMenu.getMenuId());
|
||||||
|
if (parentMenuidlist!=null&&parentMenuidlist.length>0){
|
||||||
|
sqMenuService.updateCountReduce(parentMenuidlist,bookmarkCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改
|
||||||
|
sqMenuService.updateSqMenu(sqMenu);
|
||||||
|
// ================修改后,增加上级所有目录的书签统计数量===================
|
||||||
//查询书签的所有上级
|
//查询书签的所有上级
|
||||||
|
Long[] parentMenuid = sqMenuService.selectBymenuidParentid(sqMenu.getMenuId());
|
||||||
//查询当前移动目录的 所有下级书签数量(包括下级目录书签)
|
if (parentMenuid!=null&&parentMenuid.length>0){
|
||||||
|
sqMenuService.updateCountAdd(parentMenuid,bookmarkCount);
|
||||||
|
}
|
||||||
return toAjax(sqMenuService.updateSqMenu(sqMenu));
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class SqMenu
|
|||||||
/** 下级书签数量 */
|
/** 下级书签数量 */
|
||||||
|
|
||||||
@Column(name = "bookmark_count")
|
@Column(name = "bookmark_count")
|
||||||
private Date bookmarkCount;
|
private Integer bookmarkCount;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ -68,11 +68,11 @@ public class SqMenu
|
|||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
public Date getBookmarkCount() {
|
public Integer getBookmarkCount() {
|
||||||
return bookmarkCount;
|
return bookmarkCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBookmarkCount(Date bookmarkCount) {
|
public void setBookmarkCount(Integer bookmarkCount) {
|
||||||
this.bookmarkCount = bookmarkCount;
|
this.bookmarkCount = bookmarkCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +92,11 @@ public interface ISqBookmarkService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SqBookmark> selectByUseridList(Long userId);
|
List<SqBookmark> selectByUseridList(Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据MenuId查询当前目录下 有多少书签数量
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int selectByMenuIdCount(Long menuId);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public interface ISqMenuService
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询 目录菜单的 所有下级ID
|
* 查询 目录菜单的 所有下级MenuId
|
||||||
*
|
*
|
||||||
* @param menuId 目录ID
|
* @param menuId 目录ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
@ -115,9 +115,9 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改目录下书签状态为 删除状态
|
* 根据menuID 修改目录下所有书签状态为 删除状态
|
||||||
*
|
*
|
||||||
* @param
|
* @param menuId
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -147,4 +147,25 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService
|
|||||||
sqBookmark.setIdelete(0); //未删除的书签
|
sqBookmark.setIdelete(0); //未删除的书签
|
||||||
return sqBookmarkMapper.select(sqBookmark);
|
return sqBookmarkMapper.select(sqBookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据MenuId查询当前目录下 有多少书签数量
|
||||||
|
*
|
||||||
|
* @param menuId
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int selectByMenuIdCount(Long menuId)
|
||||||
|
{
|
||||||
|
SqBookmark sqBookmark=new SqBookmark();
|
||||||
|
sqBookmark.setMenuId(menuId);
|
||||||
|
List<SqBookmark> sqBookmarks=sqBookmarkMapper.select(sqBookmark);
|
||||||
|
if (sqBookmarks!=null&&!sqBookmarks.isEmpty()){
|
||||||
|
return sqBookmarks.size();
|
||||||
|
}else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user