style: 返回值警告消除

返回值警告消除
由 Result 为  Result<?>
由 Option 为 Option<Type>
This commit is contained in:
Theo
2024-08-02 23:43:40 +08:00
parent 8c6f95148d
commit e694ac5bb7
20 changed files with 69 additions and 69 deletions

View File

@@ -23,7 +23,7 @@ public class Option<T> {
this.label = label; this.label = label;
} }
public Option(T value, String label, List<Option> children) { public Option(T value, String label, List<Option<T>> children) {
this.value = value; this.value = value;
this.label = label; this.label = label;
this.children= children; this.children= children;
@@ -37,6 +37,6 @@ public class Option<T> {
@Schema(description="子选项列表") @Schema(description="子选项列表")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY) @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<Option> children; private List<Option<T>> children;
} }

View File

@@ -42,7 +42,7 @@ public class AuthController {
@Operation(summary = "注销") @Operation(summary = "注销")
@DeleteMapping("/logout") @DeleteMapping("/logout")
@LogAnnotation(value = "注销", module = LogModuleEnum.LOGIN) @LogAnnotation(value = "注销", module = LogModuleEnum.LOGIN)
public Result logout() { public Result<?> logout() {
authService.logout(); authService.logout();
return Result.success(); return Result.success();
} }

View File

@@ -37,7 +37,7 @@ public class FileController {
@DeleteMapping @DeleteMapping
@Operation(summary = "文件删除") @Operation(summary = "文件删除")
@SneakyThrows @SneakyThrows
public Result deleteFile( public Result<?> deleteFile(
@Parameter(description = "文件路径") @RequestParam String filePath @Parameter(description = "文件路径") @RequestParam String filePath
) { ) {
boolean result = ossService.deleteFile(filePath); boolean result = ossService.deleteFile(filePath);

View File

@@ -57,14 +57,14 @@ public class GeneratorController {
@Operation(summary = "保存代码生成配置") @Operation(summary = "保存代码生成配置")
@PostMapping("/{tableName}/config") @PostMapping("/{tableName}/config")
@LogAnnotation(value = "生成代码", module = LogModuleEnum.OTHER) @LogAnnotation(value = "生成代码", module = LogModuleEnum.OTHER)
public Result saveGenConfig(@RequestBody GenConfigForm formData) { public Result<?> saveGenConfig(@RequestBody GenConfigForm formData) {
generatorService.saveGenConfig(formData); generatorService.saveGenConfig(formData);
return Result.success(); return Result.success();
} }
@Operation(summary = "删除代码生成配置") @Operation(summary = "删除代码生成配置")
@DeleteMapping("/{tableName}/config") @DeleteMapping("/{tableName}/config")
public Result deleteGenConfig( public Result<?> deleteGenConfig(
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName @Parameter(description = "表名", example = "sys_user") @PathVariable String tableName
) { ) {
generatorService.deleteGenConfig(tableName); generatorService.deleteGenConfig(tableName);
@@ -87,7 +87,7 @@ public class GeneratorController {
byte[] data = generatorService.downloadCode(tableNames); byte[] data = generatorService.downloadCode(tableNames);
response.reset(); response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"youlai-admin-code.zip\""); response.setHeader("Content-Disposition", "attachment; filename=\"youlai-admin-code.zip\"");
response.addHeader("Content-Length", "" + data.length); response.addHeader("Content-Length", String.valueOf(data.length));
response.addHeader("Access-Control-Allow-Origin", "*"); response.addHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Pragma", "no-cache"); response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache"); response.setHeader("Cache-Control", "no-cache");

View File

@@ -45,8 +45,8 @@ public class SysDeptController {
@Operation(summary = "部门下拉列表") @Operation(summary = "部门下拉列表")
@GetMapping("/options") @GetMapping("/options")
public Result<List<Option>> getDeptOptions() { public Result<List<Option<Long>>> getDeptOptions() {
List<Option> list = deptService.listDeptOptions(); List<Option<Long>> list = deptService.listDeptOptions();
return Result.success(list); return Result.success(list);
} }
@@ -54,7 +54,7 @@ public class SysDeptController {
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:dept:add')") @PreAuthorize("@ss.hasPerm('sys:dept:add')")
@PreventRepeatSubmit @PreventRepeatSubmit
public Result saveDept( public Result<?> saveDept(
@Valid @RequestBody DeptForm formData @Valid @RequestBody DeptForm formData
) { ) {
Long id = deptService.saveDept(formData); Long id = deptService.saveDept(formData);
@@ -73,7 +73,7 @@ public class SysDeptController {
@Operation(summary = "修改部门") @Operation(summary = "修改部门")
@PutMapping(value = "/{deptId}") @PutMapping(value = "/{deptId}")
@PreAuthorize("@ss.hasPerm('sys:dept:edit')") @PreAuthorize("@ss.hasPerm('sys:dept:edit')")
public Result updateDept( public Result<?> updateDept(
@PathVariable Long deptId, @PathVariable Long deptId,
@Valid @RequestBody DeptForm formData @Valid @RequestBody DeptForm formData
) { ) {
@@ -84,7 +84,7 @@ public class SysDeptController {
@Operation(summary = "删除部门") @Operation(summary = "删除部门")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('sys:dept:delete')") @PreAuthorize("@ss.hasPerm('sys:dept:delete')")
public Result deleteDepartments( public Result<?> deleteDepartments(
@Parameter(description ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids @Parameter(description ="部门ID多个以英文逗号(,)分割") @PathVariable("ids") String ids
) { ) {
boolean result = deptService.deleteByIds(ids); boolean result = deptService.deleteByIds(ids);

View File

@@ -46,17 +46,17 @@ public class SysDictController {
@Operation(summary = "字典列表") @Operation(summary = "字典列表")
@GetMapping("/list") @GetMapping("/list")
public Result<List<Option>> getDictList() { public Result<List<Option<String>>> getDictList() {
List<Option> list = dictService.getDictList(); List<Option<String>> list = dictService.getDictList();
return Result.success(list); return Result.success(list);
} }
@Operation(summary = "字典数据项列表") @Operation(summary = "字典数据项列表")
@GetMapping("/{code}/options") @GetMapping("/{code}/options")
public Result<List<Option>> getDictOptions( public Result<List<Option<Long>>> getDictOptions(
@Parameter(description = "字典编码") @PathVariable String code @Parameter(description = "字典编码") @PathVariable String code
) { ) {
List<Option> options = dictService.listDictItemsByCode(code); List<Option<Long>> options = dictService.listDictItemsByCode(code);
return Result.success(options); return Result.success(options);
} }
@@ -73,7 +73,7 @@ public class SysDictController {
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:dict:add')") @PreAuthorize("@ss.hasPerm('sys:dict:add')")
@PreventRepeatSubmit @PreventRepeatSubmit
public Result saveDict(@RequestBody DictForm formData) { public Result<?> saveDict(@RequestBody DictForm formData) {
boolean result = dictService.saveDict(formData); boolean result = dictService.saveDict(formData);
return Result.judge(result); return Result.judge(result);
} }
@@ -81,7 +81,7 @@ public class SysDictController {
@Operation(summary = "修改字典") @Operation(summary = "修改字典")
@PutMapping("/{id}") @PutMapping("/{id}")
@PreAuthorize("@ss.hasPerm('sys:dict:edit')") @PreAuthorize("@ss.hasPerm('sys:dict:edit')")
public Result updateDict( public Result<?> updateDict(
@PathVariable Long id, @PathVariable Long id,
@RequestBody DictForm DictForm @RequestBody DictForm DictForm
) { ) {
@@ -92,7 +92,7 @@ public class SysDictController {
@Operation(summary = "删除字典") @Operation(summary = "删除字典")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('sys:dict:delete')") @PreAuthorize("@ss.hasPerm('sys:dict:delete')")
public Result deleteDictionaries( public Result<?> deleteDictionaries(
@Parameter(description = "字典ID多个以英文逗号(,)拼接") @PathVariable String ids @Parameter(description = "字典ID多个以英文逗号(,)拼接") @PathVariable String ids
) { ) {
dictService.deleteDictByIds(ids); dictService.deleteDictByIds(ids);

View File

@@ -47,7 +47,7 @@ public class SysMenuController {
@Operation(summary = "菜单下拉列表") @Operation(summary = "菜单下拉列表")
@GetMapping("/options") @GetMapping("/options")
public Result listMenuOptions( public Result<?> listMenuOptions(
@Parameter(description = "是否只查询父级菜单") @Parameter(description = "是否只查询父级菜单")
@RequestParam(required = false, defaultValue = "false") boolean onlyParent @RequestParam(required = false, defaultValue = "false") boolean onlyParent
) { ) {
@@ -76,7 +76,7 @@ public class SysMenuController {
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:menu:add')") @PreAuthorize("@ss.hasPerm('sys:menu:add')")
@PreventRepeatSubmit @PreventRepeatSubmit
public Result addMenu(@RequestBody MenuForm menuForm) { public Result<?> addMenu(@RequestBody MenuForm menuForm) {
boolean result = menuService.saveMenu(menuForm); boolean result = menuService.saveMenu(menuForm);
return Result.judge(result); return Result.judge(result);
} }
@@ -84,7 +84,7 @@ public class SysMenuController {
@Operation(summary = "修改菜单") @Operation(summary = "修改菜单")
@PutMapping(value = "/{id}") @PutMapping(value = "/{id}")
@PreAuthorize("@ss.hasPerm('sys:menu:edit')") @PreAuthorize("@ss.hasPerm('sys:menu:edit')")
public Result updateMenu( public Result<?> updateMenu(
@RequestBody MenuForm menuForm @RequestBody MenuForm menuForm
) { ) {
boolean result = menuService.saveMenu(menuForm); boolean result = menuService.saveMenu(menuForm);
@@ -94,7 +94,7 @@ public class SysMenuController {
@Operation(summary = "删除菜单") @Operation(summary = "删除菜单")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("@ss.hasPerm('sys:menu:delete')") @PreAuthorize("@ss.hasPerm('sys:menu:delete')")
public Result deleteMenu( public Result<?> deleteMenu(
@Parameter(description = "菜单ID多个以英文(,)分割") @PathVariable("id") Long id @Parameter(description = "菜单ID多个以英文(,)分割") @PathVariable("id") Long id
) { ) {
boolean result = menuService.deleteMenu(id); boolean result = menuService.deleteMenu(id);
@@ -103,7 +103,7 @@ public class SysMenuController {
@Operation(summary = "修改菜单显示状态") @Operation(summary = "修改菜单显示状态")
@PatchMapping("/{menuId}") @PatchMapping("/{menuId}")
public Result updateMenuVisible( public Result<?> updateMenuVisible(
@Parameter(description = "菜单ID") @PathVariable Long menuId, @Parameter(description = "菜单ID") @PathVariable Long menuId,
@Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible @Parameter(description = "显示状态(1:显示;0:隐藏)") Integer visible

View File

@@ -49,8 +49,8 @@ public class SysRoleController {
@Operation(summary = "角色下拉列表") @Operation(summary = "角色下拉列表")
@GetMapping("/options") @GetMapping("/options")
public Result<List<Option>> listRoleOptions() { public Result<List<Option<Long>>> listRoleOptions() {
List<Option> list = roleService.listRoleOptions(); List<Option<Long>> list = roleService.listRoleOptions();
return Result.success(list); return Result.success(list);
} }
@@ -58,7 +58,7 @@ public class SysRoleController {
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:role:add')") @PreAuthorize("@ss.hasPerm('sys:role:add')")
@PreventRepeatSubmit @PreventRepeatSubmit
public Result addRole(@Valid @RequestBody RoleForm roleForm) { public Result<?> addRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm); boolean result = roleService.saveRole(roleForm);
return Result.judge(result); return Result.judge(result);
} }
@@ -75,7 +75,7 @@ public class SysRoleController {
@Operation(summary = "修改角色") @Operation(summary = "修改角色")
@PutMapping(value = "/{id}") @PutMapping(value = "/{id}")
@PreAuthorize("@ss.hasPerm('sys:role:edit')") @PreAuthorize("@ss.hasPerm('sys:role:edit')")
public Result updateRole(@Valid @RequestBody RoleForm roleForm) { public Result<?> updateRole(@Valid @RequestBody RoleForm roleForm) {
boolean result = roleService.saveRole(roleForm); boolean result = roleService.saveRole(roleForm);
return Result.judge(result); return Result.judge(result);
} }
@@ -83,7 +83,7 @@ public class SysRoleController {
@Operation(summary = "删除角色") @Operation(summary = "删除角色")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('sys:role:delete')") @PreAuthorize("@ss.hasPerm('sys:role:delete')")
public Result deleteRoles( public Result<?> deleteRoles(
@Parameter(description = "删除角色,多个以英文逗号(,)拼接") @PathVariable String ids @Parameter(description = "删除角色,多个以英文逗号(,)拼接") @PathVariable String ids
) { ) {
boolean result = roleService.deleteRoles(ids); boolean result = roleService.deleteRoles(ids);
@@ -92,7 +92,7 @@ public class SysRoleController {
@Operation(summary = "修改角色状态") @Operation(summary = "修改角色状态")
@PutMapping(value = "/{roleId}/status") @PutMapping(value = "/{roleId}/status")
public Result updateRoleStatus( public Result<?> updateRoleStatus(
@Parameter(description = "角色ID") @PathVariable Long roleId, @Parameter(description = "角色ID") @PathVariable Long roleId,
@Parameter(description = "状态(1:启用;0:禁用)") @RequestParam Integer status @Parameter(description = "状态(1:启用;0:禁用)") @RequestParam Integer status
) { ) {
@@ -111,7 +111,7 @@ public class SysRoleController {
@Operation(summary = "分配菜单(包括按钮权限)给角色") @Operation(summary = "分配菜单(包括按钮权限)给角色")
@PutMapping("/{roleId}/menus") @PutMapping("/{roleId}/menus")
public Result assignMenusToRole( public Result<?> assignMenusToRole(
@PathVariable Long roleId, @PathVariable Long roleId,
@RequestBody List<Long> menuIds @RequestBody List<Long> menuIds
) { ) {

View File

@@ -67,7 +67,7 @@ public class SysUserController {
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:user:add')") @PreAuthorize("@ss.hasPerm('sys:user:add')")
@PreventRepeatSubmit @PreventRepeatSubmit
public Result saveUser( public Result<?> saveUser(
@RequestBody @Valid UserForm userForm @RequestBody @Valid UserForm userForm
) { ) {
boolean result = userService.saveUser(userForm); boolean result = userService.saveUser(userForm);
@@ -86,7 +86,7 @@ public class SysUserController {
@Operation(summary = "修改用户") @Operation(summary = "修改用户")
@PutMapping(value = "/{userId}") @PutMapping(value = "/{userId}")
@PreAuthorize("@ss.hasPerm('sys:user:edit')") @PreAuthorize("@ss.hasPerm('sys:user:edit')")
public Result updateUser( public Result<?> updateUser(
@Parameter(description = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@RequestBody @Validated UserForm userForm) { @RequestBody @Validated UserForm userForm) {
boolean result = userService.updateUser(userId, userForm); boolean result = userService.updateUser(userId, userForm);
@@ -96,7 +96,7 @@ public class SysUserController {
@Operation(summary = "删除用户") @Operation(summary = "删除用户")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('sys:user:delete')") @PreAuthorize("@ss.hasPerm('sys:user:delete')")
public Result deleteUsers( public Result<?> deleteUsers(
@Parameter(description = "用户ID多个以英文逗号(,)分割") @PathVariable String ids @Parameter(description = "用户ID多个以英文逗号(,)分割") @PathVariable String ids
) { ) {
boolean result = userService.deleteUsers(ids); boolean result = userService.deleteUsers(ids);
@@ -106,7 +106,7 @@ public class SysUserController {
@Operation(summary = "修改用户密码") @Operation(summary = "修改用户密码")
@PatchMapping(value = "/{userId}/password") @PatchMapping(value = "/{userId}/password")
@PreAuthorize("@ss.hasPerm('sys:user:password:reset')") @PreAuthorize("@ss.hasPerm('sys:user:password:reset')")
public Result updatePassword( public Result<?> updatePassword(
@Parameter(description = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@RequestParam String password @RequestParam String password
) { ) {
@@ -116,7 +116,7 @@ public class SysUserController {
@Operation(summary = "修改用户状态") @Operation(summary = "修改用户状态")
@PatchMapping(value = "/{userId}/status") @PatchMapping(value = "/{userId}/status")
public Result updateUserStatus( public Result<?> updateUserStatus(
@Parameter(description = "用户ID") @PathVariable Long userId, @Parameter(description = "用户ID") @PathVariable Long userId,
@Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status @Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
) { ) {
@@ -152,7 +152,7 @@ public class SysUserController {
@Operation(summary = "导入用户") @Operation(summary = "导入用户")
@PostMapping("/import") @PostMapping("/import")
public Result importUsers(MultipartFile file) throws IOException { public Result<?> importUsers(MultipartFile file) throws IOException {
UserImportListener listener = new UserImportListener(); UserImportListener listener = new UserImportListener();
String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener); String msg = ExcelUtils.importExcel(file.getInputStream(), UserImportDTO.class, listener);
return Result.success(msg); return Result.success(msg);

View File

@@ -35,6 +35,6 @@ public interface DictItemConverter {
@Mapping(target = "value", source = "id"), @Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name") @Mapping(target = "label", source = "name")
}) })
Option convertToOption(SysDictItem dictItem); Option<Long> convertToOption(SysDictItem dictItem);
List<Option> convertToOption(List<SysDictItem> dictItems); List<Option<Long>> convertToOption(List<SysDictItem> dictItems);
} }

View File

@@ -30,7 +30,6 @@ public interface GenConfigConverter {
GenConfigForm.FieldConfig toGenFieldConfigForm(GenFieldConfig genFieldConfig); GenConfigForm.FieldConfig toGenFieldConfigForm(GenFieldConfig genFieldConfig);
GenConfig toGenConfig(GenConfigForm formData); GenConfig toGenConfig(GenConfigForm formData);
List<GenFieldConfig> toGenFieldConfig(List<GenConfigForm.FieldConfig> fieldConfigs); List<GenFieldConfig> toGenFieldConfig(List<GenConfigForm.FieldConfig> fieldConfigs);

View File

@@ -26,10 +26,9 @@ public interface RoleConverter {
@Mapping(target = "value", source = "id"), @Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name") @Mapping(target = "label", source = "name")
}) })
Option entity2Option(SysRole role); Option<Long> entity2Option(SysRole role);
List<Option<Long>> entities2Options(List<SysRole> roles);
List<Option> entities2Options(List<SysRole> roles);
SysRole toEntity(RoleForm roleForm); SysRole toEntity(RoleForm roleForm);

View File

@@ -14,6 +14,7 @@ import org.mapstruct.Mapper;
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface SysConfigConverter { public interface SysConfigConverter {
Page<ConfigVO> convertToPageVo(Page<SysConfig> page); Page<ConfigVO> convertToPageVo(Page<SysConfig> page);
SysConfig toEntity(ConfigForm configForm); SysConfig toEntity(ConfigForm configForm);

View File

@@ -19,31 +19,31 @@ public interface SysDeptService extends IService<SysDept> {
/** /**
* 部门列表 * 部门列表
* *
* @return * @return 部门列表
*/ */
List<DeptVO> getDeptList(DeptQuery queryParams); List<DeptVO> getDeptList(DeptQuery queryParams);
/** /**
* 部门树形下拉选项 * 部门树形下拉选项
* *
* @return * @return 部门树形下拉选项
*/ */
List<Option> listDeptOptions(); List<Option<Long>> listDeptOptions();
/** /**
* 新增部门 * 新增部门
* *
* @param formData * @param formData 部门表单
* @return * @return 部门ID
*/ */
Long saveDept(DeptForm formData); Long saveDept(DeptForm formData);
/** /**
* 修改部门 * 修改部门
* *
* @param deptId * @param deptId 部门ID
* @param formData * @param formData 部门表单
* @return * @return 部门ID
*/ */
Long updateDept(Long deptId, DeptForm formData); Long updateDept(Long deptId, DeptForm formData);
@@ -51,15 +51,15 @@ public interface SysDeptService extends IService<SysDept> {
* 删除部门 * 删除部门
* *
* @param ids 部门ID多个以英文逗号,拼接字符串 * @param ids 部门ID多个以英文逗号,拼接字符串
* @return * @return 是否成功
*/ */
boolean deleteByIds(String ids); boolean deleteByIds(String ids);
/** /**
* 获取部门详情 * 获取部门详情
* *
* @param deptId * @param deptId 部门ID
* @return * @return 部门详情
*/ */
DeptForm getDeptForm(Long deptId); DeptForm getDeptForm(Long deptId);
} }

View File

@@ -69,7 +69,7 @@ public interface SysDictService extends IService<SysDict> {
* @param code 字典编码 * @param code 字典编码
* @return * @return
*/ */
List<Option> listDictItemsByCode(String code); List<Option<Long>> listDictItemsByCode(String code);
/** /**
@@ -77,5 +77,5 @@ public interface SysDictService extends IService<SysDict> {
* *
* @return * @return
*/ */
List<Option> getDictList(); List<Option<String>> getDictList();
} }

View File

@@ -34,7 +34,7 @@ public interface SysRoleService extends IService<SysRole> {
* *
* @return * @return
*/ */
List<Option> listRoleOptions(); List<Option<Long>> listRoleOptions();
/** /**
* *

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.common.constant.SymbolConstant;
import com.youlai.system.common.constant.SystemConstants; import com.youlai.system.common.constant.SystemConstants;
import com.youlai.system.enums.StatusEnum; import com.youlai.system.enums.StatusEnum;
import com.youlai.system.converter.DeptConverter; import com.youlai.system.converter.DeptConverter;
@@ -98,7 +99,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @return 部门下拉List集合 * @return 部门下拉List集合
*/ */
@Override @Override
public List<Option> listDeptOptions() { public List<Option<Long>> listDeptOptions() {
List<SysDept> deptList = this.list(new LambdaQueryWrapper<SysDept>() List<SysDept> deptList = this.list(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, StatusEnum.ENABLE.getValue()) .eq(SysDept::getStatus, StatusEnum.ENABLE.getValue())
@@ -208,12 +209,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @param deptList 部门列表 * @param deptList 部门列表
* @return 部门表格层级列表 * @return 部门表格层级列表
*/ */
public static List<Option> recurDeptTreeOptions(long parentId, List<SysDept> deptList) { public static List<Option<Long>> recurDeptTreeOptions(long parentId, List<SysDept> deptList) {
return CollectionUtil.emptyIfNull(deptList).stream() return CollectionUtil.emptyIfNull(deptList).stream()
.filter(dept -> dept.getParentId().equals(parentId)) .filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> { .map(dept -> {
Option option = new Option(dept.getId(), dept.getName()); Option<Long> option = new Option<>(dept.getId(), dept.getName());
List<Option> children = recurDeptTreeOptions(dept.getId(), deptList); List<Option<Long>> children = recurDeptTreeOptions(dept.getId(), deptList);
if (CollectionUtil.isNotEmpty(children)) { if (CollectionUtil.isNotEmpty(children)) {
option.setChildren(children); option.setChildren(children);
} }
@@ -233,7 +234,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
public boolean deleteByIds(String ids) { public boolean deleteByIds(String ids) {
// 删除部门及子部门 // 删除部门及子部门
if (StrUtil.isNotBlank(ids)) { if (StrUtil.isNotBlank(ids)) {
String[] menuIds = ids.split(","); String[] menuIds = ids.split(SymbolConstant.COMMA);
for (String deptId : menuIds) { for (String deptId : menuIds) {
this.remove(new LambdaQueryWrapper<SysDept>() this.remove(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId) .eq(SysDept::getId, deptId)
@@ -258,7 +259,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
} else { } else {
SysDept parent = this.getById(parentId); SysDept parent = this.getById(parentId);
if (parent != null) { if (parent != null) {
treePath = parent.getTreePath() + "," + parent.getId(); treePath = parent.getTreePath() + SymbolConstant.COMMA + parent.getId();
} }
} }
return treePath; return treePath;

View File

@@ -200,7 +200,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
* @param code 字典编码 * @param code 字典编码
*/ */
@Override @Override
public List<Option> listDictItemsByCode(String code) { public List<Option<Long>> listDictItemsByCode(String code) {
// 根据字典编码获取字典ID // 根据字典编码获取字典ID
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>() SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, code) .eq(SysDict::getCode, code)
@@ -226,12 +226,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
* 获取字典列表 * 获取字典列表
*/ */
@Override @Override
public List<Option> getDictList() { public List<Option<String>> getDictList() {
return this.list(new LambdaQueryWrapper<SysDict>() return this.list(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getStatus, 1) .eq(SysDict::getStatus, 1)
.select(SysDict::getName, SysDict::getCode) .select(SysDict::getName, SysDict::getCode)
).stream() ).stream()
.map(dict -> new Option(dict.getCode(), dict.getName())) .map(dict -> new Option<>(dict.getCode(), dict.getName()))
.toList(); .toList();
} }
} }

View File

@@ -256,10 +256,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
entity.setParams(null); entity.setParams(null);
} }
if(menuType != MenuTypeEnum.BUTTON){ if(menuType != MenuTypeEnum.BUTTON){
Assert.isTrue(this.count(new LambdaQueryWrapper<SysMenu>() Assert.isFalse(this.exists(new LambdaQueryWrapper<SysMenu>()
.eq(SysMenu::getRouteName, entity.getRouteName()) .eq(SysMenu::getRouteName, entity.getRouteName())
.ne(menuForm.getId() != null, SysMenu::getId, menuForm.getId()) .ne(menuForm.getId() != null, SysMenu::getId, menuForm.getId())
) == 0, "路由名称已存在"); ), "路由名称已存在");
} }
boolean result = this.saveOrUpdate(entity); boolean result = this.saveOrUpdate(entity);

View File

@@ -79,7 +79,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
* @return {@link List<Option>} 角色下拉列表 * @return {@link List<Option>} 角色下拉列表
*/ */
@Override @Override
public List<Option> listRoleOptions() { public List<Option<Long>> listRoleOptions() {
// 查询数据 // 查询数据
List<SysRole> roleList = this.list(new LambdaQueryWrapper<SysRole>() List<SysRole> roleList = this.list(new LambdaQueryWrapper<SysRole>()
.ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE) .ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE)