大屏项目初始化

This commit is contained in:
2026-03-04 23:42:19 +08:00
parent e23a1f3965
commit b9dbd542e7
19 changed files with 641 additions and 243 deletions

View File

@@ -12,6 +12,7 @@ import com.mini.mybigscreen.utils.KeyUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -42,4 +43,22 @@ public class userController {
}
return Result.error("账号或密码错误");
}
/**
* 修改密码
*/
@PostMapping("/editPasswd")
public Result<?> getUserSave(String userId, String oldPasswd, String password) {
QueryWrapper<HomeUser> query = new QueryWrapper<>();
query.eq("user_id", userId)
.eq("password", AesUtil.encrypt(oldPasswd));
HomeUser user = userService.getOne(query, true);
if (ObjectUtils.isEmpty(user)) {
return Result.error("旧密码输入错误");
}
user.setPassword(AesUtil.encrypt(password));
userService.update(user, query);
return Result.success();
}
}

View File

@@ -4,7 +4,6 @@ import com.mini.mybigscreen.biz.domain.HomeMenu;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@@ -18,11 +17,12 @@ public class Menu implements Serializable {
private String menuIcon;
private Integer sort;
private Integer isIframe;
private String ustatus;
// 子菜单列表
private List<HomeMenu> children;
public Menu(String menuId,String parentId, String menuName, String menuType, String path,String menuIcon, Integer sort, Integer isIframe,List<HomeMenu> children) {
public Menu(String menuId, String parentId, String menuName, String menuType, String path, String menuIcon, Integer sort, Integer isIframe, String ustatus, List<HomeMenu> children) {
this.menuId = menuId;
this.parentId = parentId;
this.menuName = menuName;
@@ -31,6 +31,7 @@ public class Menu implements Serializable {
this.menuIcon = menuIcon;
this.sort = sort;
this.isIframe = isIframe;
this.ustatus = ustatus;
this.children = children;
}
}

View File

@@ -0,0 +1,24 @@
package com.mini.mybigscreen.Model;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class TreeMenu implements Serializable {
private String id;
private String label;
private List<TreeMenu> children;
public TreeMenu(){
}
public TreeMenu(String id, String label, List<TreeMenu> children) {
this.id = id;
this.label = label;
this.children = children;
}
}

View File

@@ -1,8 +1,10 @@
package com.mini.mybigscreen.biz.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mini.mybigscreen.Model.Menu;
import com.mini.mybigscreen.Model.Result;
import com.mini.mybigscreen.Model.TreeMenu;
import com.mini.mybigscreen.biz.domain.HomeMenu;
import com.mini.mybigscreen.biz.service.HomeMenuService;
import jakarta.annotation.Resource;
@@ -10,8 +12,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
@@ -31,7 +33,88 @@ public class HomeMenuController {
@GetMapping("list")
public Result<?> getList() {
public Result<?> getList(String menuName, String path, String ustatus, String menuId) {
QueryWrapper<HomeMenu> query = new QueryWrapper<>();
query.like(StrUtil.isNotBlank(menuName), "menu_name", menuName)
.like(StrUtil.isNotBlank(path), "path", path)
.eq(StrUtil.isNotBlank(ustatus), "ustatus", ustatus)
.orderByAsc("sort").orderByDesc("create_time");
List<HomeMenu> allHomeMenus = menuService.list(query);
if (StrUtil.isNotBlank(menuId)) {
Map<String, HomeMenu> menuMap = allHomeMenus.stream()
.collect(Collectors.toMap(HomeMenu::getMenuId, menu -> menu));
Set<String> targetIds = new HashSet<>();
HomeMenu targetMenu = menuMap.get(menuId);
if (targetMenu != null) {
targetIds.add(menuId);
boolean hasNew = true;
while (hasNew) {
hasNew = false;
for (HomeMenu menu : allHomeMenus) {
if (!targetIds.contains(menu.getMenuId()) && targetIds.contains(menu.getParentId())) {
targetIds.add(menu.getMenuId());
hasNew = true;
}
}
}
}
allHomeMenus = allHomeMenus.stream()
.filter(menu -> targetIds.contains(menu.getMenuId()))
.collect(Collectors.toList());
}
Map<String, List<HomeMenu>> parentIdToChildrenMap = new HashMap<>();
for (HomeMenu menu : allHomeMenus) {
parentIdToChildrenMap.computeIfAbsent(menu.getParentId(), k -> new ArrayList<>())
.add(menu);
}
List<Menu> menuList = allHomeMenus.stream()
.filter(homeMenu -> StrUtil.isNotBlank(menuId)
? menuId.equals(homeMenu.getMenuId())
: "0".equals(homeMenu.getParentId()))
.map(topHomeMenu -> new Menu(
topHomeMenu.getMenuId(),
topHomeMenu.getParentId(),
topHomeMenu.getMenuName(),
topHomeMenu.getMenuType(),
topHomeMenu.getPath(),
topHomeMenu.getMenuIcon(),
topHomeMenu.getSort(),
topHomeMenu.getIsIframe(),
topHomeMenu.getUstatus(),
parentIdToChildrenMap.getOrDefault(topHomeMenu.getMenuId(), new ArrayList<>())
))
.collect(Collectors.toList());
return Result.success(menuList);
}
@GetMapping("treeList")
public Result<?> getTreeList() {
List<TreeMenu> menuList = new ArrayList<>();
QueryWrapper<HomeMenu> query = new QueryWrapper<>();
query.eq("ustatus", "1")
.eq("parent_id", "0")
.orderByAsc("sort");
List<HomeMenu> pMenus = menuService.list(query);
for (HomeMenu menu : pMenus) {
QueryWrapper<HomeMenu> childQuery = new QueryWrapper<>();
childQuery.eq("parent_id", menu.getMenuId());
List<HomeMenu> childMenus = menuService.list(childQuery);
List<TreeMenu> treeMenus = childMenus.stream()
.map(homeMenu -> {
TreeMenu treeMenu = new TreeMenu();
treeMenu.setId(homeMenu.getMenuId());
treeMenu.setLabel(homeMenu.getMenuName());
return treeMenu;
})
.collect(Collectors.toList());
menuList.add(new TreeMenu(menu.getMenuId(), menu.getMenuName(), treeMenus));
}
return Result.success(menuList);
}
@GetMapping("userList")
public Result<?> getUserList() {
List<Menu> menuList = new ArrayList<>();
QueryWrapper<HomeMenu> query = new QueryWrapper<>();
query.eq("ustatus", "1")
@@ -51,6 +134,7 @@ public class HomeMenuController {
menu.getMenuIcon(),
menu.getSort(),
menu.getIsIframe(),
menu.getUstatus(),
childMenus
));
}

View File

@@ -73,5 +73,5 @@ public class HomeMenu implements Serializable {
private String menuIcon;
@TableField("ustatus")
private Integer ustatus;
private String ustatus;
}