From 8cba4462c803742b8bd44e17465a3e24c2f9881e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Mon, 4 Nov 2024 15:54:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/SystemController.java | 11 +++++++---- .../harmony/mapper/SystemMapper.java | 3 ++- .../harmony/service/SystemService.java | 3 +++ .../harmony/service/impl/SystemServiceImpl.java | 17 +++++++++++++++++ src/main/resources/application.properties | 2 ++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java index f2e5a5d..dbfba90 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java @@ -1,15 +1,13 @@ package com.guaiguailang.harmony.controller; import cn.dev33.satoken.stp.StpUtil; +import com.guaiguailang.harmony.domain.entity.MenuDataItem; import com.guaiguailang.harmony.service.SystemService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @Tag(name="系统相关接口") @@ -36,4 +34,9 @@ public class SystemController { return ResponseEntity.ok(systemService.getMenuAll()); } + @PostMapping("/menu-update") + public ResponseEntity updateMenu(@RequestBody MenuDataItem menuDataItem) { + return ResponseEntity.ok(systemService.updateMenu(menuDataItem)); + } + } diff --git a/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java b/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java index f1c41b7..65f443a 100644 --- a/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java +++ b/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java @@ -1,5 +1,6 @@ package com.guaiguailang.harmony.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.guaiguailang.harmony.domain.entity.MenuDataItem; import com.guaiguailang.harmony.domain.entity.SystemMenu; import org.apache.ibatis.annotations.Mapper; @@ -8,7 +9,7 @@ import org.apache.ibatis.annotations.Select; import java.util.List; @Mapper -public interface SystemMapper { +public interface SystemMapper extends BaseMapper { List getAllMenus(); @Select("SELECT * from menu_data_item where id in (select system_role_menu.menu_id from system_role_menu where role_id=#{roleId})") List getMenus(String roleId); diff --git a/src/main/java/com/guaiguailang/harmony/service/SystemService.java b/src/main/java/com/guaiguailang/harmony/service/SystemService.java index d9eff11..e202b57 100644 --- a/src/main/java/com/guaiguailang/harmony/service/SystemService.java +++ b/src/main/java/com/guaiguailang/harmony/service/SystemService.java @@ -1,9 +1,12 @@ package com.guaiguailang.harmony.service; +import com.guaiguailang.harmony.domain.entity.MenuDataItem; import com.guaiguailang.harmony.domain.vo.ResponseResult; public interface SystemService { ResponseResult getMenu(); ResponseResult getMenuAll(); + + ResponseResult updateMenu(MenuDataItem menuDataItem); } diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java index 68ff2f1..aade168 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java @@ -45,4 +45,21 @@ public class SystemServiceImpl implements SystemService { return ResponseResult.success(menus); } + @Override + public ResponseResult updateMenu(MenuDataItem menuDataItem) { + // 更新操作 + try{ + int success = systemMapper.updateById(menuDataItem); + if (success==1) { + return ResponseResult.success("菜单更新成功"); + } else { + return ResponseResult.info(0,"菜单无变化"); + } + }catch (Exception e) { + log.error(e.getMessage()); + return ResponseResult.error(e.getMessage()); + } + + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 932321d..6ca368b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,6 +20,8 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # MyBatis Setting mybatis.type-aliases-package=com.guaiguailang.harmony.domain mybatis.mapper-locations=classpath:mapper/*.xml + + # 下划线转小驼峰 mybatis.configuration.map-underscore-to-camel-case=true