mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	refactor: 适配 ContiNew Starter IService 接口,CRUD 查询详情方法不再检查是否存在
计划后期 IXxx 系列接口,区别于 Base 系列基类。Base 系列将主要为 CRUD API 服务。
This commit is contained in:
		| @@ -16,14 +16,6 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.auth.service.impl; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.lang.tree.Tree; | ||||
| @@ -33,7 +25,9 @@ import cn.hutool.core.util.RandomUtil; | ||||
| import cn.hutool.core.util.ReUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.json.JSONUtil; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import me.zhyd.oauth.model.AuthUser; | ||||
| import org.springframework.stereotype.Service; | ||||
| import top.charles7c.continew.admin.auth.model.resp.MetaResp; | ||||
| import top.charles7c.continew.admin.auth.model.resp.RouteResp; | ||||
| import top.charles7c.continew.admin.auth.service.LoginService; | ||||
| @@ -48,11 +42,11 @@ import top.charles7c.continew.admin.common.model.dto.LoginUser; | ||||
| import top.charles7c.continew.admin.common.util.SecureUtils; | ||||
| import top.charles7c.continew.admin.common.util.helper.LoginHelper; | ||||
| import top.charles7c.continew.admin.system.enums.MessageTemplateEnum; | ||||
| import top.charles7c.continew.admin.system.model.entity.DeptDO; | ||||
| import top.charles7c.continew.admin.system.model.entity.RoleDO; | ||||
| import top.charles7c.continew.admin.system.model.entity.UserDO; | ||||
| import top.charles7c.continew.admin.system.model.entity.UserSocialDO; | ||||
| import top.charles7c.continew.admin.system.model.req.MessageReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DeptDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.MenuResp; | ||||
| import top.charles7c.continew.admin.system.service.*; | ||||
| import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties; | ||||
| @@ -60,7 +54,9 @@ import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.annotation.TreeField; | ||||
| import top.charles7c.continew.starter.extension.crud.util.TreeUtils; | ||||
|  | ||||
| import me.zhyd.oauth.model.AuthUser; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| /** | ||||
|  * 登录业务实现 | ||||
| @@ -140,7 +136,7 @@ public class LoginServiceImpl implements LoginService { | ||||
|             userSocial.setOpenId(openId); | ||||
|             this.sendSystemMsg(user); | ||||
|         } else { | ||||
|             user = BeanUtil.copyProperties(userService.get(userSocial.getUserId()), UserDO.class); | ||||
|             user = BeanUtil.copyProperties(userService.getById(userSocial.getUserId()), UserDO.class); | ||||
|         } | ||||
|         this.checkUserStatus(user); | ||||
|         userSocial.setMetaJson(JSONUtil.toJsonStr(authUser)); | ||||
| @@ -209,8 +205,8 @@ public class LoginServiceImpl implements LoginService { | ||||
|      */ | ||||
|     private void checkUserStatus(UserDO user) { | ||||
|         CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, user.getStatus(), "此账号已被禁用,如有疑问,请联系管理员"); | ||||
|         DeptDetailResp deptDetailResp = deptService.get(user.getDeptId()); | ||||
|         CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, deptDetailResp.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员"); | ||||
|         DeptDO dept = deptService.getById(user.getDeptId()); | ||||
|         CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员"); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -16,14 +16,16 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import top.charles7c.continew.admin.system.model.entity.AnnouncementDO; | ||||
| import top.charles7c.continew.admin.system.model.query.AnnouncementQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.AnnouncementReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.AnnouncementDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.AnnouncementResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DashboardAnnouncementResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 公告业务接口 | ||||
| @@ -31,7 +33,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/8/20 10:55 | ||||
|  */ | ||||
| public interface AnnouncementService extends BaseService<AnnouncementResp, AnnouncementDetailResp, AnnouncementQuery, AnnouncementReq> { | ||||
| public interface AnnouncementService extends BaseService<AnnouncementResp, AnnouncementDetailResp, AnnouncementQuery, AnnouncementReq>, IService<AnnouncementDO> { | ||||
|  | ||||
|     /** | ||||
|      * 查询仪表盘公告列表 | ||||
|   | ||||
| @@ -16,11 +16,13 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import top.charles7c.continew.admin.system.model.entity.DeptDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DeptQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DeptReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DeptDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DeptResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| /** | ||||
|  * 部门业务接口 | ||||
| @@ -28,4 +30,4 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/1/22 17:54 | ||||
|  */ | ||||
| public interface DeptService extends BaseService<DeptResp, DeptDetailResp, DeptQuery, DeptReq> {} | ||||
| public interface DeptService extends BaseService<DeptResp, DeptDetailResp, DeptQuery, DeptReq>, IService<DeptDO> {} | ||||
|   | ||||
| @@ -16,14 +16,16 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.model.resp.LabelValueResp; | ||||
| import top.charles7c.continew.admin.system.model.entity.DictItemDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictItemQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictItemReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 字典项业务接口 | ||||
| @@ -31,7 +33,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| public interface DictItemService extends BaseService<DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq> { | ||||
| public interface DictItemService extends BaseService<DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq>, IService<DictItemDO> { | ||||
|  | ||||
|     /** | ||||
|      * 根据字典 ID 查询 | ||||
|   | ||||
| @@ -16,11 +16,13 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import top.charles7c.continew.admin.system.model.entity.DictDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| /** | ||||
|  * 字典业务接口 | ||||
| @@ -28,4 +30,4 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| public interface DictService extends BaseService<DictResp, DictDetailResp, DictQuery, DictReq> {} | ||||
| public interface DictService extends BaseService<DictResp, DictDetailResp, DictQuery, DictReq>, IService<DictDO> {} | ||||
| @@ -16,15 +16,16 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.dromara.x.file.storage.core.FileInfo; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  | ||||
| import top.charles7c.continew.admin.system.model.entity.FileDO; | ||||
| import top.charles7c.continew.admin.system.model.query.FileQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.FileReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.FileResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 文件业务接口 | ||||
| @@ -32,7 +33,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/23 10:38 | ||||
|  */ | ||||
| public interface FileService extends BaseService<FileResp, FileResp, FileQuery, FileReq> { | ||||
| public interface FileService extends BaseService<FileResp, FileResp, FileQuery, FileReq>, IService<FileDO> { | ||||
|  | ||||
|     /** | ||||
|      * 上传到默认存储库 | ||||
|   | ||||
| @@ -16,13 +16,15 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| import top.charles7c.continew.admin.system.model.entity.MenuDO; | ||||
| import top.charles7c.continew.admin.system.model.query.MenuQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.MenuReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.MenuResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * 菜单业务接口 | ||||
| @@ -30,7 +32,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/15 20:30 | ||||
|  */ | ||||
| public interface MenuService extends BaseService<MenuResp, MenuResp, MenuQuery, MenuReq> { | ||||
| public interface MenuService extends BaseService<MenuResp, MenuResp, MenuQuery, MenuReq>, IService<MenuDO> { | ||||
|  | ||||
|     /** | ||||
|      * 根据用户 ID 查询 | ||||
|   | ||||
| @@ -16,9 +16,6 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.model.dto.RoleDTO; | ||||
| import top.charles7c.continew.admin.common.model.resp.LabelValueResp; | ||||
| import top.charles7c.continew.admin.system.model.entity.RoleDO; | ||||
| @@ -27,6 +24,10 @@ import top.charles7c.continew.admin.system.model.req.RoleReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.RoleDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.RoleResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * 角色业务接口 | ||||
| @@ -34,7 +35,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/8 23:15 | ||||
|  */ | ||||
| public interface RoleService extends BaseService<RoleResp, RoleDetailResp, RoleQuery, RoleReq> { | ||||
| public interface RoleService extends BaseService<RoleResp, RoleDetailResp, RoleQuery, RoleReq>, IService<RoleDO> { | ||||
|  | ||||
|     /** | ||||
|      * 构建字典 | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import top.charles7c.continew.admin.system.model.req.StorageReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| /** | ||||
|  * 存储库业务接口 | ||||
| @@ -29,7 +30,7 @@ import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/26 22:09 | ||||
|  */ | ||||
| public interface StorageService extends BaseService<StorageResp, StorageDetailResp, StorageQuery, StorageReq> { | ||||
| public interface StorageService extends BaseService<StorageResp, StorageDetailResp, StorageQuery, StorageReq>, IService<StorageDO> { | ||||
|  | ||||
|     /** | ||||
|      * 查询默认存储库 | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import top.charles7c.continew.admin.system.model.req.UserRoleUpdateReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.UserDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.UserResp; | ||||
| import top.charles7c.continew.starter.extension.crud.base.BaseService; | ||||
| import top.charles7c.continew.starter.extension.crud.base.IService; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @@ -34,7 +35,7 @@ import java.util.List; | ||||
|  * @author Charles7c | ||||
|  * @since 2022/12/21 21:48 | ||||
|  */ | ||||
| public interface UserService extends BaseService<UserResp, UserDetailResp, UserQuery, UserReq> { | ||||
| public interface UserService extends BaseService<UserResp, UserDetailResp, UserQuery, UserReq>, IService<UserDO> { | ||||
|  | ||||
|     /** | ||||
|      * 新增 | ||||
|   | ||||
| @@ -34,7 +34,6 @@ import top.charles7c.continew.admin.system.model.entity.StorageDO; | ||||
| import top.charles7c.continew.admin.system.model.query.FileQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.FileReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.FileResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageDetailResp; | ||||
| import top.charles7c.continew.admin.system.service.FileService; | ||||
| import top.charles7c.continew.admin.system.service.StorageService; | ||||
| import top.charles7c.continew.starter.core.constant.StringConstants; | ||||
| @@ -66,7 +65,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes | ||||
|         List<FileDO> fileList = baseMapper.lambdaQuery().in(FileDO::getId, ids).list(); | ||||
|         Map<Long, List<FileDO>> fileListGroup = fileList.stream().collect(Collectors.groupingBy(FileDO::getStorageId)); | ||||
|         for (Map.Entry<Long, List<FileDO>> entry : fileListGroup.entrySet()) { | ||||
|             StorageDetailResp storage = storageService.get(entry.getKey()); | ||||
|             StorageDO storage = storageService.getById(entry.getKey()); | ||||
|             for (FileDO file : entry.getValue()) { | ||||
|                 FileInfo fileInfo = file.toFileInfo(storage.getCode()); | ||||
|                 fileStorageService.delete(fileInfo); | ||||
| @@ -118,7 +117,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes | ||||
|     protected void fill(Object obj) { | ||||
|         super.fill(obj); | ||||
|         if (obj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) { | ||||
|             StorageDetailResp storage = storageService.get(fileResp.getStorageId()); | ||||
|             StorageDO storage = storageService.getById(fileResp.getStorageId()); | ||||
|             fileResp.setUrl(URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileResp.getUrl())); | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user