dev-v2 #3

Merged
bunny merged 122 commits from dev-v2 into master-v2 2024-03-30 23:40:58 +08:00
8 changed files with 30 additions and 32 deletions
Showing only changes of commit ce9ccd4fd9 - Show all commits

View File

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

View File

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

View File

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

View File

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

View File

@ -55,26 +55,24 @@ public class CategoryServiceImpl implements CategoryService {
*/ */
@Override @Override
public void exportData(HttpServletResponse response) { 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 { 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); EasyExcel.write(response.getOutputStream(), CategoryExcelVo.class).sheet("分类数据").doWrite(excelVoArrayList);
} catch (IOException exception) { } catch (IOException exception) {

View File

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

View File

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

View File

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