mirror of
https://gitee.com/luojinyi/likeadmin_go.git
synced 2025-12-24 08:12:57 +08:00
feat: 完成"存储列表"和"存储详情"接口
This commit is contained in:
@@ -19,6 +19,8 @@ func init() {
|
||||
group.AddPOST("/copyright/save", copyrightSave)
|
||||
group.AddGET("/protocol/detail", protocolDetail)
|
||||
group.AddPOST("/protocol/save", protocolSave)
|
||||
group.AddGET("/storage/list", storageList)
|
||||
group.AddGET("/storage/detail", storageDetail)
|
||||
}
|
||||
|
||||
//websiteDetail 获取网站信息
|
||||
@@ -59,3 +61,15 @@ func protocolSave(c *gin.Context) {
|
||||
setting.SettingProtocolService.Save(pReq)
|
||||
response.Ok(c)
|
||||
}
|
||||
|
||||
//storageList 存储列表
|
||||
func storageList(c *gin.Context) {
|
||||
response.OkWithData(c, setting.SettingStorageService.List())
|
||||
}
|
||||
|
||||
//storageDetail 存储详情
|
||||
func storageDetail(c *gin.Context) {
|
||||
var detailReq req.SettingStorageDetailReq
|
||||
util.VerifyUtil.VerifyQuery(c, &detailReq)
|
||||
response.OkWithData(c, setting.SettingStorageService.Detail(detailReq.Alias))
|
||||
}
|
||||
|
||||
@@ -27,3 +27,8 @@ type SettingProtocolReq struct {
|
||||
Service SettingProtocolItem `form:"service" json:"service"` // 服务协议
|
||||
Privacy SettingProtocolItem `form:"privacy" json:"privacy"` // 隐私协议
|
||||
}
|
||||
|
||||
//SettingStorageDetailReq 存储详情参数
|
||||
type SettingStorageDetailReq struct {
|
||||
Alias string `form:"alias" binding:"required,oneof=local qiniu qcloud aliyun"` // 别名: [local,qiniu,qcloud,aliyun]
|
||||
}
|
||||
|
||||
42
server/admin/service/setting/storage.go
Normal file
42
server/admin/service/setting/storage.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package setting
|
||||
|
||||
import "likeadmin/util"
|
||||
|
||||
var SettingStorageService = settingStorageService{}
|
||||
|
||||
//settingWebsiteService 存储配置服务实现类
|
||||
type settingStorageService struct{}
|
||||
|
||||
var storageList = []map[string]interface{}{
|
||||
{"name": "本地存储", "alias": "local", "describe": "存储在本地服务器", "status": 0},
|
||||
}
|
||||
|
||||
//List 存储列表
|
||||
func (sSrv settingStorageService) List() []map[string]interface{} {
|
||||
// TODO: engine默认local
|
||||
engine := "local"
|
||||
mapList := storageList
|
||||
for i := 0; i < len(mapList); i++ {
|
||||
if engine == mapList[i]["alias"] {
|
||||
mapList[i]["status"] = 1
|
||||
}
|
||||
}
|
||||
return mapList
|
||||
}
|
||||
|
||||
//Detail 存储详情
|
||||
func (sSrv settingStorageService) Detail(alias string) map[string]interface{} {
|
||||
// TODO: engine默认local
|
||||
engine := "local"
|
||||
cnf, err := util.ConfigUtil.GetMap("storage", alias)
|
||||
util.CheckUtil.CheckErr(err, "Detail GetMap err")
|
||||
status := 0
|
||||
if engine == alias {
|
||||
status = 1
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"name": cnf["name"],
|
||||
"alias": alias,
|
||||
"status": status,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user