diff --git a/lidee-service/lidee-service-system-biz/pom.xml b/lidee-service/lidee-service-system-biz/pom.xml index a843a58..e58206d 100644 --- a/lidee-service/lidee-service-system-biz/pom.xml +++ b/lidee-service/lidee-service-system-biz/pom.xml @@ -120,6 +120,11 @@ com.tencentcloudapi tencentcloud-sdk-java-sms + + com.github.yulichang + mybatis-plus-join-boot-starter + 1.4.11 + diff --git a/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/mapper/OAuth2ClientJoinMapper.java b/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/mapper/OAuth2ClientJoinMapper.java new file mode 100644 index 0000000..ca1a106 --- /dev/null +++ b/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/mapper/OAuth2ClientJoinMapper.java @@ -0,0 +1,59 @@ +package com.lideeyunji.service.system.mapper; + +import com.github.yulichang.base.MPJBaseMapper; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import com.lideeyunji.service.system.controller.vo.oauth2.client.OAuth2ClientPageReqVO; +import com.lideeyunji.service.system.entity.DictDataDO; +import com.lideeyunji.service.system.entity.OAuth2ClientDO; +import com.lideeyunji.tool.framework.common.pojo.PageResult; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OAuth2ClientJoinMapper extends MPJBaseMapper { + + /** + * 分页查询(关联字典表) + */ + default PageResult selectPage(OAuth2ClientPageReqVO reqVO) { + MPJLambdaWrapper wrapper = buildQueryWrapper(reqVO); + + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>( + reqVO.getPageNo(), + reqVO.getPageSize() + ); + + com.baomidou.mybatisplus.extension.plugins.pagination.Page resultPage = + selectJoinPage(page, OAuth2ClientDO.class, wrapper); + + return new PageResult<>(resultPage.getRecords(), resultPage.getTotal()); + } + + + default MPJLambdaWrapper buildQueryWrapper(OAuth2ClientPageReqVO reqVO) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .selectAll(OAuth2ClientDO.class) + .leftJoin(DictDataDO.class, on -> on + .eq(DictDataDO::getValue, OAuth2ClientDO::getCategory) + .eq(DictDataDO::getDictType, "app_category")); + + applyQueryConditions(wrapper, reqVO); + + wrapper.orderByAsc(DictDataDO::getSort) + .orderByDesc(OAuth2ClientDO::getId); + + return wrapper; + } + + default void applyQueryConditions(MPJLambdaWrapper wrapper, OAuth2ClientPageReqVO reqVO) { + if (reqVO.getName() != null && !reqVO.getName().isEmpty()) { + wrapper.like(OAuth2ClientDO::getName, reqVO.getName()); + } + if (reqVO.getStatus() != null) { + wrapper.eq(OAuth2ClientDO::getStatus, reqVO.getStatus()); + } + if (reqVO.getIds() != null && !reqVO.getIds().isEmpty()) { + wrapper.in(OAuth2ClientDO::getId, reqVO.getIds()); + } + } +} diff --git a/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/service/impl/OAuth2ClientServiceImpl.java b/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/service/impl/OAuth2ClientServiceImpl.java index ddf8b55..8df76e9 100644 --- a/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/service/impl/OAuth2ClientServiceImpl.java +++ b/lidee-service/lidee-service-system-biz/src/main/java/com/lideeyunji/service/system/service/impl/OAuth2ClientServiceImpl.java @@ -1,26 +1,24 @@ package com.lideeyunji.service.system.service.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.stream.CollectorUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; -import com.lideeyunji.service.system.entity.AdminUserDO; +import com.google.common.annotations.VisibleForTesting; +import com.lideeyunji.service.system.config.redis.RedisKeyConstants; +import com.lideeyunji.service.system.controller.vo.oauth2.client.OAuth2ClientPageReqVO; +import com.lideeyunji.service.system.controller.vo.oauth2.client.OAuth2ClientSaveReqVO; +import com.lideeyunji.service.system.entity.OAuth2ClientDO; import com.lideeyunji.service.system.entity.UserRoleDO; +import com.lideeyunji.service.system.mapper.OAuth2ClientJoinMapper; +import com.lideeyunji.service.system.mapper.OAuth2ClientMapper; import com.lideeyunji.service.system.service.IAdminUserService; import com.lideeyunji.service.system.service.IClientPermissionService; +import com.lideeyunji.service.system.service.IOAuth2ClientService; import com.lideeyunji.service.system.service.IPermissionService; import com.lideeyunji.tool.framework.common.enums.CommonStatusEnum; import com.lideeyunji.tool.framework.common.pojo.PageResult; import com.lideeyunji.tool.framework.common.util.object.BeanUtils; -import com.lideeyunji.tool.framework.common.util.string.StrUtils; -import com.lideeyunji.service.system.controller.vo.oauth2.client.OAuth2ClientPageReqVO; -import com.lideeyunji.service.system.controller.vo.oauth2.client.OAuth2ClientSaveReqVO; -import com.lideeyunji.service.system.entity.OAuth2ClientDO; -import com.lideeyunji.service.system.mapper.OAuth2ClientMapper; -import com.lideeyunji.service.system.config.redis.RedisKeyConstants; -import com.lideeyunji.service.system.service.IOAuth2ClientService; -import com.google.common.annotations.VisibleForTesting; import com.lideeyunji.tool.framework.security.core.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.cache.annotation.CacheEvict; @@ -35,10 +33,9 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import static com.lideeyunji.tool.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.lideeyunji.service.system.constant.ErrorCodeConstants.*; +import static com.lideeyunji.tool.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.lideeyunji.tool.framework.security.core.util.SecurityFrameworkUtils.*; -import static com.lideeyunji.tool.framework.security.core.util.SecurityFrameworkUtils.getLoginRoleId; /** * OAuth2.0 Client Service 实现类 @@ -53,6 +50,9 @@ public class OAuth2ClientServiceImpl implements IOAuth2ClientService { @Resource private OAuth2ClientMapper oauth2ClientMapper; + @Resource + private OAuth2ClientJoinMapper oAuth2ClientJoinMapper; + @Resource private IClientPermissionService clientPermissionService; @Resource @@ -163,7 +163,7 @@ public class OAuth2ClientServiceImpl implements IOAuth2ClientService { Set clientIds = clientPermissionService.getRoleClientListByRoleId(roleIds); pageReqVO.setIds(clientIds); } - return oauth2ClientMapper.selectPage(pageReqVO); + return oAuth2ClientJoinMapper.selectPage(pageReqVO); } @Override