mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	refactor: 适配 Crane4j 数据填充组件
This commit is contained in:
		| @@ -16,21 +16,12 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import top.charles7c.continew.admin.common.constant.SysConstants; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.admin.system.mapper.DeptMapper; | ||||
| @@ -46,6 +37,11 @@ import top.charles7c.continew.starter.core.util.ExceptionUtils; | ||||
| import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * 部门业务实现 | ||||
|  * | ||||
| @@ -126,9 +122,9 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void fillDetail(Object detailObj) { | ||||
|         super.fillDetail(detailObj); | ||||
|         if (detailObj instanceof DeptDetailResp detail) { | ||||
|     protected void fill(Object obj) { | ||||
|         super.fill(obj); | ||||
|         if (obj instanceof DeptDetailResp detail) { | ||||
|             if (Objects.equals(SysConstants.SUPER_PARENT_ID, detail.getParentId())) { | ||||
|                 return; | ||||
|             } | ||||
|   | ||||
| @@ -16,14 +16,10 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.cache.annotation.CacheConfig; | ||||
| import org.springframework.cache.annotation.CacheEvict; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.constant.CacheConstants; | ||||
| import top.charles7c.continew.admin.common.model.resp.LabelValueResp; | ||||
| import top.charles7c.continew.admin.system.mapper.DictItemMapper; | ||||
| @@ -37,6 +33,8 @@ import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; | ||||
| import top.charles7c.continew.starter.extension.crud.model.query.SortQuery; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 字典项业务实现 | ||||
|  * | ||||
| @@ -71,7 +69,7 @@ public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictIte | ||||
|         SortQuery sortQuery = new SortQuery(); | ||||
|         sortQuery.setSort(new String[] {"sort,asc"}); | ||||
|         List<DictItemDetailResp> detailList = super.list(dictItemQuery, sortQuery, DictItemDetailResp.class); | ||||
|         detailList.forEach(super::fillDetail); | ||||
|         detailList.forEach(super::fill); | ||||
|         return detailList; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -16,22 +16,17 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
|  | ||||
| import org.dromara.x.file.storage.core.*; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.core.util.URLUtil; | ||||
|  | ||||
| import jakarta.annotation.Resource; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.dromara.x.file.storage.core.FileInfo; | ||||
| import org.dromara.x.file.storage.core.FileStorageService; | ||||
| import org.dromara.x.file.storage.core.ProgressListener; | ||||
| import org.dromara.x.file.storage.core.UploadPretreatment; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import top.charles7c.continew.admin.system.enums.StorageTypeEnum; | ||||
| import top.charles7c.continew.admin.system.mapper.FileMapper; | ||||
| import top.charles7c.continew.admin.system.model.entity.FileDO; | ||||
| @@ -47,6 +42,10 @@ import top.charles7c.continew.starter.core.util.URLUtils; | ||||
| import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * 文件业务实现 | ||||
|  * | ||||
| @@ -117,11 +116,11 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void fill(Object baseObj) { | ||||
|         if (baseObj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) { | ||||
|     protected void fill(Object obj) { | ||||
|         super.fill(obj); | ||||
|         if (obj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) { | ||||
|             StorageDetailResp storage = storageService.get(fileResp.getStorageId()); | ||||
|             fileResp.setUrl(URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileResp.getUrl())); | ||||
|         } | ||||
|         super.fill(baseObj); | ||||
|     } | ||||
| } | ||||
| @@ -16,19 +16,13 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.cache.annotation.CacheEvict; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.cache.annotation.CacheEvict; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import top.charles7c.continew.admin.auth.service.OnlineUserService; | ||||
| import top.charles7c.continew.admin.common.constant.CacheConstants; | ||||
| import top.charles7c.continew.admin.common.constant.SysConstants; | ||||
| @@ -47,6 +41,9 @@ import top.charles7c.continew.admin.system.service.*; | ||||
| import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; | ||||
|  | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * 角色业务实现 | ||||
|  * | ||||
| @@ -133,9 +130,9 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void fillDetail(Object detailObj) { | ||||
|         super.fillDetail(detailObj); | ||||
|         if (detailObj instanceof RoleDetailResp detail) { | ||||
|     protected void fill(Object obj) { | ||||
|         super.fill(obj); | ||||
|         if (obj instanceof RoleDetailResp detail) { | ||||
|             Long roleId = detail.getId(); | ||||
|             if (SysConstants.ADMIN_ROLE_CODE.equals(detail.getCode())) { | ||||
|                 List<MenuResp> list = menuService.list(null, null); | ||||
|   | ||||
| @@ -16,13 +16,12 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.io.file.FileNameUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import jakarta.annotation.Resource; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.dromara.x.file.storage.core.FileInfo; | ||||
| import org.dromara.x.file.storage.core.FileStorageService; | ||||
| import org.springframework.cache.annotation.CacheConfig; | ||||
| @@ -30,12 +29,6 @@ import org.springframework.cache.annotation.Cacheable; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.io.file.FileNameUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.constant.CacheConstants; | ||||
| import top.charles7c.continew.admin.common.constant.FileConstants; | ||||
| import top.charles7c.continew.admin.common.constant.SysConstants; | ||||
| @@ -57,6 +50,11 @@ import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; | ||||
| import top.charles7c.continew.starter.extension.crud.base.CommonUserService; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| /** | ||||
|  * 用户业务实现 | ||||
|  * | ||||
| @@ -148,9 +146,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void fillDetail(Object detailObj) { | ||||
|         super.fillDetail(detailObj); | ||||
|         if (detailObj instanceof UserDetailResp detail) { | ||||
|     protected void fill(Object obj) { | ||||
|         super.fill(obj); | ||||
|         if (obj instanceof UserDetailResp detail) { | ||||
|             detail.setDeptName(ExceptionUtils.exToNull(() -> deptService.get(detail.getDeptId()).getName())); | ||||
|             List<Long> roleIdList = userRoleService.listRoleIdByUserId(detail.getId()); | ||||
|             detail.setRoleIds(roleIdList); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user