[feat] 新增公告的对外开放接口

This commit is contained in:
hsdllcw
2025-04-11 15:18:23 +08:00
parent f09cd2a2bf
commit 4d79135b72
29 changed files with 123 additions and 28 deletions

View File

@@ -0,0 +1,19 @@
package com.ruoyi.system.api
import com.ruoyi.common.core.constant.ServiceNameConstants
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory
import com.ruoyi.system.api.inner.InnerRemoteSysNoticeService
import org.springframework.cloud.openfeign.FeignClient
/**
* 公告服务
* @author 栾成伟
*/
@FeignClient(
contextId = "remoteSysNoticeService",
value = ServiceNameConstants.SYSTEM_SERVICE,
fallbackFactory = RemoteUserFallbackFactory::class
)
interface RemoteSysNoticeService : InnerRemoteSysNoticeService {
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.system.api.factory
import com.ruoyi.common.core.domain.R
import com.ruoyi.system.api.RemoteSysNoticeService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.cloud.openfeign.FallbackFactory
import org.springframework.stereotype.Component
@Component
open class RemoteSysNoticeFallbackFactory : FallbackFactory<RemoteSysNoticeService> {
companion object {
var log: Logger = LoggerFactory.getLogger(RemoteSysNoticeFallbackFactory::class.java)
}
override fun create(throwable: Throwable): RemoteSysNoticeService {
log.error("公告服务调用失败:{}", throwable.message)
return object : RemoteSysNoticeService {
override fun getById_Inner(noticeId: Long?, source: String?): R<Any> {
return R.fail("获取公告失败")
}
}
}
}

View File

@@ -0,0 +1,21 @@
package com.ruoyi.system.api.inner
import com.ruoyi.common.core.constant.SecurityConstants
import com.ruoyi.common.core.domain.R
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
interface InnerRemoteSysNoticeService {
/**
* 根据公告ID查询公告信息
* @param noticeId 公告ID
* @return 公告信息
*/
@GetMapping("/inner/notice/detail/{noticeId}")
fun getById_Inner(
@PathVariable("noticeId") noticeId: Long?, @RequestHeader(
SecurityConstants.FROM_SOURCE
) source: String?
): R<Any>?
}