2:分页查询回收站短链接
传入的参数 - ShortLinkRecycleBinPageReqDTO
@Data
public class ShortLinkRecycleBinPageReqDTO extends Page {
private List < String > gidList;
}
分页查询回收站短链接 - pageShortLink(admin服务)
@GetMapping ( "/api/short-link/admin/v1/recycle-bin/page" )
public Result < Page < ShortLinkPageRespDTO > > pageShortLink ( ShortLinkRecycleBinPageReqDTO requestParam) {
return recycleBinService. pageRecycleBinShortLink ( requestParam) ;
}
service(admin服务)
@Service ( value = "recycleBinServiceImplByAdmin" )
@RequiredArgsConstructor
public class RecycleBinServiceImpl implements RecycleBinService {
private final ShortLinkActualRemoteService shortLinkActualRemoteService;
private final GroupMapper groupMapper;
@Override
public Result < Page < ShortLinkPageRespDTO > > pageRecycleBinShortLink ( ShortLinkRecycleBinPageReqDTO requestParam) {
LambdaQueryWrapper < GroupDO > queryWrapper = Wrappers . lambdaQuery ( GroupDO . class )
. eq ( GroupDO :: getUsername , UserContext . getUsername ( ) )
. eq ( GroupDO :: getDelFlag , 0 ) ;
List < GroupDO > groupDOList = groupMapper. selectList ( queryWrapper) ;
if ( CollUtil . isEmpty ( groupDOList) ) {
throw new ServiceException ( "用户无分组信息" ) ;
}
requestParam. setGidList ( groupDOList. stream ( ) . map ( GroupDO :: getGid ) . toList ( ) ) ;
return shortLinkActualRemoteService. pageRecycleBinShortLink ( requestParam. getGidList ( ) , requestParam. getCurrent ( ) , requestParam. getSize ( ) ) ;
}
}
短链接中台远程调用服务 - ShortLinkActualRemoteService
@FeignClient (
value = "short-link-project" ,
url = "${aggregation.remote-url:}" ,
configuration = OpenFeignConfiguration . class
)
public interface ShortLinkActualRemoteService {
@GetMapping ( "/api/short-link/v1/recycle-bin/page" )
Result < Page < ShortLinkPageRespDTO > > pageRecycleBinShortLink ( @RequestParam ( "gidList" ) List < String > gidList,
@RequestParam ( "current" ) Long current,
@RequestParam ( "size" ) Long size) ;
}
传入的参数 - ShortLinkRecycleBinPageReqDTO
@Data
public class ShortLinkRecycleBinPageReqDTO extends Page < ShortLinkDO > {
private List < String > gidList;
}
controller(project服务)
@GetMapping ( "/api/short-link/v1/recycle-bin/page" )
public Result < IPage < ShortLinkPageRespDTO > > pageShortLink ( ShortLinkRecycleBinPageReqDTO requestParam) {
return Results . success ( recycleBinService. pageShortLink ( requestParam) ) ;
}
service(project服务)
@Override
public IPage < ShortLinkPageRespDTO > pageShortLink ( ShortLinkRecycleBinPageReqDTO requestParam) {
IPage < ShortLinkDO > resultPage = baseMapper. pageRecycleBinLink ( requestParam) ;
return resultPage. convert ( each -> {
ShortLinkPageRespDTO result = BeanUtil . toBean ( each, ShortLinkPageRespDTO . class ) ;
result. setDomain ( "http://" + result. getDomain ( ) ) ;
return result;
} ) ;
}
baseMapper.pageRecycleBinLink
< select id = " pageRecycleBinLink"
parameterType = " com.nageoffer.shortlink.project.dto.req.ShortLinkRecycleBinPageReqDTO"
resultType = " com.nageoffer.shortlink.project.dao.entity.ShortLinkDO" >
SELECT t.*,
COALESCE(s.today_pv, 0) AS todayPv,
COALESCE(s.today_uv, 0) AS todayUv,
COALESCE(s.today_uip, 0) AS todayUip
FROM t_link t
LEFT JOIN t_link_stats_today s ON t.full_short_url = s.full_short_url
AND s.date = CURDATE()
WHERE t.gid IN
< foreach item = ' item' index = ' index' collection = ' gidList' open = ' (' separator = ' ,' close = ' )' >
#{item}
</ foreach>
AND t.enable_status = 1
AND t.del_flag = 0
ORDER by t.update_time
</ select>