快捷菜单
This commit is contained in:
@@ -4,14 +4,18 @@ import com.czg.account.dto.menu.MenuAddDTO;
|
|||||||
import com.czg.account.dto.menu.MenuDelDTO;
|
import com.czg.account.dto.menu.MenuDelDTO;
|
||||||
import com.czg.account.dto.menu.MenuEditDTO;
|
import com.czg.account.dto.menu.MenuEditDTO;
|
||||||
import com.czg.account.entity.CashMenu;
|
import com.czg.account.entity.CashMenu;
|
||||||
|
import com.czg.account.entity.QuickMenu;
|
||||||
import com.czg.account.entity.SysMenu;
|
import com.czg.account.entity.SysMenu;
|
||||||
|
import com.czg.account.service.QuickMenuService;
|
||||||
import com.czg.account.service.SysMenuService;
|
import com.czg.account.service.SysMenuService;
|
||||||
import com.czg.account.vo.MenuVO;
|
import com.czg.account.vo.MenuVO;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.annotation.SaAdminCheckRole;
|
import com.czg.annotation.SaAdminCheckRole;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -19,6 +23,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单管理
|
* 菜单管理
|
||||||
|
*
|
||||||
* @author zs
|
* @author zs
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@@ -27,9 +32,12 @@ public class MenuController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysMenuService menuService;
|
private SysMenuService menuService;
|
||||||
|
@Resource
|
||||||
|
private QuickMenuService quickMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户菜单列表
|
* 获取当前用户菜单列表
|
||||||
|
*
|
||||||
* @return 菜单结构
|
* @return 菜单结构
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@@ -40,6 +48,7 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 收银机菜单
|
* 收银机菜单
|
||||||
|
*
|
||||||
* @return 所有菜单
|
* @return 所有菜单
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list/cash")
|
@GetMapping("/list/cash")
|
||||||
@@ -49,6 +58,7 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有菜单
|
* 获取所有菜单
|
||||||
|
*
|
||||||
* @return 菜单结构
|
* @return 菜单结构
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:list", name = "菜单列表")
|
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:list", name = "菜单列表")
|
||||||
@@ -62,6 +72,7 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单详情
|
* 菜单详情
|
||||||
|
*
|
||||||
* @return 菜单结构
|
* @return 菜单结构
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@@ -73,6 +84,7 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单添加
|
* 菜单添加
|
||||||
|
*
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@@ -84,6 +96,7 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单修改
|
* 菜单修改
|
||||||
|
*
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@@ -95,12 +108,15 @@ public class MenuController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单删除
|
* 菜单删除
|
||||||
|
*
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:del", name = "菜单删除")
|
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:del", name = "菜单删除")
|
||||||
@DeleteMapping()
|
@DeleteMapping()
|
||||||
|
@Transactional
|
||||||
public CzgResult<Boolean> edit(@RequestBody @Validated MenuDelDTO menuDelDTO) {
|
public CzgResult<Boolean> edit(@RequestBody @Validated MenuDelDTO menuDelDTO) {
|
||||||
|
quickMenuService.remove(QueryWrapper.create().eq(QuickMenu::getMenuId, menuDelDTO.getId()));
|
||||||
return CzgResult.success(menuService.removeById(menuDelDTO.getId()));
|
return CzgResult.success(menuService.removeById(menuDelDTO.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import com.czg.account.entity.QuickMenu;
|
||||||
|
import com.czg.account.service.QuickMenuService;
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗/快捷菜单
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/quick/")
|
||||||
|
@Slf4j
|
||||||
|
public class QuickMenuController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QuickMenuService quickMenuService;
|
||||||
|
|
||||||
|
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-列表")
|
||||||
|
@GetMapping
|
||||||
|
public CzgResult<List<QuickMenu>> getQuickList(Integer status) {
|
||||||
|
return CzgResult.success(quickMenuService.list(QueryWrapper.create()
|
||||||
|
.eq(QuickMenu::getShopId, StpKit.USER.getShopId())
|
||||||
|
.eq(QuickMenu::getStatus, status)
|
||||||
|
.orderBy(QuickMenu::getSort, true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-新增")
|
||||||
|
@PostMapping
|
||||||
|
public CzgResult<Boolean> getQuickList(@RequestBody @Validated QuickMenu quickMenu) {
|
||||||
|
quickMenu.setShopId(StpKit.USER.getShopId());
|
||||||
|
return CzgResult.success(quickMenuService.save(quickMenu));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-修改")
|
||||||
|
@PutMapping
|
||||||
|
public CzgResult<Boolean> updateQuick(@RequestBody @Validated QuickMenu quickMenu) {
|
||||||
|
return CzgResult.success(quickMenuService.update(quickMenu, QueryWrapper.create()
|
||||||
|
.eq(QuickMenu::getId, quickMenu.getId()).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-删除")
|
||||||
|
@DeleteMapping
|
||||||
|
public CzgResult<Boolean> deleteQuick(@RequestBody Set<Long> ids) {
|
||||||
|
return CzgResult.success(quickMenuService.remove(QueryWrapper.create().in(QuickMenu::getId, ids).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.czg.account.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗配置 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-12-29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("tb_quick_menu")
|
||||||
|
public class QuickMenu implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺Id
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
|
/**
|
||||||
|
* 菜单图标
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单Id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "关联菜单不能为空")
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 1-启用 0-禁用
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Column(onInsertValue = "now()")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.czg.account.service;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
import com.czg.account.entity.QuickMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗配置 服务层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-12-29
|
||||||
|
*/
|
||||||
|
public interface QuickMenuService extends IService<QuickMenu> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.czg.service.account.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.czg.account.entity.QuickMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗配置 映射层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-12-29
|
||||||
|
*/
|
||||||
|
public interface QuickMenuMapper extends BaseMapper<QuickMenu> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import com.czg.account.entity.QuickMenu;
|
||||||
|
import com.czg.account.service.QuickMenuService;
|
||||||
|
import com.czg.service.account.mapper.QuickMenuMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗配置 服务层实现。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-12-29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class QuickMenuServiceImpl extends ServiceImpl<QuickMenuMapper, QuickMenu> implements QuickMenuService{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.czg.service.account.mapper.QuickMenuMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user