|
@@ -0,0 +1,26 @@
|
|
|
+package api
|
|
|
+
|
|
|
+import (
|
|
|
+ "box-cost/db/model"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+)
|
|
|
+
|
|
|
+func Setting(router *GinRouter) {
|
|
|
+
|
|
|
+ CreateCRUD(router, "/units", &CRUDOption{
|
|
|
+ Collection: "units",
|
|
|
+ NewModel: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+ entity := &model.Unit{}
|
|
|
+ c.ShouldBindJSON(entity)
|
|
|
+ entity.CreateTime = time.Now()
|
|
|
+ return entity, nil
|
|
|
+ },
|
|
|
+ EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
|
|
|
+ return &model.Unit{}
|
|
|
+ },
|
|
|
+ JWT: true,
|
|
|
+ SearchProject: []string{"name", "createTime"},
|
|
|
+ })
|
|
|
+}
|