Skip to content

Commit

Permalink
refactor: 适配 ContiNew Starter IService 接口,CRUD 查询详情方法不再检查是否存在
Browse files Browse the repository at this point in the history
计划后期 IXxx 系列接口,区别于 Base 系列基类。Base 系列将主要为 CRUD API 服务。
  • Loading branch information
Charles7c committed Jan 16, 2024
1 parent a831230 commit 47a133a
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +25,9 @@
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;
Expand All @@ -48,19 +42,21 @@
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;
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;

/**
* 登录业务实现
Expand Down Expand Up @@ -140,7 +136,7 @@ public String socialLogin(AuthUser authUser) {
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));
Expand Down Expand Up @@ -209,8 +205,8 @@ private String login(UserDO user) {
*/
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(), "此账号所属部门已被禁用,如有疑问,请联系管理员");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@

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;

/**
* 公告业务接口
*
* @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> {

/**
* 查询仪表盘公告列表
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

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;

/**
* 部门业务接口
*
* @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> {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@

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;

/**
* 字典项业务接口
*
* @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 查询
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

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;

/**
* 字典业务接口
*
* @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> {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@

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;

/**
* 文件业务接口
*
* @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> {

/**
* 上传到默认存储库
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@

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;

/**
* 菜单业务接口
*
* @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 查询
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,14 +24,18 @@
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;

/**
* 角色业务接口
*
* @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> {

/**
* 构建字典
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
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;

/**
* 存储库业务接口
*
* @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> {

/**
* 查询默认存储库
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;

Expand All @@ -34,7 +35,7 @@
* @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> {

/**
* 新增
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
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;
Expand Down Expand Up @@ -66,7 +65,7 @@ protected void beforeDelete(List<Long> ids) {
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);
Expand Down Expand Up @@ -118,7 +117,7 @@ public Long countByStorageIds(List<Long> storageIds) {
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()));
}
}
Expand Down

0 comments on commit 47a133a

Please sign in to comment.