|
@@ -11,16 +11,16 @@ import (
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
|
-func FinishArtwork(r *GinRouter) {
|
|
|
- r.POST("/finish/create", CreateFinishArtwork)
|
|
|
- r.POST("/finish/delete/:id", DeleteFinishArtwork)
|
|
|
- r.GET("/finish/list", FinishArtworkList)
|
|
|
- r.GET("/finish/detail/:id", FinishArtworkDetail)
|
|
|
- r.POST("/finish/update", UpdateFinishArtwork)
|
|
|
+func Finish(r *GinRouter) {
|
|
|
+ r.POST("/finish/create", CreateFinish)
|
|
|
+ r.POST("/finish/delete/:id", DeleteFinish)
|
|
|
+ r.GET("/finish/list", FinishList)
|
|
|
+ r.GET("/finish/detail/:id", FinishDetail)
|
|
|
+ r.POST("/finish/update", UpdateFinish)
|
|
|
}
|
|
|
|
|
|
-func CreateFinishArtwork(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- var finish model.FinishArtwork
|
|
|
+func CreateFinish(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+ var finish model.Finish
|
|
|
err := c.ShouldBindJSON(&finish)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
@@ -28,38 +28,38 @@ func CreateFinishArtwork(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
|
}
|
|
|
finish.CreateTime = time.Now()
|
|
|
finish.UpdateTime = time.Now()
|
|
|
- return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionFinishArtwork, &finish)
|
|
|
+ return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionFinish, &finish)
|
|
|
}
|
|
|
|
|
|
-func DeleteFinishArtwork(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+func DeleteFinish(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
_id := c.Param("id")
|
|
|
id, _ := primitive.ObjectIDFromHex(_id)
|
|
|
if id.IsZero() {
|
|
|
return nil, errors.New("id错误")
|
|
|
}
|
|
|
- return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionFinishArtwork, _id)
|
|
|
+ return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionFinish, _id)
|
|
|
}
|
|
|
|
|
|
-func FinishArtworkList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+func FinishList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
|
|
|
page, size, query := UtilQueryPageSize(c)
|
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionFinishArtwork,
|
|
|
+ CollectName: repo.CollectionFinish,
|
|
|
Page: page,
|
|
|
Size: size,
|
|
|
Query: query,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-func FinishArtworkDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+func FinishDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
_id := c.Param("id")
|
|
|
id, _ := primitive.ObjectIDFromHex(_id)
|
|
|
if id.IsZero() {
|
|
|
return nil, errors.New("id错误")
|
|
|
}
|
|
|
- cate := &model.FinishArtwork{}
|
|
|
+ cate := &model.Finish{}
|
|
|
found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
- CollectName: repo.CollectionFinishArtwork,
|
|
|
+ CollectName: repo.CollectionFinish,
|
|
|
Query: repo.Map{"_id": id},
|
|
|
}, cate)
|
|
|
if err != nil {
|
|
@@ -73,8 +73,8 @@ func FinishArtworkDetail(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
|
return cate, nil
|
|
|
}
|
|
|
|
|
|
-func UpdateFinishArtwork(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- var cate model.FinishArtwork
|
|
|
+func UpdateFinish(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+ var cate model.Finish
|
|
|
err := c.ShouldBindJSON(&cate)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
@@ -83,5 +83,5 @@ func UpdateFinishArtwork(c *gin.Context, apictx *ApiSession) (interface{}, error
|
|
|
if cate.Id.IsZero() {
|
|
|
return nil, errors.New("id错误")
|
|
|
}
|
|
|
- return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionFinishArtwork, cate.Id.Hex(), &cate)
|
|
|
+ return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionFinish, cate.Id.Hex(), &cate)
|
|
|
}
|