12345678910111213141516171819202122232425262728293031 |
- package api
- import (
- "box-cost/db/model"
- "time"
- "github.com/gin-gonic/gin"
- )
- func Process(r *GinRouter) {
- CreateCRUD(r, "/process", &CRUDOption{
- Collection: "process",
- NewModel: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- entity := &model.Process{}
- c.ShouldBindJSON(entity)
- entity.CreateTime = time.Now()
- entity.UpdateTime = time.Now()
- return entity, nil
- },
- EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
- return &model.Process{}
- },
- JWT: true,
- OnUpdate: func(c *gin.Context, apictx *ApiSession, entity interface{}) {
- process := entity.(*model.Process)
- process.UpdateTime = time.Now()
- },
- SearchProject: []string{"name", "unit", "norm", "price", "category", "remark"},
- })
- }
|