|
@@ -8,6 +8,7 @@ import (
|
|
|
"server/dao"
|
|
|
"server/global"
|
|
|
"server/model/common/response"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
@@ -40,6 +41,45 @@ func (fa *FileApi) CreateFileGenre(c *gin.Context) {
|
|
|
response.OkWithMessage("新增成功", c)
|
|
|
}
|
|
|
|
|
|
+func (fa *FileApi) QueryNecessaryDocuments(c *gin.Context) {
|
|
|
+ necessaryDocument, err := fileService.QueryNecessaryDocuments()
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("QueryNecessaryDocument ======= " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithData(necessaryDocument, c)
|
|
|
+}
|
|
|
+
|
|
|
+func (fa *FileApi) QueryNecessaryDocumentByGenreId(c *gin.Context) {
|
|
|
+ genreId := c.Query("genre_id")
|
|
|
+ id, _ := strconv.Atoi(genreId)
|
|
|
+ necessaryDocument, err := fileService.QueryNecessaryDocumentByGenreId(id)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("QueryNecessaryDocumentByGenreId ======= " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithData(necessaryDocument, c)
|
|
|
+}
|
|
|
+
|
|
|
+func (fa *FileApi) CreateNecessaryDocument(c *gin.Context) {
|
|
|
+ var necessaryDocument dao.NecessaryDocument
|
|
|
+ err := c.ShouldBindJSON(&necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("CreateNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = fileService.CreateNecessaryDocument(necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("CreateNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithMessage("新增成功", c)
|
|
|
+}
|
|
|
+
|
|
|
func (fa *FileApi) UpdateFileGenre(c *gin.Context) {
|
|
|
var fileGenre dao.FileGenre
|
|
|
err := c.ShouldBindJSON(&fileGenre)
|
|
@@ -57,6 +97,23 @@ func (fa *FileApi) UpdateFileGenre(c *gin.Context) {
|
|
|
response.OkWithMessage("修改成功", c)
|
|
|
}
|
|
|
|
|
|
+func (fa *FileApi) UpdateNecessaryDocument(c *gin.Context) {
|
|
|
+ var necessaryDocument dao.NecessaryDocument
|
|
|
+ err := c.ShouldBindJSON(&necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("UpdateNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = fileService.UpdateNecessaryDocument(necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("UpdateNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithMessage("修改成功", c)
|
|
|
+}
|
|
|
+
|
|
|
func (fa *FileApi) DeleteFileGenre(c *gin.Context) {
|
|
|
var fileGenre dao.FileGenre
|
|
|
err := c.ShouldBindJSON(&fileGenre)
|
|
@@ -74,6 +131,23 @@ func (fa *FileApi) DeleteFileGenre(c *gin.Context) {
|
|
|
response.OkWithMessage("删除成功", c)
|
|
|
}
|
|
|
|
|
|
+func (fa *FileApi) DeleteNecessaryDocument(c *gin.Context) {
|
|
|
+ var necessaryDocument dao.NecessaryDocument
|
|
|
+ err := c.ShouldBindJSON(&necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("DeleteNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = fileService.DeleteNecessaryDocument(necessaryDocument)
|
|
|
+ if err != nil {
|
|
|
+ response.FailWithMessage("失败", c)
|
|
|
+ global.GVA_LOG.Error("DeleteNecessaryDocument ====== " + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkWithMessage("删除成功", c)
|
|
|
+}
|
|
|
+
|
|
|
func (fa *FileApi) FileDownload(c *gin.Context) {
|
|
|
path := c.Query("path")
|
|
|
name := c.Query("name")
|