mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-26 11:51:55 +08:00
[feat] 新增公告的对外开放接口
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
@@ -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("获取公告失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>?
|
||||
}
|
||||
Reference in New Issue
Block a user