process.go 761 B

12345678910111213141516171819202122232425262728293031
  1. package api
  2. import (
  3. "box-cost/db/model"
  4. "time"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func Process(r *GinRouter) {
  8. CreateCRUD(r, "/process", &CRUDOption{
  9. Collection: "process",
  10. NewModel: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
  11. entity := &model.Process{}
  12. c.ShouldBindJSON(entity)
  13. entity.CreateTime = time.Now()
  14. entity.UpdateTime = time.Now()
  15. return entity, nil
  16. },
  17. EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
  18. return &model.Process{}
  19. },
  20. JWT: true,
  21. OnUpdate: func(c *gin.Context, apictx *ApiSession, entity interface{}) {
  22. process := entity.(*model.Process)
  23. process.UpdateTime = time.Now()
  24. },
  25. SearchProject: []string{"name", "unit", "norm", "price", "category", "remark"},
  26. })
  27. }