1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package final
- import (
- "fmt"
- "zhiyuan/pkg/db"
- "github.com/gin-gonic/gin"
- )
- type FinalMatAuxiliary struct {
- ID int64 `json:"id" prop:"add:false"`
- Name string `json:"name" label:"名称" type:"string" prop:"add edit" search:"like"`
- Type int64 `json:"type" label:"类型" type:"int" prop:"add edit" search:"="`
- Preset int64 `json:"preset" label:"是否预置" type:"int" prop:"add edit" search:"="`
- MatTypeIds string `json:"mattype_ids" label:"选材类型" type:"string" prop:"add edit"`
- Settlement int64 `json:"settlement" type:"int" prop:"edit" default:"0" search:"="`
- CalcValue string `json:"calc_value" type:"string" prop:"edit" default:"" search:"="`
- OrderAt int64 `json:"order_at" prop:"add:false select:false"`
- DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
- CreatedAt int64 `json:"created_at" prop:"add:false"`
- UpdatedAt int64 `json:"updated_at" prop:"add:false"`
- db.BaseModel
- }
- func (FinalMatAuxiliary) TableName() string {
- return "zy_final_mat_auxiliary"
- }
- func (model FinalMatAuxiliary) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- return true
- }
- func (model FinalMatAuxiliary) ListAfter(c *gin.Context, data map[string]interface{}, list []map[string]interface{}) []map[string]interface{} {
- ids := make([]int64, 0)
- idmap := make(map[int64]int)
- for i, v := range list {
- id, _ := db.ToInt64(v["id"])
- ids = append(ids, id)
- idmap[id] = i
- }
- datas, _ := db.GetModelMap(db.Type(FinalMatItem{}), map[string]interface{}{
- fmt.Sprintf("`%s`.`type_id` in", FinalMatItem{}.TableName()): ids,
- fmt.Sprintf("`%s`.`deleted_at`", FinalMatItem{}.TableName()): 0,
- }, nil)
- for _, v := range datas {
- id, _ := db.ToInt64(v["type_id"])
- if n, ok := idmap[id]; ok {
- items := make([]map[string]interface{}, 0)
- if is, ok := list[n]["items"].([]map[string]interface{}); ok {
- items = is
- }
- items = append(items, v)
- list[n]["items"] = items
- }
- }
- return list
- }
- func (FinalMatAuxiliary) OnePrivilege(c *gin.Context, id int64) bool {
- return true
- }
- func (FinalMatAuxiliary) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalMatAuxiliary) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalMatAuxiliary) DelPrivilege(c *gin.Context, id int64) error {
- return nil
- }
- func (FinalMatAuxiliary) OrderField() string {
- return "order_at"
- }
- func (FinalMatAuxiliary) Page() bool {
- return false
- }
- func (FinalMatAuxiliary) Count() bool {
- return true
- }
- func (model FinalMatAuxiliary) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return []db.JoinModel{}
- }
|