feat: 菜单更新接口
This commit is contained in:
parent
140ecadd0b
commit
8cba4462c8
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<MenuDataItem> {
|
||||
List<SystemMenu> 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<MenuDataItem> getMenus(String roleId);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user