mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-24 03:18:35 +08:00
【更新】更新restful
This commit is contained in:
@@ -31,10 +31,10 @@ type ResEmailsApi struct {
|
||||
// @Security
|
||||
func (p *ResEmailsApi) GetResEmailsList(rc *restfulx.ReqCtx) {
|
||||
|
||||
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
status := rc.GinCtx.Query("status")
|
||||
category := rc.GinCtx.Query("category")
|
||||
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
|
||||
status := restfulx.QueryParam(rc, "status")
|
||||
category := restfulx.QueryParam(rc, "category")
|
||||
|
||||
data := entity.ResEmail{Status: status, Category: category}
|
||||
list, total := p.ResEmailsApp.FindListPage(pageNum, pageSize, data)
|
||||
@@ -60,7 +60,7 @@ func (p *ResEmailsApi) GetResEmailsList(rc *restfulx.ReqCtx) {
|
||||
// @Router /resource/email/{mailId} [get]
|
||||
// @Security
|
||||
func (p *ResEmailsApi) GetResEmails(rc *restfulx.ReqCtx) {
|
||||
mailId := restfulx.PathParamInt(rc.GinCtx, "mailId")
|
||||
mailId := restfulx.PathParamInt(rc, "mailId")
|
||||
p.ResEmailsApp.FindOne(int64(mailId))
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (p *ResEmailsApi) GetResEmails(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResEmailsApi) InsertResEmails(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResEmail
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.ResEmailsApp.Insert(data)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func (p *ResEmailsApi) InsertResEmails(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResEmailsApi) UpdateResEmails(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResEmail
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
if utils.ISDdmMail(data.From) {
|
||||
data.From = ""
|
||||
}
|
||||
@@ -111,8 +111,7 @@ func (p *ResEmailsApi) UpdateResEmails(rc *restfulx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
|
||||
// @Router /resource/email/{mailId} [delete]
|
||||
func (p *ResEmailsApi) DeleteResEmails(rc *restfulx.ReqCtx) {
|
||||
|
||||
mailId := rc.GinCtx.Param("mailId")
|
||||
mailId := restfulx.PathParam(rc, "mailId")
|
||||
mailIds := utils.IdsStrToIdsIntGroup(mailId)
|
||||
p.ResEmailsApp.Delete(mailIds)
|
||||
}
|
||||
@@ -129,7 +128,7 @@ func (p *ResEmailsApi) DeleteResEmails(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResEmailsApi) UpdateMailStatus(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResEmail
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.ResEmailsApp.Update(entity.ResEmail{MailId: data.MailId, Status: data.Status})
|
||||
}
|
||||
@@ -146,7 +145,7 @@ func (p *ResEmailsApi) UpdateMailStatus(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResEmailsApi) DebugMail(rc *restfulx.ReqCtx) {
|
||||
var data from.SendMail
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
one := p.ResEmailsApp.FindOne(data.MailId)
|
||||
ml := email.Mail{
|
||||
|
||||
@@ -33,11 +33,11 @@ type ResOssesApi struct {
|
||||
// @Security
|
||||
func (p *ResOssesApi) GetResOssesList(rc *restfulx.ReqCtx) {
|
||||
|
||||
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
status := rc.GinCtx.Query("status")
|
||||
category := rc.GinCtx.Query("category")
|
||||
ossCode := rc.GinCtx.Query("ossCode")
|
||||
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
|
||||
status := restfulx.QueryParam(rc, "status")
|
||||
category := restfulx.QueryParam(rc, "category")
|
||||
ossCode := restfulx.QueryParam(rc, "ossCode")
|
||||
|
||||
data := entity.ResOss{Status: status, Category: category, OssCode: ossCode}
|
||||
list, total := p.ResOssesApp.FindListPage(pageNum, pageSize, data)
|
||||
@@ -63,7 +63,7 @@ func (p *ResOssesApi) GetResOssesList(rc *restfulx.ReqCtx) {
|
||||
// @Router /resource/oss/{ossId} [get]
|
||||
// @Security
|
||||
func (p *ResOssesApi) GetResOsses(rc *restfulx.ReqCtx) {
|
||||
ossId := restfulx.PathParamInt(rc.GinCtx, "ossId")
|
||||
ossId := restfulx.PathParamInt(rc, "ossId")
|
||||
p.ResOssesApp.FindOne(int64(ossId))
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (p *ResOssesApi) GetResOsses(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResOssesApi) InsertResOsses(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResOss
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.ResOssesApp.Insert(data)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func (p *ResOssesApi) InsertResOsses(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResOssesApi) UpdateResOsses(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResOss
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
if utils.IsDdmKey(data.AccessKey) {
|
||||
data.AccessKey = ""
|
||||
}
|
||||
@@ -114,8 +114,7 @@ func (p *ResOssesApi) UpdateResOsses(rc *restfulx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
|
||||
// @Router /resource/oss/{ossId} [delete]
|
||||
func (p *ResOssesApi) DeleteResOsses(rc *restfulx.ReqCtx) {
|
||||
|
||||
ossId := rc.GinCtx.Param("ossId")
|
||||
ossId := restfulx.PathParam(rc, "ossId")
|
||||
ossIds := utils.IdsStrToIdsIntGroup(ossId)
|
||||
p.ResOssesApp.Delete(ossIds)
|
||||
}
|
||||
@@ -127,13 +126,13 @@ func (p *ResOssesApi) DeleteResOsses(rc *restfulx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
|
||||
// @Router /resource/oss/uploadFile [post]
|
||||
func (p *ResOssesApi) UplaodResOsses(rc *restfulx.ReqCtx) {
|
||||
file, _ := rc.GinCtx.FormFile("file")
|
||||
ossCode, _ := rc.GinCtx.GetQuery("ossCode")
|
||||
_, handler, _ := rc.Request.Request.FormFile("file")
|
||||
ossCode := restfulx.QueryParam(rc, "ossCode")
|
||||
list := p.ResOssesApp.FindList(entity.ResOss{OssCode: ossCode})
|
||||
li := *list
|
||||
yunFileTmpPath := "uploads/" + time.Now().Format("2006-01-02") + "/" + file.Filename
|
||||
yunFileTmpPath := "uploads/" + time.Now().Format("2006-01-02") + "/" + handler.Filename
|
||||
// 读取本地文件。
|
||||
f, openError := file.Open()
|
||||
f, openError := handler.Open()
|
||||
biz.ErrIsNil(openError, "function file.Open() Failed")
|
||||
biz.ErrIsNil(NewOss(li[0]).PutObj(yunFileTmpPath, f), "上传OSS失败")
|
||||
|
||||
@@ -152,7 +151,7 @@ func (p *ResOssesApi) UplaodResOsses(rc *restfulx.ReqCtx) {
|
||||
// @Security X-TOKEN
|
||||
func (p *ResOssesApi) UpdateOssStatus(rc *restfulx.ReqCtx) {
|
||||
var data entity.ResOss
|
||||
restfulx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.ResOssesApp.Update(entity.ResOss{OssId: data.OssId, Status: data.Status})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user