feat(修改-bug): 修改一些bug

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-27 10:12:46 +08:00
parent e62c75b188
commit ce9ccd4fd9
8 changed files with 30 additions and 32 deletions

View File

@ -19,7 +19,7 @@ import java.util.List;
public class CategoryController {
@Autowired
private CategoryService categoryService;
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点")
@GetMapping(value = "findCategoryList/{parentId}")
@ -28,14 +28,13 @@ public class CategoryController {
return Result.success(list);
}
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Operation(summary = "导出数据", description = "导出数据")
@GetMapping(value = "/exportData")
public void exportData(HttpServletResponse response) {
public Result<String> exportData(HttpServletResponse response) {
categoryService.exportData(response);
return Result.success();
}
@Log(title = "根据parentId获取下级节点", businessType = 0)
@Operation(summary = "导入功能", description = "导入功能")
@PostMapping("importData")
public Result<String> importData(MultipartFile file) {

View File

@ -38,15 +38,15 @@ public class SysMenuController {
@Log(title = "修改菜单", businessType = 2)
@Operation(summary = "修改菜单", description = "修改菜单")
@PutMapping("updateById")
public Result<SysMenu> updateById(@RequestBody SysMenu sysMenu) {
sysMenuService.updateById(sysMenu);
@PutMapping("update")
public Result<SysMenu> update(@RequestBody SysMenu sysMenu) {
sysMenuService.update(sysMenu);
return Result.success();
}
@Log(title = "删除菜单", businessType = 3)
@Operation(summary = "删除菜单", description = "删除菜单")
@PutMapping("removeById/{id}")
@DeleteMapping("removeById/{id}")
public Result<Long> removeById(@PathVariable Long id) {
sysMenuService.removeById(id);
return Result.success();

View File

@ -26,7 +26,7 @@ public interface SysMenuMapper {
*
* @param sysMenu 系统菜单实体类
*/
void updateById(SysMenu sysMenu);
void update(SysMenu sysMenu);
/**
* 根据id查询菜单

View File

@ -25,7 +25,7 @@ public interface SysMenuService {
*
* @param sysMenu 系统菜单实体类
*/
void updateById(SysMenu sysMenu);
void update(SysMenu sysMenu);
/**
* 删除菜单

View File

@ -55,26 +55,24 @@ public class CategoryServiceImpl implements CategoryService {
*/
@Override
public void exportData(HttpServletResponse response) {
// 设置响应结果类型
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String filename = URLEncoder.encode("分类数据", StandardCharsets.UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + filename + ".xlsx");
// 查询数据库中的数据
List<Category> categoryList = categoryMapper.selectAll();
ArrayList<CategoryExcelVo> excelVoArrayList = new ArrayList<>();
// 将从数据库中查询到的Category对象转换成CategoryExcelVo对象
categoryList.forEach(category -> {
CategoryExcelVo vo = new CategoryExcelVo();
BeanUtils.copyProperties(category, vo, CategoryExcelVo.class);
excelVoArrayList.add(vo);
});
try {
// 1. 设置响应头信息
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String filename = URLEncoder.encode("分类数据", StandardCharsets.UTF_8);
response.setHeader("Content-dispostion", "attachment;filename=" + filename + ".xlsx");
// 查询数据库中的数据
List<Category> categoryList = categoryMapper.selectAll();
ArrayList<CategoryExcelVo> excelVoArrayList = new ArrayList<>();
// 将从数据库中查询到的Category对象转换成CategoryExcelVo对象
categoryList.forEach(category -> {
CategoryExcelVo vo = new CategoryExcelVo();
BeanUtils.copyProperties(category, vo, CategoryExcelVo.class);
excelVoArrayList.add(vo);
});
// 写出数据到浏览器端
EasyExcel.write(response.getOutputStream(), CategoryExcelVo.class).sheet("分类数据").doWrite(excelVoArrayList);
} catch (IOException exception) {

View File

@ -53,9 +53,9 @@ public class SysMenuServiceImpl implements SysMenuService {
* @param sysMenu 系统菜单实体类
*/
@Override
public void updateById(SysMenu sysMenu) {
public void update(SysMenu sysMenu) {
emptyUtil.isEmpty(sysMenu.getId(), MessageConstant.DELETE_ID_IS_NOT_EMPTY);
sysMenuMapper.updateById(sysMenu);
sysMenuMapper.update(sysMenu);
}
/**

View File

@ -20,4 +20,5 @@ bunny:
noAuthUrls:
- /admin/system/index/login
- /admin/system/index/generateValidateCode
- /admin/product/category/exportData

View File

@ -15,7 +15,7 @@
</insert>
<!-- 根据id修改菜单 -->
<update id="updateById">
<update id="update">
update sys_menu
set
<if test="parentId != null and parentId != ''">