chore: 优化部分命名

This commit is contained in:
Charles7c 2024-05-04 21:56:04 +08:00
parent c75e99e065
commit a3cf39f9f8
8 changed files with 40 additions and 45 deletions

View File

@ -43,7 +43,8 @@ public enum FileTypeEnum implements IBaseEnum<Integer> {
/**
* 图片
*/
IMAGE(2, "图片", List.of("jpg", "jpeg", "png", "gif", "bmp", "webp", "ico", "psd", "tiff", "dwg", "jxr", "apng", "xcf")),
IMAGE(2, "图片", List
.of("jpg", "jpeg", "png", "gif", "bmp", "webp", "ico", "psd", "tiff", "dwg", "jxr", "apng", "xcf")),
/**
* 文档

View File

@ -39,13 +39,13 @@ import java.util.List;
@RequiredArgsConstructor
public class RoleDeptServiceImpl implements RoleDeptService {
private final RoleDeptMapper roleDeptMapper;
private final RoleDeptMapper baseMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(List<Long> deptIds, Long roleId) {
// 检查是否有变更
List<Long> oldDeptIdList = roleDeptMapper.lambdaQuery()
List<Long> oldDeptIdList = baseMapper.lambdaQuery()
.select(RoleDeptDO::getDeptId)
.eq(RoleDeptDO::getRoleId, roleId)
.list()
@ -56,27 +56,27 @@ public class RoleDeptServiceImpl implements RoleDeptService {
return false;
}
// 删除原有关联
roleDeptMapper.lambdaUpdate().eq(RoleDeptDO::getRoleId, roleId).remove();
baseMapper.lambdaUpdate().eq(RoleDeptDO::getRoleId, roleId).remove();
// 保存最新关联
List<RoleDeptDO> roleDeptList = deptIds.stream().map(deptId -> new RoleDeptDO(roleId, deptId)).toList();
return roleDeptMapper.insertBatch(roleDeptList);
return baseMapper.insertBatch(roleDeptList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByRoleIds(List<Long> roleIds) {
roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getRoleId, roleIds).remove();
baseMapper.lambdaUpdate().in(RoleDeptDO::getRoleId, roleIds).remove();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByDeptIds(List<Long> deptIds) {
roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getDeptId, deptIds).remove();
baseMapper.lambdaUpdate().in(RoleDeptDO::getDeptId, deptIds).remove();
}
@Override
@ContainerMethod(namespace = ContainerConstants.ROLE_DEPT_ID_LIST, type = MappingType.ORDER_OF_KEYS)
public List<Long> listDeptIdByRoleId(Long roleId) {
return roleDeptMapper.selectDeptIdByRoleId(roleId);
return baseMapper.selectDeptIdByRoleId(roleId);
}
}

View File

@ -38,13 +38,13 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class RoleMenuServiceImpl implements RoleMenuService {
private final RoleMenuMapper roleMenuMapper;
private final RoleMenuMapper baseMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(List<Long> menuIds, Long roleId) {
// 检查是否有变更
List<Long> oldMenuIdList = roleMenuMapper.lambdaQuery()
List<Long> oldMenuIdList = baseMapper.lambdaQuery()
.select(RoleMenuDO::getMenuId)
.eq(RoleMenuDO::getRoleId, roleId)
.list()
@ -55,16 +55,16 @@ public class RoleMenuServiceImpl implements RoleMenuService {
return false;
}
// 删除原有关联
roleMenuMapper.lambdaUpdate().eq(RoleMenuDO::getRoleId, roleId).remove();
baseMapper.lambdaUpdate().eq(RoleMenuDO::getRoleId, roleId).remove();
// 保存最新关联
List<RoleMenuDO> roleMenuList = menuIds.stream().map(menuId -> new RoleMenuDO(roleId, menuId)).toList();
return roleMenuMapper.insertBatch(roleMenuList);
return baseMapper.insertBatch(roleMenuList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByRoleIds(List<Long> roleIds) {
roleMenuMapper.lambdaUpdate().in(RoleMenuDO::getRoleId, roleIds).remove();
baseMapper.lambdaUpdate().in(RoleMenuDO::getRoleId, roleIds).remove();
}
@Override
@ -72,6 +72,6 @@ public class RoleMenuServiceImpl implements RoleMenuService {
if (CollUtil.isEmpty(roleIds)) {
return new ArrayList<>(0);
}
return roleMenuMapper.selectMenuIdByRoleIds(roleIds);
return baseMapper.selectMenuIdByRoleIds(roleIds);
}
}

View File

@ -39,13 +39,13 @@ import java.util.List;
@RequiredArgsConstructor
public class UserRoleServiceImpl implements UserRoleService {
private final UserRoleMapper userRoleMapper;
private final UserRoleMapper baseMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(List<Long> roleIds, Long userId) {
// 检查是否有变更
List<Long> oldRoleIdList = userRoleMapper.lambdaQuery()
List<Long> oldRoleIdList = baseMapper.lambdaQuery()
.select(UserRoleDO::getRoleId)
.eq(UserRoleDO::getUserId, userId)
.list()
@ -56,26 +56,26 @@ public class UserRoleServiceImpl implements UserRoleService {
return false;
}
// 删除原有关联
userRoleMapper.lambdaUpdate().eq(UserRoleDO::getUserId, userId).remove();
baseMapper.lambdaUpdate().eq(UserRoleDO::getUserId, userId).remove();
// 保存最新关联
List<UserRoleDO> userRoleList = roleIds.stream().map(roleId -> new UserRoleDO(userId, roleId)).toList();
return userRoleMapper.insertBatch(userRoleList);
return baseMapper.insertBatch(userRoleList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByUserIds(List<Long> userIds) {
userRoleMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove();
baseMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove();
}
@Override
@ContainerMethod(namespace = ContainerConstants.USER_ROLE_ID_LIST, type = MappingType.ORDER_OF_KEYS)
public List<Long> listRoleIdByUserId(Long userId) {
return userRoleMapper.selectRoleIdByUserId(userId);
return baseMapper.selectRoleIdByUserId(userId);
}
@Override
public boolean isRoleIdExists(List<Long> roleIds) {
return userRoleMapper.lambdaQuery().in(UserRoleDO::getRoleId, roleIds).exists();
return baseMapper.lambdaQuery().in(UserRoleDO::getRoleId, roleIds).exists();
}
}

View File

@ -49,13 +49,13 @@ import top.continew.starter.web.model.R;
@RequestMapping("/monitor/online")
public class OnlineUserController {
private final OnlineUserService onlineUserService;
private final OnlineUserService baseService;
@Operation(summary = "分页查询列表", description = "分页查询列表")
@SaCheckPermission("monitor:online:list")
@GetMapping
public R<PageResp<OnlineUserResp>> page(OnlineUserQuery query, @Validated PageQuery pageQuery) {
return R.ok(onlineUserService.page(query, pageQuery));
return R.ok(baseService.page(query, pageQuery));
}
@Operation(summary = "强退在线用户", description = "强退在线用户")

View File

@ -43,12 +43,10 @@ import top.continew.starter.web.model.R;
@CrudRequestMapping(value = "/system/file", api = {Api.PAGE, Api.UPDATE, Api.DELETE})
public class FileController extends BaseController<FileService, FileResp, FileResp, FileQuery, FileReq> {
private final FileService fileService;
@Log(ignore = true)
@Operation(summary = "查询文件资源统计", description = "查询文件资源统计")
@GetMapping("/statistics")
public R<FileStatisticsResp> statistics() {
return R.ok(fileService.statistics());
return R.ok(baseService.statistics());
}
}

View File

@ -16,18 +16,12 @@
package top.continew.admin.webapi.system;
import java.util.List;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import top.continew.admin.system.model.query.OptionQuery;
import top.continew.admin.system.model.req.OptionReq;
import top.continew.admin.system.model.req.OptionResetValueReq;
@ -35,6 +29,8 @@ import top.continew.admin.system.model.resp.OptionResp;
import top.continew.admin.system.service.OptionService;
import top.continew.starter.web.model.R;
import java.util.List;
/**
* 参数管理 API
*
@ -47,20 +43,20 @@ import top.continew.starter.web.model.R;
@RequestMapping("/system/option")
public class OptionController {
private final OptionService optionService;
private final OptionService baseService;
@Operation(summary = "查询参数列表", description = "查询参数列表")
@SaCheckPermission("system:config:list")
@GetMapping
public R<List<OptionResp>> list(@Validated OptionQuery query) {
return R.ok(optionService.list(query));
return R.ok(baseService.list(query));
}
@Operation(summary = "修改参数", description = "修改参数")
@SaCheckPermission("system:config:update")
@PatchMapping
public R<Void> update(@Validated @RequestBody List<OptionReq> req) {
optionService.update(req);
baseService.update(req);
return R.ok();
}
@ -68,7 +64,7 @@ public class OptionController {
@SaCheckPermission("system:config:reset")
@PatchMapping("/value")
public R<Void> resetValue(@Validated @RequestBody OptionResetValueReq req) {
optionService.resetValue(req);
baseService.resetValue(req);
return R.ok();
}
}

View File

@ -53,13 +53,13 @@ import java.util.List;
@RequestMapping("/generator")
public class GeneratorController {
private final GeneratorService generatorService;
private final GeneratorService baseService;
@Operation(summary = "分页查询数据表", description = "分页查询数据表")
@SaCheckPermission("tool:generator:list")
@GetMapping("/table")
public R<PageResp<TableResp>> pageTable(TableQuery query, @Validated PageQuery pageQuery) throws SQLException {
return R.ok(generatorService.pageTable(query, pageQuery));
return R.ok(baseService.pageTable(query, pageQuery));
}
@Operation(summary = "查询字段配置列表", description = "查询字段配置列表")
@ -69,7 +69,7 @@ public class GeneratorController {
@GetMapping("/field/{tableName}")
public R<List<FieldConfigDO>> listFieldConfig(@PathVariable String tableName,
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
return R.ok(generatorService.listFieldConfig(tableName, requireSync));
return R.ok(baseService.listFieldConfig(tableName, requireSync));
}
@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
@ -77,7 +77,7 @@ public class GeneratorController {
@SaCheckPermission("tool:generator:list")
@GetMapping("/config/{tableName}")
public R<GenConfigDO> getGenConfig(@PathVariable String tableName) throws SQLException {
return R.ok(generatorService.getGenConfig(tableName));
return R.ok(baseService.getGenConfig(tableName));
}
@Operation(summary = "保存配置信息", description = "保存配置信息")
@ -85,7 +85,7 @@ public class GeneratorController {
@SaCheckPermission("tool:generator:list")
@PostMapping("/config/{tableName}")
public R<Void> saveConfig(@Validated @RequestBody GenConfigReq req, @PathVariable String tableName) {
generatorService.saveConfig(req, tableName);
baseService.saveConfig(req, tableName);
return R.ok("保存成功");
}
@ -94,7 +94,7 @@ public class GeneratorController {
@SaCheckPermission("tool:generator:list")
@GetMapping("/preview/{tableName}")
public R<List<GeneratePreviewResp>> preview(@PathVariable String tableName) {
return R.ok(generatorService.preview(tableName));
return R.ok(baseService.preview(tableName));
}
@Operation(summary = "生成代码", description = "生成代码")
@ -104,6 +104,6 @@ public class GeneratorController {
public void generate(@PathVariable List<String> tableNames,
HttpServletRequest request,
HttpServletResponse response) {
generatorService.generate(tableNames, request, response);
baseService.generate(tableNames, request, response);
}
}